run-scene-v2 0.0.17 → 0.0.18

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("uuid1"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):"function"==typeof define&&define.amd?define(["axios","uuid1","three","@allex/md5","js-funcs-three","js-funcs"],t):"object"==typeof exports?exports.RunScene=t(require("axios"),require("uuid1"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):e.RunScene=t(e.axios,e.uuid1,e.three,e["@allex/md5"],e["js-funcs-three"],e["js-funcs"])}(self,((e,t,r,n,i,o)=>{return s={685:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(t,"__esModule",{value:!0}),t.downloadFile=t.getFileName=t.urlToBase64=t.toResult=t.getPrefixWord=t.getBackWord=t.bToMB=t.arrayBufferToStr=t.strToArrayBuffer=t.toUrl=t.blobToDataUrl=t.bufferToArrayBuffer=t.base64ToFile=void 0,n(r(300)));t.base64ToFile=function(e,t){for(var r=(e=e.split(","))[0].match(/:(.*?);/)[1],n=atob(e[1]),i=n.length,o=new Uint8Array(i);i--;)o[i]=n.charCodeAt(i);return new File([o],t,{type:r})},t.bufferToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;++n)r[n]=e[n];return t},t.blobToDataUrl=function(e){return i.default.get(e,{baseURL:"",responseType:"blob",timeout:5e3}).then((function(e){return(0,t.toResult)(e.data)})).catch((function(e){return!1}))},t.toUrl=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"any.json";return e=e instanceof File?e:(e=JSON.stringify(e),new File([e],t)),window.URL.createObjectURL(e)},t.strToArrayBuffer=function(e){for(var t="",r=0;r<e.length;r++)""===t?t=e.charCodeAt(r).toString(16):t+=","+e.charCodeAt(r).toString(16);return new Uint8Array(t.match(/[\da-f]{2}/gi).map((function(e){return parseInt(e,16)}))).buffer},t.arrayBufferToStr=function(e){return new Promise((function(t){var r=new Blob([e]),n=new FileReader;n.readAsText(r,"utf-8"),n.onload=function(){t(n.result)}}))},t.bToMB=function(e){return e=e/1024/1024,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?e:e.toFixed(2)+"MB"},t.getBackWord=function(e){return e.substr(e.lastIndexOf(".")+1).toLowerCase()},t.getPrefixWord=function(e){return e.substr(0,e.lastIndexOf("."))},t.toResult=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"text",r=new FileReader;return"text"===t?r.readAsText(e):"arrayBuffer"===t?r.readAsArrayBuffer(e):"base64"===t&&r.readAsDataURL(e),new Promise((function(e){r.onload=function(t){return e(t.target.result)}}))},t.urlToBase64=function(e){return i.default.get(e,{responseType:"arraybuffer"}).then((function(e){var t=e.headers["content-type"];return e=new Buffer(e.data,"binary").toString("base64"),"data:".concat(t,";base64,")+e}))},t.getFileName=function(e){return e.substring(e.lastIndexOf("-")+1)},t.downloadFile=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"any.text",r=document.createElement("a");e instanceof File||e instanceof Blob?r.setAttribute("href",window.URL.createObjectURL(e)):r.setAttribute("href",e),r.setAttribute("download",t),document.body.insertAdjacentElement("beforeend",r),r.click(),r.remove()}},298:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(){i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=(m="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",a=m.asyncIterator||"@@asyncIterator",s=m.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(t){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i,o,a,s;return t=t&&t.prototype instanceof p?t:p,t=Object.create(t.prototype),n=new S(n||[]),t._invoke=(i=e,o=r,a=n,s="suspendedStart",function(e,t){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===e)throw t;return{value:void 0,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r&&(r=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return h;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}return"throw"===(n=c(n,t.iterator,r.arg)).type?(r.method="throw",r.arg=n.arg,r.delegate=null,h):(n=n.arg)?n.done?(r[t.resultName]=n.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,h):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}(r,a),r)){if(r===h)continue;return r}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===s)throw s="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);if(s="executing","normal"===(r=c(i,o,a)).type){if(s=a.done?"completed":"suspendedYield",r.arg===h)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(s="completed",a.method="throw",a.arg=r.arg)}}),t}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h={};function p(){}function f(){}function d(){}var m,v,y=(l(m={},o,(function(){return this})),(v=(v=Object.getPrototypeOf)&&v(v(T([]))))&&v!==t&&r.call(v,o)&&(m=v),d.prototype=p.prototype=Object.create(m));function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var i;this._invoke=function(o,a){function s(){return new t((function(i,s){!function i(o,a,s,l){var u;if("throw"!==(o=c(e[o],e,a)).type)return(a=(u=o.arg).value)&&"object"==n(a)&&r.call(a,"__await")?t.resolve(a.__await).then((function(e){i("next",e,s,l)}),(function(e){i("throw",e,s,l)})):t.resolve(a).then((function(e){u.value=e,s(u)}),(function(e){return i("throw",e,s,l)}));l(o.arg)}(o,a,i,s)}))}return i=i?i.then(s,s):s()}}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function T(e){if(e){var t,n=e[o];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return t=-1,(n=function n(){for(;++t<e.length;)if(r.call(e,t))return n.value=e[t],n.done=!1,n;return n.value=void 0,n.done=!0,n}).next=n}return{next:_}}function _(){return{value:void 0,done:!0}}return l(y,"constructor",f.prototype=d),l(d,"constructor",f),f.displayName=l(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(b.prototype),l(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new b(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),l(y,s,"Generator"),l(y,o,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t,r=[];for(t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;0<=i;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),l=r.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}var a=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,i=this.tryEntries[t];if(i.tryLoc===e)return"throw"===(r=i.completion).type&&(n=r.arg,w(i)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var s=this&&this.__awaiter||function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},l=(Object.defineProperty(t,"__esModule",{value:!0}),t.deepArrByMaps=t.map=t.multiArrToArr=t.eachTriggerArray=t.eachTriggerArrGetControls=t.emptyArray=t.delArrEle=t.lastArrayEle=void 0,r(185));function u(e,t,r,n){return s(void 0,void 0,void 0,i().mark((function o(){var a,s,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=e[t++]){i.next=3;break}return i.abrupt("return",r());case 3:if((s=a())instanceof Promise)return i.next=7,s;i.next=11;break;case 7:l=i.sent,null!=n&&n.eachCb(l,t),i.next=18;break;case 11:if(s.promise&&s.promise instanceof Promise)return null!=n&&n.eachCb(s,t),i.next=15,s.promise;i.next=17;break;case 15:i.next=18;break;case 17:null!=n&&n.eachCb(s,t);case 18:u(e,t,r,n);case 19:case"end":return i.stop()}}),o)})))}function c(e,t){e.map((function(e){if("array"===(0,l.getType)(e))return c(e,t);t.push(e)}))}t.lastArrayEle=function(e){return e.slice(-1)[0]},t.delArrEle=function(e,t){var r=e.slice(0,t);return e=e.slice(t+1),[].concat(o(r),o(e))},t.emptyArray=function(e){return 0===e.length},t.eachTriggerArrGetControls=function(e){var r=new Proxy({run:!0,clean:!1,target:e,index:0,runningAnima:null,eachCb:function(e,t){e.anima&&(r.runningAnima=e.anima),r.index=t}},{set:function(e,t,n){return"clean"===t&&!0===n&&!1===e[t]&&(r.run=!1,r.target.splice(0)),"run"===t&&!1===n&&!0===e[t]&&(console.log(r,"controls"),r.runningAnima&&r.runningAnima.pause()),"run"===t&&!0===n&&!1===e[t]&&r.runningAnima&&r.runningAnima.resume(),e[t]=n,!0}});return e=(0,t.eachTriggerArray)(e,r),{controls:r,promise:e}},t.eachTriggerArray=function(e,t){return new Promise((function(r){return u(e,0,r,t)}))},t.multiArrToArr=function(e){var t=[];return c(e,t),t},t.map=function(e,t){return e.map((function(r,n){return t(r,n,e)})).filter((function(e){return e}))},t.deepArrByMaps=function(e){var r=e.arr,n=e.typeList,i=e.findType;if(e=e.mapType,!r||!n||!i)return r;var a=o(n),s=r.find((function(e){return e[i]===n[0]}));return s?1!==n.length&&s[e]instanceof Array?(a.shift(),(0,t.deepArrByMaps)({arr:s[e],typeList:a,findType:i,mapType:e})):s:r}},594:(e,t,r)=>{"use strict";t.qR=t.js=t.CV=void 0,r(185),t.CV=function(e){return 0===Object.values(e).length},t.js=function(e,t){return Object.keys(e).map((function(r,n){var i=e[r];return t(r,i,n)}))},t.qR=function(e,t){var r=-1;return function e(n){return r++,t.length===r+1?n:e(n[t[r]])}(e)}},251:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(t,"__esModule",{value:!0}),t.getId=t.getMacro=t.getUuid=void 0,n(r(937))),o=n(r(181));t.getUuid=function(){return i.default.UUID1()},t.getMacro=function(e){var t=setTimeout((function(){return clearTimeout(t),t=null,e()}),1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)},t.getId=function(){return(0,o.default)()}},185:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTrue=t.getType=void 0,t.getType=function(e){if(void 0!==e){if(null===e)return null;var t;switch(e.constructor){case Array:t="Array";break;case Object:t="Object";break;case String:t="String";break;case Number:t="Number";break;case Boolean:t="Boolean";break;case Function:t="Function"}return t&&t.toLowerCase()||"Object"}},t.isTrue=function(e){return!(null==e||!1===e)}},326:e=>{e.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*n*r/t.length),o="";;)for(var a=e(i),s=i;s--;)if((o+=t[a[s]&n]||"").length===+r)return o}},181:(e,t,r)=>{"use strict";e.exports=r(882)},488:(e,t,r)=>{"use strict";var n,i,o,a=r(87),s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function l(){o=!1}function u(e){if(e){if(e!==n){if(e.length!==s.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. These characters were not unique: "+t.join(", "));n=e,l()}}else n!==s&&(n=s,l())}function c(){return o=o||function(){n||u(s);var e,t=n.split(""),r=[];for(a.nextValue();0<t.length;)e=a.nextValue(),e=Math.floor(e*t.length),r.push(t.splice(e,1)[0]);return r.join("")}()}e.exports={get:function(){return n||s},characters:function(e){return u(e),n},seed:function(e){a.seed(e),i!==e&&(l(),i=e)},lookup:function(e){return c()[e]},shuffled:c}},239:(e,t,r)=>{"use strict";var n,i,o=r(253);r(488),e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===i?n++:(n=0,i=r),t=(t+=o(7))+o(e),0<n&&(t+=o(n)),t+o(r)}},253:(e,t,r)=>{"use strict";var n=r(488),i=r(19),o=r(326);e.exports=function(e){for(var t,r=0,a="";!t;)a+=o(i,n.get(),1),t=e<Math.pow(16,r+1),r++;return a}},882:(e,t,r)=>{"use strict";var n=r(488),i=r(239),o=r(40),a=r(595)||0;function s(){return i(a)}e.exports=s,e.exports.generate=s,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return a=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=o},40:(e,t,r)=>{"use strict";var n=r(488);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},19:e=>{"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r="object"===("undefined"==typeof window?"undefined":t(window))&&(window.crypto||window.msCrypto),n=r&&r.getRandomValues?function(e){return r.getRandomValues(new Uint8Array(e))}:function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(256*Math.random()));return t};e.exports=n},87:e=>{"use strict";var t=1;e.exports={nextValue:function(){return(t=(9301*t+49297)%233280)/233280},seed:function(e){t=e}}},595:e=>{"use strict";e.exports=0},129:e=>{"use strict";e.exports=n},300:t=>{"use strict";t.exports=e},1:e=>{"use strict";e.exports=o},356:e=>{"use strict";e.exports=i},881:e=>{"use strict";e.exports=r},937:e=>{"use strict";e.exports=t}},l={},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u={},(()=>{"use strict";a.d(u,{default:()=>Ef});var e={},t=(a.r(e),a.d(e,{bindTextureBaseData:()=>Pi,default:()=>Si,disposeTexture:()=>Ei,getBlobByTexture:()=>Oi,getMimeByTexture:()=>_i,getSizeByTexture:()=>Di,getTextureGpuMemory:()=>Mi,getUrlByTexture:()=>Ci,initTexture:()=>Ri,loadTexture:()=>Ai,parseImageBitMapByBlob:()=>ki,setTextureMapping:()=>Li,textureNameMap:()=>Ti}),{}),r=(a.r(t),a.d(t,{angleToNum:()=>ya,anima:()=>_o,arrayBufferToBase64:()=>Do,arrayBufferToBlobUr:()=>Co,arrayToVector3:()=>da,base64ToArrayBuffer:()=>ko,base64ToBlob:()=>jo,bitMapToCanvas:()=>Ho,blobToFile:()=>Bo,canvasToBlob:()=>Qo,changeModelOpc:()=>sa,changeModelOpcs:()=>la,clone:()=>aa,compressImgToUrl:()=>Go,deepMergeObject:()=>ba,domTo2Dui:()=>na,domTo3DSprite:()=>ia,domTo3Dui:()=>ra,fileAndBlobToCanvas:()=>Vo,fileToBlob:()=>Uo,getCamAnimaData:()=>ta,getCurve:()=>fa,getDistance:()=>ea,getFilesByDataTransfer:()=>Zo,getImgPixels:()=>Yo,getImgPixels1:()=>qo,getLine2:()=>ma,getMacro:()=>oa,getMd5:()=>Fo,getNamesByNum:()=>ua,getRes:()=>Jo,getTruthBase64:()=>Ao,getType:()=>ga,getTypeByBase64:()=>zo,getVideoTexture:()=>pa,getWorldLocal:()=>Mo,hslToRgb:()=>Xo,imgArrayBufferToBlobUrl:()=>Lo,imgBitMapToBase64:()=>Eo,imgBitMapToBlob:()=>Po,imgBitMapToBlobAndBase64:()=>Ro,mergeObject:()=>$o,removeUnLess:()=>ha,reverseImg:()=>Oo,rgbToHsl:()=>Wo,setDynamic:()=>va,textureToThreeD:()=>ca,transByte:()=>No,urlToBlob:()=>Io,vector:()=>Ko}),{}),n=(a.r(r),a.d(r,{createDefMaterial:()=>Ha,defAllMaterialMap:()=>Fa,defBaseMaterialMap:()=>Na,default:()=>Va,disposeMaterial:()=>Wa,getTextures:()=>qa,getTexturesByMaterial:()=>Xa,mergeMaterial:()=>Ga}),{}),i=(a.r(n),a.d(n,{createDefModel:()=>ts,default:()=>es,disposeModel:()=>rs,instanceModel:()=>ns}),{}),o=(a.r(i),a.d(i,{AsyncCompress:()=>uu,AsyncDecompress:()=>_u,AsyncDeflate:()=>tu,AsyncGunzip:()=>fu,AsyncGzip:()=>uu,AsyncInflate:()=>ou,AsyncUnzipInflate:()=>qu,AsyncUnzlib:()=>xu,AsyncZipDeflate:()=>Hu,AsyncZlib:()=>yu,Compress:()=>lu,DecodeUTF8:()=>ku,Decompress:()=>Tu,Deflate:()=>eu,EncodeUTF8:()=>Au,Gunzip:()=>pu,Gzip:()=>lu,Inflate:()=>iu,Unzip:()=>Yu,UnzipInflate:()=>Xu,UnzipPassThrough:()=>Wu,Unzlib:()=>bu,Zip:()=>Gu,ZipDeflate:()=>Vu,ZipPassThrough:()=>Fu,Zlib:()=>vu,compress:()=>cu,compressSync:()=>hu,decompress:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return(31==e[0]&&139==e[1]&&8==e[2]?du:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?au:wu)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?mu:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?su:Su)(e,t)},deflate:()=>ru,deflateSync:()=>nu,gunzip:()=>du,gunzipSync:()=>mu,gzip:()=>cu,gzipSync:()=>hu,inflate:()=>au,inflateSync:()=>su,strFromU8:()=>Lu,strToU8:()=>Cu,unzip:()=>function(e,t){if("function"!=typeof t)throw"no callback";for(var r=[],n=function(){for(var e=0;e<r.length;++e)r[e]()},i={},o=e.length-22;101010256!=Wl(e,o);--o)if(!o||65558<e.length-o)return void t("invalid zip file",null);var a=Gl(e,o+8);a||t(null,{});var s=a,l=Wl(e,o+16),u=4294967295==l;if(u){if(o=Wl(e,o-12),101075792!=Wl(e,o))return void t("invalid zip file",null);s=a=Wl(e,o+32),l=Wl(e,o+48)}for(var c=function(o){function s(e,r){e?(n(),t(e,null)):(i[f]=r,--a||t(null,i))}var c=(m=ju(e,l,u))[0],h=m[1],p=m[2],f=m[3],d=m[4],m=m[5];if(m=Iu(e,m),l=d,c)if(8==c)if(d=e.subarray(m,m+h),h<32e4)try{s(null,su(d,new Fs(p)))}catch(o){s(o,null)}else r.push(au(d,{size:p},s));else s("unknown compression type "+c,null);else s(null,dl(e,m,m+h))},h=0;h<s;++h)c();return n},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=Wl(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var n=Gl(e,r+8);if(!n)return{};var i=Wl(e,r+16),o=4294967295==i;if(o){if(r=Wl(e,r-12),101075792!=Wl(e,r))throw"invalid zip file";n=Wl(e,r+32),i=Wl(e,r+48)}for(var a=0;a<n;++a){var s=(p=ju(e,i,o))[0],l=p[1],u=p[2],c=p[3],h=p[4],p=p[5];if(p=Iu(e,p),i=h,s){if(8!=s)throw"unknown compression type "+s;t[c]=su(e.subarray(p,p+l),new Fs(u))}else t[c]=dl(e,p,p+l)}return t},unzlib:()=>wu,unzlibSync:()=>Su,zip:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";function n(){for(var e=0;e<p.length;++e)p[e]()}function i(){for(var e=new Fs(u+22),t=l,n=u-l,i=u=0;i<c;++i){var o=h[i];try{var a=o.c.length,s=(zu(e,u,o,o.f,o.u,a),30+o.f.length+Bu(o.extra)),p=u+s;e.set(o.c,p),zu(e,l,o,o.f,o.u,a,u,o.m),l+=16+s+(o.m?o.m.length:0),u=p+a}catch(e){return r(e,null)}}Nu(e,l,h.length,n,t),r(null,e)}var o={},a=(Mu(e,"",o,t),Object.keys(o)),s=a.length,l=0,u=0,c=s,h=new Array(s),p=[];s||i();for(var f=function(e){function t(t,o){t?(n(),r(t,null)):(t=o.length,h[e]=Al(m,{size:y,crc:v.d(),c:o,f:g,m:w,u:b!=c.length||w&&x.length!=S,compression:_}),l+=30+b+T+t,u+=76+2*(b+T)+(S||0)+t,--s||i())}var c=a[e],f=o[c],d=f[0],m=f[1],v=Ol(),y=d.length,g=(v.p(d),Cu(c)),b=g.length,x=m.comment,w=x&&Cu(x),S=w&&w.length,T=Bu(m.extra),_=0==m.level?0:8;if(65535<b&&t("filename too long",null),_)if(y<16e4)try{t(null,nu(d,m))}catch(f){t(f,null)}else p.push(ru(d,m,t));else t(null,d)},d=0;d<c;++d)f(d);return n},zipSync:()=>function(e,t){var r,n={},i=[],o=(Mu(e,"",n,t=t||{}),0),a=0;for(r in n){var s,l=(s=n[r])[0],u=0==(s=s[1]).level?0:8,c=(x=Cu(r)).length,h=s.comment,p=h&&Cu(h),f=p&&p.length,d=Bu(s.extra);if(65535<c)throw"filename too long";var m=u?nu(l,s):l,v=m.length,y=Ol();y.p(l),i.push(Al(s,{size:l.length,crc:y.d(),c:m,f:x,m:p,u:c!=r.length||p&&h.length!=f,o,compression:u})),o+=30+c+d+v,a+=76+2*(c+d)+(f||0)+v}for(var g=new Fs(a+22),b=(e=o,t=a-o,0);b<i.length;++b){var x=i[b],w=(zu(g,x.o,x,x.f,x.u,x.c.length),30+x.f.length+Bu(x.extra));g.set(x.c,x.o+w),zu(g,o,x,x.f,x.u,x.c.length,x.o,x.m),o+=16+w+(x.m?x.m.length:0)}return Nu(g,o,i.length,t,e),g},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[jl,zl,function(){return[gu]}],(function(e){return Fl(gu(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>gu}),a(300)),s=a.n(o),l=a(251),c=a(881);function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=b(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(r=t?(r=b(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===h(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var x=new c.Vector3,w=new c.Quaternion,S=new c.Vector3,T=function(){v(t,c.Object3D);var e=g(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return p(this,t),(r=e.call(this)).element=n,r.element.style.position="absolute",r.element.style.pointerEvents="auto",r.element.style.userSelect="none",r.element.setAttribute("draggable",!1),r.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))})),r}return d(t,[{key:"copy",value:function(e,r){return m(b(t.prototype),"copy",this).call(this,e,r),this.element=e.element.cloneNode(!0),this}}]),t}(),_=(T.prototype.isCSS3DObject=!0,function(){v(t,T);var e=g(t);function t(r){return p(this,t),(r=e.call(this,r)).rotation2D=0,r}return d(t,[{key:"copy",value:function(e,r){return m(b(t.prototype),"copy",this).call(this,e,r),this.rotation2D=e.rotation2D,this}}]),t}()),M=(_.prototype.isCSS3DSprite=!0,new c.Matrix4),E=new c.Matrix4,P=d((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(p(this,e),this),s={camera:{fov:0,style:""},objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div"),u=(l.style.overflow="hidden",this.domElement=l,document.createElement("div"));function c(e){return Math.abs(e)<1e-10?0:e}function h(e){return"matrix3d("+c((e=e.elements)[0])+","+c(-e[1])+","+c(e[2])+","+c(e[3])+","+c(e[4])+","+c(-e[5])+","+c(e[6])+","+c(e[7])+","+c(e[8])+","+c(-e[9])+","+c(e[10])+","+c(e[11])+","+c(e[12])+","+c(-e[13])+","+c(e[14])+","+c(e[15])+")"}function f(e){return"translate(-50%,-50%)matrix3d("+c((e=e.elements)[0])+","+c(e[1])+","+c(e[2])+","+c(e[3])+","+c(-e[4])+","+c(-e[5])+","+c(-e[6])+","+c(-e[7])+","+c(e[8])+","+c(e[9])+","+c(e[10])+","+c(e[11])+","+c(e[12])+","+c(e[13])+","+c(e[14])+","+c(e[15])+")"}u.style.transformStyle="preserve-3d",u.style.pointerEvents="none",l.appendChild(u),this.getSize=function(){return{width:t,height:r}},this.render=function(e,t){var r=t.projectionMatrix.elements[5]*i,o=(s.camera.fov!==r&&(l.style.perspective=t.isPerspectiveCamera?r+"px":"",s.camera.fov=r),!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.isOrthographicCamera&&(o=-(t.right+t.left)/2,p=(t.top+t.bottom)/2),t.isOrthographicCamera?"scale("+r+")translate("+c(o)+"px,"+c(p)+"px)"+h(t.matrixWorldInverse):"translateZ("+r+"px)"+h(t.matrixWorldInverse)),p=o+"translate("+n+"px,"+i+"px)";s.camera.style!==p&&(u.style.transform=p,s.camera.style=p),function e(t,r,n,i){var o,l,c;t.isCSS3DObject&&(o=!0===t.visible&&!0===t.layers.test(n.layers),t.element.style.display=1==o?"":"none",1==o&&(t.onBeforeRender(a,r,n),o=t.isCSS3DSprite?(M.copy(n.matrixWorldInverse),M.transpose(),0!==t.rotation2D&&M.multiply(E.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(x,w,S),M.setPosition(x),M.scale(S),M.elements[3]=0,M.elements[7]=0,M.elements[11]=0,M.elements[15]=1,f(M)):f(t.matrixWorld),l=t.element,void 0!==(c=s.objects.get(t))&&c.style===o||(c={style:l.style.transform=o},s.objects.set(t,c)),l.parentNode!==u&&u.appendChild(l),t.onAfterRender(a,r,n)));for(var h=0,p=t.children.length;h<p;h++)e(t.children[h],r,n,i)}(e,e,t,o)},this.setSize=function(e,o){n=(t=e)/2,i=(r=o)/2,l.style.width=e+"px",l.style.height=o+"px",u.style.width=e+"px",u.style.height=o+"px"}}));function O(e){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,t,r){return t&&k(e.prototype,t),r&&k(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function C(){return(C="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=D(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var I=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&L(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=D(e);if(r=t?(r=D(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===O(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return R(this,n),(e=r.call(this)).element=t,e.element.style.position="absolute",e.element.style.userSelect="none",e.element.setAttribute("draggable",!1),e.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))})),e}return A(n,[{key:"copy",value:function(e,t){return C(D(n.prototype),"copy",this).call(this,e,t),this.element=e.element.cloneNode(!0),this}}]),n}(c.Object3D),j=(I.prototype.isCSS2DObject=!0,new c.Vector3),U=new c.Matrix4,B=new c.Matrix4,z=new c.Vector3,N=new c.Vector3,F=A((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(R(this,e),this),s={objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div");function u(e,t){return z.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(t.matrixWorld),z.distanceToSquared(N)}l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:t,height:r}},this.render=function(e,t){!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),U.copy(t.matrixWorldInverse),B.multiplyMatrices(t.projectionMatrix,U),function e(t,r,o){var c;t.isCSS2DObject&&(j.setFromMatrixPosition(t.matrixWorld),j.applyMatrix4(B),c=!0===t.visible&&-1<=j.z&&j.z<=1&&!0===t.layers.test(o.layers),t.element.style.display=1==c?"":"none",1==c&&(t.onBeforeRender(a,r,o),c=t.element,/apple/i.test(navigator.vendor)?c.style.transform="translate(-50%,-50%) translate("+Math.round(j.x*n+n)+"px,"+Math.round(-j.y*i+i)+"px)":c.style.transform="translate(-50%,-50%) translate("+(j.x*n+n)+"px,"+(-j.y*i+i)+"px)",c.parentNode!==l&&l.appendChild(c),t.onAfterRender(a,r,o)),c={distanceToCameraSquared:u(o,t)},s.objects.set(t,c));for(var h=0,p=t.children.length;h<p;h++)e(t.children[h],r,o)}(e,e,t);for(var r=function(e){var t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){return e.renderOrder!==t.renderOrder?t.renderOrder-e.renderOrder:s.objects.get(e).distanceToCameraSquared-s.objects.get(t).distanceToCameraSquared})),o=r.length,c=0,h=r.length;c<h;c++)r[c].element.style.zIndex=o-c},this.setSize=function(e,o){n=(t=e)/2,i=(r=o)/2,l.style.width=e+"px",l.style.height=o+"px"}}));class V{constructor(e){this.scene=null,this.camera=null,this.controls=null,this.renderer=null,this.engineDom=null,this.disposeRender=e=>{e&&(e.render=()=>{},e.domElement.remove())},this.runScene=e}initRender3(){const e=new P;return e.setSize(this.engineDom.clientWidth,this.engineDom.clientHeight),e.domElement.style.position="absolute",e.domElement.style.top=String(0),e.domElement.className="css3dRenderer",this.engineDom.appendChild(e.domElement),e}initRender2(){const e=new F;return e.setSize(this.engineDom.clientWidth,this.engineDom.clientHeight),e.domElement.style.position="absolute",e.domElement.classList.add("css2dRenderer"),e.domElement.style.top="0px",e.domElement.style.left="0px",this.engineDom.insertBefore(e.domElement,this.engineDom.childNodes[0]),e}reset(){this.renderer=this.runScene.renderEx.create(this.engineDom),this.runScene.renderEx.setSize(),this.renderer.setAnimationLoop(this.runScene.render.bind(this.runScene));var e=this.camera;this.controls=this.runScene.controlsEx.create(e,this.renderer.domElement)}dispose(){this.disposeRender(this.render2),this.disposeRender(this.render3)}init(e){var t=this.runScene.sceneEx.create(),r=this.runScene.cameraEx.create();const n=this.runScene.renderEx.create(e);var i=this.runScene.controlsEx.create(r,e),{render2:o,render3:a}=this.runScene.optionsEx.options;return this.camera=r,this.scene=t,this.renderer=n,this.controls=i,this.engineDom=e,this.runScene.renderEx.setSize(),o&&(this.render2=this.initRender2()),a&&(this.render3=this.initRender3()),n.setAnimationLoop(this.runScene.render.bind(this.runScene)),{scene:t,camera:r,render:n,controls:i,engineDom:e}}get(){var{scene:e,camera:t,renderer:r,controls:n,engineDom:i}=this;return{scene:e,camera:t,renderer:r,controls:n,engineDom:i}}}var H={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\tgl_FragColor = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor.a *= opacity;\n\n\n\t\t}"};function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function W(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function X(e,t,r){t&&W(e.prototype,t),r&&W(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var q=function(){function e(){G(this,e),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}return X(e,[{key:"setSize",value:function(){}},{key:"render",value:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}]),e}(),Y=new c.OrthographicCamera(-1,1,1,-1,0,1),Z=new c.BufferGeometry,Q=(Z.setAttribute("position",new c.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),Z.setAttribute("uv",new c.Float32BufferAttribute([0,2,0,0,2,0],2)),function(){function e(t){G(this,e),this._mesh=new c.Mesh(Z,t)}return X(e,[{key:"dispose",value:function(){this._mesh.geometry.dispose()}},{key:"render",value:function(e){e.render(this._mesh,Y)}},{key:"material",get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}]),e}());function K(e){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ee=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&J(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=$(e);if(r=t?(r=$(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===K(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t){var i;if(this instanceof n)return(i=r.call(this)).textureID=void 0!==t?t:"tDiffuse",e instanceof c.ShaderMaterial?(i.uniforms=e.uniforms,i.material=e):e&&(i.uniforms=c.UniformsUtils.clone(e.uniforms),i.material=new c.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:i.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),i.fsQuad=new Q(i.material),i;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"render",value:function(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),te={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new c.Color(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}"};function re(e){return(re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ne(e,t){return(ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){return(ie=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var oe=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ne(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ie(e);if(r=t?(r=ie(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===re(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){var a;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(a=r.call(this)).strength=void 0!==t?t:1,a.radius=i,a.threshold=o,a.resolution=void 0!==e?new c.Vector2(e.x,e.y):new c.Vector2(256,256),a.clearColor=new c.Color(0,0,0),a.renderTargetsHorizontal=[],a.renderTargetsVertical=[],a.nMips=5;var s=Math.round(a.resolution.x/2),l=Math.round(a.resolution.y/2);a.renderTargetBright=new c.WebGLRenderTarget(s,l),a.renderTargetBright.texture.name="UnrealBloomPass.bright",a.renderTargetBright.texture.generateMipmaps=!1;for(var u=0;u<a.nMips;u++){var h;((h=new c.WebGLRenderTarget(s,l)).texture.name="UnrealBloomPass.h"+u,h.texture.generateMipmaps=!1,a.renderTargetsHorizontal.push(h),h=new c.WebGLRenderTarget(s,l)).texture.name="UnrealBloomPass.v"+u,h.texture.generateMipmaps=!1,a.renderTargetsVertical.push(h),s=Math.round(s/2),l=Math.round(l/2)}i=te;for(var p=(a.highPassUniforms=c.UniformsUtils.clone(i.uniforms),a.highPassUniforms.luminosityThreshold.value=o,a.highPassUniforms.smoothWidth.value=.01,a.materialHighPassFilter=new c.ShaderMaterial({uniforms:a.highPassUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,defines:{}}),a.separableBlurMaterials=[],[3,5,7,9,11]),f=(s=Math.round(a.resolution.x/2),l=Math.round(a.resolution.y/2),0);f<a.nMips;f++)a.separableBlurMaterials.push(a.getSeperableBlurMaterial(p[f])),a.separableBlurMaterials[f].uniforms.texSize.value=new c.Vector2(s,l),s=Math.round(s/2),l=Math.round(l/2);return a.compositeMaterial=a.getCompositeMaterial(a.nMips),a.compositeMaterial.uniforms.blurTexture1.value=a.renderTargetsVertical[0].texture,a.compositeMaterial.uniforms.blurTexture2.value=a.renderTargetsVertical[1].texture,a.compositeMaterial.uniforms.blurTexture3.value=a.renderTargetsVertical[2].texture,a.compositeMaterial.uniforms.blurTexture4.value=a.renderTargetsVertical[3].texture,a.compositeMaterial.uniforms.blurTexture5.value=a.renderTargetsVertical[4].texture,a.compositeMaterial.uniforms.bloomStrength.value=t,a.compositeMaterial.uniforms.bloomRadius.value=.1,a.compositeMaterial.needsUpdate=!0,a.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],a.bloomTintColors=[new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1)],a.compositeMaterial.uniforms.bloomTintColors.value=a.bloomTintColors,e=H,a.copyUniforms=c.UniformsUtils.clone(e.uniforms),a.copyUniforms.opacity.value=1,a.materialCopy=new c.ShaderMaterial({uniforms:a.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:c.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),a.enabled=!0,a.needsSwap=!1,a._oldClearColor=new c.Color,a.oldClearAlpha=1,a.basic=new c.MeshBasicMaterial,a.fsQuad=new Q(null),a}return e=n,(t=[{key:"dispose",value:function(){for(var e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(var t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()}},{key:"setSize",value:function(e,t){var r=Math.round(e/2),n=Math.round(t/2);this.renderTargetBright.setSize(r,n);for(var i=0;i<this.nMips;i++)this.renderTargetsHorizontal[i].setSize(r,n),this.renderTargetsVertical[i].setSize(r,n),this.separableBlurMaterials[i].uniforms.texSize.value=new c.Vector2(r,n),r=Math.round(r/2),n=Math.round(n/2)}},{key:"render",value:function(e,t,r,i,o){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();for(var a=e.autoClear,s=(e.autoClear=!1,e.setClearColor(this.clearColor,0),o&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=r.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e),this.renderTargetBright),l=0;l<this.nMips;l++)this.fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[l].uniforms.direction.value=n.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=n.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this.fsQuad.render(e),s=this.renderTargetsVertical[l];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,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,o&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(r),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}},{key:"getSeperableBlurMaterial",value:function(e){return new c.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new c.Vector2(.5,.5)},direction:{value:new c.Vector2(.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}"})}},{key:"getCompositeMaterial",value:function(e){return new c.ShaderMaterial({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{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 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}"})}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function ae(e){return(ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function le(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ue(e,t,r){t&&le(e.prototype,t),r&&le(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function ce(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&he(e,t)}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=fe(e);if(r=t?(r=fe(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ae(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function fe(e){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}oe.BlurDirectionX=new c.Vector2(1,0),oe.BlurDirectionY=new c.Vector2(0,1);var de=function(){ce(t,q);var e=pe(t);function t(r,n){var i;return se(this,t),(i=e.call(this)).scene=r,i.camera=n,i.clear=!0,i.needsSwap=!1,i.inverse=!1,i}return ue(t,[{key:"render",value:function(e,t,r){var n,i,o=e.getContext(),a=e.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0),i=this.inverse?(n=0,1):(n=1,0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(o.REPLACE,o.REPLACE,o.REPLACE),a.buffers.stencil.setFunc(o.ALWAYS,n,4294967295),a.buffers.stencil.setClear(i),a.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(o.EQUAL,1,4294967295),a.buffers.stencil.setOp(o.KEEP,o.KEEP,o.KEEP),a.buffers.stencil.setLocked(!0)}}]),t}(),me=function(){ce(t,q);var e=pe(t);function t(){var r;return se(this,t),(r=e.call(this)).needsSwap=!1,r}return ue(t,[{key:"render",value:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}]),t}();function ve(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var ye=function(){function e(t,r){var n;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.renderer=t,void 0===r?(n=t.getSize(new c.Vector2),this._pixelRatio=t.getPixelRatio(),this._width=n.width,this._height=n.height,(r=new c.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio)).texture.name="EffectComposer.rt1"):(this._pixelRatio=1,this._width=r.width,this._height=r.height),this.renderTarget1=r,this.renderTarget2=r.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===ee&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new ee(H),this.clock=new c.Clock}return function(e,t,r){t&&ve(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"swapBuffers",value:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}},{key:"addPass",value:function(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}},{key:"insertPass",value:function(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}},{key:"removePass",value:function(e){-1!==(e=this.passes.indexOf(e))&&this.passes.splice(e,1)}},{key:"isLastEnabledPass",value:function(e){for(var t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}},{key:"render",value:function(e){void 0===e&&(e=this.clock.getDelta());for(var t=this.renderer.getRenderTarget(),r=!1,n=0,i=this.passes.length;n<i;n++){var o,a,s=this.passes[n];!1!==s.enabled&&(s.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(n),s.render(this.renderer,this.writeBuffer,this.readBuffer,e,r),s.needsSwap&&(r&&(o=this.renderer.getContext(),(a=this.renderer.state.buffers.stencil).setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),a.setFunc(o.EQUAL,1,4294967295)),this.swapBuffers()),void 0!==de&&(s instanceof de?r=!0:s instanceof me&&(r=!1)))}this.renderer.setRenderTarget(t)}},{key:"reset",value:function(e){var t;void 0===e&&(t=this.renderer.getSize(new c.Vector2),this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,(e=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}},{key:"setSize",value:function(e,t){this._width=e,this._height=t;var r=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(r,n),this.renderTarget2.setSize(r,n);for(var i=0;i<this.passes.length;i++)this.passes[i].setSize(r,n)}},{key:"setPixelRatio",value:function(e){this._pixelRatio=e,this.setSize(this._width,this._height)}}]),e}();function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function be(e,t){return(be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function xe(e){return(xe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}new c.OrthographicCamera(-1,1,1,-1,0,1),(o=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new c.Float32BufferAttribute([0,2,0,0,2,0],2));var we=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&be(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=xe(e);if(r=t?(r=xe(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ge(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){var a;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(a=r.call(this)).scene=e,a.camera=t,a.sampleLevel=4,a.unbiased=!0,a.clearColor=void 0!==i?i:0,a.clearAlpha=void 0!==o?o:0,a._oldClearColor=new c.Color,e=H,a.copyUniforms=c.UniformsUtils.clone(e.uniforms),a.copyMaterial=new c.ShaderMaterial({uniforms:a.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:c.AdditiveBlending,depthTest:!1,depthWrite:!1}),a.fsQuad=new Q(a.copyMaterial),a}return e=n,(t=[{key:"dispose",value:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}},{key:"setSize",value:function(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}},{key:"render",value:function(e,t,r){this.sampleRenderTarget||(this.sampleRenderTarget=new c.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var n=Se[Math.max(0,Math.min(this.sampleLevel,5))],i=e.autoClear,o=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),a=1/n.length,s=(this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,{fullWidth:r.width,fullHeight:r.height,offsetX:0,offsetY:0,width:r.width,height:r.height});(r=Object.assign({},this.camera.view)).enabled&&Object.assign(s,r);for(var l=0;l<n.length;l++){var u=n[l];this.camera.setViewOffset&&this.camera.setViewOffset(s.fullWidth,s.fullHeight,s.offsetX+.0625*u[0],s.offsetY+.0625*u[1],s.width,s.height),u=a,this.unbiased&&(u+=1/32*((l+.5)/n.length-.5)),this.copyUniforms.opacity.value=u,e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(this.renderToScreen?null:t),0===l&&(e.setClearColor(0,0),e.clear()),this.fsQuad.render(e)}this.camera.setViewOffset&&r.enabled?this.camera.setViewOffset(r.fullWidth,r.fullHeight,r.offsetX,r.offsetY,r.width,r.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),e.autoClear=i,e.setClearColor(this._oldClearColor,o)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),Se=[[[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]]];function Te(e){return(Te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _e(){return(_e="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ee(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function Me(e,t){return(Me=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ee(e){return(Ee=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Pe=function(){var e=n,t=we;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Me(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Ee(e);if(r=t?(r=Ee(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Te(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){if(this instanceof n)return(e=r.call(this,e,t,i,o)).sampleLevel=0,e.accumulate=!1,e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"render",value:function(e,t,r,i){if(!1===this.accumulate)return _e(Ee(n.prototype),"render",this).call(this,e,t,r,i),void(this.accumulateIndex=-1);var o=Oe[5],a=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new c.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new c.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(_e(Ee(n.prototype),"render",this).call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0),i=e.autoClear,e.autoClear=!1,1/o.length);if(0<=this.accumulateIndex&&this.accumulateIndex<o.length){this.copyUniforms.opacity.value=a,this.copyUniforms.tDiffuse.value=t.texture;for(var s=Math.pow(2,this.sampleLevel),l=0;l<s;l++){var u=o[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*u[0],.0625*u[1],r.width,r.height),e.setRenderTarget(t),e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(this.sampleRenderTarget),0===this.accumulateIndex&&e.clear(),this.fsQuad.render(e),this.accumulateIndex++,this.accumulateIndex>=o.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(a=this.accumulateIndex*a)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),a<1&&(this.copyUniforms.opacity.value=1-a,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==a&&e.clear(),this.fsQuad.render(e)),e.autoClear=i}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),Oe=[[[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]]];class Re extends q{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof c.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=c.UniformsUtils.clone(e.uniforms),this.material=new c.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Q(this.material)}render(e,t,r){this.uniforms[this.baseTextureID]&&(this.uniforms[this.baseTextureID].value=t.texture),this.uniforms[this.effectTextureID]&&(this.uniforms[this.effectTextureID].value=r.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)}}class ke extends q{constructor(e,t,r,n,i){super(),this.scene=e,this.camera=t,this.layerIndex=0,this.overrideMaterial=r,this.clearColor=n,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.oldClearColor=new c.Color,this.oldCameraLayer=t.layers.mask}render(e,t,r){var n=e.autoClear;let i,o;e.autoClear=!1,void 0!==this.overrideMaterial&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this.oldClearColor),i=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.sceneBg&&(this.scene.background=null),e.setRenderTarget(this.renderToScreen?null:r),this.clear&&e.clear(e.autoClearColor,this.clearDepth,e.autoClearStencil),this.camera.layers.set(this.layerIndex),e.render(this.scene,this.camera),this.camera.layers.mask=this.oldCameraLayer,this.clearColor&&e.setClearColor(this.oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=o),this.scene.background=this.sceneBg,e.autoClear=n}}const Ae={uniforms:{baseTexture:{value:null},bloomTexture:{value:null}},vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D baseTexture;\n uniform sampler2D bloomTexture;\n \n varying vec2 vUv;\n \n void main() {\n vec4 lastColor = texture2D(baseTexture, vUv);\n \n // gl_FragColor = lastColor;\n // gl_FragColor = texture2D(bloomTexture, vUv);\n gl_FragColor = lastColor + texture2D(bloomTexture, vUv);\n }\n "};class Ce{constructor(e){this.modelLength=new Set,this.runScene=e,this.init()}init(){const{setLayers:e,add:t,remove:r}=this.runScene.optionsEx.cb.model;e.add("glow-set-layers",(e=>{var{model:e,val:t}=e;0===t&&0===this.modelLength.size||this[0===t?"remove":"add"](e)})),r.add("glow-set-layers",(({model:e})=>{1!==e.layers.mask&&this.remove(e)})),t.add("glow-set-layers",(({model:e})=>{1!==e.layers.mask&&this.add(e)}))}add(e){this.modelLength.add(e.userData.id),0<this.modelLength.size&&(this.runScene.optionsEx.cb.bloom.glow.setStatus.cb(!0),this.runScene.bloom.glow.bloomParams.isBloom=!0)}remove(e){this.modelLength.delete(e.userData.id),this.modelLength.size<=0&&(this.runScene.optionsEx.cb.bloom.glow.setStatus.cb(!1),this.runScene.bloom.glow.bloomParams.isBloom=!1)}}class Le{constructor(e){this.bloomParams={isBloom:!1,bloomStrength:2,bloomThreshold:0,bloomRadius:0},this.runScene=e,this.info=new Ce(this.runScene),this.BLOOM_SCENE=1,this.bloomParams.isBloom=!1,this.isUpdate=!0,this.sceneBackground=null,this.runScene.exporter.gltf.options.addOption({type:"bloom-glow",process:e=>this.toJSON(),parse:e=>{e=JSON.parse(e),this.setData(e)}})}static getInstance(e){return Le.instance||(Le.instance=new Le(e)),Le.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?c.ACESFilmicToneMapping:c.NoToneMapping)}init(e){var{camera:e,scene:t,renderer:r}=e;this.mainScene=t,this.mainCamera=e,this.renderer=r,this.renderer&&(t=this.renderer.getDrawingBufferSize(new c.Vector2),this.rtSize={width:t.width,height:t.height},this.postProcessing())}setData(e){e=e.bloomParams;var{bloomRadius:e,bloomStrength:t,bloomThreshold:r,isBloom:n}=e;this.bloomParams.isBloom=n,this.bloomParams.bloomRadius=e,this.bloomParams.bloomStrength=t,this.bloomParams.bloomThreshold=r,this.bloomPass&&(this.bloomPass.strength=t,this.bloomPass.radius=e,this.bloomPass.threshold=r),this.runScene.optionsEx.cb.bloom.glow.setData.cb(this.bloomParams)}setSize(e,t){this.renderer&&(this.rtSize={width:e,height:t},this.effectComposer&&this.effectComposer.setSize(this.rtSize.width,this.rtSize.height))}setBackground(e){this.sceneBackground&&this.sceneBackground instanceof c.Texture&&this.sceneBackground.dispose(),this.sceneBackground=e,this.bloomRenderPass&&(this.bloomRenderPass.sceneBg=this.sceneBackground)}setUpdate(e){this.isUpdate=e}postProcessing(){this.renderer&&(this.renderer.autoClear=!1),this.effectRT?(this.effectRT.setSize(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.dispose()):(this.effectRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=c.FloatType,this.effectRT.texture.format=c.RGBAFormat,this.effectRT.texture.encoding=c.sRGBEncoding,this.effectRT.texture.minFilter=c.LinearFilter,this.effectRT.texture.magFilter=c.LinearFilter),this.effectRT.depthTexture=new c.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=c.DepthFormat,this.effectRT.depthTexture.type=c.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new Pe(this.mainScene,this.mainCamera,0,0),this.taaRenderPass.unbiased=!1,this.taaRenderPass.sampleLevel=1,this.taaRenderPass.accumulate=!1),this.sampleRT?this.sampleRT.setSize(this.rtSize.width,this.rtSize.height):(this.sampleRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=c.FloatType,this.sampleRT.texture.format=c.RGBAFormat,this.sampleRT.texture.encoding=c.sRGBEncoding,this.sampleRT.texture.minFilter=c.LinearFilter,this.sampleRT.texture.magFilter=c.LinearFilter,this.sampleRT.depthTexture=this.effectRT.depthTexture,this.taaRenderPass.sampleRenderTarget=this.sampleRT),this.holdRT?this.holdRT.setSize(this.rtSize.width,this.rtSize.height):(this.holdRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=c.FloatType,this.holdRT.texture.format=c.RGBAFormat,this.holdRT.texture.encoding=c.sRGBEncoding,this.holdRT.texture.minFilter=c.LinearFilter,this.holdRT.texture.magFilter=c.LinearFilter,this.holdRT.depthTexture=this.effectRT.depthTexture,this.taaRenderPass.holdRenderTarget=this.holdRT),this.bloomRenderPass?(this.bloomRenderPass.scene=this.mainScene,this.bloomRenderPass.camera=this.mainCamera):(this.bloomRenderPass=new ke(this.mainScene,this.mainCamera),this.bloomRenderPass.layerIndex=this.BLOOM_SCENE,this.bloomRenderPass.clearDepth=!1,this.bloomRenderPass.sceneBg=this.sceneBackground),this.bloomPass?this.bloomPass.setSize(this.rtSize.width,this.rtSize.height):this.bloomPass=new oe(new c.Vector2(this.rtSize.width,this.rtSize.height),1.5,.4,.85),this.bloomPass.strength=this.bloomParams.bloomStrength,this.bloomPass.radius=this.bloomParams.bloomRadius,this.bloomPass.threshold=this.bloomParams.bloomThreshold,this.mixingPass||(this.mixingPass=new Re(Ae,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new ee(H),this.effectCopy.clear=!1,this.effectCopy.renderToScreen=!1,this.effectCopy.needsSwap=!1,this.effectCopy.material.depthWrite=!1),this.effectComposer?this.effectComposer.renderer=this.renderer:(this.effectComposer=new ye(this.renderer,this.effectRT),this.effectComposer.addPass(this.taaRenderPass),this.effectComposer.addPass(this.effectCopy),this.effectComposer.addPass(this.bloomRenderPass),this.effectComposer.addPass(this.bloomPass),this.effectComposer.addPass(this.mixingPass))}dispose(){this.mainScene=null,this.mainCamera=null,this.setBackground(null),this.effectRT&&(this.effectRT.depthTexture.dispose(),this.effectRT.depthTexture=null,this.effectRT.dispose(),this.effectRT=null),this.sampleRT&&(this.sampleRT.depthTexture.dispose(),this.sampleRT.depthTexture=null,this.sampleRT.dispose(),this.sampleRT=null),this.holdRT&&(this.holdRT.depthTexture.dispose(),this.holdRT.depthTexture=null,this.holdRT.dispose(),this.holdRT=null),this.taaRenderPass&&(this.taaRenderPass.dispose(),this.taaRenderPass=null),this.bloomPass&&(this.bloomPass.dispose(),this.bloomPass=null),this.mixingPass=null,this.effectCopy=null,this.effectComposer&&(this.effectComposer.renderTarget1&&(this.effectComposer.renderTarget1.dispose(),this.effectComposer.renderTarget1=null),this.effectComposer.renderTarget2&&(this.effectComposer.renderTarget2.dispose(),this.effectComposer.renderTarget2=null),this.effectComposer=null)}update(){this.isUpdate&&this.mainCamera&&this.mainScene&&this.renderer&&(this.renderer.clear(),this.bloomParams.isBloom?this.effectComposer.render():this.renderer.render(this.mainScene,this.mainCamera))}toJSON(){const e={};var t=this.bloomParams;return e.bloomParams=Object.assign({},t),JSON.stringify(e)}reset(){this.bloomParams.isBloom=!1,this.rendererTone=!1,this.setBackground(null)}}class De{constructor(e){this.runScene=e}create(){return new c.PerspectiveCamera}reset(e){e.position.set(0,20,20);const t=this.runScene.assetsEx.get().controls;t.target.set(0,0,0),t.update()}get(){return this.runScene.assetsEx.get().camera}}function Ie(e){return(Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ue(e,t)}function Ue(e,t){return(Ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Be(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ze(e){return(ze=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ne={type:"change"},Fe={type:"start"},Ve={type:"end"},He=function(){je(t,c.EventDispatcher);var e=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ze(e);if(r=t?(r=ze(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ie(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return Be(n)}}(t);function t(r,n){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,t),i=e.call(this),void 0===n&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),n===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),i.object=r,i.domElement=n,i.domElement.style.touchAction="none",i.enabled=!0,i.target=new c.Vector3,i.minDistance=0,i.maxDistance=1/0,i.minZoom=0,i.maxZoom=1/0,i.minPolarAngle=0,i.maxPolarAngle=Math.PI,i.minAzimuthAngle=-1/0,i.maxAzimuthAngle=1/0,i.enableDamping=!1,i.dampingFactor=.05,i.enableZoom=!0,i.zoomSpeed=1,i.enableRotate=!0,i.rotateSpeed=1,i.enablePan=!0,i.panSpeed=1,i.screenSpacePanning=!0,i.keyPanSpeed=7,i.autoRotate=!1,i.autoRotateSpeed=2,i.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},i.mouseButtons={LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN},i.touches={ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN},i.target0=i.target.clone(),i.position0=i.object.position.clone(),i.zoom0=i.object.zoom,i._domElementKeyEvents=null,i.getPolarAngle=function(){return v.phi},i.getAzimuthalAngle=function(){return v.theta},i.getDistance=function(){return this.object.position.distanceTo(this.target)},i.listenToKeyEvents=function(e){e.addEventListener("keydown",re),this._domElementKeyEvents=e},i.saveState=function(){p.target0.copy(p.target),p.position0.copy(p.object.position),p.zoom0=p.object.zoom},i.reset=function(){p.target.copy(p.target0),p.object.position.copy(p.position0),p.object.zoom=p.zoom0,p.object.updateProjectionMatrix(),p.dispatchEvent(Ne),p.update(),d=f.NONE},i.update=(o=new c.Vector3,a=(new c.Quaternion).setFromUnitVectors(r.up,new c.Vector3(0,1,0)),s=a.clone().invert(),l=new c.Vector3,u=new c.Quaternion,h=2*Math.PI,function(){var e=p.object.position,t=(o.copy(e).sub(p.target),o.applyQuaternion(a),v.setFromVector3(o),p.autoRotate&&d===f.NONE&&L(2*Math.PI/60/60*p.autoRotateSpeed),p.enableDamping?(v.theta+=y.theta*p.dampingFactor,v.phi+=y.phi*p.dampingFactor):(v.theta+=y.theta,v.phi+=y.phi),p.minAzimuthAngle),r=p.maxAzimuthAngle;return isFinite(t)&&isFinite(r)&&(t<-Math.PI?t+=h:t>Math.PI&&(t-=h),r<-Math.PI?r+=h:r>Math.PI&&(r-=h),v.theta=t<=r?Math.max(t,Math.min(r,v.theta)):v.theta>(t+r)/2?Math.max(t,v.theta):Math.min(r,v.theta)),v.phi=Math.max(p.minPolarAngle,Math.min(p.maxPolarAngle,v.phi)),v.makeSafe(),v.radius*=g,v.radius=Math.max(p.minDistance,Math.min(p.maxDistance,v.radius)),!0===p.enableDamping?p.target.addScaledVector(b,p.dampingFactor):p.target.add(b),o.setFromSpherical(v),o.applyQuaternion(s),e.copy(p.target).add(o),p.object.lookAt(p.target),!0===p.enableDamping?(y.theta*=1-p.dampingFactor,y.phi*=1-p.dampingFactor,b.multiplyScalar(1-p.dampingFactor)):(y.set(0,0,0),b.set(0,0,0)),g=1,!(!(x||l.distanceToSquared(p.object.position)>m||8*(1-u.dot(p.object.quaternion))>m)||(p.dispatchEvent(Ne),l.copy(p.object.position),u.copy(p.object.quaternion),x=!1))}),i.dispose=function(){p.domElement.removeEventListener("contextmenu",ne),p.domElement.removeEventListener("pointerdown",K),p.domElement.removeEventListener("pointercancel",ee),p.domElement.removeEventListener("wheel",te),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$),null!==p._domElementKeyEvents&&p._domElementKeyEvents.removeEventListener("keydown",re)};var i,o,a,s,l,u,h,p=Be(i),f={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},d=f.NONE,m=1e-6,v=new c.Spherical,y=new c.Spherical,g=1,b=new c.Vector3,x=!1,w=new c.Vector2,S=new c.Vector2,T=new c.Vector2,_=new c.Vector2,M=new c.Vector2,E=new c.Vector2,P=new c.Vector2,O=new c.Vector2,R=new c.Vector2,k=[],A={};function C(){return Math.pow(.95,p.zoomSpeed)}function L(e){y.theta-=e}function D(e){y.phi-=e}I=new c.Vector3;var I,j,U,B=function(e,t){I.setFromMatrixColumn(t,0),I.multiplyScalar(-e),b.add(I)},z=(j=new c.Vector3,function(e,t){!0===p.screenSpacePanning?j.setFromMatrixColumn(t,1):(j.setFromMatrixColumn(t,0),j.crossVectors(p.object.up,j)),j.multiplyScalar(e),b.add(j)}),N=(U=new c.Vector3,function(e,t){var r,n=p.domElement;p.object.isPerspectiveCamera?(r=p.object.position,U.copy(r).sub(p.target),r=U.length(),r*=Math.tan(p.object.fov/2*Math.PI/180),B(2*e*r/n.clientHeight,p.object.matrix),z(2*t*r/n.clientHeight,p.object.matrix)):p.object.isOrthographicCamera?(B(e*(p.object.right-p.object.left)/p.object.zoom/n.clientWidth,p.object.matrix),z(t*(p.object.top-p.object.bottom)/p.object.zoom/n.clientHeight,p.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),p.enablePan=!1)});function F(e){p.object.isPerspectiveCamera?g/=e:p.object.isOrthographicCamera?(p.object.zoom=Math.max(p.minZoom,Math.min(p.maxZoom,p.object.zoom*e)),p.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),p.enableZoom=!1)}function V(e){p.object.isPerspectiveCamera?g*=e:p.object.isOrthographicCamera?(p.object.zoom=Math.max(p.minZoom,Math.min(p.maxZoom,p.object.zoom/e)),p.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),p.enableZoom=!1)}function H(e){w.set(e.clientX,e.clientY)}function G(e){_.set(e.clientX,e.clientY)}function W(){var e,t;1===k.length?w.set(k[0].pageX,k[0].pageY):(e=.5*(k[0].pageX+k[1].pageX),t=.5*(k[0].pageY+k[1].pageY),w.set(e,t))}function X(){var e,t;1===k.length?_.set(k[0].pageX,k[0].pageY):(e=.5*(k[0].pageX+k[1].pageX),t=.5*(k[0].pageY+k[1].pageY),_.set(e,t))}function q(){var e=k[0].pageX-k[1].pageX,t=k[0].pageY-k[1].pageY;e=Math.sqrt(e*e+t*t),P.set(0,e)}function Y(e){1==k.length?S.set(e.pageX,e.pageY):(r=ae(e),t=.5*(e.pageX+r.x),e=.5*(e.pageY+r.y),S.set(t,e)),T.subVectors(S,w).multiplyScalar(p.rotateSpeed);var t,r=p.domElement;L(2*Math.PI*T.x/r.clientHeight),D(2*Math.PI*T.y/r.clientHeight),w.copy(S)}function Z(e){var t,r;1===k.length?M.set(e.pageX,e.pageY):(t=ae(e),r=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),M.set(r,e)),E.subVectors(M,_).multiplyScalar(p.panSpeed),N(E.x,E.y),_.copy(M)}function Q(e){var t=ae(e),r=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(r*r+e*e),O.set(0,t),R.set(0,Math.pow(O.y/P.y,p.zoomSpeed)),F(R.y),P.copy(O)}function K(e){if(!1!==p.enabled)if(0===k.length&&(p.domElement.setPointerCapture(e.pointerId),p.domElement.addEventListener("pointermove",J),p.domElement.addEventListener("pointerup",$)),k.push(e),"touch"===e.pointerType){switch(oe(e),k.length){case 1:switch(p.touches.ONE){case c.TOUCH.ROTATE:if(!1===p.enableRotate)return;W(),d=f.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(!1===p.enablePan)return;X(),d=f.TOUCH_PAN;break;default:d=f.NONE}break;case 2:switch(p.touches.TWO){case c.TOUCH.DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;p.enableZoom&&q(),p.enablePan&&X(),d=f.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;p.enableZoom&&q(),p.enableRotate&&W(),d=f.TOUCH_DOLLY_ROTATE;break;default:d=f.NONE}break;default:d=f.NONE}d!==f.NONE&&p.dispatchEvent(Fe)}else{var t,r=e;switch(r.button){case 0:t=p.mouseButtons.LEFT;break;case 1:t=p.mouseButtons.MIDDLE;break;case 2:t=p.mouseButtons.RIGHT;break;default:t=-1}switch(t){case c.MOUSE.DOLLY:if(!1===p.enableZoom)return;!function(e){P.set(e.clientX,e.clientY)}(r),d=f.DOLLY;break;case c.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enablePan)return;G(r),d=f.PAN}else{if(!1===p.enableRotate)return;H(r),d=f.ROTATE}break;case c.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enableRotate)return;H(r),d=f.ROTATE}else{if(!1===p.enablePan)return;G(r),d=f.PAN}break;default:d=f.NONE}d!==f.NONE&&p.dispatchEvent(Fe)}}function J(e){if(!1!==p.enabled)if("touch"===e.pointerType){var t=e;switch(oe(t),d){case f.TOUCH_ROTATE:if(!1===p.enableRotate)return;Y(t),p.update();break;case f.TOUCH_PAN:if(!1===p.enablePan)return;Z(t),p.update();break;case f.TOUCH_DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;!function(e){p.enableZoom&&Q(e),p.enablePan&&Z(e)}(t),p.update();break;case f.TOUCH_DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;!function(e){p.enableZoom&&Q(e),p.enableRotate&&Y(e)}(t),p.update();break;default:d=f.NONE}}else{var r=e;if(!1!==p.enabled)switch(d){case f.ROTATE:if(!1===p.enableRotate)return;!function(e){S.set(e.clientX,e.clientY),T.subVectors(S,w).multiplyScalar(p.rotateSpeed),e=p.domElement,L(2*Math.PI*T.x/e.clientHeight),D(2*Math.PI*T.y/e.clientHeight),w.copy(S),p.update()}(r);break;case f.DOLLY:if(!1===p.enableZoom)return;!function(e){O.set(e.clientX,e.clientY),R.subVectors(O,P),0<R.y?F(C()):R.y<0&&V(C()),P.copy(O),p.update()}(r);break;case f.PAN:if(!1===p.enablePan)return;!function(e){M.set(e.clientX,e.clientY),E.subVectors(M,_).multiplyScalar(p.panSpeed),N(E.x,E.y),_.copy(M),p.update()}(r)}}}function $(e){ie(e),0===k.length&&(p.domElement.releasePointerCapture(e.pointerId),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$)),p.dispatchEvent(Ve),d=f.NONE}function ee(e){ie(e)}function te(e){!1!==p.enabled&&!1!==p.enableZoom&&d===f.NONE&&(e.preventDefault(),p.dispatchEvent(Fe),e.deltaY<0?V(C()):0<e.deltaY&&F(C()),p.update(),p.dispatchEvent(Ve))}function re(e){if(!1!==p.enabled&&!1!==p.enablePan){var t=!1;switch(e.code){case p.keys.UP:N(0,p.keyPanSpeed),t=!0;break;case p.keys.BOTTOM:N(0,-p.keyPanSpeed),t=!0;break;case p.keys.LEFT:N(p.keyPanSpeed,0),t=!0;break;case p.keys.RIGHT:N(-p.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),p.update())}}function ne(e){!1!==p.enabled&&e.preventDefault()}function ie(e){delete A[e.pointerId];for(var t=0;t<k.length;t++)if(k[t].pointerId==e.pointerId)return void k.splice(t,1)}function oe(e){var t=A[e.pointerId];void 0===t&&(t=new c.Vector2,A[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ae(e){return e=e.pointerId===k[0].pointerId?k[1]:k[0],A[e.pointerId]}return p.domElement.addEventListener("contextmenu",ne),p.domElement.addEventListener("pointerdown",K),p.domElement.addEventListener("pointercancel",ee),p.domElement.addEventListener("wheel",te,{passive:!1}),i.update(),i}return function(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}(t)}();class Ge{create(e,t){return new He(e,t)}}class We{constructor(e){this._state=!1,this._libsState=!1,this.map={val:"Box",type:"base-model"},this.libsMap={data:"Box",type:"texture"},this.events=e}get state(){return this._state}set state(e){this._state=e}setVal(e){this.state=!0,this.map=e}getVal(){if(this.state)return this.state=!1,this.map}setLibsVal(e){this._libsState=!0,this.libsMap=e}getLibsVal(){if(this._libsState)return this._libsState=!1,this.libsMap}}var Xe=a(594),qe=a(129),Ye=a(685);function Ze(){return(Ze="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=et(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function Qe(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ke(e,t)}function Ke(e,t){return(Ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Je(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=et(e);if(r=t?(r=et(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===at(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return $e(n)}}function $e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function et(e){return(et=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rt(e,t,r){return t&&tt(e.prototype,t),r&&tt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function nt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function it(e){return function(e){if(Array.isArray(e))return ot(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ot(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ot(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function at(e){return(at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function st(e){return void 0===e}function lt(){return"undefined"!=typeof window}function ut(e){return Ir(e)||Dr(e)}function ct(e){return(Zr=bt(e,Yr))&&mi}function ht(e,t){return!t&&console.warn(e)}function pt(e,t){return e&&(Yr[e]=t)&&Zr&&(Zr[e]=t)||Yr}function ft(){return 0}function dt(e,t,r){return(r=e[t])&&Ir(r)?e[t]():st(r)&&e.getAttribute&&e.getAttribute(t)||r}function mt(e,t){(e=e.split(",")).forEach(t)}function vt(e,t,r,n){Jr.length&&un(),e.render(t,r,n),Jr.length&&un()}function yt(e){var t=parseFloat(e);return(t||0===t)&&(e+"").match(Xr).length<2?t:Dr(e)?e.trim():e}function gt(e){return e}function bt(e,t){for(var r in t)e[r]=t[r];return e}function xt(e,t){for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=Ur(t[r])?xt(e[r]||(e[r]={}),t[r]):t[r]);return e}function wt(e){var t,r=e.parent||er,n=e.keyframes?(t=Nr(e.keyframes),function(e,r){for(var n in r)n in e||"duration"===n&&t||"ease"===n||(e[n]=r[n])}):cn;if(Br(e.inherit))for(;r;)n(e,r.vars.defaults),r=r.parent||r._dp;return e}function St(e){return!e||e._ts&&St(e.parent)}function Tt(e){return e._repeat?_t(e._tTime,e=e.duration()+e._rDelay)*e:0}function _t(e,t){return t=Math.floor(e/=t),e&&t===e?t-1:t}function Mt(e,t){return(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur)}function Et(e,t){var r;if((t._time||t._initted&&!t._dur)&&(r=Mt(e.rawTime(),t),(!t._dur||jt(0,t.totalDuration(),r)-t._tTime>Pr)&&t.render(r,!0)),dn(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur<e.duration())for(r=e;r._dp;)0<=r.rawTime()&&r.totalTime(r._tTime),r=r._dp;e._zTime=-Pr}}function Pt(e,t,r,n){return t.parent&&fn(t),t._start=ln((jr(r)?r:r||e!==er?Dt(e,r,t):e._time)+t._delay),t._end=ln(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),function(e,t){var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"_first",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_last",o=4<arguments.length?arguments[4]:void 0,a=e[i];if(o)for(r=t[o];a&&a[o]>r;)a=a._prev;a?(t._next=a._next,a._next=t):(t._next=e[n],e[n]=t),t._next?t._next._prev=t:e[i]=t,t._prev=a,t.parent=t._dp=e}(e,t,"_first","_last",e._sort?"_start":0),At(t)||(e._recent=t),n||Et(e,t),e}function Ot(e,t){(Yr.ScrollTrigger||Qr("scrollTrigger",t))&&Yr.ScrollTrigger.create(t,e)}function Rt(e,t,r,n){return Nn(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&or!==An.frame?(Jr.push(e),e._lazy=[t,n]):void 0:1}function kt(e){return(e=e.parent)&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||kt(e))}function At(e){return"isFromStart"===(e=e.data)||"isStart"===e}function Ct(e,t,r,n){var i=e._repeat,o=ln(t)||0;return(t=e._tTime/e._tDur)&&!n&&(e._time*=o/e._dur),e._dur=o,e._tDur=i?i<0?1e10:ln(o*(i+1)+e._rDelay*i):o,0<t&&!n?vn(e,e._tTime=e._tDur*t):e.parent&&mn(e),r||dn(e.parent,e),e}function Lt(e){return e instanceof Jn?dn(e):Ct(e,e._dur)}function Dt(e,t,r){var n,i,o,a=e.labels,s=e._recent||yn,l=e.duration()>=Er?s.endTime(!1):e._dur;return Dr(t)&&(isNaN(t)||t in a)?(i=t.charAt(0),o="%"===t.substr(-1),n=t.indexOf("="),"<"===i||">"===i?(0<=n&&(t=t.replace(/=/,"")),("<"===i?s._start:s.endTime(0<=s._repeat))+(parseFloat(t.substr(1))||0)*(o?(n<0?s:r).totalDuration()/100:1)):n<0?(t in a||(a[t]=l),a[t]):(i=parseFloat(t.charAt(n-1)+t.substr(n+1)),o&&r&&(i=i/100*(Nr(r)?r[0]:r).totalDuration()),1<n?Dt(e,t.substr(0,n-1),r)+i:l+i)):null==t?l:+t}function It(e,t,r){var n,i,o=jr(t[1]),a=(o?2:1)+(e<2?0:1),s=t[a];if(o&&(s.duration=t[1]),s.parent=r,e){for(n=s,i=r;i&&!("immediateRender"in n);)n=i.vars.defaults||{},i=Br(i.vars.inherit)&&i.parent;s.immediateRender=Br(n.immediateRender),e<2?s.runBackwards=1:s.startAt=t[a-1]}return new ii(t[0],s,t[1+a])}function jt(e,t,r){return r<e?e:t<r?t:r}function Ut(e){if(Ir(e))return e;var t=Ur(e)?e:{each:e},r=Un(t.ease),n=t.from||0,i=parseFloat(t.base)||0,o={},a=(e=0<n&&n<1,isNaN(n)||e),s=t.axis,l=n,u=n;return Dr(n)?l=u={center:.5,edges:.5,end:1}[n]||0:!e&&a&&(l=n[0],u=n[1]),function(e,c,h){var p,f,d,m,v,y,g,b,x=(h||t).length,w=o[x];if(!w){if(!(b="auto"===t.grid?0:(t.grid||[1,Er])[1])){for(y=-Er;y<(y=h[b++].getBoundingClientRect().left)&&b<x;);b--}for(w=o[x]=[],p=a?Math.min(b,x)*l-.5:n%b,f=b===Er?0:a?x*u/b-.5:n/b|0,g=Er,v=y=0;v<x;v++)m=v%b-p,d=f-(v/b|0),w[v]=m=s?Math.abs("y"===s?d:m):Ar(m*m+d*d),y<m&&(y=m),m<g&&(g=m);"random"===n&&Tn(w),w.max=y-g,w.min=g,w.v=x=(parseFloat(t.amount)||parseFloat(t.each)*(x<b?x-1:s?"y"===s?x/b:b:Math.max(b,x/b))||0)*("edges"===n?-1:1),w.b=x<0?i-x:i,w.u=bn(t.amount||t.each)||0,r=r&&x<0?jn(r):r}return x=(w[e]-w.min)/w.max||0,ln(w.b+(r?r(x):x)*w.v)+w.u}}function Bt(e){var t=Math.pow(10,((e+"").split(".")[1]||"").length);return function(r){var n=Math.round(parseFloat(r)/e)*e*t;return(n-n%1)/t+(jr(r)?0:bn(r))}}function zt(e,t){var r,n,i=Nr(e);return!i&&Ur(e)&&(r=i=e.radius||Er,e.values?(e=Sn(e.values),(n=!jr(e[0]))&&(r*=r)):e=Bt(e.increment)),gn(t,i?Ir(e)?function(t){return n=e(t),Math.abs(n-t)<=r?n:t}:function(t){for(var i,o,a=parseFloat(n?t.x:t),s=parseFloat(n?t.y:0),l=Er,u=0,c=e.length;c--;)(i=n?(i=e[c].x-a)*i+(o=e[c].y-s)*o:Math.abs(e[c]-a))<l&&(l=i,u=c);return u=!r||l<=r?e[u]:t,n||u===t||jr(t)?u:u+bn(t)}:Bt(e))}function Nt(e,t,r,n){return gn(Nr(e)?!t:!0===r?!!(r=0):!n,(function(){return Nr(e)?e[~~(Math.random()*e.length)]:(r=r||1e-5)&&(n=r<1?Math.pow(10,(r+"").length-2):1)&&Math.floor(Math.round((e-r/2+Math.random()*(t-e+.99*r))/r)*r*n)/n}))}function Ft(e,t,r){return gn(r,(function(r){return e[~~t(r)]}))}function Vt(e,t,r,n,i){var o=t-e,a=n-r;return gn(i,(function(t){return r+((t-e)/o*a||0)}))}function Ht(e,t,r){var n,i,o,a=e.labels,s=Er;for(n in a)(i=a[n]-t)<0==!!r&&i&&s>(i=Math.abs(i))&&(o=n,s=i);return o}function Gt(e,t,r){var n=e.vars,i=n[t];i&&(t=n[t+"Params"],n=n.callbackScope||e,r&&Jr.length&&un(),t?i.apply(n,t):i.call(n))}function Wt(e){return fn(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&Gt(e,"onInterrupt"),e}function Xt(e,t,r){return(6*(e+=e<0?1:1<e?-1:0)<1?t+(r-t)*e*6:e<.5?r:3*e<2?t+(r-t)*(2/3-e)*6:t)*Mn+.5|0}function qt(e,t,r){var n,i,o,a,s="",l=(e+s).match(Rn),u=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((function(e){return(e=Pn(e,t,1))&&u+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")"})),r&&(o=On(e),(n=r.c).join(s)!==o.c.join(s)))for(a=(i=e.replace(Rn,"1").split(Hr)).length-1;c<a;c++)s+=i[c]+(~n.indexOf(c)?l.shift()||u+"0,0,0,0)":(o.length?o:l.length?l:r).shift());if(!i)for(a=(i=e.split(Rn)).length-1;c<a;c++)s+=i[c]+l[c];return s+i[a]}function Yt(e,t){for(var r,n=e._first;n;)n instanceof Jn?Yt(n,t):!n.vars.yoyoEase||n._yoyo&&n._repeat||n._yoyo===t||(n.timeline?Yt(n.timeline,t):(r=n._ease,n._ease=n._yEase,n._yEase=r,n._yoyo=t)),n=n._next}function Zt(e,t){var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(e){return 1-t(1-e)},i={easeIn:t,easeOut:n,easeInOut:3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(e){return e<.5?t(2*e)/2:1-t(2*(1-e))/2}};mt(e,(function(e){for(var t in Ln[e]=Yr[e]=i,Ln[r=e.toLowerCase()]=n,i)Ln[r+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Ln[e+"."+t]=i[t]}))}function Qt(e){return function(t){return t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2}}function Kt(e,t,r){function n(e){return 1===e?1:i*Math.pow(2,-10*e)*Lr((e-o)*a)+1}var i=1<=t?t:1,o=(a=(r||(e?.3:.45))/(t<1?t:1))/Or*(Math.asin(1/i)||0),a=(r="out"===e?n:"in"===e?function(e){return 1-n(1-e)}:Qt(n),Or/a);return r.config=function(t,r){return Kt(e,t,r)},r}function Jt(e){function t(e){return e?--e*e*((r+1)*e+r)+1:0}var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1.70158,n="out"===e?t:"in"===e?function(e){return 1-t(1-e)}:Qt(t);return n.config=function(t){return Jt(e,t)},n}var $t,er,tr,rr,nr,ir,or,ar,sr,lr,ur,cr,hr,pr,fr,dr,mr,vr,yr,gr,br,xr,wr,Sr,Tr,_r={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},Mr={duration:.5,overwrite:!1,delay:0},Er=1e8,Pr=1/Er,Or=2*Math.PI,Rr=Or/4,kr=0,Ar=Math.sqrt,Cr=Math.cos,Lr=Math.sin,Dr=function(e){return"string"==typeof e},Ir=function(e){return"function"==typeof e},jr=function(e){return"number"==typeof e},Ur=function(e){return"object"==at(e)},Br=function(e){return!1!==e},zr="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},Nr=Array.isArray,Fr=/(?:-?\.?\d|\.)+/gi,Vr=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Hr=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,Gr=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,Wr=/[+-]=-?[.\d]+/,Xr=/[^,'"\[\]\s]+/gi,qr=/[\d.+\-=]+(?:e[-+]\d*)*/i,Yr={},Zr={},Qr=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Kr={},Jr=[],$r={},en={},tn={},rn=30,nn=[],on="",an=function(e){var t,r,n=e[0];if(Ur(n)||Ir(n)||(e=[e]),!(t=(n._gsap||{}).harness)){for(r=nn.length;r--&&!nn[r].targetTest(n););t=nn[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new Qn(e[r],t)))||e.splice(r,1);return e},sn=function(e){return e._gsap||an(Sn(e))[0]._gsap},ln=function(e){return Math.round(1e7*e)/1e7||0},un=function(){var e,t,r=Jr.length,n=Jr.slice(0);for($r={},e=Jr.length=0;e<r;e++)(t=n[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},cn=function(e,t){for(var r in t)r in e||(e[r]=t[r]);return e},hn=function(e,t){var r,n={};for(r in e)r in t||(n[r]=e[r]);return n},pn=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"_first",n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_last",i=t._prev,o=t._next;i?i._next=o:e[r]===t&&(e[r]=o),o?o._prev=i:e[n]===t&&(e[n]=i),t._next=t._prev=t.parent=null},fn=function(e,t){!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},dn=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var r=e;r;)r._dirty=1,r=r.parent;return e},mn=function(e){return e._end=ln(e._start+(e._tDur/Math.abs(e._ts||e._rts||Pr)||0))},vn=function(e,t){var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=ln(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),mn(e),r._dirty||dn(r,e)),e},yn={_start:0,endTime:ft,totalDuration:ft},gn=function(e,t){return e||0===e?t(e):t},bn=function(e,t){return Dr(e)&&(t=qr.exec(e))?e.substr(t.index+t[0].length):""},xn=[].slice,wn=function(e,t){return e&&Ur(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Ur(e[0]))&&!e.nodeType&&e!==tr},Sn=function(e,t,r){return!Dr(e)||r||!rr&&Cn()?Nr(e)?function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return e.forEach((function(e){return Dr(e)&&!t||wn(e,1)?r.push.apply(r,it(Sn(e))):r.push(e)}))||r}(e,r):wn(e)?xn.call(e,0):e?[e]:[]:xn.call((t||nr).querySelectorAll(e),0)},Tn=function(e){return e.sort((function(){return.5-Math.random()}))},_n=function(e){for(var t,r,n,i,o=0,a="";~(t=e.indexOf("random(",o));)n=e.indexOf(")",t),i="["===e.charAt(t+7),r=e.substr(t+7,n-t-7).match(i?Xr:Fr),a+=e.substr(o,t-o)+Nt(i?r:+r[0],i?0:+r[1],+r[2]||1e-5),o=n+1;return a+e.substr(o,e.length-o)},Mn=255,En={aqua:[0,Mn,Mn],lime:[0,Mn,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,Mn],navy:[0,0,128],white:[Mn,Mn,Mn],olive:[128,128,0],yellow:[Mn,Mn,0],orange:[Mn,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[Mn,0,0],pink:[Mn,192,203],cyan:[0,Mn,Mn],transparent:[Mn,Mn,Mn,0]},Pn=function(e,t,r){var n,i,o,a,s,l,u,c=e?jr(e)?[e>>16,e>>8&Mn,e&Mn]:0:En.black;if(!c){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),En[e])c=En[e];else if("#"===e.charAt(0)){if(9===(e=e.length<6?"#"+(n=e.charAt(1))+n+(i=e.charAt(2))+i+(o=e.charAt(3))+o+(5===e.length?e.charAt(4)+e.charAt(4):""):e).length)return[(c=parseInt(e.substr(1,6),16))>>16,c>>8&Mn,c&Mn,parseInt(e.substr(7),16)/255];c=[(e=parseInt(e.substr(1),16))>>16,e>>8&Mn,e&Mn]}else if("hsl"===e.substr(0,3))if(c=u=e.match(Fr),t){if(~e.indexOf("="))return c=e.match(Vr),r&&c.length<4&&(c[3]=1),c}else a=+c[0]%360/360,s=+c[1]/100,n=2*(l=+c[2]/100)-(i=l<=.5?l*(s+1):l+s-l*s),3<c.length&&(c[3]*=1),c[0]=Xt(a+1/3,n,i),c[1]=Xt(a,n,i),c[2]=Xt(a-1/3,n,i);else c=e.match(Fr)||En.transparent;c=c.map(Number)}return t&&!u&&(n=c[0]/Mn,i=c[1]/Mn,o=c[2]/Mn,l=((e=Math.max(n,i,o))+(t=Math.min(n,i,o)))/2,e===t?a=s=0:(u=e-t,s=.5<l?u/(2-e-t):u/(e+t),a=e===n?(i-o)/u+(i<o?6:0):e===i?(o-n)/u+2:(n-i)/u+4,a*=60),c[0]=~~(a+.5),c[1]=~~(100*s+.5),c[2]=~~(100*l+.5)),r&&c.length<4&&(c[3]=1),c},On=function(e){var t=[],r=[],n=-1;return e.split(Rn).forEach((function(e){e=e.match(Hr)||[],t.push.apply(t,it(e)),r.push(n+=e.length+1)})),t.c=r,t},Rn=function(){var e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in En)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),kn=/hsl[a]?\(/,An=(fr=Date.now,dr=500,mr=33,vr=fr(),yr=vr,br=gr=1e3/240,wr={time:0,frame:0,tick:function(){Bn(!0)},deltaRatio:function(e){return hr/(1e3/(e||60))},wake:function(){ir&&(!rr&&lt()&&(tr=rr=window,nr=tr.document||{},Yr.gsap=mi,(tr.gsapVersions||(tr.gsapVersions=[])).push(mi.version),ct(Zr||tr.GreenSockGlobals||!tr.gsap&&tr||{}),cr=tr.requestAnimationFrame),lr&&wr.sleep(),ur=cr||function(e){return setTimeout(e,br-1e3*wr.time+1|0)},sr=1,Bn(2))},sleep:function(){(cr?tr.cancelAnimationFrame:clearTimeout)(lr),sr=0,ur=ft},lagSmoothing:function(e,t){dr=e||1/Pr,mr=Math.min(t,dr,0)},fps:function(e){gr=1e3/(e||240),br=1e3*wr.time+gr},add:function(e){xr.indexOf(e)<0&&xr.push(e),Cn()},remove:function(e,t){~(t=xr.indexOf(e))&&xr.splice(t,1)&&t<=pr&&pr--},_listeners:xr=[]}),Cn=function(){return!sr&&An.wake()},Ln={},Dn=/^[\d.\-M][\d.\-,\s]/,In=/["']/g,jn=function(e){return function(t){return 1-e(1-t)}},Un=function(e,t){return e&&(Ir(e)?e:Ln[e]||function(e){var t,r,n,i=(e+"").split("("),o=Ln[i[0]];return o&&1<i.length&&o.config?o.config.apply(null,~e.indexOf("{")?[function(e){for(var t,r,n,i={},o=e.substr(1,e.length-3).split(":"),a=o[0],s=1,l=o.length;s<l;s++)r=o[s],t=s!==l-1?r.lastIndexOf(","):r.length,n=r.substr(0,t),i[a]=isNaN(n)?n.replace(In,"").trim():+n,a=r.substr(t+1).trim();return i}(i[1])]:(t=(i=e).indexOf("(")+1,r=i.indexOf(")"),n=i.indexOf("(",t),i.substring(t,~n&&n<r?i.indexOf(")",r+1):r).split(",").map(yt))):Ln._CE&&Dn.test(e)?Ln._CE("",e):o}(e))||t};function Bn(e){var t,r,n,i=fr()-yr,o=!0===e;if(dr<i&&(vr+=i-mr),(0<(i=(r=(yr+=i)-vr)-br)||o)&&(n=++wr.frame,hr=r-1e3*wr.time,wr.time=r/=1e3,br+=i+(gr<=i?4:gr-i),t=1),o||(lr=ur(Bn)),t)for(pr=0;pr<xr.length;pr++)xr[pr](r,hr,n,e)}function zn(e){return e<Tr?Sr*e*e:e<.7272727272727273?Sr*Math.pow(e-1.5/2.75,2)+.75:e<.9090909090909092?Sr*(e-=2.25/2.75)*e+.9375:Sr*Math.pow(e-2.625/2.75,2)+.984375}function Nn(e,t){var r,n,i,o,a,s,l,u,c,h,p,f,d,m=e.vars,v=m.ease,y=m.startAt,g=m.immediateRender,b=m.lazy,x=m.onUpdate,w=m.onUpdateParams,S=m.callbackScope,T=m.runBackwards,_=m.yoyoEase,M=m.keyframes,E=m.autoRevert,P=e._dur,O=e._startAt,R=e._targets,k=e.parent,A=k&&"nested"===k.data?k.parent._targets:R,C="auto"===e._overwrite&&!$t,L=e.timeline;if(e._ease=Un(v=!L||M&&v?v:"none",Mr.ease),e._yEase=_?jn(Un(!0===_?v:_,Mr.ease)):0,_&&e._yoyo&&!e._repeat&&(_=e._yEase,e._yEase=e._ease,e._ease=_),e._from=!L&&!!m.runBackwards,!L||M&&!m.stagger){if(f=(u=R[0]?sn(R[0]).harness:0)&&m[u.prop],r=hn(m,Kr),O&&fn(O.render(-1,!0)),y)if(fn(e._startAt=ii.set(R,cn({data:"isStart",overwrite:!1,parent:k,immediateRender:!0,lazy:Br(b),startAt:null,delay:0,onUpdate:x,onUpdateParams:w,callbackScope:S,stagger:0},y))),t<0&&!g&&!E&&e._startAt.render(-1,!0),g){if(0<t&&!E&&(e._startAt=0),P&&t<=0)return void(t&&(e._zTime=t))}else!1===E&&(e._startAt=0);else if(T&&P)if(O)E||(e._startAt=0);else if(i=cn({overwrite:!1,data:"isFromStart",lazy:(g=!t&&g)&&Br(b),immediateRender:g,stagger:0,parent:k},r),f&&(i[u.prop]=f),fn(e._startAt=ii.set(R,i)),t<0&&e._startAt.render(-1,!0),e._zTime=t,g){if(!t)return}else Nn(e._startAt,Pr);for(e._pt=0,b=P&&Br(b)||b&&!P,n=0;n<R.length;n++){if(l=(a=R[n])._gsap||an(R)[n]._gsap,e._ptLookup[n]=h={},$r[l.id]&&Jr.length&&un(),p=A===R?n:A.indexOf(a),u&&!1!==(c=new u).init(a,f||r,e,p,A)&&(e._pt=o=new pi(e._pt,a,c.name,0,1,c.render,c,0,c.priority),c._props.forEach((function(e){h[e]=o})),c.priority&&(s=1)),!u||f)for(i in r)en[i]&&(c=ti(i,r,e,p,a,A))?c.priority&&(s=1):h[i]=o=ei.call(e,a,i,"get",r[i],p,A,0,m.stringFilter);e._op&&e._op[n]&&e.kill(a,e._op[n]),C&&e._pt&&(Zn=e,er.killTweensOf(a,h,e.globalTime(t)),d=!e.parent,Zn=0),e._pt&&b&&($r[l.id]=1)}s&&hi(e),e._onInit&&e._onInit(e)}e._onUpdate=x,e._initted=(!e._op||e._pt)&&!d,M&&t<=0&&L.render(Er,!0,!0)}function Fn(e,t,r,n,i){return Ir(e)?e.call(t,r,n,i):Dr(e)&&~e.indexOf("random(")?_n(e):e}function Vn(e,t,r){return e.setAttribute(t,r)}function Hn(e,t){var r=t._pt,n="";if(!e&&t.b)n=t.b;else if(1===e&&t.e)n=t.e;else{for(;r;)n=r.p+(r.m?r.m(r.s+r.c*e):Math.round(1e4*(r.s+r.c*e))/1e4)+n,r=r._next;n+=t.c}t.set(t.t,t.p,n,t)}function Gn(e,t){for(var r=t._pt;r;)r.r(e,r.d),r=r._next}function Wn(e,t,r,n){for(var i,o=this._pt;o;)i=o._next,o.p===n&&o.modifier(e,t,r),o=i}function Xn(e){for(var t,r,n=this._pt;n;)r=n._next,n.p===e&&!n.op||n.op===e?pn(this,n,"_pt"):n.dep||(t=1),n=r;return!t}function qn(e,t,r,n){n.mSet(e,t,n.m.call(n.tween,r,n.mt),n)}function Yn(e,t){return{name:e,rawVars:1,init:function(e,r,n){n._onInit=function(e){var n,i;if(Dr(r)&&(n={},mt(r,(function(e){return n[e]=1})),r=n),t){for(i in n={},r)n[i]=t(r[i]);r=n}var o,a,s,l=e,u=r,c=l._targets;for(o in u)for(a=c.length;a--;)(s=(s=l._ptLookup[a][o])&&s.d)&&(s=s._pt?di(s,o):s)&&s.modifier&&s.modifier(u[o],l,c[a],o)}}}}mt("Linear,Quad,Cubic,Quart,Quint,Strong",(function(e,t){var r=t<5?t+1:t;Zt(e+",Power"+(r-1),t?function(e){return Math.pow(e,r)}:function(e){return e},(function(e){return 1-Math.pow(1-e,r)}),(function(e){return e<.5?Math.pow(2*e,r)/2:1-Math.pow(2*(1-e),r)/2}))})),Ln.Linear.easeNone=Ln.none=Ln.Linear.easeIn,Zt("Elastic",Kt("in"),Kt("out"),Kt()),Sr=7.5625,Tr=1/2.75,Zt("Bounce",(function(e){return 1-zn(1-e)}),zn),Zt("Expo",(function(e){return e?Math.pow(2,10*(e-1)):0})),Zt("Circ",(function(e){return-(Ar(1-e*e)-1)})),Zt("Sine",(function(e){return 1===e?1:1-Cr(e*Rr)})),Zt("Back",Jt("in"),Jt("out"),Jt()),Ln.SteppedEase=Ln.steps=Yr.SteppedEase={config:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,t=1<arguments.length?arguments[1]:void 0,r=1/e,n=e+(t?0:1),i=t?1:0,o=1-Pr;return function(e){return((n*jt(0,o,e)|0)+i)*r}}},Mr.ease=Ln["quad.out"],mt("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(function(e){return on+=e+","+e+"Params,"}));var Zn,Qn=rt((function e(t,r){nt(this,e),this.id=kr++,(t._gsap=this).target=t,this.harness=r,this.get=r?r.get:dt,this.set=r?r.getSetter:li})),Kn=function(){function e(t){nt(this,e),this.vars=t,this._delay=+t.delay||0,(this._repeat=t.repeat===1/0?-2:t.repeat||0)&&(this._rDelay=t.repeatDelay||0,this._yoyo=!!t.yoyo||!!t.yoyoEase),this._ts=1,Ct(this,+t.duration,1,1),this.data=t.data,sr||An.wake()}return rt(e,[{key:"delay",value:function(e){return e||0===e?(this.parent&&this.parent.smoothChildTiming&&this.startTime(this._start+e-this._delay),this._delay=e,this):this._delay}},{key:"duration",value:function(e){return arguments.length?this.totalDuration(0<this._repeat?e+(e+this._rDelay)*this._repeat:e):this.totalDuration()&&this._dur}},{key:"totalDuration",value:function(e){return arguments.length?(this._dirty=0,Ct(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}},{key:"totalTime",value:function(e,t){if(Cn(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(vn(this,e),r._dp&&!r.parent&&Et(r,this);r&&r.parent;)r.parent._time!==r._start+(0<=r._ts?r._tTime/r._ts:(r.totalDuration()-r._tTime)/-r._ts)&&r.totalTime(r._tTime,!0),r=r.parent;!this.parent&&this._dp.autoRemoveChildren&&(0<this._ts&&e<this._tDur||this._ts<0&&0<e||!this._tDur&&!e)&&Pt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===Pr||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),vt(this,e,t)),this}},{key:"time",value:function(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+Tt(this))%(this._dur+this._rDelay)||(e?this._dur:0),t):this._time}},{key:"totalProgress",value:function(e,t){return arguments.length?this.totalTime(this.totalDuration()*e,t):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.ratio}},{key:"progress",value:function(e,t){return arguments.length?this.totalTime(this.duration()*(!this._yoyo||1&this.iteration()?e:1-e)+Tt(this),t):this.duration()?Math.min(1,this._time/this._dur):this.ratio}},{key:"iteration",value:function(e,t){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(e-1)*r,t):this._repeat?_t(this._tTime,r)+1:1}},{key:"timeScale",value:function(e){if(!arguments.length)return this._rts===-Pr?0:this._rts;if(this._rts===e)return this;for(var t=this.parent&&this._ts?Mt(this.parent._time,this):this._tTime,r=(this._rts=+e||0,this._ts=this._ps||e===-Pr?0:this._rts,e=this.totalTime(jt(-this._delay,this._tDur,t),!0)).parent;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent;return mn(this),this}},{key:"paused",value:function(e){return arguments.length?(this._ps!==e&&((this._ps=e)?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(Cn(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==Pr&&(this._tTime-=Pr)))),this):this._ps}},{key:"startTime",value:function(e){var t;return arguments.length?(this._start=e,!(t=this.parent||this._dp)||!t._sort&&this.parent||Pt(t,this,e-this._delay),this):this._start}},{key:"endTime",value:function(e){return this._start+(Br(e)?this.totalDuration():this.duration())/Math.abs(this._ts||1)}},{key:"rawTime",value:function(e){var t=this.parent||this._dp;return t?e&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?Mt(t.rawTime(e),this):this._tTime:this._tTime}},{key:"globalTime",value:function(e){for(var t=this,r=arguments.length?e:t.rawTime();t;)r=t._start+r/(t._ts||1),t=t._dp;return r}},{key:"repeat",value:function(e){return arguments.length?(this._repeat=e===1/0?-2:e,Lt(this)):-2===this._repeat?1/0:this._repeat}},{key:"repeatDelay",value:function(e){var t;return arguments.length?(t=this._time,this._rDelay=e,Lt(this),t?this.time(t):this):this._rDelay}},{key:"yoyo",value:function(e){return arguments.length?(this._yoyo=e,this):this._yoyo}},{key:"seek",value:function(e,t){return this.totalTime(Dt(this,e),Br(t))}},{key:"restart",value:function(e,t){return this.play().totalTime(e?-this._delay:0,Br(t))}},{key:"play",value:function(e,t){return null!=e&&this.seek(e,t),this.reversed(!1).paused(!1)}},{key:"reverse",value:function(e,t){return null!=e&&this.seek(e||this.totalDuration(),t),this.reversed(!0).paused(!1)}},{key:"pause",value:function(e,t){return null!=e&&this.seek(e,t),this.paused(!0)}},{key:"resume",value:function(){return this.paused(!1)}},{key:"reversed",value:function(e){return arguments.length?(!!e!==this.reversed()&&this.timeScale(-this._rts||(e?-Pr:0)),this):this._rts<0}},{key:"invalidate",value:function(){return this._initted=this._act=0,this._zTime=-Pr,this}},{key:"isActive",value:function(){var e=this.parent||this._dp,t=this._start;return!(e&&!(this._ts&&this._initted&&e.isActive()&&(e=e.rawTime(!0))>=t&&e<this.endTime(!0)-Pr))}},{key:"eventCallback",value:function(e,t,r){var n=this.vars;return 1<arguments.length?(t?(n[e]=t,r&&(n[e+"Params"]=r),"onUpdate"===e&&(this._onUpdate=t)):delete n[e],this):n[e]}},{key:"then",value:function(e){var t=this;return new Promise((function(r){function n(){var e=t.then;t.then=null,Ir(i)&&(i=i(t))&&(i.then||i===t)&&(t.then=e),r(i),t.then=e}var i=Ir(e)?e:gt;t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?n():t._prom=n}))}},{key:"kill",value:function(){Wt(this)}}]),e}(),Jn=(cn(Kn.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-Pr,_prom:0,_ps:!1,_rts:1}),function(){Qe(t,Kn);var e=Je(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=1<arguments.length?arguments[1]:void 0;return nt(this,t),(r=e.call(this,n)).labels={},r.smoothChildTiming=!!n.smoothChildTiming,r.autoRemoveChildren=!!n.autoRemoveChildren,r._sort=Br(n.sortChildren),er&&Pt(n.parent||er,$e(r),i),n.reversed&&r.reverse(),n.paused&&r.paused(!0),n.scrollTrigger&&Ot($e(r),n.scrollTrigger),r}return rt(t,[{key:"to",value:function(e,t,r){return It(0,arguments,this),this}},{key:"from",value:function(e,t,r){return It(1,arguments,this),this}},{key:"fromTo",value:function(e,t,r,n){return It(2,arguments,this),this}},{key:"set",value:function(e,t,r){return t.duration=0,t.parent=this,wt(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new ii(e,t,Dt(this,r),1),this}},{key:"call",value:function(e,t,r){return Pt(this,ii.delayedCall(0,e,t),r)}},{key:"staggerTo",value:function(e,t,r,n,i,o,a){return r.duration=t,r.stagger=r.stagger||n,r.onComplete=o,r.onCompleteParams=a,r.parent=this,new ii(e,r,Dt(this,i)),this}},{key:"staggerFrom",value:function(e,t,r,n,i,o,a){return r.runBackwards=1,wt(r).immediateRender=Br(r.immediateRender),this.staggerTo(e,t,r,n,i,o,a)}},{key:"staggerFromTo",value:function(e,t,r,n,i,o,a,s){return n.startAt=r,wt(n).immediateRender=Br(n.immediateRender),this.staggerTo(e,t,n,i,o,a,s)}},{key:"render",value:function(e,t,r){var n,i,o,a,s,l,u,c,h,p,f=this._time,d=this._dirty?this.totalDuration():this._tDur,m=this._dur,v=e<=0?0:ln(e),y=this._zTime<0!=e<0&&(this._initted||!m);if((v=this!==er&&d<v&&0<=e?d:v)!==this._tTime||r||y){if(f!==this._time&&m&&(v+=this._time-f,e+=this._time-f),n=v,c=this._start,s=!(u=this._ts),y&&(m||(f=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(y=this._yoyo,a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(n=ln(v%a),v===d?(o=this._repeat,n=m):((o=~~(v/a))&&o===v/a&&(n=m,o--),m<n&&(n=m)),h=_t(this._tTime,a),y&&1&o&&(n=m-n,p=1),o!==(h=!f&&this._tTime&&h!==o?o:h)&&!this._lock){var g=y&&1&h;if(y=g===(y&&1&o),f=(g=o<h?!g:g)?0:m,this._lock=1,this.render(f||(p?0:ln(o*a)),t,!m)._lock=0,this._tTime=v,!t&&this.parent&&Gt(this,"onRepeat"),this.vars.repeatRefresh&&!p&&(this.invalidate()._lock=1),f&&f!==this._time||s!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(m=this._dur,d=this._tDur,y&&(this._lock=2,this.render(f=g?m:-1e-4,!0),this.vars.repeatRefresh&&!p&&this.invalidate()),this._lock=0,!this._ts&&!s)return this;Yt(this,p)}}if(this._hasPause&&!this._forcing&&this._lock<2&&(l=function(e,t,r){var n;if(t<r)for(n=e._first;n&&n._start<=r;){if("isPause"===n.data&&n._start>t)return n;n=n._next}else for(n=e._last;n&&n._start>=r;){if("isPause"===n.data&&n._start<t)return n;n=n._prev}}(this,ln(f),ln(n)))&&(v-=n-(n=l._start)),this._tTime=v,this._time=n,this._act=!u,this._initted||(this._onUpdate=this.vars.onUpdate,this._initted=1,this._zTime=e,f=0),!f&&n&&!t&&(Gt(this,"onStart"),this._tTime!==v))return this;if(f<=n&&0<=e)for(b=this._first;b;){if(i=b._next,(b._act||n>=b._start)&&b._ts&&l!==b){if(b.parent!==this)return this.render(e,t,r);if(b.render(0<b._ts?(n-b._start)*b._ts:(b._dirty?b.totalDuration():b._tDur)+(n-b._start)*b._ts,t,r),n!==this._time||!this._ts&&!s){l=0,i&&(v+=this._zTime=-Pr);break}}b=i}else for(var b=this._last,x=e<0?e:n;b;){if(i=b._prev,(b._act||x<=b._end)&&b._ts&&l!==b){if(b.parent!==this)return this.render(e,t,r);if(b.render(0<b._ts?(x-b._start)*b._ts:(b._dirty?b.totalDuration():b._tDur)+(x-b._start)*b._ts,t,r),n!==this._time||!this._ts&&!s){l=0,i&&(v+=this._zTime=x?-Pr:Pr);break}}b=i}if(l&&!t&&(this.pause(),l.render(f<=n?0:-Pr)._zTime=f<=n?1:-1,this._ts))return this._start=c,mn(this),this.render(e,t,r);this._onUpdate&&!t&&Gt(this,"onUpdate",!0),!(v===d&&d>=this.totalDuration()||!v&&f)||c!==this._start&&Math.abs(u)===Math.abs(this._ts)||this._lock||(!e&&m||!(v===d&&0<this._ts||!v&&this._ts<0)||fn(this,1),t||e<0&&!f||!v&&!f&&d||(Gt(this,v===d&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||v<d&&0<this.timeScale()||this._prom()))}return this}},{key:"add",value:function(e,t){var r=this;if(jr(t)||(t=Dt(this,t,e)),!(e instanceof Kn)){if(Nr(e))return e.forEach((function(e){return r.add(e,t)})),this;if(Dr(e))return this.addLabel(e,t);if(!Ir(e))return this;e=ii.delayedCall(0,e)}return this!==e?Pt(this,e,t):this}},{key:"getChildren",value:function(){for(var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:-Er,i=[],o=this._first;o;)o._start>=n&&(o instanceof ii?t&&i.push(o):(r&&i.push(o),e&&i.push.apply(i,it(o.getChildren(!0,t,r))))),o=o._next;return i}},{key:"getById",value:function(e){for(var t=this.getChildren(1,1,1),r=t.length;r--;)if(t[r].vars.id===e)return t[r]}},{key:"remove",value:function(e){return Dr(e)?this.removeLabel(e):Ir(e)?this.killTweensOf(e):(pn(this,e),e===this._recent&&(this._recent=this._last),dn(this))}},{key:"totalTime",value:function(e,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ln(An.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),Ze(et(t.prototype),"totalTime",this).call(this,e,r),this._forcing=0,this):this._tTime}},{key:"addLabel",value:function(e,t){return this.labels[e]=Dt(this,t),this}},{key:"removeLabel",value:function(e){return delete this.labels[e],this}},{key:"addPause",value:function(e,t,r){return(t=ii.delayedCall(0,t||ft,r)).data="isPause",this._hasPause=1,Pt(this,t,Dt(this,e))}},{key:"removePause",value:function(e){var t=this._first;for(e=Dt(this,e);t;)t._start===e&&"isPause"===t.data&&fn(t),t=t._next}},{key:"killTweensOf",value:function(e,t,r){for(var n=this.getTweensOf(e,r),i=n.length;i--;)Zn!==n[i]&&n[i].kill(e,t);return this}},{key:"getTweensOf",value:function(e,t){for(var r,n=[],i=Sn(e),o=this._first,a=jr(t);o;)o instanceof ii?function(e,t){for(var r=t.length,n=0;e.indexOf(t[n])<0&&++n<r;);return n<r}(o._targets,i)&&(a?(!Zn||o._initted&&o._ts)&&o.globalTime(0)<=t&&o.globalTime(o.totalDuration())>t:!t||o.isActive())&&n.push(o):(r=o.getTweensOf(i,t)).length&&n.push.apply(n,it(r)),o=o._next;return n}},{key:"tweenTo",value:function(e,t){t=t||{};var r,n=this,i=Dt(n,e),o=(e=t).startAt,a=e.onStart,s=e.onStartParams,l=(e=e.immediateRender,ii.to(n,cn({ease:t.ease||"none",lazy:!1,immediateRender:!1,time:i,overwrite:"auto",duration:t.duration||Math.abs((i-(o&&"time"in o?o.time:n._time))/n.timeScale())||Pr,onStart:function(){var e;n.pause(),r||(e=t.duration||Math.abs((i-(o&&"time"in o?o.time:n._time))/n.timeScale()),l._dur!==e&&Ct(l,e,0,1).render(l._time,!0,!0),r=1),a&&a.apply(l,s||[])}},t)));return e?l.render(0):l}},{key:"tweenFromTo",value:function(e,t,r){return this.tweenTo(t,cn({startAt:{time:Dt(this,e)}},r))}},{key:"recent",value:function(){return this._recent}},{key:"nextLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ht(this,Dt(this,e))}},{key:"previousLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ht(this,Dt(this,e),1)}},{key:"currentLabel",value:function(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+Pr)}},{key:"shiftChildren",value:function(e,t){for(var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=this._first,o=this.labels;i;)i._start>=n&&(i._start+=e,i._end+=e),i=i._next;if(t)for(r in o)o[r]>=n&&(o[r]+=e);return dn(this)}},{key:"invalidate",value:function(){var e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return Ze(et(t.prototype),"invalidate",this).call(this)}},{key:"clear",value:function(){for(var e,t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],r=this._first;r;)e=r._next,this.remove(r),r=e;return this._dp&&(this._time=this._tTime=this._pTime=0),t&&(this.labels={}),dn(this)}},{key:"totalDuration",value:function(e){var t,r,n,i=0,o=this,a=o._last,s=Er;if(arguments.length)return o.timeScale((o._repeat<0?o.duration():o.totalDuration())/(o.reversed()?-e:e));if(o._dirty){for(n=o.parent;a;)t=a._prev,a._dirty&&a.totalDuration(),(r=a._start)>s&&o._sort&&a._ts&&!o._lock?(o._lock=1,Pt(o,a,r-a._delay,1)._lock=0):s=r,r<0&&a._ts&&(i-=r,(!n&&!o._dp||n&&n.smoothChildTiming)&&(o._start+=r/o._ts,o._time-=r,o._tTime-=r),o.shiftChildren(-r,!1,-1/0),s=0),a._end>i&&a._ts&&(i=a._end),a=t;Ct(o,o===er&&o._time>i?o._time:i,1,1),o._dirty=0}return o._tDur}}],[{key:"updateRoot",value:function(e){if(er._ts&&(vt(er,Mt(e,er)),or=An.frame),An.frame>=rn){rn+=_r.autoSleep||120;var t=er._first;if((!t||!t._ts)&&_r.autoSleep&&An._listeners.length<2){for(;t&&!t._ts;)t=t._next;t||An.sleep()}}}}]),t}()),$n=(cn(Jn.prototype,{_lock:0,_hasPause:0,_forcing:0}),function(e,t,r,n,i,o,a){var s,l,u,c,h,p=new pi(this._pt,e,t,0,1,Hn,null,i),f=0,d=0;for(p.b=r,p.e=n,r+="",(i=~(n+="").indexOf("random("))&&(n=_n(n)),o&&(o(o=[r,n],e,t),r=o[0],n=o[1]),s=r.match(Gr)||[];c=Gr.exec(n);)u=c[0],c=n.substring(f,c.index),l?l=(l+1)%5:"rgba("===c.substr(-5)&&(l=1),u!==s[d++]&&(h=parseFloat(s[d-1])||0,p._pt={_next:p._pt,p:c||1===d?c:",",s:h,c:"="===u.charAt(1)?parseFloat(u.substr(2))*("-"===u.charAt(0)?-1:1):parseFloat(u)-h,m:l&&l<4?Math.round:0},f=Gr.lastIndex);return p.c=f<n.length?n.substring(f,n.length):"",p.fp=a,(Wr.test(n)||i)&&(p.e=0),this._pt=p}),ei=function(e,t,r,n,i,o,a,s,l){var u;if(Ir(n)&&(n=n(i||0,e,o)),i=e[t],o="get"!==r?r:Ir(i)?l?e[t.indexOf("set")||!Ir(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():i,r=Ir(i)?l?si:ai:oi,Dr(n)&&"="===(n=~n.indexOf("random(")?_n(n):n).charAt(1)&&(!(u=parseFloat(o)+parseFloat(n.substr(2))*("-"===n.charAt(0)?-1:1)+(bn(o)||0))&&0!==u||(n=u)),o!==n)return isNaN(o*n)||""===n?(i||t in e||Qr(t,n),$n.call(this,e,t,o,n,r,s||_r.stringFilter,l)):(u=new pi(this._pt,e,t,+o||0,n-(o||0),"boolean"==typeof i?ci:ui,0,r),l&&(u.fp=l),a&&u.modifier(a,this,e),this._pt=u)},ti=function(e,t,r,n,i,o){var a,s,l,u;if(en[e]&&!1!==(a=new en[e]).init(i,a.rawVars?t[e]:function(e,t,r,n,i){if(Ir(e)&&(e=Fn(e,i,t,r,n)),!Ur(e)||e.style&&e.nodeType||Nr(e)||zr(e))return Dr(e)?Fn(e,i,t,r,n):e;var o,a={};for(o in e)a[o]=Fn(e[o],i,t,r,n);return a}(t[e],n,i,o,r),r,n,o)&&(r._pt=s=new pi(r._pt,i,e,0,1,a.render,a,0,a.priority),r!==ar))for(l=r._ptLookup[r._targets.indexOf(i)],u=a._props.length;u--;)l[a._props[u]]=s;return a},ri=on+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",ni={},ii=(mt(ri+",id,stagger,delay,duration,paused,scrollTrigger",(function(e){return ni[e]=1})),function(){Qe(t,Kn);var e=Je(t);function t(r,n,i,o){nt(this,t),"number"==typeof n&&(i.duration=n,n=i,i=null);var a,s,l,u,c,h,p,f,d,m=(o=(a=e.call(this,o?n:wt(n))).vars).duration,v=o.delay,y=o.immediateRender,g=o.stagger,b=o.overwrite,x=o.keyframes,w=o.defaults,S=o.scrollTrigger,T=o.yoyoEase,_=(o=n.parent||er,(Nr(r)||zr(r)?jr(r[0]):"length"in n)?[r]:Sn(r));if(a._targets=_.length?an(_):ht("GSAP target "+r+" not found. https://greensock.com",!_r.nullTargetWarn)||[],a._ptLookup=[],a._overwrite=b,x||g||ut(m)||ut(v)){if(n=a.vars,(s=a.timeline=new Jn({data:"nested",defaults:w||{}})).kill(),s.parent=s._dp=$e(a),s._start=0,g||ut(m)||ut(v)){if(c=_.length,f=g&&Ut(g),Ur(g))for(h in g)~ri.indexOf(h)&&((d=d||{})[h]=g[h]);for(l=0;l<c;l++)(u=hn(n,ni)).stagger=0,T&&(u.yoyoEase=T),d&&bt(u,d),p=_[l],u.duration=+Fn(m,$e(a),l,p,_),u.delay=(+Fn(v,$e(a),l,p,_)||0)-a._delay,!g&&1===c&&u.delay&&(a._delay=v=u.delay,a._start+=v,u.delay=0),s.to(p,u,f?f(l,p,_):0),s._ease=Ln.none;s.duration()?m=v=0:a.timeline=0}else if(x){wt(cn(s.vars.defaults,{ease:"none"})),s._ease=Un(x.ease||n.ease||"none");var M,E,P,O=0;if(Nr(x))x.forEach((function(e){return s.to(_,e,">")}));else{for(h in u={},x)"ease"!==h&&"easeEach"!==h&&function(e,t,r,n){var i,o,a=t.ease||n||"power1.inOut";if(Nr(t))o=r[e]||(r[e]=[]),t.forEach((function(e,r){return o.push({t:r/(t.length-1)*100,v:e,e:a})}));else for(i in t)o=r[i]||(r[i]=[]),"ease"!==i&&o.push({t:parseFloat(e),v:t[i],e:a})}(h,x[h],u,x.easeEach);for(h in u)for(M=u[h].sort((function(e,t){return e.t-t.t})),l=O=0;l<M.length;l++)(P={ease:(E=M[l]).e,duration:(E.t-(l?M[l-1].t:0))/100*m})[h]=E.v,s.to(_,P,O),O+=P.duration;s.duration()<m&&s.to({},{duration:m-s.duration()})}}m||a.duration(m=s.duration())}else a.timeline=0;return!0!==b||$t||(Zn=$e(a),er.killTweensOf(_),Zn=0),Pt(o,$e(a),i),n.reversed&&a.reverse(),n.paused&&a.paused(!0),(y||!m&&!x&&a._start===ln(o._time)&&Br(y)&&St($e(a))&&"nested"!==o.data)&&(a._tTime=-Pr,a.render(Math.max(0,-v))),S&&Ot($e(a),S),a}return rt(t,[{key:"render",value:function(e,t,r){var n,i,o=this._time,a=this._tDur,s=this._dur,l=a-Pr<e&&0<=e?a:e<Pr?0:e;if(s){if(l!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(m=l,d=this.timeline,this._repeat){if(h=s+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*h+e,t,r);if(m=ln(l%h),l===a?(y=this._repeat,m=s):((y=~~(l/h))&&y===l/h&&(m=s,y--),s<m&&(m=s)),(f=this._yoyo&&1&y)&&(p=this._yEase,m=s-m),g=_t(this._tTime,h),m===o&&!r&&this._initted)return this;y!==g&&(d&&this._yEase&&Yt(d,f),!this.vars.repeatRefresh||f||this._lock||(this._lock=r=1,this.render(ln(h*y),!0).invalidate()._lock=0))}if(!this._initted){if(Rt(this,e<0?e:m,r,t))return this._tTime=0,this;if(s!==this._dur)return this.render(e,t,r)}if(this._tTime=l,this._time=m,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=i=(p||this._ease)(m/s),this._from&&(this.ratio=i=1-i),m&&!o&&!t&&(Gt(this,"onStart"),this._tTime!==l))return this;for(n=this._pt;n;)n.r(i,n.d),n=n._next;d&&d.render(e<0?e:!m&&f?-Pr:d._dur*d._ease(m/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),Gt(this,"onUpdate")),this._repeat&&y!==g&&this.vars.onRepeat&&!t&&this.parent&&Gt(this,"onRepeat"),l!==this._tDur&&l||this._tTime!==l||(e<0&&this._startAt&&!this._onUpdate&&this._startAt.render(e,!0,!0),!e&&s||!(l===this._tDur&&0<this._ts||!l&&this._ts<0)||fn(this,1),t||e<0&&!o||!l&&!o||(Gt(this,l===a?"onComplete":"onReverseComplete",!0),!this._prom||l<a&&0<this.timeScale()||this._prom()))}}else{var u,c,h=this,p=e,f=t,d=r,m=h.ratio,v=p<0||!p&&(!h._start&&kt(h)&&(h._initted||!At(h))||(h._ts<0||h._dp._ts<0)&&!At(h))?0:1,y=h._rDelay,g=0;if(y&&h._repeat&&(c=_t(g=jt(0,h._tDur,p),y),h._yoyo&&1&c&&(v=1-v),c!==_t(h._tTime,y)&&(m=1-v,h.vars.repeatRefresh&&h._initted&&h.invalidate())),v!==m||d||h._zTime===Pr||!p&&h._zTime){if(h._initted||!Rt(h,p,d,f)){for(c=h._zTime,h._zTime=p||(f?Pr:0),f=f||p&&!c,h.ratio=v,h._from&&(v=1-v),h._time=0,h._tTime=g,u=h._pt;u;)u.r(v,u.d),u=u._next;h._startAt&&p<0&&h._startAt.render(p,!0,!0),h._onUpdate&&!f&&Gt(h,"onUpdate"),g&&h._repeat&&!f&&h.parent&&Gt(h,"onRepeat"),(p>=h._tDur||p<0)&&h.ratio===v&&(v&&fn(h,1),f||(Gt(h,v?"onComplete":"onReverseComplete",!0),h._prom&&h._prom()))}}else h._zTime||(h._zTime=p)}return this}},{key:"targets",value:function(){return this._targets}},{key:"invalidate",value:function(){return this._pt=this._op=this._startAt=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(),Ze(et(t.prototype),"invalidate",this).call(this)}},{key:"kill",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";if(!(e||t&&"all"!==t))return this._lazy=this._pt=0,this.parent?Wt(this):this;if(this.timeline)return p=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,Zn&&!0!==Zn.vars.overwrite)._first||Wt(this),this.parent&&p!==this.timeline.totalDuration()&&Ct(this,this._dur*this.timeline._tDur/p,0,1),this;var r,n,i,o,a,s,l,u=this._targets,c=e?Sn(e):u,h=this._ptLookup,p=this._pt;if((!t||"all"===t)&&function(e,t){for(var r=e.length,n=r===t.length;n&&r--&&e[r]===t[r];);return r<0}(u,c))return"all"===t&&(this._pt=0),Wt(this);for(r=this._op=this._op||[],"all"!==t&&(Dr(t)&&(a={},mt(t,(function(e){return a[e]=1})),t=a),t=function(e,t){var r,n,i,o,a=(e=e[0]?sn(e[0]).harness:0)&&e.aliases;if(!a)return t;for(n in r=bt({},t),a)if(n in r)for(i=(o=a[n].split(",")).length;i--;)r[o[i]]=r[n];return r}(u,t)),l=u.length;l--;)if(~c.indexOf(u[l]))for(a in n=h[l],"all"===t?(r[l]=t,o=n,i={}):(i=r[l]=r[l]||{},o=t),o)(s=n&&n[a])&&("kill"in s.d&&!0!==s.d.kill(a)||pn(this,s,"_pt"),delete n[a]),"all"!==i&&(i[a]=1);return this._initted&&!this._pt&&p&&Wt(this),this}}],[{key:"to",value:function(e,r){return new t(e,r,arguments[2])}},{key:"from",value:function(e,t){return It(1,arguments)}},{key:"delayedCall",value:function(e,r,n,i){return new t(r,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:e,onComplete:r,onReverseComplete:r,onCompleteParams:n,onReverseCompleteParams:n,callbackScope:i})}},{key:"fromTo",value:function(e,t,r){return It(2,arguments)}},{key:"set",value:function(e,r){return r.duration=0,r.repeatDelay||(r.repeat=0),new t(e,r)}},{key:"killTweensOf",value:function(e,t,r){return er.killTweensOf(e,t,r)}}]),t}()),oi=(cn(ii.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),mt("staggerTo,staggerFrom,staggerFromTo",(function(e){ii[e]=function(){var t=new Jn,r=xn.call(arguments,0);return r.splice("staggerFromTo"===e?5:4,0,0),t[e].apply(t,r)}})),function(e,t,r){return e[t]=r}),ai=function(e,t,r){return e[t](r)},si=function(e,t,r,n){return e[t](n.fp,r)},li=function(e,t){return Ir(e[t])?ai:st(e[t])&&e.setAttribute?Vn:oi},ui=function(e,t){return t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t)},ci=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},hi=function(e){for(var t,r,n,i,o=e._pt;o;){for(t=o._next,r=n;r&&r.pr>o.pr;)r=r._next;(o._prev=r?r._prev:i)?o._prev._next=o:n=o,(o._next=r)?r._prev=o:i=o,o=t}e._pt=n},pi=function(){function e(t,r,n,i,o,a,s,l,u){nt(this,e),this.t=r,this.s=i,this.c=o,this.p=n,this.r=a||ui,this.d=s||this,this.set=l||oi,this.pr=u||0,(this._next=t)&&(t._prev=this)}return rt(e,[{key:"modifier",value:function(e,t,r){this.mSet=this.mSet||this.set,this.set=qn,this.m=e,this.mt=r,this.tween=t}}]),e}(),fi=(mt(on+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",(function(e){return Kr[e]=1})),Yr.TweenMax=Yr.TweenLite=ii,Yr.TimelineLite=Yr.TimelineMax=Jn,er=new Jn({sortChildren:!1,defaults:Mr,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),_r.stringFilter=function(e){var t=e.join(" ");if(Rn.lastIndex=0,Rn.test(t))return t=kn.test(t),e[1]=qt(e[1],t),e[0]=qt(e[0],t,On(e[1])),!0},{registerPlugin:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((function(e){var t=(e=!e.name&&e.default||e).name,r=Ir(e),n=(r=t&&!r&&e.init?function(){this._props=[]}:e,{init:ft,render:Gn,add:ei,kill:Xn,modifier:Wn,rawVars:0}),i={targetTest:0,get:0,getSetter:li,aliases:{},register:0};if(Cn(),e!==r){if(en[t])return;cn(r,cn(hn(e,n),i)),bt(r.prototype,bt(n,hn(e,i))),en[r.prop=t]=r,e.targetTest&&(nn.push(r),Kr[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}pt(t,r),e.register&&e.register(mi,r,pi)}))},timeline:function(e){return new Jn(e)},getTweensOf:function(e,t){return er.getTweensOf(e,t)},getProperty:function(e,t,r,n){Dr(e)&&(e=Sn(e)[0]);var i=sn(e||{}).get,o=r?gt:yt;return"native"===r&&(r=""),e&&(t?o((en[t]&&en[t].get||i)(e,t,r,n)):function(t,r,n){return o((en[t]&&en[t].get||i)(e,t,r,n))})},quickSetter:function(e,t,r){var n,i;if(1<(e=Sn(e)).length)return n=e.map((function(e){return mi.quickSetter(e,t,r)})),i=n.length,function(e){for(var t=i;t--;)n[t](e)};e=e[0]||{};var o=en[t],a=sn(e),s=a.harness&&(a.harness.aliases||{})[t]||t,l=o?function(t){var n=new o;ar._pt=0,n.init(e,r?t+r:t,ar,0,[e]),n.render(1,n),ar._pt&&Gn(1,ar)}:a.set(e,s);return o?l:function(t){return l(e,s,r?t+r:t,a,1)}},isTweening:function(e){return 0<er.getTweensOf(e,!0).length},defaults:function(e){return e&&e.ease&&(e.ease=Un(e.ease,Mr.ease)),xt(Mr,e||{})},config:function(e){return xt(_r,e||{})},registerEffect:function(e){var t=e.name,r=e.effect,n=e.plugins,i=e.defaults;e=e.extendTimeline,(n||"").split(",").forEach((function(e){return e&&!en[e]&&!Yr[e]&&ht(t+" effect requires "+e+" plugin.")})),tn[t]=function(e,t,n){return r(Sn(e),cn(t||{},i),n)},e&&(Jn.prototype[t]=function(e,r,n){return this.add(tn[t](e,Ur(r)?r:(n=r)&&{},this),n)})},registerEase:function(e,t){Ln[e]=Un(t)},parseEase:function(e,t){return arguments.length?Un(e,t):Ln},getById:function(e){return er.getById(e)},exportRoot:function(){var e,t,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=1<arguments.length?arguments[1]:void 0,i=new Jn(r);for(i.smoothChildTiming=Br(r.smoothChildTiming),er.remove(i),i._dp=0,i._time=i._tTime=er._time,e=er._first;e;)t=e._next,!n&&!e._dur&&e instanceof ii&&e.vars.onComplete===e._targets[0]||Pt(i,e,e._start-e._delay),e=t;return Pt(er,i,0),i},utils:{wrap:function e(t,r,n){var i=r-t;return Nr(t)?Ft(t,e(0,t.length),r):gn(n,(function(e){return(i+(e-t)%i)%i+t}))},wrapYoyo:function e(t,r,n){var i=r-t,o=2*i;return Nr(t)?Ft(t,e(0,t.length-1),r):gn(n,(function(e){return t+(i<(e=(o+(e-t)%o)%o||0)?o-e:e)}))},distribute:Ut,random:Nt,snap:zt,normalize:function(e,t,r){return Vt(e,t,0,1,r)},getUnit:bn,clamp:function(e,t,r){return gn(r,(function(r){return jt(e,t,r)}))},splitColor:Pn,toArray:Sn,selector:function(e){return e=Sn(e)[0]||ht("Invalid scope")||{},function(t){var r=e.current||e.nativeElement||e;return Sn(t,r.querySelectorAll?r:r===e?ht("Invalid scope")||nr.createElement("div"):e)}},mapRange:Vt,pipe:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.reduce((function(e,t){return t(e)}),e)}},unitize:function(e,t){return function(r){return e(parseFloat(r))+(t||bn(r))}},interpolate:function e(t,r,n,i){var o=isNaN(t+r)?0:function(e){return(1-e)*t+e*r};if(!o){var a,s,l,u,c,h=Dr(t),p={};if(!0===n&&(i=1)&&(n=null),h)t={p:t},r={p:r};else if(Nr(t)&&!Nr(r)){for(l=[],u=t.length,c=u-2,s=1;s<u;s++)l.push(e(t[s-1],t[s]));u--,o=function(e){e*=u;var t=Math.min(c,~~e);return l[t](e-t)},n=r}else i||(t=bt(Nr(t)?[]:{},t));if(!l){for(a in r)ei.call(p,t,a,"get",r[a]);o=function(e){return Gn(e,p),h?t.p:t}}}return gn(n,o)},shuffle:Tn},install:ct,effects:tn,ticker:An,updateRoot:Jn.updateRoot,plugins:en,globalTimeline:er,core:{PropTween:pi,globals:pt,Tween:ii,Timeline:Jn,Animation:Kn,getCache:sn,_removeLinkedListItem:pn,suppressOverwrites:function(e){return $t=e}}}),di=(mt("to,from,fromTo,delayedCall,set,killTweensOf",(function(e){return fi[e]=ii[e]})),An.add(Jn.updateRoot),ar=fi.to({},{duration:0}),function(e,t){for(var r=e._pt;r&&r.p!==t&&r.op!==t&&r.fp!==t;)r=r._next;return r}),mi=fi.registerPlugin({name:"attr",init:function(e,t,r,n,i){var o,a;for(o in t)(a=this.add(e,"setAttribute",(e.getAttribute(o)||0)+"",t[o],n,i,0,0,o))&&(a.op=o),this._props.push(o)}},{name:"endArray",init:function(e,t){for(var r=t.length;r--;)this.add(e,r,e[r]||0,t[r])}},Yn("roundProps",Bt),Yn("modifiers"),Yn("snap",zt))||fi;ii.version=Jn.version=mi.version="3.9.1",ir=1,lt()&&Cn(),Ln.Power0,Ln.Power1,Ln.Power2,Ln.Power3,Ln.Power4,Ln.Linear,Ln.Quad,Ln.Cubic,Ln.Quart,Ln.Quint,Ln.Strong,Ln.Elastic,Ln.Back,Ln.SteppedEase,Ln.Bounce,Ln.Sine,Ln.Expo,Ln.Circ;const vi=c,yi=["map","normalMap","aoMap"],gi=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"];class bi{}const xi=class extends bi{constructor(e){super(),this.type="修改材质";var{target:e,info:t,newVal:r,oldVal:n,runScene:i}=e;this.runScene=i,this.target=e,this.info=t,this.newVal=r,this.oldVal=n}_execute(e,t){this.target[this.info]=e,this.target.needsUpdate=!0,gi.includes(this.info)&&e&&this.runScene.uniqueEx.texture.addMaterial(e,{material:this.target,type:this.info})}execute(){return this.redo(),this}undo(){this._execute(this.oldVal,this.newVal)}redo(){this._execute(this.newVal,this.oldVal)}};var wi=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class Si{constructor(e){this.allTextures=new Set,this.runScene=e}load(e){return wi(this,void 0,void 0,(function*(){var t=yield Io(e);return this.parse(t)}))}parse(e){return wi(this,void 0,void 0,(function*(){var t="Blob"===ga(e)?e:yield Uo(e);return this.afterLoad(t,yield Ai(t))}))}clone(e){const t=new c.Texture(e.image);return t.userData=Object.assign(Object.assign({},e.userData),{id:(0,l.getId)()}),Pi(t),this.getSameAndAddtoAll(t)}getDef(e){return e=new c.Texture(e),Pi(e),this.getSameAndAddtoAll(e)}getSameAndAddtoAll(e){var t=e.userData.md5;return(t=this.getSameTexture(t,e))?(Ei(e),t):(this.initTextureAndAddtoAll(e),e)}afterLoad(e,t){return wi(this,void 0,void 0,(function*(){return this.getSameAndAddtoAll(yield Pi(t,e))}))}getSameTexture(e,t){for(const n in this.runScene.uniqueEx.texture.map){var r=this.runScene.uniqueEx.texture.get(n);if(r.userData.md5===e&&r.mapping===t.mapping)return r}}initTextureAndAddtoAll(e){return wi(this,void 0,void 0,(function*(){return Ri(e),Pi(e),this.addTextureToAll(e),e}))}addTextureToAll(e){var t=this.runScene.uniqueEx.texture.getLength();this.runScene.uniqueEx.texture.add(e),this.runScene.uniqueEx.texture.getLength()!==t&&this.runScene.optionsEx.cb.texture.add.cb(e)}getBlobAndBase64(e){return e.userData.blob?e.userData:Ro(e)}coverByImage(e,t){return wi(this,void 0,void 0,(function*(){let r;r=t instanceof c.Texture?t:t?yield this.parse(t):null;var n=this.runScene.uniqueEx.texture.getMaterials(this.runScene.uniqueEx.getId(e));if(n){const t=[];(0,Xe.js)(n,((n,i)=>{const o=this.runScene.uniqueEx.material.get(n);o&&i.forEach((n=>{t.push(new xi({target:o,info:n,newVal:r,oldVal:e,runScene:this.runScene}).execute())}))})),this.runScene.undoEx.addUndo(t)}}))}removeTexture(e){this.runScene.optionsEx.cb.texture.remove.cb(e),this.runScene.uniqueEx.texture.remove(e)}}const Ti={环境遮蔽:"aoMap",法线:"normalMap",金属度:"metalnessMap",粗糙度:"roughnessMap",自发光:"emissiveMap",颜色:"map",置换:"displacementMap",光照贴图:"lightMap",环境:"envMap",透明度:"alphaMap"},_i=e=>1023===e.format?"image/png":"image/jpeg",Mi=e=>{var{width:e,height:t}=e.image;return e*t*4*1.33},Ei=e=>{if(e){const r=e.image;var t=e.userData.url;r.close(),URL.revokeObjectURL(t),e.dispose()}},Pi=(e,t)=>wi(void 0,void 0,void 0,(function*(){const r=t||e.userData.blob||(yield Oi(e));var{md5:n,url:i}=e.userData;return e.userData.blob=r,n||(e.userData.md5=Fo(yield r.arrayBuffer())),i||(e.userData.url=URL.createObjectURL(r)),e.userData.gm=Mi(e),e.format=e.userData.format||-1!==r.type.indexOf("png")?1023:1022,e})),Oi=e=>e.userData.blob||Po(e.image),Ri=e=>(e.magFilter=1003,e.wrapS=vi.RepeatWrapping,e.wrapT=vi.RepeatWrapping,e.encoding=3e3,e.version=3,e.flipY=!1,e.minFilter=vi.LinearMipmapLinearFilter,e.needsUpdate=!0,e),ki=e=>createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"}),Ai=e=>wi(void 0,void 0,void 0,(function*(){var t=yield ki(e instanceof Blob?e:yield Io(e));return new c.Texture(t)})),Ci=e=>e.userData.url,Li=(e,t="repeat")=>(e.mapping="repeat"===t?vi.EquirectangularReflectionMapping:300,e.needsUpdate=!0,e),Di=e=>{var{width:e,height:t}=e.image;return{width:e,height:t}};function Ii(e){return(Ii="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ji(e,t){return(ji=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ui(e){return(Ui=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Bi=new c.Box3,zi=new c.Vector3,Ni=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ji(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Ui(e);if(r=t?(r=Ui(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ii(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(e=r.call(this)).type="LineSegmentsGeometry",e.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),e.setAttribute("position",new c.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),e.setAttribute("uv",new c.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2)),e}return t=n,(e=[{key:"applyMatrix4",value:function(e){var t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),r.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}},{key:"setPositions",value:function(e){var t;return e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e)),e=new c.InstancedInterleavedBuffer(t,6,1),this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(e,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(e,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}},{key:"setColors",value:function(e){var t;return e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e)),e=new c.InstancedInterleavedBuffer(t,6,1),this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(e,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(e,3,3)),this}},{key:"fromWireframeGeometry",value:function(e){return this.setPositions(e.attributes.position.array),this}},{key:"fromEdgesGeometry",value:function(e){return this.setPositions(e.attributes.position.array),this}},{key:"fromMesh",value:function(e){return this.fromWireframeGeometry(new c.WireframeGeometry(e.geometry)),this}},{key:"fromLineSegments",value:function(e){if(!(e=e.geometry).isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}},{key:"computeBoundingBox",value:function(){null===this.boundingBox&&(this.boundingBox=new c.Box3);var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),Bi.setFromBufferAttribute(t),this.boundingBox.union(Bi))}},{key:"computeBoundingSphere",value:function(){null===this.boundingSphere&&(this.boundingSphere=new c.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){for(var r=this.boundingSphere.center,n=(this.boundingBox.getCenter(r),0),i=0,o=e.count;i<o;i++)zi.fromBufferAttribute(e,i),n=Math.max(n,r.distanceToSquared(zi)),zi.fromBufferAttribute(t,i),n=Math.max(n,r.distanceToSquared(zi));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}},{key:"toJSON",value:function(){}},{key:"applyMatrix",value:function(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.InstancedBufferGeometry);function Fi(e){return(Fi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Vi(e,t){return(Vi=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Hi(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Gi(e){return(Gi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Ni.prototype.isLineSegmentsGeometry=!0,c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};var Wi=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vi(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Gi(e);if(r=t?(r=Gi(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Fi(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return Hi(n)}}(n);function n(e){var t;if(this instanceof n)return t=r.call(this,{type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(Hi(t),{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set:function(e){Boolean(e)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)},set:function(e){Boolean(e)!==Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),t.setValues(e),t;throw new TypeError("Cannot call a class as a function")}return t=n,Object.defineProperty(t,"prototype",{writable:!1}),t}(c.ShaderMaterial);function Xi(e){return(Xi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qi(e,t){return(qi=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Yi(e){return(Yi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Wi.prototype.isLineMaterial=!0;var Zi,Qi,Ki,Ji,$i=new c.Vector3,eo=new c.Vector3,to=new c.Vector4,ro=new c.Vector4,no=new c.Vector4,io=new c.Vector3,oo=new c.Matrix4,ao=new c.Line3,so=new c.Vector3,lo=new c.Box3,uo=new c.Sphere,co=new c.Vector4;function ho(e,t,r){return co.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),co.multiplyScalar(1/co.w),co.x=Ji/r.width,co.y=Ji/r.height,co.applyMatrix4(e.projectionMatrixInverse),co.multiplyScalar(1/co.w),Math.abs(Math.max(co.x,co.y))}var po=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&qi(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Yi(e);if(r=t?(r=Yi(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Xi(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ni,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Wi({color:16777215*Math.random()}),i=this,o=n;if(i instanceof o)return(i=r.call(this,e,t)).type="LineSegments2",i;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"computeLineDistances",value:function(){for(var e=this.geometry,t=e.attributes.instanceStart,r=e.attributes.instanceEnd,n=new Float32Array(2*t.count),i=0,o=0,a=t.count;i<a;i++,o+=2)$i.fromBufferAttribute(t,i),eo.fromBufferAttribute(r,i),n[o]=0===o?0:n[o-1],n[o+1]=n[o]+$i.distanceTo(eo);var s=new c.InstancedInterleavedBuffer(n,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(s,1,1)),this}},{key:"raycast",value:function(e,t){var r=this.material.worldUnits,n=e.camera,i=(null!==n||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),void 0!==e.params.Line2&&e.params.Line2.threshold||0),o=(Zi=e.ray,e=this.matrixWorld,this.geometry),a=this.material;if(Ji=a.linewidth+i,Qi=o.attributes.instanceStart,Ki=o.attributes.instanceEnd,null===o.boundingSphere&&o.computeBoundingSphere(),uo.copy(o.boundingSphere).applyMatrix4(e),i=r?.5*Ji:ho(n,Math.max(n.near,uo.distanceToPoint(Zi.origin)),a.resolution),uo.radius+=i,!1!==Zi.intersectsSphere(uo)&&(null===o.boundingBox&&o.computeBoundingBox(),lo.copy(o.boundingBox).applyMatrix4(e),i=r?.5*Ji:ho(n,Math.max(n.near,lo.distanceToPoint(Zi.origin)),a.resolution),lo.expandByScalar(i),!1!==Zi.intersectsBox(lo)))if(r)for(var s=t,l=0,u=Qi.count;l<u;l++){ao.start.fromBufferAttribute(Qi,l),ao.end.fromBufferAttribute(Ki,l);var h=new c.Vector3,p=new c.Vector3;Zi.distanceSqToSegment(ao.start,ao.end,p,h),p.distanceTo(h)<.5*Ji&&s.push({point:p,pointOnLine:h,distance:Zi.origin.distanceTo(p),object:this,face:null,faceIndex:l,uv:null,uv2:null})}else{var f=this,d=t,m=(o=n).projectionMatrix,v=f.material.resolution,y=f.matrixWorld,g=(e=f.geometry).attributes.instanceStart,b=e.attributes.instanceEnd,x=-o.near;Zi.at(1,no),no.w=1,no.applyMatrix4(o.matrixWorldInverse),no.applyMatrix4(m),no.multiplyScalar(1/no.w),no.x*=v.x/2,no.y*=v.y/2,no.z=0,io.copy(no),oo.multiplyMatrices(o.matrixWorldInverse,y);for(var w,S,T,_,M=0,E=g.count;M<E;M++)to.fromBufferAttribute(g,M),ro.fromBufferAttribute(b,M),to.w=1,ro.w=1,to.applyMatrix4(oo),ro.applyMatrix4(oo),to.z>x&&ro.z>x||(to.z>x?(w=to.z-ro.z,w=(to.z-x)/w,to.lerp(ro,w)):ro.z>x&&(w=ro.z-to.z,S=(ro.z-x)/w,ro.lerp(to,S)),to.applyMatrix4(m),ro.applyMatrix4(m),to.multiplyScalar(1/to.w),ro.multiplyScalar(1/ro.w),to.x*=v.x/2,to.y*=v.y/2,ro.x*=v.x/2,ro.y*=v.y/2,ao.start.copy(to),ao.start.z=0,ao.end.copy(ro),ao.end.z=0,S=ao.closestPointToPointParameter(io,!0),ao.at(S,so),T=-1<=(T=c.MathUtils.lerp(to.z,ro.z,S))&&T<=1,_=io.distanceTo(so)<.5*Ji,T&&_&&(ao.start.fromBufferAttribute(g,M),ao.end.fromBufferAttribute(b,M),ao.start.applyMatrix4(y),ao.end.applyMatrix4(y),T=new c.Vector3,_=new c.Vector3,Zi.distanceSqToSegment(ao.start,ao.end,_,T),d.push({point:_,pointOnLine:T,distance:Zi.origin.distanceTo(_),object:f,face:null,faceIndex:M,uv:null,uv2:null})))}}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Mesh);function fo(e){return(fo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mo(){return(mo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=yo(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function vo(e,t){return(vo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function yo(e){return(yo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}po.prototype.isLineSegments2=!0;var go=function(){var e=n,t=Ni;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vo(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=yo(e);if(r=t?(r=yo(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===fo(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e;if(this instanceof n)return(e=r.call(this)).type="LineGeometry",e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"setPositions",value:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return mo(yo(n.prototype),"setPositions",this).call(this,r),this}},{key:"setColors",value:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return mo(yo(n.prototype),"setColors",this).call(this,r),this}},{key:"fromLine",value:function(e){if(!(e=e.geometry).isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function bo(e){return(bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xo(e,t){return(xo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function wo(e){return(wo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}go.prototype.isLineGeometry=!0;var So=function(){var e=n,t=po;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&xo(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=wo(e);if(r=t?(r=wo(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===bo(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new go,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Wi({color:16777215*Math.random()}),i=this,o=n;if(i instanceof o)return(i=r.call(this,e,t)).type="Line2",i;throw new TypeError("Cannot call a class as a function")}return e=n,Object.defineProperty(e,"prototype",{writable:!1}),e}(),To=(So.prototype.isLine2=!0,function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))});const _o=(e,t,r,n,i)=>{let o=Object.assign({},e),a=new ii(o,r,t).eventCallback("onUpdate",(e=>n&&n(o))).eventCallback("onComplete",(e=>{i&&i(),ii.killTweensOf(a)}));return a},Mo=(e,t)=>(t.updateMatrixWorld(!0),t=new vi.Vector3,e.getWorldPosition(t),t),Eo=e=>{const t=document.createElement("canvas");return(t.width=e.width,t.height=e.height,t.getContext("2d")).drawImage(e,0,0,t.width,t.height),t.toDataURL()},Po=e=>To(void 0,void 0,void 0,(function*(){const t=document.createElement("canvas");return(t.width=e.width,t.height=e.height,t.getContext("2d")).drawImage(e,0,0,t.width,t.height),new Promise((e=>{t.toBlob((t=>{e(t)}))}))})),Oo=e=>{const t=document.createElement("canvas"),r=(t.width=e.width,t.height=e.height,t.getContext("2d"));r.translate(0,t.height),r.scale(1,-1),r.drawImage(e,0,0,t.width,t.height)},Ro=e=>To(void 0,void 0,void 0,(function*(){var t=e.image;const r=document.createElement("canvas"),n=(r.width=t.width,r.height=t.height,r.getContext("2d")),i=_i(e);return n.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(i)})}),i)}))})),ko=e=>To(void 0,void 0,void 0,(function*(){-1!==e.indexOf(",")&&(e=Ao(e));const t=window.atob(e);var r=t.length;const n=new Uint8Array(r);for(let e=0;e<r;e++)n[e]=t.charCodeAt(e);return n.buffer})),Ao=e=>e.substring(e.indexOf(",")+1),Co=e=>URL.createObjectURL(new Blob([e])),Lo=(e,t)=>URL.createObjectURL(new Blob([e],t)),Do=e=>{let t="";var r=new Uint8Array(e);for(let e=0,n=r.byteLength;e<n;e++)t+=String.fromCharCode(r[e]);return"data:image/jpg;base64,"+window.btoa(t)},Io=e=>To(void 0,void 0,void 0,(function*(){return(yield s().get(e,{responseType:"blob"})).data})),jo=e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]),i=n.length,o=new Uint8Array(i);for(;i--;)o[i]=n.charCodeAt(i);return new Blob([o],{type:r})},Uo=e=>To(void 0,void 0,void 0,(function*(){return jo(yield(0,Ye.toResult)(e,"base64"))})),Bo=(e,t)=>new File([e],t),zo=e=>e.substring(e.indexOf(":")+1,e.indexOf(";")),No=e=>{let t="";const r=t=e<102.4?e.toFixed(2)+"B":e<1048576?(e/1024).toFixed(2)+"KB":e<1073741824?(e/1048576).toFixed(2)+"M":(e/1073741824).toFixed(2)+"G";return e=r.indexOf("."),"00"==r.substr(e+1,2)?r.substring(0,e)+r.substr(e+3,2):t},Fo=e=>(0,qe.md5)(e),Vo=(e,t)=>{var{width:t,height:r}=t;let n=new Image,i=(n.src=e,n.width=t,n.height=r,document.createElement("canvas")),o=(i.width=t,i.height=r,i.getContext("2d"));return new Promise((e=>{n.onload=function(){o.drawImage(n,0,0,i.width,i.height),e({canvas:i,ctx:o})}}))},Ho=e=>{const t=document.createElement("canvas"),r=t.getContext("2d");return r.drawImage(e,0,0,e.width,e.height),{ctx:r,canvas:t}},Go=(e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d");return r.width=e.width,r.height=e.height,n.drawImage(e,0,0,e.width,e.height),new Promise((e=>{r.toBlob((t=>{t&&e(URL.createObjectURL(t))}),"image/webp",t)}))},Wo=(e,t,r)=>{e/=255,t/=255,r/=255;var n,i=Math.max(e,t,r),o=Math.min(e,t,r),a=(i+o)/2;if(i==o)n=l=0;else{var s=i-o,l=.5<a?s/(2-i-o):s/(i+o);switch(i){case e:n=(t-r)/s+(t<r?6:0);break;case t:n=(r-e)/s+2;break;case r:n=(e-t)/s+4}n/=6}return[100*n,100*l,100*a]},Xo=(e,t,r)=>{var n,i,o,a;return 0==t?i=o=a=r:(i=(n=function(e,t,r){return r<0&&(r+=1),1<r&&--r,r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e})(t=2*r-(r=r<.5?r*(1+t):r+t-r*t),r,e+1/3),o=n(t,r,e),a=n(t,r,e-1/3)),[255*i,255*o,255*a]},qo=e=>To(void 0,void 0,void 0,(function*(){var{bitmap:t,texture:r}=e;const{ctx:n,canvas:i}=yield Vo(URL.createObjectURL(r.userData.blob),{width:t.width,height:t.height});for(var o=n.getImageData(0,0,t.width,t.height,{colorSpace:"srgb"}),a=0,s=o.data.length;a<s;a+=4){var l=(c=Wo(o.data[a],o.data[a+1],o.data[a+2]))[0]/100,u=c[1]/100,c=c[2]/100;l=Xo(l,u,c),o.data[a]=l[0],o.data[a+1]=l[1],o.data[a+2]=l[2]}return n.putImageData(o,0,0),new vi.Texture(i)})),Yo=e=>{for(var t=(e=e.bitmap).width,r=e.height,n=Ho(e).ctx.getImageData(0,0,t,r).data,i=[],o=0;o<n/4;o+=1)i.push(n.slice(4*o,4*(o+1)))},Zo=e=>new Array(e.files.length).fill(0).map(((t,r)=>e.files.item(r))).filter((e=>null!==e)),Qo=e=>new Promise((t=>{e.toBlob((e=>{t(e)}))})),Ko={parse(e){var{x:e,y:t,z:r}=e;return void 0===r?new c.Vector2(e,t):new c.Vector3(e,t,r)},toJSON(e){var{x:t,y:r}=e;return e instanceof c.Vector2?{x:t,y:r}:{x:t,y:r,z:e.z}}},Jo=(e,t)=>s().get(e,{responseType:t||"arraybuffer"}).then((e=>e.data)).catch((e=>{console.log(e,"加载出错")})),$o=(e,t)=>Object.assign(e,t||{}),ea=(e,t)=>e.distanceTo(t),ta=(e,t,r,n,i,o)=>({cx:e,cy:t,cz:r,tx:n,ty:i,tz:o}),ra=e=>new T(e),na=e=>new I(e),ia=e=>new _(e),oa=(e,t=0)=>{let r=setTimeout((()=>(null!==r&&clearTimeout(r),r=null,e())),t)},aa=e=>{if(null===e)return null;if("object"!=typeof e)return e;var t,r,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]=r);return n},sa=(e,t=.5,r=!1)=>{if("Group"===e.type)throw TypeError("该模型为Group类型");if(!e.material)throw TypeError("该模型没有材质");if(void 0===e.material.oldOpc&&(e.material.oldOpc=e.material.opacity,e.material.oldTransparent=e.material.transparent),r)return e.material.opacity=e.material.oldOpc,void(e.material.transparent=e.material.oldTransparent);1===t?(e.material.transparent=!1,e.material.opacity=1):(e.material.transparent=!0,e.material.opacity=t)},la=(e,t,r)=>{"Group"===e.type||"Object3D"===e.type?e.children.forEach((e=>la(e,t,r))):sa(e,t,r)},ua=(e,t,r=1,n)=>new Array(t).fill("").map(((t,i)=>e+(i+r)+(n||""))),ca=e=>(e.mapping=c.EquirectangularReflectionMapping,e),ha=e=>{let t=e=>"Group"!==e.type&&"Object3D"!==e.type||1!==e.children.length?e:t(e.children[0]);return t(e)},pa=(e,t)=>{let r=document.createElement("video");return r.style="position:absolute;top:0;left:0;z-index:1000000;",r.src=e,r.loop="loop",r.muted="muted",r.play(),t.appendChild(r),new c.VideoTexture(r)},fa=(e,t=!1)=>{let r=new c.CatmullRomCurve3(e),n=new c.BufferGeometry;e=r.getSpacedPoints(100),n.setFromPoints(e),e=new c.LineBasicMaterial({color:26214});let i=new c.Line(n,e);return i.visible=t,{line:i,curve:r}},da=e=>{let t=0;const r=[],n={},i={0:"x",1:"y",2:"z"};return e.map((e=>{var o,a,s;3===t&&(t=0,({x:o,y:a,z:s}=n),r.push(new c.Vector3(o,a,s))),n[i[t]]=e,t++})),r},ma=e=>{var{pointArray:e,material:t,lineWidth:r,colorArray:n}=e;const i=new go,o=(i.setPositions(e),t||new Wi({transparent:!0,side:c.DoubleSide,linewidth:r||5,vertexColors:!0})),a=(i.setColors(n||[1,1,1]),o.resolution.set(window.innerWidth,window.innerHeight),new So(i,o));return a.name="gw",a.computeLineDistances(),a},va=(()=>{const e=(e,t,r)=>{e.matrixAutoUpdate=t,r&&(r(),t&&(e.matrixAutoUpdate=!t))};return(t,r,n)=>{if(0===t.children.length)return e(t,r,n);const i=[];t.traverse((e=>i.push(e))),i.map((t=>e(t,r,n)))}})(),ya=e=>3.1415926*e/180,ga=e=>e.toString().replace(/(\[object )([a-zA-Z]+)(])/,"$2"),ba=(e,t)=>((0,Xe.js)(e,((r,n)=>{let i=t[r];void 0!==i&&("Object"===ga(n)&&"Object"===ga(i)&&(i=ba(n,i)),e[r]=i)})),e);class xa{constructor(e){this.alt=!1,this.ctrl=!1,this.shift=!1,this.eventsMap={down:{},up:{}},this.allFn={s_saveScene:()=>function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.events.runScene.optionsEx.log("正在保存","base","info"),yield this.events.runScene.optionsEx.cb.scene.saveNet.cb("")})),d_exporter_Gltf:()=>{this.events.runScene.exporter.gltf.scene()},alt_selectDom:()=>{console.log("多选dom")},r_runScript:()=>{console.log("运行脚本")},d_copyModel:()=>{console.log("复制模型")},g_createGroup:()=>{console.log("生成组")},meta_showMateriallLibrary:()=>{console.log("弹出材质库窗口")},f_focusModel:()=>{const e=this.events.runScene.modelEx.select;if(e){const{scene:r,camera:n,renderer:i,controls:o}=this.events.runScene.assetsEx.get(),a=new c.Vector3,s=new c.Vector3;if("Mesh"===e.type||"Group"===e.type||"Object3D"===e.type){const e=this.events.runScene.helperEx.boxHelper;if(e.update(),!e||!e.object)return;var t=i.domElement.getBoundingClientRect();let r=t.width/t.height;const o=new c.Vector3;t=e.geometry.attributes.position.array,o.set(Math.abs(t[0]-t[3]),Math.abs(t[1]-t[7]),Math.abs(t[2]-t[14])),s.x=.5*(t[0]+t[3]),s.y=.5*(t[1]+t[7]),s.z=.5*(t[2]+t[14]);let l=new c.Vector3;l.subVectors(n.position,s),l.projectOnPlane(new c.Vector3(0,1,0)),l.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*n.fov*Math.PI/180),t=o.length()/r/t,a.addVectors(s,l.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new c.Vector3,e.getWorldPosition(t),s.set(t.x,t.y,t.z);let i=new c.Vector3;i.subVectors(n.position,s),i.projectOnPlane(new c.Vector3(0,1,0)),i.normalize(),a.addVectors(s,i.multiplyScalar(3))}_o({positionX:n.position.x,positionY:n.position.y,positionZ:n.position.z,targetX:o.target.x,targetY:o.target.y,targetZ:o.target.z},{positionX:a.x,positionY:a.y,positionZ:a.z,targetX:s.x,targetY:s.y,targetZ:s.z},.5,(e=>{n.position.set(e.positionX,e.positionY,e.positionZ),n.lookAt(e.targetX,e.targetY,e.targetZ),o.target.set(e.targetX,e.targetY,e.targetZ),o.update()}))}},z_undo:e=>{this.events.runScene.undoEx.undo()},y_redo:e=>{this.events.runScene.undoEx.redo()}},this.events=e}bindEvent(e,t,r){if(void 0!==this.eventsMap[e][t])throw SyntaxError("该函数名已存在");this.eventsMap[e][t]=r}init(e){"running"!==this.events.runScene.optionsEx.options.mode&&(document.addEventListener("keydown",this.keyDown.bind(this)),document.addEventListener("keyup",this.keyUp.bind(this)))}keyDown(e){const t=e.key.toLowerCase();switch((0,Xe.js)(this.eventsMap.down,((r,n)=>{n(t,e)})),t){case"s":this.ctrl&&(e.preventDefault(),this.allFn.s_saveScene());break;case"d":if(this.ctrl){e.preventDefault();var r=this.events.runScene.modelEx.select;if(!r)return;this.events.runScene.modelEx.selectNull();var n=this.events.runScene.modelEx.clone(r);if(!n)return;this.events.runScene.modelEx.add(n,r.parent,{isClone:!0})}break;case"alt":this.ctrl&&(e.preventDefault(),this.allFn.alt_selectDom()),this.alt=!0;break;case"control":case"ctrl":this.ctrl=!0;break;case"shift":this.shift=!0;break;case"w":e.preventDefault(),e.stopPropagation(),this.events.runScene.helperEx.transContro.changeMode("position");break;case"e":this.events.runScene.helperEx.transContro.changeMode("rotation");break;case"r":if(this.events.runScene.helperEx.transContro.changeMode("scale"),!this.ctrl)return;e.preventDefault(),this.allFn.r_runScript();break;case"g":this.events.runScene.optionsEx.cb.events.key.g.cb({event:e,eventKey:this});break;case"f":this.allFn.f_focusModel();break;case"delete":console.log("删除"),this.events.runScene.helperEx.unfocus(),n=this.events.runScene.multipSelector.getSelectedList("value"),this.events.runScene.sceneEx.remove(this.events.runScene.modelEx.select||n),n&&this.events.runScene.multipSelector.delete();break;case"z":if(!this.ctrl)return;this.allFn.z_undo(e),console.log("撤销功能~~~~");break;case"y":if(!this.ctrl)return;this.allFn.y_redo(e),console.log("向前功能~~~~")}}keyUp(e){const t=e.key.toLowerCase();switch((0,Xe.js)(this.eventsMap.up,((r,n)=>{n(t,e)})),t){case"meta":if(!this.ctrl)return;this.allFn.meta_showMateriallLibrary();break;case"s":if(this.ctrl)break;return;case"alt":this.alt=!1;break;case"control":case"ctrl":this.ctrl=!1;break;case"shift":this.shift=!1}}}class wa{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.down=e=>{(0,Xe.js)(this.fnMap.local.down,((t,r)=>{r(e)})),this.downPosition={x:e.offsetX,y:e.offsetY}},this.up=e=>{var t,r,n,i;2===e.button||null!=(t=this.events.runScene.helperEx.transContro)&&t.isDraggingChange||((0,Xe.js)(this.fnMap.local.up,((t,r)=>{r(e)})),t=e.offsetX,r=e.offsetY,({x:n,y:i}=this.downPosition),t===n&&r===i&&this.trigger(e))},this.events=e}bindEvent(e){var{type:e,name:t,fn:r,local:n}=e;this.fnMap[n][e][t]=r}init(e){e.addEventListener("pointerdown",this.down.bind(this)),e.addEventListener("pointerup",this.up.bind(this)),window.addEventListener("pointerdown",(e=>{this.events.runScene.optionsEx.cb.events.pointer.down.cb(e)})),window.addEventListener("pointerup",(e=>{this.events.runScene.optionsEx.cb.events.pointer.up.cb(e)}))}getTriggerModels(e){const t=new c.Raycaster,r=new c.Vector2,{engineDom:n,camera:i,scene:o}=this.events.runScene.assetsEx.get();return r.x=e.offsetX/n.clientWidth*2-1,r.y=-e.offsetY/n.clientHeight*2+1,t.setFromCamera(r,i),e=o.children.filter((e=>{if((!this.events.runScene.helperEx.isHelper(e)||e.userData.id)&&!e.userData.unClick)return e})),t.intersectObjects(e,!0).map((e=>e.object))}removeHideModel(e){return e.find((e=>this.events.runScene.modelEx.deepIsVisible(e)))}trigger(e){let t=this.removeHideModel(this.getTriggerModels(e));if(!t)return this.events.runScene.multipSelector.setEmpty(),void this.events.runScene.modelEx.selectNull();if(this.events.runScene.helperEx.isHelper(t)&&(e=this.events.runScene.uniqueEx.getId(t),t=this.events.runScene.uniqueEx.model.get(e)),!this.enableUp){if(t===this.events.runScene.helperEx.transContro.multipObj)return;this.enableUp=!0}if(console.log("鼠标按下选中的模型:",t),this.events.key.ctrl)return this.enableUp=!1,this.events.runScene.multipSelector.add(t);if(this.events.key.shift){const e=t.parent;return e?void e.children.map((e=>{this.events.runScene.multipSelector.add(e)})):void 0}this.events.runScene.modelEx.setSelectByModel(t),this.events.runScene.lightEx.isLight(t)&&this.events.runScene.lightEx.setSelect(t)}}o=a(356);var Sa=a.n(o),Ta=a(298);const _a=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"];class Ma{static create(){return new c.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],n=e[t];if(r instanceof c.Color){if(r.getHexString()!==n.getHexString())return!1}else if("object"==typeof r){if(n.x!==r.x)return!1}else if(n!==r)return!1}for(const t of gi)if(e[t])return!1;return!0}}Ma.defVal={color:new c.Color(16777215),emissive:new c.Color(0),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new c.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class Ea{constructor(e){this.undos=[],this.redos=[],this.dataMap={history:[],index:0},this.runScene=e}undo(){if(0!==this.undos.length){const e=this.removeUndos(-1)[0];e&&(e instanceof Array?e.reverse().map((e=>e.undo())):e.undo(),this.redos.push(e))}}addUndos(e){var t;return this.undos.push(e),t=this.dataMap.history.push(e),this.dataMap.index=this.undos.length-1,this.runScene.optionsEx.cb.undo.addUndos.cb(e,this.undos),t}removeUndos(e){var t;return this.undos.splice(e),t=this.dataMap.history.splice(e),this.dataMap.index=this.undos.length-1,this.runScene.optionsEx.cb.undo.removeUndos.cb(e),t}undoByIndex(e){e>this.dataMap.index?this.undos.slice(this.dataMap.index+1,e+1).map((e=>{e instanceof Array?e.map((e=>e.redo())):e.redo()})):e<this.dataMap.index&&this.undos.slice(e+1,this.dataMap.index+1).reverse().map((e=>{e instanceof Array?e.map((e=>e.undo())):e.undo()})),this.dataMap.index=e,this.runScene.optionsEx.cb.undo.undoByIndex.cb(e)}addUndo(e){this.dataMap.index!==this.undos.length&&this.removeUndos(this.dataMap.index+1),this.addUndos(e)}addRedo(e){this.redos.push(e)}redo(){if(0!==this.redos.length){const e=this.redos.splice(-1)[0];e&&(e instanceof Array?e.reverse().map((e=>e.redo())):e.redo(),this.addUndo(e))}}reset(){this.undos=[],this.redos=[],this.dataMap.history=[],this.dataMap.index=0,this.runScene.optionsEx.cb.undo.reset.cb("")}}function Pa(e){if("object"!=typeof e)return e;if(null===e)return null;if(e){var t,r,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=Pa(e[t]),n[t]=r);return n}}const Oa=class extends bi{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,Xe.qR)(e.target,this.typeList)[(0,Ta.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,Xe.qR)(this.target,this.typeList);t[(0,Ta.lastArrayEle)(this.typeList)]=e,this.cb&&this.cb(t),"shadow"!==this.typeList[0]&&this.typeList[1]}undo(){this._execute(this.old)}redo(){this._execute(this.new)}};class Ra{constructor(e){this.tools={type:"FakeInterior",getTextures(e){const t=[];return e.uniforms.ceilingTex.value&&t.push({type:"ceilingTex",texture:e.uniforms.ceilingTex.value}),e.uniforms.floorTex.value&&t.push({type:"floorTex",texture:e.uniforms.floorTex.value}),e.uniforms.sideWallTex.value&&t.push({type:"sideWallTex",texture:e.uniforms.sideWallTex.value}),e.uniforms.backWallTex.value&&t.push({type:"backWallTex",texture:e.uniforms.backWallTex.value}),t},parseData:e=>{const{textures:t,normal:r}=e,n=new c.ShaderMaterial({uniforms:Pa(ka.uniforms),vertexShader:ka.vertexShader,fragmentShader:ka.fragmentShader});return t.forEach((e=>{"ceilingTex"===e.type?n.uniforms.ceilingTex.value=e.texture||null:"floorTex"===e.type?n.uniforms.floorTex.value=e.texture||null:"sideWallTex"===e.type?n.uniforms.sideWallTex.value=e.texture||null:"backWallTex"===e.type&&(n.uniforms.backWallTex.value=e.texture||null)})),Object.keys(r.uniforms).filter((e=>!Ra.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];n.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new c.Vector4(t.x,t.y,t.z,t.w):t})),n.userData.tools=this.tools,n},toNormal:e=>{const t=Ha(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),{}),n=e.uniforms,i=ka.uniforms;return Object.keys(n).filter((e=>!Ra.TextureNames.includes(e))).map((e=>{var t,o,a,s,l,u,h=n[e].value,p=i[e].value;h instanceof c.Vector4?(({x:t,y:o,z:a}=h),({x:s,y:l,z:u}=p),t===s&&o===l&&a===u||(r[e]=h)):h!==p&&(r[e]=h)})),t.userData.normal.uniforms=r,t},clone:function(e,t){return e}},this.runScene=e}create(){const e=new c.ShaderMaterial({uniforms:Pa(ka.uniforms),vertexShader:ka.vertexShader,fragmentShader:ka.fragmentShader});return e.userData.tools=this.tools,e}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Oa({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}Ra.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"];const ka={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new c.Vector4(1,1,1,1)},sideWallTex:{value:null},backWallTex:{value:null},floorTex:{value:null},ceilingTex:{value:null},sideWallTexTiling:{value:.097},backWallTexTiling:{value:.097},floorTexTiling:{value:.15},ceilingTexTiling:{value:.15},roomTile:{value:.3},roomsXYZPropsW:{value:new c.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new c.Vector4(4.7,2,-11,-3)}},vertexShader:"\n varying vec2 vUv;\n varying vec3 vPos;\n varying mat4 vModelMatrix;\n \n void main() {\n vUv = uv;\n vPos = position;\n vModelMatrix = modelMatrix;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float roomIntensity;\n uniform vec4 roomColorTint;\n \n uniform sampler2D sideWallTex;\n uniform sampler2D backWallTex;\n uniform sampler2D floorTex;\n uniform sampler2D ceilingTex;\n \n uniform float sideWallTexTiling;\n uniform float backWallTexTiling;\n uniform float floorTexTiling;\n uniform float ceilingTexTiling;\n \n uniform float roomTile;\n uniform vec4 roomsXYZPropsW;\n uniform vec4 positionOffsetRoomsXYZPropsW;\n \n varying vec2 vUv;\n varying vec3 vPos;\n varying mat4 vModelMatrix;\n \n void main() {\n vec4 interpVertexPos = vec4(vPos.xyz, vPos.z);\n // 将相机世界空间坐标转换为对象空间坐标\n vec4 cameraObjectPos = inverse(vModelMatrix) * vec4(cameraPosition, 1.0);\n vec4 transCameraPos = vec4(cameraObjectPos.xyz, cameraObjectPos.z);\n \n vec4 temp1 = (interpVertexPos - positionOffsetRoomsXYZPropsW);\n vec4 temp2 = ((roomsXYZPropsW + vec4(-1E-05, -1E-05, -1E-05, -1E-05)) * roomTile);\n vec4 V2 = transCameraPos - positionOffsetRoomsXYZPropsW;\n vec4 V1 = temp1 - V2;\n vec4 middleman = ((floor(temp2 * temp1) + step(vec4(0, 0, 0, 0), V1)) / temp2 - V2) / V1;\n \n // Side Walls\n vec2 sideWallUv = (middleman.x * V1 + V2).zy * sideWallTexTiling;\n vec4 sideWallColor = texture2D(sideWallTex, sideWallUv);\n \n // Back Wall\n vec2 backWallUv = (middleman.z * V1 + V2).xy * backWallTexTiling;\n vec4 backWallColor = texture2D(backWallTex, backWallUv);\n \n // Floor Ceiling\n vec2 floorUv = ((middleman.y * V1) + V2).xz * floorTexTiling;\n vec2 ceilingUv = ((middleman.y * V1) + V2).xz * ceilingTexTiling;\n vec4 floorColor = texture2D(floorTex, floorUv);\n vec4 ceilingColor = texture2D(ceilingTex, ceilingUv);\n vec4 cfColor = mix(floorColor, ceilingColor, step(0.0, V1.y));\n \n // Mix\n float compareXZ = 0.0;\n float stepXZ = step(middleman.z, middleman.x);\n if(stepXZ <= 0.0)\n compareXZ = middleman.x;\n else\n compareXZ = middleman.z;\n \n vec4 wallColor = vec4(0);\n if(stepXZ <= 0.0)\n wallColor = sideWallColor;\n else\n wallColor = backWallColor;\n \n vec4 finalColor = vec4(0);\n if(middleman.y <= compareXZ)\n finalColor = cfColor;\n else\n finalColor = wallColor;\n \n // Tint Room\n vec4 tintColor = roomColorTint * finalColor * roomIntensity;\n \n gl_FragColor = tintColor;\n }\n "},Aa={uniforms:{tDiffuse:new c.Uniform(null),h:new c.Uniform(1/512)},vertexShader:"\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\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 sum = vec4( 0.0 );\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\t\n\t\t\tgl_FragColor = sum;\n\t\t}"},Ca={uniforms:{tDiffuse:new c.Uniform(null),v:new c.Uniform(1/512)},vertexShader:"\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\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 sum = vec4( 0.0 );\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\t\t\t\n\t\t\tgl_FragColor = sum;\n\t\t}"};new c.Uniform(null),new c.Uniform(null),new c.Uniform(0),new c.Uniform(0),new c.Uniform(0),new c.Uniform(new c.Vector2),new c.Uniform(.1),new c.Uniform(1e3);class La{constructor(e){this.materials={},this.render=()=>{(0,Xe.js)(this.materials,((e,t)=>{const{model:r,material:n}=t;n.update(r)}))},this.tools={type:"Reflector",getTextures:e=>Xa(e),parseData:e=>{const{textures:t,normal:r,models:n,material:i}=e,o=Ga(i,new Da(void 0,void 0,this.runScene));return o.name=i.name,t.forEach((e=>{o[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!La.TextureNames.includes(e))).map((e=>{o[e]=r.uniforms[e]})),o.setRTSize(o.resolution),o.setBlurPass(o.blurSize),o.insertReflectorShader(),o.userData.tools=this.tools,this.bindData({model:n[0],material:o}),o},toNormal:e=>{const t=Ga(e,Ha()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),n=Ia.uniforms;return Object.keys(n).filter((e=>!La.TextureNames.includes(e))).map((t=>{var i=e[t],o=n[t].value;"mirror"===t||"mixBlur"===t||"mixStrength"===t||"mixContrast"===t?i.value!==o&&(r[t]=i):i!==o&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>this.create(t)},this.runScene=e,this.init()}init(){this.runScene.optionsEx.cb.render.add("Reflector-render",this.render),this.runScene.optionsEx.cb.model.add.add("",(({model:e})=>{var t;e.material&&"Reflector"===(null==(t=null==(t=e.material.userData)?void 0:t.tools)?void 0:t.type)&&(t=e.material,this.materials[t.userData.id]||(this.materials[t.userData.id]={model:e,material:t}))})),this.runScene.optionsEx.cb.model.remove.add("",(({model:e})=>{var t;e.material&&"Reflector"===(null==(t=null==(t=e.material.userData)?void 0:t.tools)?void 0:t.type)&&(t=e.material,delete this.materials[t.userData.id])}))}bindData(e){const t=e.material;var r=(0,l.getId)();t.userData.id=r,this.materials[r]=e}create(e){const t=new Da(void 0,void 0,this.runScene);return t.insertReflectorShader(),t.userData.tools=this.tools,(e=e||this.runScene.modelEx.select)&&(t.name=e.name),this.bindData({model:e,material:t}),t}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Oa({target:e,typeList:[...t],newVal:r}).execute())}dispose(){this.materials={}}}La.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"];class Da extends c.MeshStandardMaterial{constructor(e,t,r){e?super(e):(super(),this.opacity=Ia.uniforms.opacity.value,this.transparent=Ia.uniforms.transparent.value,this.roughness=Ia.uniforms.roughness.value,this.metalness=Ia.uniforms.metalness.value),this.runScene=r,t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new c.Uniform(t.mirror),this.mixBlur=new c.Uniform(t.mixBlur),this.mixStrength=new c.Uniform(t.mixStrength),this.mixContrast=new c.Uniform(t.mixContrast)):(this.resolution=Ia.uniforms.resolution.value,this.blurSize=Ia.uniforms.blurSize.value,this.mirror=new c.Uniform(Ia.uniforms.mirror.value),this.mixBlur=new c.Uniform(Ia.uniforms.mixBlur.value),this.mixStrength=new c.Uniform(Ia.uniforms.mixStrength.value),this.mixContrast=new c.Uniform(Ia.uniforms.mixContrast.value)),this.textureMatrix=new c.Uniform(new c.Matrix4),this.reflectorWorldPosition=new c.Vector3,this.cameraWorldPosition=new c.Vector3,this.rotationMatrix=new c.Matrix4,this.normal=new c.Vector3,this.view=new c.Vector3,this.lookAtPosition=new c.Vector3,this.target=new c.Vector3,this.tempQuaternion=new c.Vector4,this.virtualCamera=new c.PerspectiveCamera,this.reflectorPlane=new c.Plane,this.clipPlane=new c.Vector4,e={minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType,encoding:this.runScene.assetsEx.get().renderer.outputEncoding},this.glRT1=new c.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new c.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new c.Uniform(this.glRT1.texture),this.tDiffuseBlur=new c.Uniform(this.glRT2.texture),this.hBlurPass=new ee(Aa),this.hBlurPass.uniforms.h.value=1/this.blurSize,this.hBlurPass.clear=!1,this.hBlurPass.renderToScreen=!1,this.hBlurPass.enabled=0<this.blurSize,this.hBlurPass.material.depthWrite=!1,this.vBlurPass=new ee(Ca),this.vBlurPass.uniforms.v.value=1/this.blurSize,this.vBlurPass.clear=!1,this.vBlurPass.renderToScreen=!1,this.vBlurPass.enabled=0<this.blurSize,this.vBlurPass.material.depthWrite=!1}insertReflectorShader(){this.onBeforeCompile=e=>{var t;null!=(t=e.defines)&&t.USE_UV||(e.defines.USE_UV=""),null!=(t=e.defines)&&t.USE_BLUR||(e.defines.USE_BLUR=""),e.uniforms.tDiffuse=this.tDiffuse,e.uniforms.tDiffuseBlur=this.tDiffuseBlur,e.uniforms.textureMatrix=this.textureMatrix,e.uniforms.mirror=this.mirror,e.uniforms.mixBlur=this.mixBlur,e.uniforms.mixStrength=this.mixStrength,e.uniforms.mixContrast=this.mixContrast,e.vertexShader=Ia.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",Ia.vertexShader),e.fragmentShader=Ia.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",Ia.fragmentShader)}}setRTSize(e){this.glRT1.setSize(e,e),this.glRT2.setSize(e,e),this.hBlurPass.setSize(e,e),this.vBlurPass.setSize(e,e)}setBlurPass(e){this.hBlurPass.enabled=0<e,this.hBlurPass.enabled&&(this.hBlurPass.uniforms.h.value=1/e),this.vBlurPass.enabled=0<e,this.vBlurPass.enabled&&(this.vBlurPass.uniforms.v.value=1/e)}copy(e){return super.copy(e),this.resolution=e.resolution,this.blurSize=e.blurSize,this.mirror.value=e.mirror.value,this.mixBlur.value=e.mixBlur.value,this.mixStrength.value=e.mixStrength.value,this.mixContrast.value=e.mixContrast.value,this}swapBuffers(){var e=this.glRT1;this.glRT1=this.glRT2,this.glRT2=e}beforeRender(e){if(this.reflectorWorldPosition.setFromMatrixPosition(e.matrixWorld),this.cameraWorldPosition.setFromMatrixPosition(this.runScene.assetsEx.get().camera.matrixWorld),this.rotationMatrix.extractRotation(e.matrixWorld),this.normal.set(0,0,1),this.normal.applyMatrix4(this.rotationMatrix),this.reflectorWorldPosition.addScaledVector(this.normal,0),this.view.subVectors(this.reflectorWorldPosition,this.cameraWorldPosition),!(0<this.view.dot(this.normal))){this.view.reflect(this.normal).negate(),this.view.add(this.reflectorWorldPosition),this.rotationMatrix.extractRotation(this.runScene.assetsEx.get().camera.matrixWorld),this.lookAtPosition.set(0,0,-1),this.lookAtPosition.applyMatrix4(this.rotationMatrix),this.lookAtPosition.add(this.cameraWorldPosition),this.target.subVectors(this.reflectorWorldPosition,this.lookAtPosition),this.target.reflect(this.normal).negate(),this.target.add(this.reflectorWorldPosition),this.virtualCamera.position.copy(this.view),this.virtualCamera.up.set(0,1,0),this.virtualCamera.up.applyMatrix4(this.rotationMatrix),this.virtualCamera.up.reflect(this.normal),this.virtualCamera.lookAt(this.target),this.virtualCamera.far=this.runScene.assetsEx.get().camera.far,this.virtualCamera.updateMatrixWorld(),this.virtualCamera.projectionMatrix.copy(this.runScene.assetsEx.get().camera.projectionMatrix),this.textureMatrix.value.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.value.multiply(this.virtualCamera.projectionMatrix),this.textureMatrix.value.multiply(this.virtualCamera.matrixWorldInverse),this.textureMatrix.value.multiply(e.matrixWorld),this.reflectorPlane.setFromNormalAndCoplanarPoint(this.normal,this.reflectorWorldPosition),this.reflectorPlane.applyMatrix4(this.virtualCamera.matrixWorldInverse),this.clipPlane.set(this.reflectorPlane.normal.x,this.reflectorPlane.normal.y,this.reflectorPlane.normal.z,this.reflectorPlane.constant);const t=this.virtualCamera.projectionMatrix;this.tempQuaternion.x=(Math.sign(this.clipPlane.x)+t.elements[8])/t.elements[0],this.tempQuaternion.y=(Math.sign(this.clipPlane.y)+t.elements[9])/t.elements[5],this.tempQuaternion.z=-1,this.tempQuaternion.w=(1+t.elements[10])/t.elements[14],this.clipPlane.multiplyScalar(2/this.clipPlane.dot(this.tempQuaternion)),t.elements[2]=this.clipPlane.x,t.elements[6]=this.clipPlane.y,t.elements[10]=this.clipPlane.z+1,t.elements[14]=this.clipPlane.w}}update(e){e&&e.visible&&(this.beforeRender(e),e.visible=!1,this.runScene.assetsEx.get().renderer.setRenderTarget(this.glRT1),this.runScene.assetsEx.get().renderer.clear(),this.runScene.assetsEx.get().renderer.render(this.runScene.assetsEx.get().scene,this.virtualCamera),this.hBlurPass&&this.hBlurPass.enabled&&(this.hBlurPass.render(this.runScene.assetsEx.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),this.vBlurPass&&this.vBlurPass.enabled&&(this.vBlurPass.render(this.runScene.assetsEx.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),e.visible=!0,this.runScene.assetsEx.get().renderer.setRenderTarget(null))}}const Ia={uniforms:{opacity:new c.Uniform(1),transparent:new c.Uniform(!1),roughness:new c.Uniform(1),metalness:new c.Uniform(.6),resolution:new c.Uniform(1024),blurSize:new c.Uniform(1024),mirror:new c.Uniform(0),mixBlur:new c.Uniform(10),mixStrength:new c.Uniform(2),mixContrast:new c.Uniform(1)},vertexParas:"\n uniform mat4 textureMatrix;\n varying vec4 my_vUv;\n ",vertexShader:"\n #include <project_vertex>\n my_vUv = textureMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n ",fragmentParas:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDiffuseBlur;\n uniform sampler2D tDepth;\n uniform sampler2D distortionMap;\n uniform float distortion;\n uniform float mirror;\n uniform float mixBlur;\n uniform float mixStrength;\n uniform float mixContrast;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec4 my_vUv;\n ",fragmentShader:"\n #include <emissivemap_fragment>\n float distortionFactor = 0.0;\n #ifdef USE_DISTORTION\n distortionFactor = texture2D(distortionMap, vUv).r * distortion;\n #endif\n \n vec4 new_vUv = my_vUv;\n new_vUv.x += distortionFactor;\n new_vUv.y += distortionFactor;\n \n vec4 base = texture2DProj(tDiffuse, new_vUv);\n vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);\n \n vec4 merge = base;\n \n #ifdef USE_NORMALMAP\n vec2 normal_uv = vec2(0.0);\n vec4 normalColor = texture2D(normalMap, vUv * normalScale);\n vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );\n vec3 coord = new_vUv.xyz / new_vUv.w;\n normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;\n vec4 base_normal = texture2D(tDiffuse, normal_uv);\n vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);\n merge = base_normal;\n blur = blur_normal;\n #endif\n \n float blurFactor = 0.0;\n float depthFactor = 0.0001;\n \n #ifdef USE_DEPTH\n vec4 depth = texture2DProj(tDepth, new_vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0001, min(1.0, depthFactor));\n #ifdef USE_BLUR\n blur = blur * min(1.0, depthFactor + depthToBlurRatioBias);\n merge = merge * min(1.0, depthFactor + 0.5);\n #else\n merge = merge * depthFactor;\n #endif\n #endif\n \n float reflectorRoughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv );\n reflectorRoughnessFactor *= reflectorTexelRoughness.g;\n #endif\n \n #ifdef USE_BLUR\n blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor);\n merge = mix(merge, blur, blurFactor);\n #endif\n \n vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0);\n newMerge.r = (merge.r - 0.5) * mixContrast + 0.5;\n newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;\n newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;\n \n diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);\n "};class ja{constructor(e){this.tools={type:"Fresnel",getTextures(e){const t=[];return e.envMap&&t.push({type:"envMap",texture:e.envMap}),t},parseData:e=>{const{textures:t,normal:r,material:n}=e,i=Ga(n,new Ua(void 0,void 0,this.runScene));return i.name=n.name,t.forEach((e=>{i[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!ja.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.insertFresnelShader(),i.userData.tools=this.tools,i},toNormal:e=>{const t=Ga(e,Ha()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),n=Ba.uniforms;return Object.keys(n).filter((e=>!ja.TextureNames.includes(e))).map((t=>{var i=e[t],o=n[t].value;"fresnelBias"===t||"fresnelScale"===t||"fresnelPower"===t?i.value!==o&&(r[t]=i):i!==o&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>this.create(t)},this.runScene=e}create(e){const t=new Ua(void 0,void 0,this.runScene);return t.insertFresnelShader(),t.userData.tools=this.tools,(e=e||this.runScene.modelEx.select)&&(t.name=e.name),t}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Oa({target:e,typeList:[...t],newVal:r}).execute())}}ja.TextureNames=["envMap"];class Ua extends c.MeshPhysicalMaterial{constructor(e,t,r){if(e?super(e):(super(),this.emissive=new c.Color(65535),this.envMap=null,this.metalness=0,this.roughness=0,this.ior=1.5,this.transmission=1,this.opacity=1,this.transparent=!0,this.thickness=0),this.runScene=r,t?(this.fresnelBias=new c.Uniform(t.fresnelBias),this.fresnelScale=new c.Uniform(t.fresnelScale),this.fresnelPower=new c.Uniform(t.fresnelPower)):(this.fresnelBias=new c.Uniform(Ba.uniforms.fresnelBias.value),this.fresnelScale=new c.Uniform(Ba.uniforms.fresnelScale.value),this.fresnelPower=new c.Uniform(Ba.uniforms.fresnelPower.value)),!this.cubeCamera){const e=new c.WebGLCubeRenderTarget(2048);e.texture.mapping=c.CubeRefractionMapping,this.cubeCamera=new c.CubeCamera(.1,1e5,e),this.runScene.assetsEx.scene.add(this.cubeCamera),this.runScene.optionsEx.cb.render.add("Fresnel",(()=>{this.update()}))}}insertFresnelShader(){this.onBeforeCompile=e=>{e.uniforms.fresnelBias=this.fresnelBias,e.uniforms.fresnelScale=this.fresnelScale,e.uniforms.fresnelPower=this.fresnelPower,e.vertexShader=e.vertexShader.replace(/varying vec3 vWorldPosition;/g,Ba.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,Ba.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,Ba.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,Ba.fragmentShaderEmissive)}}update(){this.cubeCamera&&(this.cubeCamera.position.copy(this.runScene.assetsEx.camera.position),this.cubeCamera.update(this.runScene.assetsEx.renderer,this.runScene.assetsEx.scene))}}const Ba={uniforms:{fresnelBias:new c.Uniform(0),fresnelScale:new c.Uniform(1),fresnelPower:new c.Uniform(3)},vertexParas:"\n varying vec3 vWorldPosition;\n varying vec3 vWorldNormal;\n ",vertexShader:"\n vWorldPosition = worldPosition.xyz;\n vWorldNormal = normalize(vec3(modelMatrix * vec4(normal, 0.0)));\n ",fragmentParas:"\n #include <transmission_pars_fragment>\n varying vec3 vWorldNormal;\n uniform float fresnelBias;\n uniform float fresnelScale;\n uniform float fresnelPower;\n ",fragmentShaderEmissive:"\n vec3 viewDir = normalize(cameraPosition - vWorldPosition);\n float fresnelNdot = dot(viewDir, vWorldNormal);\n float fresnelValue = fresnelBias + fresnelScale * pow(1.0 - fresnelNdot, fresnelPower);\n // fresnelValue = [0, 1], 0=center,1=edge\n \n vec3 totalEmissiveRadiance = emissive * fresnelValue;\n "},za=class extends bi{constructor(e){super(),this.type="修改属性",this.cb=e=>{};var{target:e,info:t,oldVal:r,newVal:n,runScene:i,cb:o,executeCb:a}=e;this.runScene=i,this.target=e,this.info=t,this.newVal=n,this.oldVal=r,o&&(this.cb=o),a&&(this.executeCb=a)}_execute(e){var{target:t,info:r}=this;if(this.executeCb)return this.executeCb({target:t,info:r,val:e});this.target[this.info]=e,"name"===this.info&&this.target.isObject3D?(t=this.runScene.uniqueEx.model.parseName(this.target),r=e,this.runScene.optionsEx.cb.model.changeName.cb({model:this.target,name:e=t||e,oldName:r})):"material"===this.info?this.runScene.uniqueEx.material.addModel(this.target,e,e===this.newVal?this.oldVal:this.newVal):"visible"===this.info&&this.runScene.optionsEx.cb.model.setVisible.cb({model:this.target,visible:e}),this.cb(this.target)}execute(){return this.redo(),this}undo(){this._execute(this.oldVal)}redo(){this._execute(this.newVal)}},Na={depthTest:!0,depthWrite:!0,alphaTest:0,side:0,displacementScale:1,vertexColors:!0,visible:!0,normalScale:{x:1,y:1},aoMapIntensity:1,lightMapIntensity:1,envMapIntensity:1},Fa=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];class Va{constructor(e){this.defMaterialMap={BaseMaterial:Ma,SpriteMaterial:Ya,FakeInterior:Ra,Reflector:La,Fresnel:ja},this.defMaterial=Ha(),this.addCb=e=>{this.runScene.optionsEx.cb.material.add.cb(e)},this.runScene=e,this.runScene.optionsEx.cb.unique.material.add.add("engine-material-add",(e=>{"SpriteMaterial"!==e.type&&this.addCb(e)})),this.defMaterialMap={BaseMaterial:Ma,SpriteMaterial:Ya,FakeInterior:new Ra(e),Reflector:new La(e),Fresnel:new ja(e)}}add(e,t,r){this.runScene.uniqueEx.material.add(e,t,r)}create(){var e=new c.MeshStandardMaterial;return this.add(e),e}clone(e){const t=e.clone();return t.userData.id=(0,l.getId)(),t}setNormal(e,t=!0){return e=new xi(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute(),t&&this.runScene.undoEx.addUndo(e),e}setTexture(e,t=!0){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{info:r,newVal:n}=e,n=(n instanceof File&&(e.newVal=yield this.runScene.textureEx.parse(n)),"envMap"===r&&Li(e.newVal),new xi(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute());return t&&this.runScene.undoEx.addUndo(n),e.newVal}))}resetMaterial(e,t,r=!0){var n;e&&t&&e.material&&(n=new za({target:e,runScene:this.runScene,info:"material",newVal:t,oldVal:e.material}).execute(),this.runScene.modelEx.select===e&&this.runScene.optionsEx.cb.setSelectMaterial.cb(t),r&&this.runScene.undoEx.addUndo(n))}getBase(e){const t=this.defMaterialMap[e];if(("SpriteMaterial"!==e||"Sprite"===(null==(e=this.runScene.modelEx.select)?void 0:e.type))&&t)return t.create()}toNromal(e){var t;const r=(null==(t=e.userData.tools)?void 0:t.toNormal(e))||e.clone();return r.userData=Object.assign(Object.assign({},r.userData),e.userData),r}setSelect(e){this.runScene.optionsEx.cb.setSelectMaterial.cb(e)}getDataByType(e,t){return this.defMaterialMap[e].tools.parseData(t)}dispose(){this.defMaterialMap.Reflector.dispose(),this.runScene.optionsEx.cb.material.dispose.cb("")}remove(e){}getDefNromals(e){var t;if(null!=(t=null==(t=e.userData)?void 0:t.tools)&&t.type)return{};const r={};return(0,Xe.js)(Na,((t,n)=>{const i=e[t];if("object"==typeof i)for(const e in i)if(i[e]!==n[e])return void(r[t]=i.clone());i!==n&&(r[t]=i)})),r}parseNromals(e,t){(0,Xe.js)(e,((e,r)=>{var n,i,o,a,s;void 0!==Na[e]&&("object"==typeof r?(({x:o,y:a,z:s}=r),null!=(i=null==(n=t[e])?void 0:n.set)&&i.call(n,o,a,s)):t[e]=r)}))}isBaseMaterial(e){return"MeshStandardMaterial"===e.type&&!e.userData.isTimeLineUsed&&Ma.isDefval(e)}}const Ha=()=>{const e=new c.MeshStandardMaterial;return e.userData.id=(0,l.getId)(),e},Ga=(e,t)=>(Fa.map((r=>{const n=e[r];"object"==typeof n&&(t[r]=n.clone()),t[r]=n})),t),Wa=e=>{e.dispose();const t=Xa(e);0!==t.length&&t.map((e=>{e=e.texture,Ei(e)}))},Xa=e=>{var t=e.userData.textures||gi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t},qa=e=>{var t;return(null==(t=e.userData.tools)?void 0:t.getTextures(e))||gi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture))};class Ya{static create(){const e=new c.SpriteMaterial;return e.userData.tools=this.tools,e}}Ya.modelTools={merge(e,t){t.position.copy(e.position),t.rotation.copy(e.rotation),t.scale.copy(e.scale),t.renderOrder=e.renderOrder,t.castShadow=e.castShadow,t.receiveShadow=e.receiveShadow,1===e.layers.mask?t.layers.set(0):t.layers.enable(1)},toNormal:e=>{const t=ts("Box");return t.userData.normal={type:"MySpriteMaterial"},Ya.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=ts("Sprite");return Ya.modelTools.merge(e,r),r.material=e.material,r}},Ya.tools={type:"SpriteMaterial",getTextures:function(e){return["map","alphaMap"].map((t=>{var r=e[t];if(r)return{type:t,texture:r}})).filter((e=>e))},parseData:function(e){const{textures:t,material:r}=e,n=Ga(r,Ya.create());return t.map((e=>{var{type:e,texture:t}=e;n[e]=t})),n},toNormal:e=>{const t=Ga(e,Ha());return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Ya.tools.type},textures:Ya.tools.getTextures(e)}),t},clone:function(e,t){return e}};class Za{constructor(e){this.addTree=!0,this.isClone=!1,this.cb=(e,t)=>{};var{model:e,parent:t,cb:r,addTree:n,isClone:i,runScene:o}=e;this.runScene=o,this.model=e,this.parent=t,!1===n&&(this.addTree=n),!0===i&&(this.isClone=i),r&&(this.cb=r)}remove(e){const{model:t,parent:r,addTree:n,runScene:i}=e;i.modelEx.select===t&&i.modelEx.selectNull(),r.remove(t),n&&i.uniqueEx.model.remove(t),n&&i.optionsEx.cb.model.remove.cb({model:t,parent:r}),this.cb(t,"remove"),i.uniqueEx.material.addModel(t,void 0,t.material)}add(e){const{model:t,parent:r,addTree:n,isClone:i,runScene:o}=e;r.add(t),n&&o.uniqueEx.model.add(t),n&&o.optionsEx.cb.model.add.cb({model:t,parent:r,isClone:i}),this.cb(t,"add"),o.uniqueEx.material.addModel(t,t.material)}}class Qa extends Za{constructor(e){super(e),this.type="添加模型"}_execute(e){return Promise.reject()}undo(){this.remove({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone,runScene:this.runScene})}redo(){this.add({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone,runScene:this.runScene})}execute(){return this.redo(),this}}const Ka=class extends bi{constructor(e){super(),this.type="修改父元素",this.runScene=e.runScene,this.oldParent=e.oldParent,this.newParent=e.newParent,this.target=e.target}execute(){return this.redo(),this}_execute(e){e.attach(this.target),this.runScene.optionsEx.cb.model.setParent.cb({model:this.target,parent:e})}undo(){this._execute(this.oldParent)}redo(){this._execute(this.newParent)}};class Ja extends Za{constructor(e){super(e),this.type="移除模型"}undo(){this.add({model:this.model,parent:this.parent,addTree:this.addTree,runScene:this.runScene})}redo(){this.remove({model:this.model,parent:this.parent,addTree:this.addTree,runScene:this.runScene})}_execute(e){return Promise.reject()}execute(){return this.redo(),this}}const $a=class extends bi{constructor(e){super(),this.type="三维矩阵修改";var{target:e,info:t,newV3:r,oldV3:n,runScene:i}=e;this.target=e,this.info=t,this.runScene=i,this.newV3=r,this.oldV3=n,this.target.uuid===(null==(e=this.runScene.modelEx.select)?void 0:e.uuid)&&(this.runScene.optionsEx.cb.model.setSelect.cb(null),this.runScene.optionsEx.cb.model.setSelect.cb(this.target))}_execute(e){this.target[this.info].copy(e),this.target.uuid===(null==(e=this.runScene.modelEx.select)?void 0:e.uuid)&&this.runScene.helperEx.focus(this.target)}execute(){return this.redo(),this}undo(){this._execute(this.oldV3)}redo(){this._execute(this.newV3)}};class es{constructor(e){this._selectModel=void 0,this.defNodeMap={castShadow:!1,receiveShadow:!1,renderOrder:0,visible:!0},this.deepIsVisible=e=>"Scene"===e.type||!!e.visible&&!!e.parent&&this.deepIsVisible(e.parent),this.runScene=e}get select(){return this._selectModel}set select(e){this.setSelectByModel(e)}add(e,t,r){var{addUndo:n,isClone:i,select:o}=$o({addUndo:!0,isClone:!1,select:!0},r);if(e instanceof Array)return e.map((e=>this.add(e,t,r)));i&&(this.runScene.uniqueEx.model.add(e,{hasReset:!0}),this.runScene.optionsEx.cb.model.clone.cb(e));var a=new Qa({model:e,parent:t||this.runScene.sceneEx.get(),isClone:i,runScene:this.runScene}).execute();!0===n&&this.runScene.undoEx.addUndo(a),o&&this.setSelectByModel(e,{isDomTreeActive:!1,isClone:i})}setSelectByModel(e,t){var r,{isDomTreeActive:t,isClone:n}=t||{};if(this.runScene.events.key.shift&&this._selectModel)return(r=this.getBeTweenChildByTwoModel(this._selectModel,e))?void this.runScene.multipSelector.add([...r,e],!0):void 0;if(this.runScene.events.key.ctrl&&!n)this.runScene.multipSelector.add(e);else{if(this.runScene.multipSelector.isEmpty()||this.runScene.multipSelector.setEmpty(),this._selectModel){if(this._selectModel===e)return void(this.runScene.helperEx.focusModelId||this.runScene.helperEx.focus(e));this.runScene.lightEx.setNull(this._selectModel),this.runScene.optionsEx.cb.model.unFocus.cb(this._selectModel)}e&&(e.isCamera||(this.runScene.helperEx.focus(e),this.runScene.lightEx.setSelect(e)),this.runScene.optionsEx.cb.model.focus.cb({model:e,status:!0,domActive:!t}),this.runScene.materialEx.setSelect(e.material),this.runScene.optionsEx.cb.model.setSelect.cb(e),this._selectModel=e)}}setSelectById(e){(e=this.runScene.uniqueEx.model.get(e))&&this.setSelectByModel(e)}remove(e,t=!0){if(e instanceof Array)return e.map((e=>this.remove(e)));e=new Ja({runScene:this.runScene,model:e,parent:e.parent||this.runScene.sceneEx.get()}).execute(),t&&this.runScene.undoEx.addUndo(e)}isNavieV3(e,t=0){var{x:e,y:r,z:n}=e;return e+r+n===t}isNavieV2(e,t=0){var{x:e,y:r}=e;return e===t&&r===t}isUnless(e){return!e.material&&this.isNavieV3(e.position)&&this.isNavieV3(e.rotation)&&this.isNavieV3(e.scale,3)&&0===e.children.length}isUnlessLevel(e){return this.isNavieV3(e.position)&&this.isNavieV3(e.rotation)&&this.isNavieV3(e.scale,3)&&1===e.children.length}create(){return Sa().model.getModelByType("Box")}clone(e){if(!this.runScene.lightEx.isLight(e)){let n=e.clone();n.userData.cloneId=e.userData.id;var t,r=null==e?void 0:e.material;return null!=(t=null==r?void 0:r.userData)&&t.tools&&(t=null==(t=r.userData.tools)?void 0:t.clone(r,n))&&t.uuid!==r.uuid&&(this.runScene.materialEx.resetMaterial(n,t,!0),this.runScene.materialEx.add(t,e,r)),this.runScene.uniqueEx.model.add(n,{reset:!0}),n}this.runScene.lightEx.clone(e)}getLevel(e,t=0){return e.parent&&"Scene"!==e.parent.type?this.getLevel(e.parent,++t):t}selectNull(){var e=this._selectModel;e&&(this.runScene.optionsEx.cb.model.unFocus.cb(e),this.runScene.materialEx.setSelect(null),this.runScene.lightEx.setNull(e)),this._selectModel=void 0,this.runScene.optionsEx.cb.model.setSelect.cb(null),this.runScene.helperEx.unfocus()}cloneV3(e){return e.clone()}setParent(e,t,r=!0){if(t=new Ka({oldParent:e.parent,newParent:t,target:e,runScene:this.runScene}).execute(),!r)return t;this.runScene.undoEx.addUndo(t)}setV3(e,t=!0,r=!0){var{model:e,info:n,newV3:i,oldV3:o}=e;const a=new $a({target:e,info:n,oldV3:o,newV3:i,runScene:this.runScene});r&&a.execute(),t&&this.runScene.undoEx.addUndo(a)}setNormal(e,t=!0){var{model:e,info:r,val:n}=e;e=new za({target:e,info:r,runScene:this.runScene,oldVal:e[r],newVal:n}).execute(),t&&this.runScene.undoEx.addUndo(e)}setMaterial(e,t,r=!0){var n=new za({target:e,info:"material",runScene:this.runScene,oldVal:e.material,newVal:t}).execute();this.select===e&&this.runScene.optionsEx.cb.setSelectMaterial.cb(t),e.material.needsUpdate=!0,r&&this.runScene.undoEx.addUndo(n)}addDef(e){this.add(ts(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new c.MeshBasicMaterial,t=new c.SphereGeometry(.7,150,150);return new c.Mesh(t,e)}getIndexByModel(e){var t;return e.parent?null==(t=e.parent)?void 0:t.children.findIndex((t=>t===e)):-1}getBeTweenChildByTwoModel(e,t){if(e.parent.uuid===t.parent.uuid){var r=this.getIndexByModel(e);if(t=this.getIndexByModel(t),-1!==r&&-1!==t){const n=Math.max(r,t),i=r===n?t:r;return e.parent.children.map(((e,t)=>t>i&&t<n&&e)).filter((e=>e))}}}setMultip(e){var{model:e,typeList:t,newVal:r}=e;this.runScene.undoEx.addUndo(new Oa({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const n=t||new c.Group,i=[];i.push(new Qa({model:n,runScene:this.runScene,parent:r||this.runScene.assetsEx.get().scene}).execute()),e instanceof Array?i.push(...e.map((e=>new Ka({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()))):i.push(new Ka({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()),r&&this.runScene.optionsEx.cb.model.setOpen.cb({isOpen:!0,model:r}),this.runScene.optionsEx.cb.model.setOpen.cb({isOpen:!0,model:n}),this.runScene.optionsEx.cb.model.setMainStatue.cb({status:!0,model:n}),this.runScene.undoEx.addUndo(i),this.setSelectByModel(n)}cleanGroup(e,t=!0){if(e instanceof Array){const t=(0,Ta.multiArrToArr)(e.map((e=>(this.runScene.optionsEx.cb.model.unFocus.cb(e),this.cleanGroup(e,!1)))).filter((e=>e)));return this.runScene.undoEx.addUndo(t),t}if(this.runScene.optionsEx.cb.model.unFocus.cb(e),0!==e.children.length){const r=[],n=e.children.map((e=>{if(e.parent.parent)return new Ka({target:e,oldParent:e.parent,newParent:e.parent.parent,runScene:this.runScene})})).filter((e=>e));return r.push(...n.map((e=>e.execute()))),r.push(new Ja({runScene:this.runScene,model:e,parent:e.parent}).execute()),t&&this.runScene.undoEx.addUndo(r),r}}hideOther(e){const t=e.uuid,r=0<e.children.length,n=this.runScene.sceneEx.getClearModels(),i=[];n.map((n=>{n.traverse((n=>{r?!1===Sa().model.deepFindParentByUuid(n,t)&&n.uuid!==e.uuid&&i.push(n):n.uuid!==e.uuid&&i.push(n)}))}));var o=i.map((e=>new za({target:e,info:"visible",newVal:!1,runScene:this.runScene,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(o),Sa().model.setParentVisible(e,!0)}showAll(){const e=this.runScene.sceneEx.getClearModels(),t=[];e.map((e=>{e.traverse((e=>{"materialHelper"!==e.name&&!1===e.visible&&t.push(e)}))}));var r=t.map((e=>new za({target:e,info:"visible",runScene:this.runScene,newVal:!0,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(r)}removeHide(){const e=this.runScene.sceneEx.getClearModels(),t=new Set,r=[];e.map((e=>{e.traverse((e=>{e.visible||t.add(e)}))})),t.forEach((e=>{r.push(new Ja({runScene:this.runScene,model:e,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(r)}_getModel(e){if(e=this.runScene.uniqueEx.model.nameMap[e])return this.runScene.uniqueEx.model.get(e)}getModel(e,t="array"){if(!(e instanceof Array))return this._getModel(e);if("array"===t)return e.map((e=>this._getModel(e)));if("map"===t){const t={};return e.map((e=>{t[e]=this.getModel(e)})),t}}getWorldLocal(e){this.runScene.assetsEx.scene.updateMatrixWorld(!0);var t=new c.Vector3;return e.getWorldPosition(t),t}getClickObj(e,t,r=!1){let n=new c.Raycaster,i=new c.Vector2,o=(i.x=e.offsetX/this.runScene.assetsEx.engineDom.clientWidth*2-1,i.y=-e.offsetY/this.runScene.assetsEx.engineDom.clientHeight*2+1,n.setFromCamera(i,this.runScene.assetsEx.camera),n.intersectObjects(t,!0)),a={intersects:null,obj:null};if(0===o.length)return a;if(r){if(0===(e=o.filter((e=>Sa().model.isVisible(e.object)))).length)return a;a={intersects:e,obj:e[0].object}}else a={intersects:o,obj:o[0].object};return a}getCamLocal(){var{x:e,y:t,z:r}=this.runScene.assetsEx.camera.position,{x:n,y:i,z:o}=this.runScene.assetsEx.controls.target;return{cx:e,cy:t,cz:r,tx:n,ty:i,tz:o}}camAnima(e,t,r=1,n,i){return _o(e,t,r,(e=>{i&&i(e),this.runScene.assetsEx.camera.position.set(e.cx,e.cy,e.cz),this.runScene.assetsEx.controls.target.set(e.tx,e.ty,e.tz),this.runScene.assetsEx.camera.lookAt(this.runScene.assetsEx.controls.target)}),(e=>{n&&n()}))}setGlow(e,t=!0){t=t?1:0,0==(e.userData.layers=t)?e.layers.set(0):e.layers.enable(1),this.runScene.optionsEx.cb.model.setLayers.cb({model:e,val:t})}}const ts=e=>{if(_a.includes(e)){const t=Sa().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=Ya.tools),t}throw TypeError("")},rs=(e,t)=>{t=(t||{}).remove;const{geomerty:r,material:n}=e;r&&(null!=r&&r.dispose(),delete e.geometry),n&&(Wa(e.material),e.material.dispose(),delete e.material),!1!==t&&e.parent&&e.parent.remove(e)},ns=(e,t)=>{var{material:r,geometry:n}=e;const i=new vi.InstancedMesh(n,r,t.length+1);return[e,...t].map(((e,t)=>{i.setMatrixAt(t,e.matrix)})),i};class is{constructor(){this.optionsConfigs={}}getParse(e){return this.optionsConfigs[e]}addOption(e){var t=e.type;if(this.optionsConfigs[t])throw TypeError("该配置项已被挂载");this.optionsConfigs[t]=e}getOptions(e){return Object.values(this.optionsConfigs).map((t=>{const{process:r,type:n}=t;return{type:n,data:r(e)}}))}}class os{constructor(e){this.JsonMaterialMap={},this.materialMap={},this.textureMap={},this.runScene=e}setMaterialMap(e){var{materialMap:e,textureMap:t}=e;this.materialMap=e,this.textureMap=t}parseMaterial(e){const{material:t,materialDef:r}=e;r.id=t.userData.id,this.parseNormal(t)}parseNormal(e){this.materialMap[e.userData.id]||(this.materialMap[e.userData.id]={normal:{},textures:{}}),this.materialMap[e.userData.id].normal=Object.assign(Object.assign({},this.materialMap[e.userData.id].normal),this.runScene.materialEx.getDefNromals(e))}setMaterialDef(e){const{type:t,data:r,normal:n}=e;n[t]=r}processTexture(e){const{texture:t,textureDef:r}=e;e=t.userData.notCompress;var{width:e,height:n}=(e&&(r.notCompress=!0),r.md5=t.userData.md5,r.id=t.userData.id,r.format=t.userData.format,Di(t));r.size={w:e,h:n}}done(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{textureMap:t,materialMap:r}=this;e.asset.ex=Object.assign(Object.assign({},e.asset.ex),{textureMap:t,materialMap:r})}))}}class as{constructor(e){this.runScene=e}init(){}done(e){var t=this.runScene.sceneEx.get();e.asset.ex=Object.assign(Object.assign({},e.asset.ex),{lights:this.getLights(),camera:this.getCamera(),sceneEx:this.getSceneEx(t),timeLine:this.runScene.timeLineEx.getSavedData(),controls:this.getControls(),options:this.runScene.exporter.gltf.options.getOptions(t)})}getSceneEx(e){const t=Object.assign({},e.userData.ex);return e.fog&&(t.fog=this.runScene.sceneEx.getFogJson(e.fog)),e.background instanceof c.Color&&(t.backgroundColor=e.background.getHexString()),t}getLights(){return this.runScene.lightEx.getLightsByScene().map((e=>{var t=e.type;return this.runScene.lightEx.lightExMap[t].toJSON(e)}))}getCamera(){return this.runScene.cameraEx.get().toJSON()}getControls(){return this.runScene.assetsEx.controls.target}}class ss{constructor(e,t){this.helperModels=[],this.runScene=t,this.type=e,this.material=new os(t),this.scene=new as(t)}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,Xe.js)(this.runScene.modelEx.defNodeMap,((e,n)=>{t[e]!==n&&(r[e]=t[e])})),t.material&&t.material.wireframe&&(t.material.wireframe=!1,r.wireframe=!0)}parseSprite(){}done(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){e.asset.ex||(e.asset.ex={type:this.type}),"scene"===this.type&&(yield this.scene.done(e)),yield this.material.done(e)}))}}var ls=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class us{constructor(e,t){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.modelType={Sprite:Ya},this.type=e,this.runScene=t}parse(e){return ls(this,void 0,void 0,(function*(){const t=new c.Group;return t.name="back-texture-ex",t.userData.isHelper=!0,e.add(t),"scene"===this.type&&this.parseScene(t),this.parseMaterial(e),yield Promise.all(this.materialMapToJson()),this.setMultipMaterial(t,Object.keys(this.textureMap)),this.json}))}parseScene(e){const t=this.runScene.sceneEx.get();if(t.background instanceof c.Texture||t.environment instanceof c.Texture){t.userData.ex={},this.runScene.bloom.glow.setUpdate(!1);const{background:r,environment:n}=t,i=(this.runScene.bloom.glow.setUpdate(!0),this.runScene.modelEx.create()),o=Ha();i.material=o,e.add(i),e=(0,l.getId)(),t.userData.ex.materialId=e,o.userData.id=e,this.materialMap[e]={material:o},r instanceof c.Texture&&(r.userData.notCompress=!0,303===(o.map=r).mapping&&(t.userData.ex.backgroundMapping=303)),n instanceof c.Texture&&(n.userData.notCompress=!0,o.envMap=n)}}_processMaterial(e){if(e.material&&e.material.userData){var t=this.runScene.materialEx.isBaseMaterial(e.material),r=this.materialMap[e.material.userData.id];return r?(r.normalMaterial&&(e.material=r.normalMaterial),void(null!=(r=r.models)&&r.push(e))):(r=t||this.runScene.optionsEx.exporterOptions.notMaterial?this.runScene.materialEx.defMaterial:this.runScene.materialEx.toNromal(e.material),e.material=r,this.materialMap[r.userData.id]={material:r,normalMaterial:r,models:[e]},r)}}compressLocal(e){var{x:t,y:r,z:n}=e.position;0===t&&0===r&&0===n||(e.position.set(0,0,0),e.userData.local=t+","+r+","+n)}_processModel(e,t){const r=this.modelType[e.type];if(!r)return e;const n=r.modelTools.toNormal(e);return t&&(n.material=t),e.parent.add(n),e.parent.remove(e),n}parseMaterial(e){const t=new Set;e.traverse((e=>t.add(e))),t.forEach((e=>{var t=this._processMaterial(e);e=this._processModel(e,t),this.runScene.optionsEx.options.hideLocal&&this.compressLocal(e)}))}materialMapToJson(){return(0,Xe.js)(this.materialMap,((e,t)=>ls(this,void 0,void 0,(function*(){var e=t.material,r=Xa(e);return this.json.materialMap[e.userData.id]={normal:e.userData.normal||{},textures:{}},this.mergeAndRemoveTexture(r,e)}))))}mergeSame(e){var t=e.userData;for(const i in this.textureMap){var{md5:r,texture:n}=this.textureMap[i];if(t.md5===r&&e.mapping===n.mapping)return{isSame:!0,texture:n}}return this.textureMap[e.userData.id]=Object.assign(Object.assign({},t),{texture:e}),{isSame:!1,texture:e}}mergeAndRemoveTexture(e,t){return ls(this,void 0,void 0,(function*(){return e.map((e=>{var{type:e,texture:r}=e;this.runScene.uniqueEx.texture.add(r),t[e]=null;const n=this.mergeSame(r).texture;if(!this.json.textureMap[n.userData.id]){var i,{format:r,repeat:o,center:a,rotation:s,offset:l}=n;const e={format:r};this.runScene.modelEx.isNavieV2(o,1)||(({x:r,y:i}=o),e.repeat=r===i?r:o),this.runScene.modelEx.isNavieV2(a,0)||(({x:i,y:r}=a),e.center=i===r?i:a),this.runScene.modelEx.isNavieV2(l,0)||(({x:o,y:r}=l),e.offset=o===r?o:l),0!==s&&(e.rotation=s),this.json.textureMap[n.userData.id]=e}"normalMap"!==e||n.userData.isNormalMap||(n.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[e]=n.userData.id}))}))}setMultipMaterial(e,t){const r=this.runScene.modelEx.create(),n=Ha();r.material=n,e.add(r);for(const e of yi){if(!t.length)return;var i=t.pop();if(!i)return;n[e]=this.textureMap[i].texture}t.length&&this.setMultipMaterial(e,t)}}function cs(){cs=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=(f="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",i=f.asyncIterator||"@@asyncIterator",o=f.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(t){a=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i,o,a,s;return t=t&&t.prototype instanceof c?t:c,t=Object.create(t.prototype),n=new x(n||[]),t._invoke=(i=e,o=r,a=n,s="suspendedStart",function(e,t){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===e)throw t;return{value:void 0,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r&&(r=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return u;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}return"throw"===(n=l(n,t.iterator,r.arg)).type?(r.method="throw",r.arg=n.arg,r.delegate=null,u):(n=n.arg)?n.done?(r[t.resultName]=n.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,u):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,u)}(r,a),r)){if(r===u)continue;return r}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===s)throw s="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);if(s="executing","normal"===(r=l(i,o,a)).type){if(s=a.done?"completed":"suspendedYield",r.arg===u)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(s="completed",a.method="throw",a.arg=r.arg)}}),t}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var u={};function c(){}function h(){}function p(){}var f,d,m=(a(f={},n,(function(){return this})),(d=(d=Object.getPrototypeOf)&&d(d(w([]))))&&d!==t&&r.call(d,n)&&(f=d),p.prototype=c.prototype=Object.create(f));function v(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u;if("throw"!==(i=l(e[i],e,o)).type)return(o=(u=i.arg).value)&&"object"==ps(o)&&r.call(o,"__await")?t.resolve(o.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(o).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}));s(i.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function g(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(g,this),this.reset(!0)}function w(e){if(e){var t,i=e[n];if(i)return i.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return t=-1,(i=function n(){for(;++t<e.length;)if(r.call(e,t))return n.value=e[t],n.done=!1,n;return n.value=void 0,n.done=!0,n}).next=i}return{next:S}}function S(){return{value:void 0,done:!0}}return a(m,"constructor",h.prototype=p),a(p,"constructor",h),h.displayName=a(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},v(y.prototype),a(y.prototype,i,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new y(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(m),a(m,o,"Generator"),a(m,n,(function(){return this})),a(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t,r=[];for(t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=w,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;0<=i;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),l=r.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}var a=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,i=this.tryEntries[t];if(i.tryLoc===e)return"throw"===(r=i.completion).type&&(n=r.arg,b(i)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:w(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}function hs(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function ps(e){return(ps="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function fs(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ds(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ms(e,t,r){t&&ds(e.prototype,t),r&&ds(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var vs=function(){function e(){fs(this,e),this.pluginCallbacks=[],this.register((function(e){return new Rs(e)})),this.register((function(e){return new ks(e)})),this.register((function(e){return new As(e)})),this.register((function(e){return new Ls(e)})),this.register((function(e){return new Ds(e)})),this.register((function(e){return new Cs(e)}))}return ms(e,[{key:"register",value:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}},{key:"unregister",value:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}},{key:"parse",value:function(e,t,r,n){"object"===ps(r)&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),n=r);for(var i=new Os,o=[],a=0,s=this.pluginCallbacks.length;a<s;a++)o.push(this.pluginCallbacks[a](i));i.setPlugins(o),i.write(e,t,n).catch(r)}},{key:"parseAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.parse(e,n,i,t)}))}}]),e}(),ys=5121,gs=5123,bs=(o=9728,9729),xs=9984,ws=9986,Ss={},Ts=(Ss[c.NearestFilter]=o,Ss[c.NearestMipmapNearestFilter]=xs,Ss[c.NearestMipmapLinearFilter]=ws,Ss[c.LinearFilter]=bs,Ss[c.LinearMipmapNearestFilter]=9985,Ss[c.LinearMipmapLinearFilter]=9987,Ss[c.ClampToEdgeWrapping]=33071,Ss[c.RepeatWrapping]=10497,Ss[c.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function _s(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Ms(e){return 4*Math.ceil(e/4)}function Es(e,t){var r=1<arguments.length&&void 0!==t?t:0,n=Ms(e.byteLength);if(n===e.byteLength)return e;var i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==r)for(var o=e.byteLength;o<n;o++)i[o]=r;return i.buffer}var Ps=null,Os=function(){function e(){fs(this,e),this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}var t,r;return ms(e,[{key:"setPlugins",value:function(e){this.plugins=e}},{key:"write",value:(t=cs().mark((function e(t,r,n){var i,o,a,s,l,u,c;return cs().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(t),e.next=5,Promise.all(this.pending);case 5:return o=(i=this).buffers,a=i.json,n=i.options,e.next=11,i.options.myOptions.helper.done(a);case 11:l=i.extensionsUsed,s=new Blob(o,{type:"application/octet-stream"}),0<(l=Object.keys(l)).length&&(a.extensionsUsed=l),a.buffers&&0<a.buffers.length&&(a.buffers[0].byteLength=s.size),!0===n.binary?((u=new window.FileReader).readAsArrayBuffer(s),u.onloadend=function(){var e=Es(u.result),t=new DataView(new ArrayBuffer(8)),n=(t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0),Es(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;for(var t=new Uint8Array(new ArrayBuffer(e.length)),r=0,n=e.length;r<n;r++){var i=e.charCodeAt(r);t[r]=255<i?32:i}return t.buffer}(JSON.stringify(a)),32)),i=new DataView(new ArrayBuffer(8)),o=(i.setUint32(0,n.byteLength,!0),i.setUint32(4,1313821514,!0),new ArrayBuffer(12)),s=((l=new DataView(o)).setUint32(0,1179937895,!0),l.setUint32(4,2,!0),12+i.byteLength+n.byteLength+t.byteLength+e.byteLength),l=(l.setUint32(8,s,!0),new Blob([o,i,n,t,e],{type:"application/octet-stream"})),c=new window.FileReader;c.readAsArrayBuffer(l),c.onloadend=function(){r(c.result)}}):a.buffers&&0<a.buffers.length?((c=new window.FileReader).readAsDataURL(s),c.onloadend=function(){var e=c.result;a.buffers[0].uri=e,r(a)}):r(a);case 17:case"end":return e.stop()}}),e,this)})),r=function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(e){hs(o,n,i,a,s,"next",e)}function s(e){hs(o,n,i,a,s,"throw",e)}a(void 0)}))},function(e,t,n){return r.apply(this,arguments)})},{key:"serializeUserData",value:function(e,t){if(0!==Object.keys(e.userData).length){var r=this.options,n=this.extensionsUsed;try{var i=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&i.gltfExtensions){for(var o in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[o]=i.gltfExtensions[o],n[o]=!0;delete i.gltfExtensions}0<Object.keys(i).length&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}}},{key:"getUID",value:function(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}},{key:"isNormalizedNormalAttribute",value:function(e){if(this.cache.attributesNormalized.has(e))return!1;for(var t=new c.Vector3,r=0,n=e.count;r<n;r++)if(5e-4<Math.abs(t.fromBufferAttribute(e,r).length()-1))return!1;return!0}},{key:"createNormalizedNormalAttribute",value:function(e){var t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);for(var r=e.clone(),n=new c.Vector3,i=0,o=r.count;i<o;i++)n.fromBufferAttribute(r,i),0===n.x&&0===n.y&&0===n.z?n.setX(1):n.normalize(),r.setXYZ(i,n.x,n.y,n.z);return t.attributesNormalized.set(e,r),r}},{key:"applyTextureTransform",value:function(e,t){var r=!1,n={};0===t.offset.x&&0===t.offset.y||(n.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(n.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(n.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}},{key:"buildORMTexture",value:function(e){var t=null==(t=e.aoMap)?void 0:t.image,r=null==(r=e.roughnessMap)?void 0:r.image,n=null==(n=e.metalnessMap)?void 0:n.image;if(t===r&&r===n)return e.aoMap;if(t||r||n){e=Math.max((null==t?void 0:t.width)||0,(null==r?void 0:r.width)||0,(null==n?void 0:n.width)||0);var i=Math.max((null==t?void 0:t.height)||0,(null==r?void 0:r.height)||0,(null==n?void 0:n.height)||0),o=document.createElement("canvas"),a=(o.width=e,o.height=i,o.getContext("2d")),s=(a.fillStyle="#ffffff",a.fillRect(0,0,e,i),a.getImageData(0,0,e,i));if(t){a.drawImage(t,0,0,e,i);for(var l=a.getImageData(0,0,e,i).data,u=0;u<l.length;u+=4)s.data[u]=l[u]}if(r){a.drawImage(r,0,0,e,i);for(var h=a.getImageData(0,0,e,i).data,p=1;p<h.length;p+=4)s.data[p]=h[p]}if(n){a.drawImage(n,0,0,e,i);for(var f=a.getImageData(0,0,e,i).data,d=2;d<f.length;d+=4)s.data[d]=f[d]}return a.putImageData(s,0,0),new c.Texture(o)}}},{key:"processBuffer",value:function(e){var t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}},{key:"processBufferView",value:function(e,t,r,n,i){for(var o,a=this.json,s=(a.bufferViews||(a.bufferViews=[]),o=t===ys?1:t===gs?2:4,Ms(n*e.itemSize*o)),l=new DataView(new ArrayBuffer(s)),u=0,c=r;c<r+n;c++)for(var h=0;h<e.itemSize;h++){var p=void 0;4<e.itemSize?p=e.array[c*e.itemSize+h]:0===h?p=e.getX(c):1===h?p=e.getY(c):2===h?p=e.getZ(c):3===h&&(p=e.getW(c)),5126===t?l.setFloat32(u,p,!0):5125===t?l.setUint32(u,p,!0):t===gs?l.setUint16(u,p,!0):t===ys&&l.setUint8(u,p),u+=o}var f={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};return void 0!==i&&(f.target=i),34962===i&&(f.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(f),{id:a.bufferViews.length-1,byteLength:0}}},{key:"processBufferViewImage",value:function(e){var t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(n,i){var o=new window.FileReader;if(!(e instanceof Blob))return i();o.readAsArrayBuffer(e),o.onloadend=function(){var e=Es(o.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,n(r.bufferViews.push(i)-1)}}))}},{key:"processAccessor",value:function(e,t,r,n){var i,o=this.options,a=this.json;if(e.array.constructor===Float32Array)i=5126;else if(e.array.constructor===Uint32Array)i=5125;else if(e.array.constructor===Uint16Array)i=gs;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");i=ys}if(void 0===r&&(r=0),void 0===n&&(n=e.count),o.truncateDrawRange&&void 0!==t&&null===t.index&&(o=r+n,l=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count,r=Math.max(r,t.drawRange.start),(n=Math.min(o,l)-r)<0&&(n=0)),0===n)return null;o=function(e,t,r){for(var n={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},i=t;i<t+r;i++)for(var o=0;o<e.itemSize;o++){var a=void 0;4<e.itemSize?a=e.array[i*e.itemSize+o]:0===o?a=e.getX(i):1===o?a=e.getY(i):2===o?a=e.getZ(i):3===o&&(a=e.getW(i)),n.min[o]=Math.min(n.min[o],a),n.max[o]=Math.max(n.max[o],a)}return n}(e,r,n);var s,l=(void 0!==t&&(s=e===t.index?34963:34962),this.processBufferView(e,i,r,n,s));return t={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:n,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]},!0===e.normalized&&(t.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(t)-1}},{key:"processImage",value:function(e,t,r,n){var i,o=this,a=o.cache,s=o.json,l=o.options,u=o.pending,h=(a.images.has(e)||a.images.set(e,{}),a=a.images.get(e),null==(h=n.userData)?void 0:h.blob),p=n.userData.isNormalMap,f=(i=o.options.myOptions.optionsEx.exporterOptions.compressTexture)?"image/webp":"image/png";if(void 0!==a[(i&&(h=!!p),i=f+":flipY/"+r.toString())])return a[i];s.images||(s.images=[]);var d={mimeType:f};if(!0===l.binary&&h)u.push(new Promise((function(e){o.processBufferViewImage(n.userData.blob).then((function(t){d.bufferView=t,e()}))})));else if(l.embedImages){var m=Ps=Ps||document.createElement("canvas");if((m.width=Math.min(e.width,l.maxTextureSize),m.height=Math.min(e.height,l.maxTextureSize),p=m.getContext("2d")).translate(0,m.height),p.scale(1,-1),"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)p.drawImage(e,0,0,m.width,m.height);else{t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);for(var v=new Uint8ClampedArray(e.height*e.width*4),y=0;y<v.length;y+=4)v[y+0]=e.data[y+0],v[y+1]=e.data[y+1],v[y+2]=e.data[y+2],v[y+3]=e.data[y+3];p.putImageData(new ImageData(v,e.width,e.height),0,0)}!0===l.binary?u.push(new Promise((function(e){m.toBlob((function(t){o.processBufferViewImage(t).then((function(t){d.bufferView=t,e()}))}),f)}))):d.uri=m.toDataURL(f)}else d.uri=e.src;return r=s.images.push(d)-1,a[i]=r}},{key:"processSampler",value:function(e){var t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:Ss[e.magFilter],minFilter:Ss[e.minFilter],wrapS:Ss[e.wrapS],wrapT:Ss[e.wrapT]},t.samplers.push(e)-1}},{key:"processTexture",value:function(e){var t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);var n={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,e)};return e.name&&(n.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,n)})),r=r.textures.push(n)-1,t.textures.set(e,r),this.options.myOptions.helper.material.processTexture({texture:e,textureDef:n}),r}},{key:"processMaterial",value:function(e){var t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);var n,i={pbrMetallicRoughness:{}},o=(_s((this.options.myOptions.helper.material.parseMaterial({material:e,materialDef:i,options:this}),!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results."),o=e.color.toArray().concat([e.opacity])),[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(o={index:this.processTexture(null)},this.applyTextureTransform(o,e.metalnessMap||e.roughnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=o),e.map&&(o={index:this.processTexture(e.map)},this.applyTextureTransform(o,e.map),i.pbrMetallicRoughness.baseColorTexture=o),e.emissive&&(o=e.emissive.clone().multiplyScalar(e.emissiveIntensity),1<(n=Math.max(o.r,o.g,o.b))&&(o.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<n&&(i.emissiveFactor=o.toArray()),e.emissiveMap&&(n={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(n,e.emissiveMap),i.emissiveTexture=n)),e.normalMap&&(o={index:this.processTexture(e.normalMap)},e.normalScale&&1!==e.normalScale.x&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),i.normalTexture=o),e.aoMap&&(n={index:this.processTexture(e.aoMap),texCoord:1},1!==e.aoMapIntensity&&(n.strength=e.aoMapIntensity),this.applyTextureTransform(n,e.aoMap),i.occlusionTexture=n),e.transparent?i.alphaMode="BLEND":0<e.alphaTest&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)})),r.materials.push(i)-1);return t.materials.set(e,o),o}},{key:"processMesh",value:function(e){var t=this.cache,r=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(var i=0,o=e.material.length;i<o;i++)n.push(e.material[i].uuid);else n.push(e.material.uuid);var a=n.join(":");if(t.meshes.has(a))return t.meshes.get(a);var s=e.geometry,l=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4;if(!0!==s.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");var u,h,p,f={},d={},m=[],v=[],y={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},g=s.getAttribute("normal"),b=(void 0===g||this.isNormalizedNormalAttribute(g)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(g))),null);for(h in s.attributes)"morph"!==h.slice(0,5)&&(u=s.attributes[h],h=y[h]||h.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(h)||(h="_"+h),t.attributes.has(this.getUID(u))?d[h]=t.attributes.get(this.getUID(u)):(b=null,p=u.array,"JOINTS_0"!==h||p instanceof Uint16Array||p instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=new c.BufferAttribute(new Uint16Array(p),u.itemSize,u.normalized)),null!==(p=this.processAccessor(b||u,s))&&(d[h]=p,t.attributes.set(this.getUID(u),p))));if(void 0!==g&&s.setAttribute("normal",g),0===Object.keys(d).length)return null;if(void 0!==e.morphTargetInfluences&&0<e.morphTargetInfluences.length){var x=[],w=[],S={};if(void 0!==e.morphTargetDictionary)for(var T in e.morphTargetDictionary)S[e.morphTargetDictionary[T]]=T;for(var _=0;_<e.morphTargetInfluences.length;++_){var M,E={},P=!1;for(M in s.morphAttributes)if("position"!==M&&"normal"!==M)P||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),P=!0);else{var O=s.morphAttributes[M][_],R=M.toUpperCase(),k=s.attributes[M];if(t.attributes.has(this.getUID(O)))E[R]=t.attributes.get(this.getUID(O));else{var A=O.clone();if(!s.morphTargetsRelative)for(var C=0,L=O.count;C<L;C++)A.setXYZ(C,O.getX(C)-k.getX(C),O.getY(C)-k.getY(C),O.getZ(C)-k.getZ(C));E[R]=this.processAccessor(A,s),t.attributes.set(this.getUID(k),E[R])}}v.push(E),x.push(e.morphTargetInfluences[_]),void 0!==e.morphTargetDictionary&&w.push(S[_])}f.weights=x,0<w.length&&(f.extras={},f.extras.targetNames=w)}if((g=Array.isArray(e.material))&&0===s.groups.length)return null;for(var D=g?e.material:[e.material],I=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}],j=0,U=I.length;j<U;j++){var B={mode:l,attributes:d},z=(this.serializeUserData(s,B),0<v.length&&(B.targets=v),null!==s.index&&(z=this.getUID(s.index),void 0===I[j].start&&void 0===I[j].count||(z+=":"+I[j].start+":"+I[j].count),t.attributes.has(z)?B.indices=t.attributes.get(z):(B.indices=this.processAccessor(s.index,s,I[j].start,I[j].count),t.attributes.set(z,B.indices)),null===B.indices&&delete B.indices),this.processMaterial(D[I[j].materialIndex]));null!==z&&(B.material=z),m.push(B)}return f.primitives=m,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,f)})),g=r.meshes.push(f)-1,t.meshes.set(a,g),g}},{key:"processCamera",value:function(e){var t=this.json,r=(t.cameras||(t.cameras=[]),e.isOrthographicCamera),n={type:r?"orthographic":"perspective"};return r?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:c.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),t.cameras.push(n)-1}},{key:"processAnimation",value:function(e,t){for(var r=this.json,n=this.nodeMap,i=(r.animations||(r.animations=[]),(e=vs.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks),o=[],a=[],s=0;s<i.length;++s){var l=i[s],u=c.PropertyBinding.parseTrackName(l.name),h=c.PropertyBinding.findNode(t,u.nodeName),p=Ts[u.propertyName];if(!(h="bones"===u.objectName?!0===h.isSkinnedMesh?h.skeleton.getBoneByName(u.objectIndex):void 0:h)||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name),null;u=l.values.length/l.times.length;var f=void(p===Ts.morphTargetInfluences&&(u/=h.morphTargetInfluences.length));!0===l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(f="CUBICSPLINE",u/=3):f=l.getInterpolation()===c.InterpolateDiscrete?"STEP":"LINEAR",a.push({input:this.processAccessor(new c.BufferAttribute(l.times,1)),output:this.processAccessor(new c.BufferAttribute(l.values,u)),interpolation:f}),o.push({sampler:a.length-1,target:{node:n.get(h),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:a,channels:o}),r.animations.length-1}},{key:"processSkin",value:function(e){var t=this.json,r=this.nodeMap,n=t.nodes[r.get(e)],i=e.skeleton;if(void 0===i)return null;var o=e.skeleton.bones[0];if(void 0===o)return null;for(var a=[],s=new Float32Array(16*i.bones.length),l=new c.Matrix4,u=0;u<i.bones.length;++u)a.push(r.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(s,16*u);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(s,16)),joints:a,skeleton:r.get(o)}),n.skin=t.skins.length-1}},{key:"processNode",value:function(e){var t,r,n=this.json,i=this.options,o=this.nodeMap,a=(n.nodes||(n.nodes=[]),{});if(i.myOptions.helper.parseNode({object:e,nodeDef:a,options:this}),i.trs?(r=e.quaternion.toArray(),h=e.position.toArray(),t=e.scale.toArray(),_s(r,[0,0,0,1])||(a.rotation=r),_s(h,[0,0,0])||(a.translation=h),_s(t,[1,1,1])||(a.scale=t)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===_s(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(a.matrix=e.matrix.elements)),""!==e.name&&(a.name=String(e.name)),this.serializeUserData(e,a),e.isMesh||e.isLine||e.isPoints?null!==(r=this.processMesh(e))&&(a.mesh=r):e.isCamera&&(a.camera=this.processCamera(e)),e.isSkinnedMesh&&this.skins.push(e),0<e.children.length){for(var s=[],l=0,u=e.children.length;l<u;l++){var c=e.children[l];!c.visible&&!1!==i.onlyVisible||null!==(c=this.processNode(c))&&s.push(c)}0<s.length&&(a.children=s)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,a)}));var h=n.nodes.push(a)-1;return o.set(e,h),h}},{key:"processScene",value:function(e){for(var t=this.json,r=this.options,n=(t.scenes||(t.scenes=[],t.scene=0),{}),i=(""!==e.name&&(n.name=e.name),t.scenes.push(n),[]),o=0,a=e.children.length;o<a;o++){var s=e.children[o];!s.visible&&!1!==r.onlyVisible||null!==(s=this.processNode(s))&&i.push(s)}0<i.length&&(n.nodes=i),this.serializeUserData(e,n)}},{key:"processObjects",value:function(e){var t=new c.Scene;t.name="AuxScene";for(var r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}},{key:"processInput",value:function(e){for(var t,r,n=this.options,i=(e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)})),[]),o=0;o<e.length;o++)e[o]instanceof c.Scene?this.processScene(e[o]):i.push(e[o]);1===i.length?(t=i[0],["Group","Object3D"].includes(t.type)||((r=new c.Group).name="glb_model",r.add(t),t=r),this.processScene(t)):1<i.length&&this.processObjects(i);for(var a=0;a<this.skins.length;++a)this.processSkin(this.skins[a]);for(var s=0;s<n.animations.length;++s)this.processAnimation(n.animations[s],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}},{key:"_invokeAll",value:function(e){for(var t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}]),e}(),Rs=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_lights_punctual"}return ms(e,[{key:"writeNode",value:function(e,t){var r,n,i;e.isLight&&(e.isDirectionalLight||e.isPointLight||e.isSpotLight?(r=(i=this.writer).json,i=i.extensionsUsed,n={},e.name&&(n.name=e.name),n.color=e.color.toArray(),n.intensity=e.intensity,e.isDirectionalLight?n.type="directional":e.isPointLight?(n.type="point",0<e.distance&&(n.range=e.distance)):e.isSpotLight&&(n.type="spot",0<e.distance&&(n.range=e.distance),n.spot={},n.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,n.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0),(i=r.extensions[this.name].lights).push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:i.length-1}):console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e))}}]),e}(),ks=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_materials_unlit"}return ms(e,[{key:"writeMaterial",value:function(e,t){e.isMeshBasicMaterial&&(e=this.writer.extensionsUsed,t.extensions=t.extensions||{},t.extensions[this.name]={},e[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9)}}]),e}(),As=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_materials_pbrSpecularGlossiness"}return ms(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isGLTFSpecularGlossinessMaterial&&(n=(r=this.writer).extensionsUsed,i={},t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor),e.specular.toArray(o=[1,1,1],0),i.specularFactor=o,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap&&(o={index:r.processTexture(e.specularMap)},r.applyTextureTransform(o,e.specularMap),i.specularGlossinessTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Cs=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_materials_clearcoat"}return ms(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&(n=(r=this.writer).extensionsUsed,(i={}).clearcoatFactor=e.clearcoat,e.clearcoatMap&&(o={index:r.processTexture(e.clearcoatMap)},r.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o),i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap&&(o={index:r.processTexture(e.clearcoatRoughnessMap)},r.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o),e.clearcoatNormalMap&&(o={index:r.processTexture(e.clearcoatNormalMap)},r.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Ls=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_materials_transmission"}return ms(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&0!==e.transmission&&(n=(r=this.writer).extensionsUsed,(i={}).transmissionFactor=e.transmission,e.transmissionMap&&(o={index:r.processTexture(e.transmissionMap)},r.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Ds=function(){function e(t){fs(this,e),this.writer=t,this.name="KHR_materials_volume"}return ms(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&0!==e.transmission&&(n=(r=this.writer).extensionsUsed,(i={}).thicknessFactor=e.thickness,e.thicknessMap&&(o={index:r.processTexture(e.thicknessMap)},r.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o),i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Is=(vs.Utils={insertKeyframe:function(e,t){var r,n=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),o=new e.ValueBufferType(e.values.length+n),a=e.createInterpolant(new e.ValueBufferType(n));if(0===e.times.length){i[0]=t;for(var s=0;s<n;s++)o[s]=0;r=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;i[0]=t,i.set(e.times,1),o.set(a.evaluate(t),0),o.set(e.values,n),r=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(a.evaluate(t),e.values.length),r=i.length-1}else for(var l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<.001)return l;if(e.times[l]<t&&e.times[l+1]>t){i.set(e.times.slice(0,l+1),0),i[l+1]=t,i.set(e.times.slice(l+1),l+2),o.set(e.values.slice(0,(l+1)*n),0),o.set(a.evaluate(t),(l+1)*n),o.set(e.values.slice((l+1)*n),(l+2)*n),r=l+1;break}}return e.times=i,e.values=o,r},mergeMorphTargetTracks:function(e,t){for(var r=[],n={},i=e.tracks,o=0;o<i.length;++o){var a=i[o],s=c.PropertyBinding.parseTrackName(a.name),l=c.PropertyBinding.findNode(t,s.nodeName);if("morphTargetInfluences"!==s.propertyName||void 0===s.propertyIndex)r.push(a);else{if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),(a=a.clone()).setInterpolation(c.InterpolateLinear)}var u=l.morphTargetInfluences.length,h=l.morphTargetDictionary[s.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+s.propertyIndex);var p=void 0;if(void 0===n[l.uuid]){for(var f=new((p=a.clone()).ValueBufferType)(u*p.times.length),d=0;d<p.times.length;d++)f[d*u+h]=p.values[d];p.name=(s.nodeName||"")+".morphTargetInfluences",p.values=f,n[l.uuid]=p,r.push(p)}else{var m=a.createInterpolant(new a.ValueBufferType(1));p=n[l.uuid];for(var v=0;v<p.times.length;v++)p.values[v*u+h]=m.evaluate(p.times[v]);for(var y=0;y<a.times.length;y++){var g=this.insertKeyframe(p,a.times[y]);p.values[g*u+h]=a.values[y]}}}}return e.tracks=r,e}},function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))});class js{constructor(e){this._gltf=new vs,this.options=new is,this.runScene=e}getArrayBuffer(e=this.runScene.sceneEx.getClear(),t="scene"){return Is(this,void 0,void 0,(function*(){const r=new ss(t,this.runScene),n=new us(t,this.runScene);var i=yield n.parse(e);return r.material.setMaterialMap(i),new Promise((t=>{this._gltf.parse(e,(e=>{t(e)}),{binary:!0,onlyVisible:!1,includeCustomExtensions:!0,myOptions:{helper:r,optionsEx:this.runScene.optionsEx}})}))}))}export(e){return Is(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,Ye.downloadFile)(new Blob([t]),"scene.glb")}))}model(){return Is(this,void 0,void 0,(function*(){const e=this.runScene.modelEx.select;var t,r;e&&(t=e.name||e.type,r=yield this.getArrayBuffer(e.clone(),"model"),(0,Ye.downloadFile)(new Blob([r]),t+".glb"))}))}material(){var e;return Is(this,void 0,void 0,(function*(){if(t=null==(e=this.runScene.modelEx.select)?void 0:e.material){const e=ts("Box");var t=(e.material=t).name||"material",r=yield this.getArrayBuffer(e,"material");(0,Ye.downloadFile)(new Blob([r]),t+".glb")}}))}scene(){return Is(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,Ye.downloadFile)(new Blob([e]),"scene.glb")}))}}class Us{constructor(e){this.runScene=e,this.gltf=new js(e)}}var Bs={},zs=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Ns=function(e){return new Worker(e)};try{URL.revokeObjectURL(zs(""))}catch(Js){zs=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Ns=function(e){return new Worker(e,{type:"module"})}}for(var Fs=Uint8Array,Vs=Uint16Array,Hs=Uint32Array,Gs=new Fs([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]),Ws=new Fs([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]),Xs=new Fs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qs=(o=function(e,t){for(var r=new Vs(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new Hs(r[30]);for(n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return[r,i]},(xs=o(Gs,2))[0]),Ys=xs[1],Zs=(qs[28]=258,Ys[258]=28,ws=o(Ws,0))[0],Qs=ws[1],Ks=new Vs(32768),Js=0;Js<32768;++Js){var $s=(43690&Js)>>>1|(21845&Js)<<1;Ks[Js]=((65280&($s=(61680&($s=(52428&$s)>>>2|(13107&$s)<<2))>>>4|(3855&$s)<<4))>>>8|(255&$s)<<8)>>>1}var el=function(e,t,r){for(var n=e.length,i=0,o=new Vs(t);i<n;++i)++o[e[i]-1];var a=new Vs(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(r){var s=new Vs(1<<t),l=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],h=a[e[i]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[Ks[h]>>>l]=u}else for(s=new Vs(n),i=0;i<n;++i)e[i]&&(s[i]=Ks[a[e[i]-1]++]>>>15-e[i]);return s},tl=new Fs(288);for(Js=0;Js<144;++Js)tl[Js]=8;for(Js=144;Js<256;++Js)tl[Js]=9;for(Js=256;Js<280;++Js)tl[Js]=7;for(Js=280;Js<288;++Js)tl[Js]=8;var rl=new Fs(32);for(Js=0;Js<32;++Js)rl[Js]=5;function nl(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}}function il(e,t,r,n,i){var o,a=Dl(e,n,i,(function(e,r){e?(a.terminate(),t.ondata.call(t,e)):(r[1]&&a.terminate(),t.ondata.call(t,e,r[0],r[1]))}));a.postMessage(r),t.push=function(e,r){if(o)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,o=r],[e.buffer])},t.terminate=function(){a.terminate()}}function ol(e,t){return Wl(e,t)+4294967296*Wl(e,t+4)}var al=el(tl,9,0),sl=el(tl,9,1),ll=el(rl,5,0),ul=el(rl,5,1),cl=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},hl=function(e,t,r){var n=t/8|0;return(e[n]|e[1+n]<<8)>>(7&t)&r},pl=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},fl=function(e){return(e/8|0)+(7&e&&1)},dl=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof Vs?Vs:e instanceof Hs?Hs:Fs)(r-(t=null==t||t<0?0:t));return n.set(e.subarray(t,r)),n},ml=function(e,t,r){var n=e.length;if(!n||r&&!r.l&&n<5)return t||new Fs(0);function i(e){var r=t.length;r<e&&((r=new Fs(Math.max(2*r,e))).set(t),t=r)}var o=!t||r,a=!r||r.i,s=(r=r||{},t=t||new Fs(3*n),r.f||0),l=r.p||0,u=r.b||0,c=r.l,h=r.d,p=r.m,f=r.n,d=8*n;do{if(!c){r.f=s=hl(e,l,1);var m=hl(e,l+1,3);if(l+=3,!m){var v=e[(M=fl(l)+4)-4]|e[M-3]<<8;if(n<(S=M+v)){if(a)throw"unexpected EOF";break}o&&i(u+v),t.set(e.subarray(M,S),u),r.b=u+=v,r.p=l=8*S;continue}if(1==m)c=sl,h=ul,p=9,f=5;else{if(2!=m)throw"invalid block type";v=hl(e,l,31)+257;for(var y=hl(e,l+10,15)+4,g=v+hl(e,l+5,31)+1,b=(l+=14,new Fs(g)),x=new Fs(19),w=0;w<y;++w)x[Xs[w]]=hl(e,l+3*w,7);l+=3*y;var S,T=(1<<(S=cl(x)))-1,_=el(x,S,1);for(w=0;w<g;){var M,E=_[hl(e,l,T)];if(l+=15&E,(M=E>>>4)<16)b[w++]=M;else{var P=0,O=0;for(16==M?(O=3+hl(e,l,3),l+=2,P=b[w-1]):17==M?(O=3+hl(e,l,7),l+=3):18==M&&(O=11+hl(e,l,127),l+=7);O--;)b[w++]=P}}m=b.subarray(0,v);var R=b.subarray(v);p=cl(m),f=cl(R),c=el(m,p,1),h=el(R,f,1)}if(d<l){if(a)throw"unexpected EOF";break}}o&&i(u+131072);for(var k=(1<<p)-1,A=(1<<f)-1,C=l;;C=l){var L=(P=c[pl(e,l)&k])>>>4;if(d<(l+=15&P)){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(L<256)t[u++]=L;else{if(256==L){C=l,c=null;break}var D,I=L-254,j=(264<L&&(D=Gs[w=L-257],I=hl(e,l,(1<<D)-1)+qs[w],l+=D),(L=h[pl(e,l)&A])>>>4);if(!L)throw"invalid distance";if(l+=15&L,R=Zs[j],3<j&&(D=Ws[j],R+=pl(e,l)&(1<<D)-1,l+=D),d<l){if(a)throw"unexpected EOF";break}o&&i(u+131072);for(var U=u+I;u<U;u+=4)t[u]=t[u-R],t[u+1]=t[u+1-R],t[u+2]=t[u+2-R],t[u+3]=t[u+3-R];u=U}}r.l=c,r.p=C,r.b=u,c&&(s=1,r.m=p,r.d=h,r.n=f)}while(!s);return u==t.length?t:dl(t,0,u)},vl=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8},yl=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8,e[2+n]|=r>>>16},gl=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var i=r.length,o=r.slice();if(!i)return[Ml,0];if(1==i)return(m=new Fs(r[0].s+1))[r[0].s]=1,[m,1];r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var a=r[0],s=r[1],l=0,u=1,c=2;for(r[0]={s:-1,f:a.f+s.f,l:a,r:s};u!=i-1;)a=r[r[l].f<r[c].f?l++:c++],s=r[l!=u&&r[l].f<r[c].f?l++:c++],r[u++]={s:-1,f:a.f+s.f,l:a,r:s};var h=o[0].s;for(n=1;n<i;++n)o[n].s>h&&(h=o[n].s);var p=new Vs(h+1),f=bl(r[u-1],p,0);if(t<f){n=0;var d=0,m=f-t,v=1<<m;for(o.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));n<i;++n){var y=o[n].s;if(!(p[y]>t))break;d+=v-(1<<f-p[y]),p[y]=t}for(d>>>=m;0<d;){var g=o[n].s;p[g]<t?d-=1<<t-p[g]++-1:++n}for(;0<=n&&d;--n){var b=o[n].s;p[b]==t&&(--p[b],++d)}f=t}return[new Fs(p),f]},bl=function e(t,r,n){return-1==t.s?Math.max(e(t.l,r,n+1),e(t.r,r,n+1)):r[t.s]=n},xl=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Vs(++t),n=0,i=e[0],o=1,a=function(e){r[n++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++o;else{if(!i&&2<o){for(;138<o;o-=138)a(32754);2<o&&(a(10<o?o-11<<5|28690:o-3<<5|12305),o=0)}else if(3<o){for(a(i),--o;6<o;o-=6)a(8304);2<o&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=e[s]}return[r.subarray(0,n),t]},wl=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},Sl=function(e,t,r){var n=r.length,i=fl(t+2);e[i]=255&n,e[i+1]=n>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var o=0;o<n;++o)e[i+o+4]=r[o];return 8*(i+4+n)},Tl=function(e,t,r,n,i,o,a,s,l,u,c){vl(t,c++,r),++i[256];for(var h=(r=gl(i,15))[0],p=(r=r[1],(f=gl(o,15))[0]),f=f[1],d=(m=xl(h))[0],m=m[1],v=(y=xl(p))[0],y=y[1],g=new Vs(19),b=0;b<d.length;++b)g[31&d[b]]++;for(b=0;b<v.length;++b)g[31&v[b]]++;for(var x=(w=gl(g,7))[0],w=w[1],S=19;4<S&&!x[Xs[S-1]];--S);var T,_=u+5<<3,M=wl(i,tl)+wl(o,rl)+a;if(i=wl(i,h)+wl(o,p)+a+14+3*S+wl(g,x)+(2*g[16]+3*g[17]+7*g[18]),_<=M&&_<=i)return Sl(t,c,e.subarray(l,l+u));if(vl(t,c,1+(i<M)),c+=2,i<M){var E=el(h,r,0),P=h,O=el(p,f,0),R=p,k=el(x,w,0);for(vl(t,c,m-257),vl(t,c+5,y-1),vl(t,c+10,S-4),c+=14,b=0;b<S;++b)vl(t,c+3*b,x[Xs[b]]);c+=3*S;for(var A=[d,v],C=0;C<2;++C){var L=A[C];for(b=0;b<L.length;++b){var D=31&L[b];vl(t,c,k[D]),c+=x[D],15<D&&(vl(t,c,L[b]>>>5&127),c+=L[b]>>>12)}}}else E=al,P=tl,O=ll,R=rl;for(b=0;b<s;++b)255<n[b]?(D=n[b]>>>18&31,yl(t,c,E[D+257]),c+=P[D+257],7<D&&(vl(t,c,n[b]>>>23&31),c+=Gs[D]),T=31&n[b],yl(t,c,O[T]),c+=R[T],3<T&&(yl(t,c,n[b]>>>5&8191),c+=Ws[T])):(yl(t,c,E[n[b]]),c+=P[n[b]]);return yl(t,c,E[256]),c+P[256]},_l=new Hs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ml=new Fs(0),El=function(e,t,r,n,i,o){var a=e.length,s=new Fs(n+a+5*(1+Math.ceil(a/7e3))+i),l=s.subarray(n,s.length-i),u=0;if(!t||a<8)for(var c=0;c<=a;c+=65535){var h=c+65535;u=h<a?Sl(l,u,e.subarray(c,h)):(l[c]=o,Sl(l,u,e.subarray(c,a)))}else{for(var p=(t=_l[t-1])>>>13,f=8191&t,d=(1<<r)-1,m=new Vs(32768),v=new Vs(1+d),y=Math.ceil(r/3),g=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<g)&d},x=new Hs(25e3),w=new Vs(288),S=new Vs(32),T=0,_=0,M=(c=0,0),E=0,P=0;c<a;++c){var O=b(c),R=32767&c,k=v[O];if(m[R]=k,v[O]=R,E<=c){var A=a-c;if((7e3<T||24576<M)&&423<A){u=Tl(e,l,0,x,w,S,_,M,P,c-P,u),M=T=_=0,P=c;for(var C=0;C<286;++C)w[C]=0;for(C=0;C<30;++C)S[C]=0}var L=2,D=0,I=f,j=R-k&32767;if(2<A&&O==b(c-j))for(var U=Math.min(p,A)-1,B=Math.min(32767,c),z=Math.min(258,A);j<=B&&--I&&R!=k;){if(e[c+L]==e[c+L-j]){for(var N=0;N<z&&e[c+N]==e[c+N-j];++N);if(L<N){if(D=j,U<(L=N))break;var F=Math.min(j,N-2),V=0;for(C=0;C<F;++C){var H=c-j+C+32768&32767,G=H-m[H]+32768&32767;V<G&&(V=G,k=H)}}}j+=(R=k)-(k=m[R])+32768&32767}D?(x[M++]=268435456|Ys[L]<<18|Qs[D],O=31&Ys[L],A=31&Qs[D],_+=Gs[O]+Ws[A],++w[257+O],++S[A],E=c+L,++T):(x[M++]=e[c],++w[e[c]])}}u=Tl(e,l,o,x,w,S,_,M,P,c-P,u),!o&&7&u&&(u=Sl(l,u+1,Ml))}return dl(s,0,n+fl(u)+i)},Pl=function(){for(var e=new Hs(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),Ol=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=Pl[255&r^t[n]]^r>>>8;e=r},d:function(){return~e}}},Rl=function(){var e=1,t=0;return{p:function(r){for(var n=e,i=t,o=r.length,a=0;a!=o;){for(var s=Math.min(a+2655,o);a<s;++a)i+=n+=r[a];n=(65535&n)+15*(n>>16),i=(65535&i)+15*(i>>16)}e=n,t=i},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},kl=function(e,t,r,n,i){return El(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,n,!i)},Al=function(e,t){var r,n={};for(r in e)n[r]=e[r];for(r in t)n[r]=t[r];return n},Cl=function(e,t,r){for(var n=e(),i=(e=e.toString()).slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<n.length;++o){var a=n[o],s=i[o];if("function"==typeof a){t+=";"+s+"=";var l=a.toString();if(a.prototype)if(-1!=l.indexOf("[native code]")){var u=l.indexOf(" ",8)+1;t+=l.slice(u,l.indexOf("(",u))}else for(var c in t+=l,a.prototype)t+=";"+s+".prototype."+c+"="+a.prototype[c].toString();else t+=l}else r[s]=a}return[t,r]},Ll=[],Dl=function(e,t,r,n){var i;if(!Ll[r]){for(var o="",a={},s=e.length-1,l=0;l<s;++l)o=(i=Cl(e[l],o,a))[0],a=i[1];Ll[r]=Cl(e[s],o,a)}var u=Al({},Ll[r][1]);return function(e,t,r,n,i){return(t=Ns(Bs[t]||(Bs[t]=zs(e)))).onerror=function(e){return i(e.error,null)},t.onmessage=function(e){return i(null,e.data)},t.postMessage(r,n),t}(Ll[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,u,function(e){var t,r=[];for(t in e)(e[t]instanceof Fs||e[t]instanceof Vs||e[t]instanceof Hs)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(u),n)},Il=function(){return[Fs,Vs,Hs,Gs,Ws,Xs,qs,Zs,sl,ul,Ks,el,cl,hl,pl,fl,dl,ml,su,Fl,Vl]},jl=function(){return[Fs,Vs,Hs,Gs,Ws,Xs,Ys,Qs,al,tl,ll,rl,Ks,_l,Ml,el,vl,yl,gl,bl,xl,wl,Sl,Tl,fl,dl,El,kl,nu,Fl]},Ul=function(){return[ql,Ql,Xl,Ol,Pl]},Bl=function(){return[Yl,Zl]},zl=function(){return[Kl,Xl,Rl]},Nl=function(){return[Jl]},Fl=function(e){return postMessage(e,[e.buffer])},Vl=function(e){return e&&e.size&&new Fs(e.size)},Hl=function(e,t,r,n,i,o){var a=Dl(r,n,i,(function(e,t){a.terminate(),o(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},Gl=function(e,t){return e[t]|e[t+1]<<8},Wl=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Xl=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},ql=function(e,t){var r=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Xl(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var n=0;n<=r.length;++n)e[n+10]=r.charCodeAt(n)}},Yl=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],r=10;4&t&&(r+=e[10]|2+(e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);0<n;n-=!e[r++]);return r+(2&t)},Zl=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Ql=function(e){return 10+(e.filename&&e.filename.length+1||0)},Kl=function(e,t){t=0==(t=t.level)?0:t<6?1:9==t?3:2,e[0]=120,e[1]=t<<6|(t?32-2*t:1)},Jl=function(e){if(8!=(15&e[0])||7<e[0]>>>4||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function $l(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var eu=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(kl(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),tu=function(e,t){il([jl,function(){return[nl,eu]}],this,$l.call(this,e,t),(function(e){e=new eu(e.data),onmessage=nl(e)}),6)};function ru(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[jl],(function(e){return Fl(nu(e.data[0],e.data[1]))}),0,r)}function nu(e,t){return kl(e,t||{},0,0)}var iu=function(){function e(e){this.s={},this.p=new Fs(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,r=new Fs(t+e.length);r.set(this.p),r.set(e,t),this.p=r},e.prototype.c=function(e){this.d=this.s.i=e||!1,e=this.s.b;var t=ml(this.p,this.o,this.s);this.ondata(dl(t,e,this.s.b),this.d),this.o=dl(t,this.s.b-32768),this.s.b=this.o.length,this.p=dl(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ou=function(e){this.ondata=e,il([Il,function(){return[nl,iu]}],this,0,(function(){var e=new iu;onmessage=nl(e)}),7)};function au(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[Il],(function(e){return Fl(su(e.data[0],Vl(e.data[1])))}),1,r)}function su(e,t){return ml(e,t)}var lu=function(){function e(e,t){this.c=Ol(),this.l=0,this.v=1,eu.call(this,e,t)}return e.prototype.push=function(e,t){eu.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=kl(e,this.o,this.v&&Ql(this.o),t&&8,!t),this.v&&(ql(e,this.o),this.v=0),t&&(Xl(e,e.length-8,this.c.d()),Xl(e,e.length-4,this.l)),this.ondata(e,t)},e}(),uu=function(e,t){il([jl,Ul,function(){return[nl,eu,lu]}],this,$l.call(this,e,t),(function(e){e=new lu(e.data),onmessage=nl(e)}),8)};function cu(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[jl,Ul,function(){return[hu]}],(function(e){return Fl(hu(e.data[0],e.data[1]))}),2,r)}function hu(e,t){t=t||{};var r=Ol(),n=e.length,i=(r.p(e),e=kl(e,t,Ql(t),8)).length;return ql(e,t),Xl(e,i-8,r.d()),Xl(e,i-4,n),e}var pu=function(){function e(e){this.v=1,iu.call(this,e)}return e.prototype.push=function(e,t){if(iu.prototype.e.call(this,e),this.v){if((e=3<this.p.length?Yl(this.p):4)>=this.p.length&&!t)return;this.p=this.p.subarray(e),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}iu.prototype.c.call(this,t)},e}(),fu=function(e){this.ondata=e,il([Il,Bl,function(){return[nl,iu,pu]}],this,0,(function(){var e=new pu;onmessage=nl(e)}),9)};function du(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[Il,Bl,function(){return[mu]}],(function(e){return Fl(mu(e.data[0]))}),3,r)}function mu(e,t){return ml(e.subarray(Yl(e),-8),t||new Fs(Zl(e)))}var vu=function(){function e(e,t){this.c=Rl(),this.v=1,eu.call(this,e,t)}return e.prototype.push=function(e,t){eu.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=kl(e,this.o,this.v&&2,t&&4,!t),this.v&&(Kl(e,this.o),this.v=0),t&&Xl(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),yu=function(e,t){il([jl,zl,function(){return[nl,eu,vu]}],this,$l.call(this,e,t),(function(e){e=new vu(e.data),onmessage=nl(e)}),10)};function gu(e,t){t=t||{};var r=Rl();return r.p(e),e=kl(e,t,2,4),Kl(e,t),Xl(e,e.length-4,r.d()),e}var bu=function(){function e(e){this.v=1,iu.call(this,e)}return e.prototype.push=function(e,t){if(iu.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}iu.prototype.c.call(this,t)},e}(),xu=function(e){this.ondata=e,il([Il,Nl,function(){return[nl,iu,bu]}],this,0,(function(){var e=new bu;onmessage=nl(e)}),11)};function wu(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Hl(e,t,[Il,Nl,function(){return[Su]}],(function(e){return Fl(Su(e.data[0],Vl(e.data[1])))}),5,r)}function Su(e,t){return ml((Jl(e),e.subarray(2,-4)),t)}var Tu=function(){function e(e){this.G=pu,this.I=iu,this.Z=bu,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";var r,n;this.s?this.s.push(e,t):(this.p&&this.p.length?((r=new Fs(this.p.length+e.length)).set(this.p),r.set(e,this.p.length)):this.p=e,2<this.p.length&&((n=this).s=new(31==this.p[0]&&139==this.p[1]&&8==this.p[2]?this.G:8!=(15&this.p[0])||7<this.p[0]>>4||(this.p[0]<<8|this.p[1])%31?this.I:this.Z)((function(){n.ondata.apply(n,arguments)})),this.s.push(this.p,t),this.p=null))},e}(),_u=function(){function e(e){this.G=fu,this.I=ou,this.Z=xu,this.ondata=e}return e.prototype.push=function(e,t){Tu.prototype.push.call(this,e,t)},e}(),Mu=function e(t,r,n,i){for(var o in t){var a=t[o];o=r+o,a instanceof Fs?n[o]=[a,i]:Array.isArray(a)?n[o]=[a[0],Al(i,a[1])]:e(a,o+"/",n,i)}},Eu="undefined"!=typeof TextEncoder&&new TextEncoder,Pu="undefined"!=typeof TextDecoder&&new TextDecoder,Ou=0;try{Pu.decode(Ml,{stream:!0}),Ou=1}catch(Js){}var Ru=function(e){for(var t="",r=0;;){var n=e[r++],i=(127<n)+(223<n)+(239<n);if(r+i>e.length)return[t,dl(e,r-1)];i?3==i?(n=((15&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=1&i?String.fromCharCode((31&n)<<6|63&e[r++]):String.fromCharCode((15&n)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(n)}},ku=function(){function e(e){this.ondata=e,Ou?this.t=new TextDecoder:this.p=Ml}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var r=((r=new Fs(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=Ru(r))[0];if(e=e[1],t){if(e.length)throw"invalid utf-8 data";this.p=null}else this.p=e;this.ondata(r,t)}},e}(),Au=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Cu(e),this.d=t||!1)},e}();function Cu(e,t){if(t){for(var r=new Fs(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(Eu)return Eu.encode(e);var i=e.length,o=new Fs(e.length+(e.length>>1)),a=0,s=function(e){o[a++]=e};for(n=0;n<i;++n){a+5>o.length&&((l=new Fs(a+8+(i-n<<1))).set(o),o=l);var l=e.charCodeAt(n);l<128||t?s(l):(l<2048?s(192|l>>6):(55295<l&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++n))>>18),s(128|l>>12&63)):s(224|l>>12),s(128|l>>6&63)),s(128|63&l))}return dl(o,0,a)}function Lu(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}if(Pu)return Pu.decode(e);var i=(t=Ru(e))[0];if(t[1].length)throw"invalid utf-8 data";return i}function Du(e){return 1==e?3:e<6?2:9==e?1:0}var Iu=function(e,t){return t+30+Gl(e,t+26)+Gl(e,t+28)},ju=function(e,t,r){var n=Gl(e,t+28),i=Lu(e.subarray(t+46,t+46+n),!(2048&Gl(e,t+8))),o=(n=t+46+n,Wl(e,t+20)),a=(o=(r=r&&4294967295==o?Uu(e,n):[o,Wl(e,t+24),Wl(e,t+42)])[0],r[1]);return r=r[2],[Gl(e,t+10),o,a,i,n+Gl(e,t+30)+Gl(e,t+32),r]},Uu=function(e,t){for(;1!=Gl(e,t);t+=4+Gl(e,t+2));return[ol(e,t+12),ol(e,t+4),ol(e,t+20)]},Bu=function(e){var t=0;if(e)for(var r in e){if(65535<(r=e[r].length))throw"extra field too long";t+=r+4}return t},zu=function(e,t,r,n,i,o,a,s){var l=n.length,u=r.extra,c=s&&s.length,h=Bu(u),p=(Xl(e,t,null!=a?33639248:67324752),t+=4,null!=a&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(null==o&&8),e[t++]=i&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8,i=new Date(null==r.mtime?Date.now():r.mtime)).getFullYear()-1980;if(p<0||119<p)throw"date not in range 1980-2099";if(Xl(e,t,p<<25|i.getMonth()+1<<21|i.getDate()<<16|i.getHours()<<11|i.getMinutes()<<5|i.getSeconds()>>>1),t+=4,null!=o&&(Xl(e,t,r.crc),Xl(e,t+4,o),Xl(e,t+8,r.size)),Xl(e,t+12,l),Xl(e,t+14,h),t+=16,null!=a&&(Xl(e,t,c),Xl(e,t+6,r.attrs),Xl(e,t+10,a),t+=14),e.set(n,t),t+=l,h)for(var f in u){var d=u[f],m=d.length;Xl(e,t,+f),Xl(e,t+2,m),e.set(d,t+4),t+=4+m}return c&&(e.set(s,t),t+=c),t},Nu=function(e,t,r,n,i){Xl(e,t,101010256),Xl(e,t+8,r),Xl(e,t+10,r),Xl(e,t+12,n),Xl(e,t+16,i)},Fu=function(){function e(e){this.filename=e,this.c=Ol(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Vu=function(){function e(e,t){var r=this;t=t||{},Fu.call(this,e),this.d=new eu(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=Du(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Fu.prototype.push.call(this,e,t)},e}(),Hu=function(){function e(e,t){var r=this;t=t||{},Fu.call(this,e),this.d=new tu(t,(function(e,t,n){r.ondata(e,t,n)})),this.compression=8,this.flag=Du(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Fu.prototype.push.call(this,e,t)},e}(),Gu=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var r=Cu(e.filename),n=r.length,i=(o=e.comment)&&Cu(o),o=n!=e.filename.length||i&&o.length!=i.length,a=n+Bu(e.extra)+30;if(65535<n)throw"filename too long";function s(){for(var e=0,r=l;e<r.length;e++){var n=r[e];t.ondata(null,n,!1)}l=[]}n=new Fs(a);var l=(zu(n,0,e,r,o),[n]),u=this.d,c=(this.d=0,this.u.length),h=Al(e,{f:r,u:o,o:i,t:function(){e.terminate&&e.terminate()},r:function(){var e;s(),u&&((e=t.u[c+1])?e.r():t.d=1),u=1}}),p=0;e.ondata=function(r,n,i){r?(t.ondata(r,n,i),t.terminate()):(p+=n.length,l.push(n),i?(r=new Fs(16),Xl(r,0,134695760),Xl(r,4,e.crc),Xl(r,8,p),Xl(r,12,e.size),l.push(r),h.c=p,h.b=a+p+16,h.crc=e.crc,h.size=e.size,u&&h.r(),u=1):u&&s())},this.u.push(h)},e.prototype.end=function(){var e=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&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,r=0,n=0,i=this.u;n<i.length;n++)r+=46+(l=i[n]).f.length+Bu(l.extra)+(l.o?l.o.length:0);for(var o=new Fs(r+22),a=0,s=this.u;a<s.length;a++){var l=s[a];zu(o,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+Bu(l.extra)+(l.o?l.o.length:0),t+=l.b}Nu(o,e,this.u.length,r,t),this.ondata(null,o,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2},e}(),Wu=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),Xu=function(){function e(){var e=this;this.i=new iu((function(t,r){e.ondata(null,t,r)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(r){this.ondata(r,e,t)}},e.compression=8,e}(),qu=function(){function e(e,t){var r=this;t<32e4?this.i=new iu((function(e,t){r.ondata(null,e,t)})):(this.i=new ou((function(e,t,n){r.ondata(e,t,n)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=dl(e,0)),this.i.push(e,t)},e.compression=8,e}(),Yu=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Wu},this.p=Ml}return e.prototype.push=function(e,t){var r=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(0<this.c){var n=Math.min(this.c,e.length),i=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(n)).length)return this.push(e,t)}else{for(var o=0,a=0,s=void 0,l=void 0,u=(this.p.length?e.length?((l=new Fs(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e,l.length),c=this.c,h=(i=c&&this.d,this);a<u-4&&"break"!==function(){var e,t,n,i,p,f,d,m,v,y,g,b=Wl(l,a);return 67324752==b?(o=1,s=a,h.d=null,h.c=0,n=Gl(l,a+6),e=Gl(l,a+8),t=2048&n,n&=8,i=Gl(l,a+26),p=Gl(l,a+28),a+30+i+p<u&&(h.k.unshift(f=[]),o=2,d=Wl(l,a+18),m=Wl(l,a+22),v=Lu(l.subarray(a+30,a+=30+i),!t),4294967295==d?(i=n?[-2]:Uu(l,a),d=i[0],m=i[1]):n&&(d=-1),a+=p,h.c=d,g={name:v,compression:e,start:function(){if(!g.ondata)throw"no callback";if(d){var t=r.o[e];if(!t)throw"unknown compression type "+e;(y=d<0?new t(v):new t(v,d,m)).ondata=function(e,t,r){g.ondata(e,t,r)};for(var n=0,i=f;n<i.length;n++)y.push(i[n],!1);r.k[0]==f&&r.c?r.d=y:y.push(Ml,!0)}else g.ondata(null,Ml,!0)},terminate:function(){y&&y.terminate&&y.terminate()}},0<=d&&(g.size=d,g.originalSize=m),h.onfile(g)),"break"):c?134695760==b?(s=a+=12+(-2==c&&8),o=3,h.c=0,"break"):33639248==b?(s=a-=4,o=3,h.c=0,"break"):void 0:void 0}();++a);if(this.p=Ml,c<0&&(n=o?l.subarray(0,s-12-(-2==c&&8)-(134695760==Wl(l,s-16)&&4)):l.subarray(0,a),i?i.push(n,!!o):this.k[+(2==o)].push(n)),2&o)return this.push(l.subarray(a),t);this.p=l.subarray(a)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();function Zu(e,t,r){var n=r.length-e-1;if(t>=r[n])return n-1;if(t<=r[e])return e;for(var i=e,o=n,a=Math.floor((i+o)/2);t<r[a]||t>=r[a+1];)t<r[a]?o=a:i=a,a=Math.floor((i+o)/2);return a}function Qu(e,t,r,n){for(var i=[],o=[],a=[],s=i[0]=1;s<=r;++s){o[s]=t-n[e+1-s],a[s]=n[e+s]-t;for(var l=0,u=0;u<s;++u){var c=a[u+1],h=o[s-u],p=i[u]/(c+h);i[u]=l+c*p,l=h*p}i[s]=l}return i}function Ku(e,t,r,n,i){for(var o=i<e?i:e,a=[],s=Zu(e,n,t),l=function(e,t,r,n,i){for(var o=[],a=0;a<=r;++a)o[a]=0;for(var s=[],l=0;l<=n;++l)s[l]=o.slice(0);for(var u=[],c=0;c<=r;++c)u[c]=o.slice(0);u[0][0]=1;for(var h=o.slice(0),p=o.slice(0),f=1;f<=r;++f){h[f]=t-i[e+1-f],p[f]=i[e+f]-t;for(var d=0,m=0;m<f;++m){var v=p[m+1],y=h[f-m],g=(u[f][m]=v+y,u[m][f-1]/u[f][m]);u[m][f]=d+v*g,d=y*g}u[f][f]=d}for(var b=0;b<=r;++b)s[0][b]=u[b][r];for(var x=0;x<=r;++x){for(var w=0,S=1,T=[],_=0;_<=r;++_)T[_]=o.slice(0);for(var M=T[0][0]=1;M<=n;++M){var E=0,P=x-M,O=r-M;M<=x&&(T[S][0]=T[w][0]/u[1+O][P],E=T[S][0]*u[P][O]);for(var R=x-1<=O?M-1:r-x,k=-1<=P?1:-P;k<=R;++k)T[S][k]=(T[w][k]-T[w][k-1])/u[1+O][P+k],E+=T[S][k]*u[P+k][O];x<=O&&(T[S][M]=-T[w][M-1]/u[1+O][x],E+=T[S][M]*u[x][O]),s[M][x]=E;var A=w;w=S,S=A}}for(var C=r,L=1;L<=n;++L){for(var D=0;D<=r;++D)s[L][D]*=C;C*=r-L}return s}(s,n,e,o,t),u=[],h=0;h<r.length;++h){var p=r[h].clone(),f=p.w;p.x*=f,p.y*=f,p.z*=f,u[h]=p}for(var d=0;d<=o;++d){for(var m=u[s-e].clone().multiplyScalar(l[d][0]),v=1;v<=e;++v)m.add(u[s-e+v].clone().multiplyScalar(l[d][v]));a[d]=m}for(var y=o+1;y<=i+1;++y)a[y]=new c.Vector4(0,0,0);return a}function Ju(e){for(var t=e.length,r=[],n=[],i=0;i<t;++i){var o=e[i];r[i]=new c.Vector3(o.x,o.y,o.z),n[i]=o.w}for(var a=[],s=0;s<t;++s){for(var l=r[s].clone(),u=1;u<=s;++u)l.sub(a[s-u].clone().multiplyScalar(function(e,t){for(var r=1,n=2;n<=e;++n)r*=n;for(var i=1,o=2;o<=t;++o)i*=o;for(var a=2;a<=e-t;++a)i*=a;return r/i}(s,u)*n[u]));a[s]=l.divideScalar(n[0])}return a}function $u(e){return($u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ec(e,t){return(ec=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tc(e){return(tc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var rc,nc,ic,oc=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ec(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=tc(e);if(r=t?(r=tc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===$u(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(s=r.call(this)).degree=e,s.knots=t,s.controlPoints=[],s.startKnot=o||0,s.endKnot=a||s.knots.length-1;for(var l=0;l<i.length;++l){var u=i[l];s.controlPoints[l]=new c.Vector4(u.x,u.y,u.z,u.w)}return s}return t=n,(e=[{key:"getPoint",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new c.Vector3;return e=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),e=function(e,t,r,n){for(var i=Zu(e,n,t),o=Qu(i,n,e,t),a=new c.Vector4(0,0,0,0),s=0;s<=e;++s){var l=r[i-e+s],u=o[s],h=l.w*u;a.x+=l.x*h,a.y+=l.y*h,a.z+=l.z*h,a.w+=l.w*u}return a}(this.degree,this.knots,this.controlPoints,e),1!==e.w&&e.divideScalar(e.w),t.set(e.x,e.y,e.z)}},{key:"getTangent",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new c.Vector3,r=(e=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),Ju(Ku(r=this.degree,this.knots,this.controlPoints,e,1)));return t.copy(r[1]).normalize(),t}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Curve);function ac(e){return(ac="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function sc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lc(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function uc(e,t,r){t&&lc(e.prototype,t),r&&lc(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function cc(e,t){return(cc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hc(e){return(hc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var pc=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&cc(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=hc(e);if(r=t?(r=hc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ac(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){return sc(this,n),r.call(this,e)}return uc(n,[{key:"load",value:function(e,t,r,n){var i=this,o=""===i.path?c.LoaderUtils.extractUrlBase(e):i.path,a=new c.FileLoader(this.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(r){try{t(i.parse(r,o))}catch(r){n?n(r):console.error(r),i.manager.itemError(e)}}),r,n)}},{key:"parse",value:function(e,t){if(n="Kaydara FBX Binary \0",(r=e).byteLength>=n.length&&n===Rc(r,0,n.length))rc=(new yc).parse(e);else{if(!function(e){for(var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0,n=0;n<t.length;++n)if(function(t){var n=e[0];return e=e.slice(r+1),r++,n}()===t[n])return;return 1}(r=Rc(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(xc(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+xc(r));rc=(new vc).parse(r)}var r,n=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new fc(n,this.manager).parse(rc)}}]),n}(c.Loader),fc=function(){function e(t,r){sc(this,e),this.textureLoader=t,this.manager=r}return uc(e,[{key:"parse",value:function(){nc=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new dc).parse(t);return this.parseScene(t,r,e),ic}},{key:"parseConnections",value:function(){var e=new Map;return"Connections"in rc&&rc.Connections.connections.forEach((function(t){var r=t[0],n=t[1],i=(t=t[2],e.has(r)||e.set(r,{parents:[],children:[]}),{ID:n,relationship:t});e.get(r).parents.push(i),e.has(n)||e.set(n,{parents:[],children:[]}),i={ID:r,relationship:t},e.get(n).children.push(i)})),e}},{key:"parseImages",value:function(){var e,t={},r={};if("Video"in rc.Objects){var n,i=rc.Objects.Video;for(n in i){var o,a,s=i[n];t[parseInt(n)]=s.RelativeFilename||s.Filename,"Content"in s&&(a=s.Content instanceof ArrayBuffer&&0<s.Content.byteLength,o="string"==typeof s.Content&&""!==s.Content,(a||o)&&(a=this.parseImage(i[n]),r[s.RelativeFilename||s.Filename]=a))}}for(e in t){var l=t[e];void 0!==r[l]?t[e]=r[l]:t[e]=t[e].split("\\").pop()}return t}},{key:"parseImage",value:function(e){var t,r=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();switch(i){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}return"string"==typeof r?"data:"+t+";base64,"+r:(e=new Uint8Array(r),window.URL.createObjectURL(new Blob([e],{type:t})))}},{key:"parseTextures",value:function(e){var t=new Map;if("Texture"in rc.Objects){var r,n=rc.Objects.Texture;for(r in n){var i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}},{key:"parseTexture",value:function(e,t){var r=((t=this.loadTexture(e,t)).ID=e.id,t.name=e.attrName,e.WrapModeU),n=e.WrapModeV;return r=void 0!==r?r.value:0,n=void 0!==n?n.value:0,t.wrapS=0===r?c.RepeatWrapping:c.ClampToEdgeWrapping,t.wrapT=0===n?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e&&(r=e.Scaling.value,t.repeat.x=r[0],t.repeat.y=r[1]),"Translation"in e&&(n=e.Translation.value,t.offset.x=n[0],t.offset.y=n[1]),t}},{key:"loadTexture",value:function(e,t){var r,n=this.textureLoader.path,i=nc.get(e.id).children;return i="tga"===(void 0!==i&&0<i.length&&void 0!==t[i[0].ID]&&(0!==(r=t[i[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0)),t=e.FileName.slice(-3).toLowerCase())?null===(i=this.manager.getHandler(".tga"))?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),new c.Texture):(i.setPath(this.textureLoader.path),i.load(r)):"psd"===t?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),new c.Texture):this.textureLoader.load(r),this.textureLoader.setPath(n),i}},{key:"parseMaterials",value:function(e){var t=new Map;if("Material"in rc.Objects){var r,n=rc.Objects.Material;for(r in n){var i=this.parseMaterial(n[r],e);null!==i&&t.set(parseInt(r),i)}}return t}},{key:"parseMaterial",value:function(e,t){var r,n=e.id,i=e.attrName,o=e.ShadingModel;if("object"===ac(o)&&(o=o.value),!nc.has(n))return null;switch(e=this.parseParameters(e,t,n),o.toLowerCase()){case"phong":r=new c.MeshPhongMaterial;break;case"lambert":r=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),r=new c.MeshPhongMaterial}return r.setValues(e),r.name=i,r}},{key:"parseParameters",value:function(e,t,r){var n={},i=(e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new c.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new c.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new c.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new c.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=(new c.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new c.Color).fromArray(e.SpecularColor.value)),this);return nc.get(r).children.forEach((function(e){var r=e.relationship;switch(r){case"Bump":n.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=i.getTexture(t,e.ID),void 0!==n.map&&(n.map.encoding=c.sRGBEncoding);break;case"DisplacementColor":n.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=i.getTexture(t,e.ID),void 0!==n.emissiveMap&&(n.emissiveMap.encoding=c.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=i.getTexture(t,e.ID),void 0!==n.envMap&&(n.envMap.mapping=c.EquirectangularReflectionMapping,n.envMap.encoding=c.sRGBEncoding);break;case"SpecularColor":n.specularMap=i.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.encoding=c.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=i.getTexture(t,e.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}})),n}},{key:"getTexture",value:function(e,t){return"LayeredTexture"in rc.Objects&&t in rc.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=nc.get(t).children[0].ID),e.get(t)}},{key:"parseDeformers",value:function(){var e={},t={};if("Deformer"in rc.Objects){var r,n=rc.Objects.Deformer;for(r in n){var i,o=n[r],a=nc.get(parseInt(r));"Skin"===o.attrType?((i=this.parseSkeleton(a,n)).ID=r,1<a.parents.length&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),i.geometryID=a.parents[0].ID,e[r]=i):"BlendShape"===o.attrType&&((i={id:r}).rawTargets=this.parseMorphTargets(a,n),i.id=r,1<a.parents.length&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=i)}}return{skeletons:e,morphTargets:t}}},{key:"parseSkeleton",value:function(e,t){var r=[];return e.children.forEach((function(e){var n=t[e.ID];"Cluster"===n.attrType&&(e={ID:e.ID,indices:[],weights:[],transformLink:(new c.Matrix4).fromArray(n.TransformLink.a)},"Indexes"in n&&(e.indices=n.Indexes.a,e.weights=n.Weights.a),r.push(e))})),{rawBones:r,bones:[]}}},{key:"parseMorphTargets",value:function(e,t){for(var r=[],n=0;n<e.children.length;n++){var i=e.children[n],o=t[i.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if("BlendShapeChannel"!==o.attrType)return;a.geoID=nc.get(parseInt(i.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,r.push(a)}return r}},{key:"parseScene",value:function(e,t,r){ic=new c.Group;var n=this.parseModels(e.skeletons,t,r),i=rc.Objects.Model,o=this;n.forEach((function(e){var t=i[e.ID];o.setLookAtProperties(e,t),nc.get(e.ID).parents.forEach((function(t){void 0!==(t=n.get(t.ID))&&t.add(e)})),null===e.parent&&ic.add(e)})),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),ic.traverse((function(e){var t;e.userData.transformData&&(e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld),t=Ec(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new mc).parse(),1===ic.children.length&&ic.children[0].isGroup&&(ic.children[0].animations=r,ic=ic.children[0]),ic.animations=r}},{key:"parseModels",value:function(e,t,r){var n,i=new Map,o=rc.Objects.Model;for(n in o){var a=parseInt(n),s=o[n],l=nc.get(a),u=this.buildSkeleton(l,e,a,s.attrName);if(!u){switch(s.attrType){case"Camera":u=this.createCamera(l);break;case"Light":u=this.createLight(l);break;case"Mesh":u=this.createMesh(l,t,r);break;case"NurbsCurve":u=this.createCurve(l,t);break;case"LimbNode":case"Root":u=new c.Bone;break;default:u=new c.Group}u.name=s.attrName?c.PropertyBinding.sanitizeNodeName(s.attrName):"",u.ID=a}this.getTransformData(u,s),i.set(a,u)}return i}},{key:"buildSkeleton",value:function(e,t,r,n){var i=null;return e.parents.forEach((function(e){for(var o in t)!function(o){var a=t[o];a.rawBones.forEach((function(t,o){var s;t.ID===e.ID&&(s=i,(i=new c.Bone).matrixWorld.copy(t.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=r,a.bones[o]=i,null!==s&&i.add(s))}))}(o)})),i}},{key:"createCamera",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=rc.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new c.Object3D;else{var n=0,i=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(n=1),1),o=(void 0!==r.NearPlane&&(i=r.NearPlane.value/1e3),1e3),a=(void 0!==r.FarPlane&&(o=r.FarPlane.value/1e3),window.innerWidth),s=window.innerHeight,l=(void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(a=r.AspectWidth.value,s=r.AspectHeight.value),a/s),u=45,h=(void 0!==r.FieldOfView&&(u=r.FieldOfView.value),r.FocalLength?r.FocalLength.value:null);switch(n){case 0:t=new c.PerspectiveCamera(u,l,i,o),null!==h&&t.setFocalLength(h);break;case 1:t=new c.OrthographicCamera(-a/2,a/2,s/2,-s/2,i,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new c.Object3D}}return t}},{key:"createLight",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=rc.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new c.Object3D;else{e=void 0===r.LightType?0:r.LightType.value;var n=16777215,i=(void 0!==r.Color&&(n=(new c.Color).fromArray(r.Color.value)),void 0===r.Intensity?1:r.Intensity.value/100),o=(void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(i=0),0);switch(void 0!==r.FarAttenuationEnd&&(o=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value),e){case 0:t=new c.PointLight(n,i,o,1);break;case 1:t=new c.DirectionalLight(n,i);break;case 2:var a=Math.PI/3,s=(void 0!==r.InnerAngle&&(a=c.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(s=c.MathUtils.degToRad(r.OuterAngle.value),s=Math.max(s,1)),t=new c.SpotLight(n,i,o,a,s,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(n,i)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t}},{key:"createMesh",value:function(e,t,r){var n,i=null,o=null,a=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),r.has(e.ID)&&a.push(r.get(e.ID))})),1<a.length?o=a:0<a.length?o=a[0]:(o=new c.MeshPhongMaterial({color:13421772}),a.push(o)),"color"in i.attributes&&a.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(n=new c.SkinnedMesh(i,o)).normalizeSkinWeights():n=new c.Mesh(i,o),n}},{key:"createCurve",value:function(e,t){e=e.children.reduce((function(e,r){return t.has(r.ID)?t.get(r.ID):e}),null);var r=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(e,r)}},{key:"getTransformData",value:function(e,t){var r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?Pc(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r}},{key:"setLookAtProperties",value:function(e,t){"LookAtProperty"in t&&nc.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=rc.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),ic.add(e.target)):e.lookAt((new c.Vector3).fromArray(t)))}))}},{key:"bindSkeleton",value:function(e,t,r){var n,i=this.parsePoseNodes();for(n in e)!function(n){var o=e[n];nc.get(parseInt(o.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,nc.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new c.Skeleton(o.bones),i[e.ID])})))}))}(n)}},{key:"parsePoseNodes",value:function(){var e={};if("Pose"in rc.Objects){var t,r,n=rc.Objects.Pose;for(t in n)"BindPose"===n[t].attrType&&0<n[t].NbPoseNodes&&(r=n[t].PoseNode,Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new c.Matrix4).fromArray(t.Matrix.a)})):e[r.Node]=(new c.Matrix4).fromArray(r.Matrix.a))}return e}},{key:"createAmbientLight",value:function(){var e,t,r;"GlobalSettings"in rc&&"AmbientColor"in rc.GlobalSettings&&(r=(t=rc.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new c.Color(r,e,t),ic.add(new c.AmbientLight(r,1))))}}]),e}(),dc=function(){function e(){sc(this,e)}return uc(e,[{key:"parse",value:function(e){var t=new Map;if("Geometry"in rc.Objects){var r,n=rc.Objects.Geometry;for(r in n){var i=nc.get(parseInt(r));i=this.parseGeometry(i,n[r],e),t.set(parseInt(r),i)}}return t}},{key:"parseGeometry",value:function(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}},{key:"parseMeshGeometry",value:function(e,t,r){var n,i=r.skeletons,o=[],a=e.parents.map((function(e){return rc.Objects.Model[e.ID]}));if(0!==a.length)return n=e.children.reduce((function(e,t){return void 0!==i[t.ID]?i[t.ID]:e}),null),e.children.forEach((function(e){void 0!==r.morphTargets[e.ID]&&o.push(r.morphTargets[e.ID])})),e=a[0],a={},"RotationOrder"in e&&(a.eulerOrder=Pc(e.RotationOrder.value)),"InheritType"in e&&(a.inheritType=parseInt(e.InheritType.value)),"GeometricTranslation"in e&&(a.translation=e.GeometricTranslation.value),"GeometricRotation"in e&&(a.rotation=e.GeometricRotation.value),"GeometricScaling"in e&&(a.scale=e.GeometricScaling.value),e=Ec(a),this.genGeometry(t,n,o,e)}},{key:"genGeometry",value:function(e,t,r,n){var i,o,a=new c.BufferGeometry,s=(e.attrName&&(a.name=e.attrName),this.parseGeoNode(e,t)),l=this.genBuffers(s),u=new c.Float32BufferAttribute(l.vertex,3);return u.applyMatrix4(n),a.setAttribute("position",u),0<l.colors.length&&a.setAttribute("color",new c.Float32BufferAttribute(l.colors,3)),t&&(a.setAttribute("skinIndex",new c.Uint16BufferAttribute(l.weightsIndices,4)),a.setAttribute("skinWeight",new c.Float32BufferAttribute(l.vertexWeights,4)),a.FBX_Deformer=t),0<l.normal.length&&(u=(new c.Matrix3).getNormalMatrix(n),(t=new c.Float32BufferAttribute(l.normal,3)).applyNormalMatrix(u),a.setAttribute("normal",t)),l.uvs.forEach((function(e,t){var r="uv"+(t+1).toString();a.setAttribute(r=0===t?"uv":r,new c.Float32BufferAttribute(l.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType&&(i=l.materialIndex[0],o=0,l.materialIndex.forEach((function(e,t){e!==i&&(a.addGroup(o,t-o,i),i=e,o=t)})),0<a.groups.length&&(t=(u=a.groups[a.groups.length-1]).start+u.count)!==l.materialIndex.length&&a.addGroup(t,l.materialIndex.length-t,i),0===a.groups.length&&a.addGroup(0,l.materialIndex.length,l.materialIndex[0])),this.addMorphTargets(a,e,r,n),a}},{key:"parseGeoNode",value:function(e,t){var r={};if(r.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],r.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];for(var n=0;e.LayerElementUV[n];)e.LayerElementUV[n].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[n])),n++}return r.weightTable={},null!==t&&(r.skeleton=t).rawBones.forEach((function(e,t){e.indices.forEach((function(n,i){void 0===r.weightTable[n]&&(r.weightTable[n]=[]),r.weightTable[n].push({id:t,weight:e.weights[i]})}))})),r}},{key:"genBuffers",value:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},r=0,n=0,i=!1,o=[],a=[],s=[],l=[],u=[],c=[],h=this;return e.vertexIndices.forEach((function(p,f){var d,m,v,y,g=!1,b=(p<0&&(p^=-1,g=!0),[]),x=[];if(o.push(3*p,3*p+1,3*p+2),e.color&&(y=Tc(f,r,p,e.color),s.push(y[0],y[1],y[2])),e.skeleton){for(void 0!==e.weightTable[p]&&e.weightTable[p].forEach((function(e){x.push(e.weight),b.push(e.id)})),4<x.length&&(i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0),m=[0,0,0,0],v=[0,0,0,0],x.forEach((function(e,t){var r=e,n=b[t];v.forEach((function(e,t,i){e<r&&(i[t]=r,r=e,i=m[t],m[t]=n,n=i)}))})),b=m,x=v);x.length<4;)x.push(0),b.push(0);for(var w=0;w<4;++w)u.push(x[w]),c.push(b[w])}e.normal&&(y=Tc(f,r,p,e.normal),a.push(y[0],y[1],y[2])),e.material&&"AllSame"!==e.material.mappingType&&(d=Tc(f,r,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=Tc(f,r,p,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),n++,g&&(h.genFace(t,e,o,d,a,s,l,u,c,n),r++,n=0,o=[],a=[],s=[],l=[],u=[],c=[])})),t}},{key:"genFace",value:function(e,t,r,n,i,o,a,s,l,u){for(var c=2;c<u;c++)!function(u){e.vertex.push(t.vertexPositions[r[0]]),e.vertex.push(t.vertexPositions[r[1]]),e.vertex.push(t.vertexPositions[r[2]]),e.vertex.push(t.vertexPositions[r[3*(u-1)]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[r[3*u]]),e.vertex.push(t.vertexPositions[r[3*u+1]]),e.vertex.push(t.vertexPositions[r[3*u+2]]),t.skeleton&&(e.vertexWeights.push(s[0]),e.vertexWeights.push(s[1]),e.vertexWeights.push(s[2]),e.vertexWeights.push(s[3]),e.vertexWeights.push(s[4*(u-1)]),e.vertexWeights.push(s[4*(u-1)+1]),e.vertexWeights.push(s[4*(u-1)+2]),e.vertexWeights.push(s[4*(u-1)+3]),e.vertexWeights.push(s[4*u]),e.vertexWeights.push(s[4*u+1]),e.vertexWeights.push(s[4*u+2]),e.vertexWeights.push(s[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[3*(u-1)]),e.colors.push(o[3*(u-1)+1]),e.colors.push(o[3*(u-1)+2]),e.colors.push(o[3*u]),e.colors.push(o[3*u+1]),e.colors.push(o[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(u-1)]),e.normal.push(i[3*(u-1)+1]),e.normal.push(i[3*(u-1)+2]),e.normal.push(i[3*u]),e.normal.push(i[3*u+1]),e.normal.push(i[3*u+2])),t.uv&&t.uv.forEach((function(t,r){void 0===e.uvs[r]&&(e.uvs[r]=[]),e.uvs[r].push(a[r][0]),e.uvs[r].push(a[r][1]),e.uvs[r].push(a[r][2*(u-1)]),e.uvs[r].push(a[r][2*(u-1)+1]),e.uvs[r].push(a[r][2*u]),e.uvs[r].push(a[r][2*u+1])}))}(c)}},{key:"addMorphTargets",value:function(e,t,r,n){var i;0!==r.length&&(e.morphTargetsRelative=!0,e.morphAttributes.position=[],i=this,r.forEach((function(r){r.rawTargets.forEach((function(r){var o=rc.Objects.Geometry[r.geoID];void 0!==o&&i.genMorphGeometry(e,t,o,n,r.name)}))})))}},{key:"genMorphGeometry",value:function(e,t,r,n,i){t=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[];for(var o=void 0!==r.Vertices?r.Vertices.a:[],a=void 0!==r.Indexes?r.Indexes.a:[],s=3*e.attributes.position.count,l=new Float32Array(s),u=0;u<a.length;u++){var h=3*a[u];l[h]=o[3*u],l[1+h]=o[3*u+1],l[2+h]=o[3*u+2]}s=this.genBuffers({vertexIndices:t,vertexPositions:l}),(t=new c.Float32BufferAttribute(s.vertex,3)).name=i||r.attrName,t.applyMatrix4(n),e.morphAttributes.position.push(t)}},{key:"parseNormals",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=e.Normals.a,i=[];return"IndexToDirect"===r&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:i,mappingType:t,referenceType:r}}},{key:"parseUVs",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=[];return{dataSize:2,buffer:e.UV.a,indices:n="IndexToDirect"===r?e.UVIndex.a:n,mappingType:t,referenceType:r}}},{key:"parseVertexColors",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=[];return{dataSize:4,buffer:e.Colors.a,indices:n="IndexToDirect"===r?e.ColorIndex.a:n,mappingType:t,referenceType:r}}},{key:"parseMaterialIndices",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};for(var n=e.Materials.a,i=[],o=0;o<n.length;++o)i.push(o);return{dataSize:1,buffer:n,indices:i,mappingType:t,referenceType:r}}},{key:"parseNurbsGeometry",value:function(e){if(void 0===oc)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 c.BufferGeometry;var t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;for(var r=t-1,n=(t=e.KnotVector.a,[]),i=e.Points.a,o=0,a=i.length;o<a;o+=4)n.push((new c.Vector4).fromArray(i,o));if("Closed"===e.Form)n.push(n[0]);else if("Periodic"===e.Form)for(var s=r,l=t.length-1-s,u=0;u<r;++u)n.push(n[u]);return e=new oc(r,t,n,s,l).getPoints(12*n.length),(new c.BufferGeometry).setFromPoints(e)}}]),e}(),mc=function(){function e(){sc(this,e)}return uc(e,[{key:"parse",value:function(){var e=[],t=this.parseClips();if(void 0!==t)for(var r in t)r=t[r],r=this.addClip(r),e.push(r);return e}},{key:"parseClips",value:function(){var e;if(void 0!==rc.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}},{key:"parseAnimationCurveNodes",value:function(){var e,t=rc.Objects.AnimationCurveNode,r=new Map;for(e in t){var n=t[e];null!==n.attrName.match(/S|R|T|DeformPercent/)&&(n={id:n.id,attr:n.attrName,curves:{}},r.set(n.id,n))}return r}},{key:"parseAnimationCurves",value:function(e){var t,r=rc.Objects.AnimationCurve;for(t in r){var n,i={id:r[t].id,times:r[t].KeyTime.a.map(wc),values:r[t].KeyValueFloat.a},o=nc.get(i.id);void 0!==o&&(n=o.parents[0].ID,(o=o.parents[0].relationship).match(/X/)?e.get(n).curves.x=i:o.match(/Y/)?e.get(n).curves.y=i:o.match(/Z/)?e.get(n).curves.z=i:o.match(/d|DeformPercent/)&&e.has(n)&&(e.get(n).curves.morph=i))}}},{key:"parseAnimationLayers",value:function(e){var t,r=rc.Objects.AnimationLayer,n=new Map;for(t in r)!function(t){var r=[],i=nc.get(parseInt(t));void 0!==i&&(i.children.forEach((function(t,n){if(e.has(t.ID)){var i=e.get(t.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===r[n]){var o=nc.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==o){var a=rc.Objects.Model[o.toString()];if(void 0===a)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",t);var s={modelName:a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",ID:a.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ic.traverse((function(e){e.ID===a.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new c.Matrix4),"PreRotation"in a&&(s.preRotation=a.PreRotation.value),"PostRotation"in a&&(s.postRotation=a.PostRotation.value),r[n]=s}}r[n]&&(r[n][i.attr]=i)}else void 0!==i.curves.morph&&(void 0===r[n]&&(o=nc.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,t=nc.get(o).parents[0].ID,t=nc.get(t).parents[0].ID,t=nc.get(t).parents[0].ID,t={modelName:(t=rc.Objects.Model[t]).attrName?c.PropertyBinding.sanitizeNodeName(t.attrName):"",morphName:rc.Objects.Deformer[o].attrName},r[n]=t),r[n][i.attr]=i)}})),n.set(parseInt(t),r))}(t);return n}},{key:"parseAnimStacks",value:function(e){var t,r=rc.Objects.AnimationStack,n={};for(t in r){var i=(1<(i=nc.get(parseInt(t)).children).length&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers."),e.get(i[0].ID));n[t]={name:r[t].attrName,layer:i}}return n}},{key:"addClip",value:function(e){var t=[],r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new c.AnimationClip(e.name,-1,t)}},{key:"generateTracks",value:function(e){var t=[],r=new c.Vector3,n=new c.Quaternion,i=new c.Vector3;return e.transform&&e.transform.decompose(r,n,i),r=r.toArray(),n=(new c.Euler).setFromQuaternion(n,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&0<Object.keys(e.T.curves).length&&void 0!==(r=this.generateVectorTrack(e.modelName,e.T.curves,r,"position"))&&t.push(r),void 0!==e.R&&0<Object.keys(e.R.curves).length&&void 0!==(r=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder))&&t.push(r),void 0!==e.S&&0<Object.keys(e.S.curves).length&&void 0!==(n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale"))&&t.push(n),void 0!==e.DeformPercent&&void 0!==(r=this.generateMorphTrack(e))&&t.push(r),t}},{key:"generateVectorTrack",value:function(e,t,r,n){var i=this.getTimesForAllAxes(t);return t=this.getKeyframeTrackValues(i,t,r),new c.VectorKeyframeTrack(e+"."+n,i,t)}},{key:"generateRotationTrack",value:function(e,t,r,n,i,o){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));for(var a=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(a,t,r),l=(void 0!==n&&((n=n.map(c.MathUtils.degToRad)).push(o),n=(new c.Euler).fromArray(n),n=(new c.Quaternion).setFromEuler(n)),void 0!==i&&((i=i.map(c.MathUtils.degToRad)).push(o),i=(new c.Euler).fromArray(i),i=(new c.Quaternion).setFromEuler(i).invert()),new c.Quaternion),u=new c.Euler,h=[],p=0;p<s.length;p+=3)u.set(s[p],s[p+1],s[p+2],o),l.setFromEuler(u),void 0!==n&&l.premultiply(n),void 0!==i&&l.multiply(i),l.toArray(h,p/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",a,h)}},{key:"generateMorphTrack",value:function(e){var t=e.DeformPercent.curves.morph,r=t.values.map((function(e){return e/100})),n=ic.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+n+"]",t.times,r)}},{key:"getTimesForAllAxes",value:function(e){var t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),1<(t=(t=void 0!==e.z?t.concat(e.z.times):t).sort((function(e,t){return e-t}))).length){for(var r=1,n=t[0],i=1;i<t.length;i++){var o=t[i];o!==n&&(n=t[r]=o,r++)}t=t.slice(0,r)}return t}},{key:"getKeyframeTrackValues",value:function(e,t,r){var n=r,i=[],o=-1,a=-1,s=-1;return e.forEach((function(e){t.x&&(o=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),-1!==o?(e=t.x.values[o],i.push(e),n[0]=e):i.push(n[0]),-1!==a?(e=t.y.values[a],i.push(e),n[1]=e):i.push(n[1]),-1!==s?(e=t.z.values[s],i.push(e),n[2]=e):i.push(n[2])})),i}},{key:"interpolateRotations",value:function(e){for(var t=1;t<e.values.length;t++){var r=e.values[t-1],n=e.values[t]-r;if(180<=(i=Math.abs(n))){for(var i,o=n/(i/=180),a=r+o,s=(n=e.times[t-1],(e.times[t]-n)/i),l=n+s,u=[],c=[];l<e.times[t];)u.push(l),l+=s,c.push(a),a+=o;e.times=kc(e.times,t,u),e.values=kc(e.values,t,c)}}}}]),e}(),vc=function(){function e(){sc(this,e)}return uc(e,[{key:"getPrevNode",value:function(){return this.nodeStack[this.currentIndent-2]}},{key:"getCurrentNode",value:function(){return this.nodeStack[this.currentIndent-1]}},{key:"getCurrentProp",value:function(){return this.currentProp}},{key:"pushStack",value:function(e){this.nodeStack.push(e),this.currentIndent+=1}},{key:"popStack",value:function(){this.nodeStack.pop(),--this.currentIndent}},{key:"setCurrentProp",value:function(e,t){this.currentProp=e,this.currentPropName=t}},{key:"parse",value:function(e){this.currentIndent=0,this.allNodes=new bc,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var t=this,r=e.split(/[\r\n]+/);return r.forEach((function(e,n){var i,o=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);o||a||(o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),i=e.match("^\\t{"+(t.currentIndent-1)+"}}"),o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,r[++n]):i?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e))})),this.allNodes}},{key:"parseNodeBegin",value:function(e,t){var r=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=(t=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),{name:r}),i=(t=this.parseNodeAttr(t),this.getCurrentNode());0===this.currentIndent?this.allNodes.add(r,n):r in i?("PoseNode"===r?i.PoseNode.push(n):void 0!==i[r].id&&(i[r]={},i[r][i[r].id]=i[r]),""!==t.id&&(i[r][t.id]=n)):"number"==typeof t.id?(i[r]={},i[r][t.id]=n):"Properties70"!==r&&(i[r]="PoseNode"===r?[n]:n),"number"==typeof t.id&&(n.id=t.id),""!==t.name&&(n.attrName=t.name),""!==t.type&&(n.attrType=t.type),this.pushStack(n)}},{key:"parseNodeAttr",value:function(e){var t=e[0],r=(""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0])),""),n="";return 1<e.length&&(r=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:r,type:n}}},{key:"parseNodeProperty",value:function(e,t,r){var n=t[1].replace(/^"/,"").replace(/"$/,"").trim();if(t=t[2].replace(/^"/,"").replace(/"$/,"").trim(),"Properties70"===("Content"===n&&","===t&&(t=r.replace(/"/g,"").replace(/,$/,"").trim()),r=this.getCurrentNode()).name)this.parseNodeSpecialProperty(e,n,t);else{if("C"===n){e=t.split(",").slice(1);for(var i=parseInt(e[0]),o=(e=parseInt(e[1]),(o=t.split(",").slice(3)).map((function(e){return e.trim().replace(/^"/,"")}))),a=(n="connections",t=[i,e]),s=o,l=0,u=a.length,c=s.length;l<c;l++,u++)a[u]=s[l];void 0===r[n]&&(r[n]=[])}"Node"===n&&(r.id=t),n in r&&Array.isArray(r[n])?r[n].push(t):"a"!==n?r[n]=t:r.a=t,this.setCurrentProp(r,n),"a"===n&&","!==t.slice(-1)&&(r.a=Oc(t))}}},{key:"parseNodePropertyContinued",value:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=Oc(t.a))}},{key:"parseNodeSpecialProperty",value:function(e,t,r){r=r.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}));var n=r[0],i=r[1],o=r[2],a=r[3],s=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":s=parseFloat(s);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":s=Oc(s)}this.getPrevNode()[n]={type:i,type2:o,flag:a,value:s},this.setCurrentProp(this.getPrevNode(),n)}}]),e}(),yc=function(){function e(){sc(this,e)}return uc(e,[{key:"parse",value:function(e){var t=new gc(e),r=(t.skip(23),t.getUint32());if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);for(var n=new bc;!this.endOfContent(t);){var i=this.parseNode(t,r);null!==i&&n.add(i.name,i)}return n}},{key:"endOfContent",value:function(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}},{key:"parseNode",value:function(e,t){var r={},n=7500<=t?e.getUint64():e.getUint32(),i=7500<=t?e.getUint64():e.getUint32(),o=(7500<=t?e.getUint64():e.getUint32(),e.getUint8()),a=e.getString(o);if(0===n)return null;for(var s=[],l=0;l<i;l++)s.push(this.parseProperty(e));o=0<s.length?s[0]:"";var u=1<s.length?s[1]:"",c=2<s.length?s[2]:"";for(r.singleProperty=1===i&&e.getOffset()===n;n>e.getOffset();){var h=this.parseNode(e,t);null!==h&&this.parseSubNode(a,r,h)}return r.propertyList=s,"number"==typeof o&&(r.id=o),""!==u&&(r.attrName=u),""!==c&&(r.attrType=c),""!==a&&(r.name=a),r}},{key:"parseSubNode",value:function(e,t,r){var n,i,o,a,s;!0===r.singleProperty?(i=r.propertyList[0],Array.isArray(i)?(t[r.name]=r).a=i:t[r.name]=i):"Connections"===e&&"C"===r.name?(n=[],r.propertyList.forEach((function(e,t){0!==t&&n.push(e)})),void 0===t.connections&&(t.connections=[]),t.connections.push(n)):"Properties70"===r.name?Object.keys(r).forEach((function(e){t[e]=r[e]})):"Properties70"===e&&"P"===r.name?(i=r.propertyList[0],e=r.propertyList[1],o=r.propertyList[2],a=r.propertyList[3],0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),s="Color"===(e=0===e.indexOf("Lcl ")?e.replace("Lcl ","Lcl_"):e)||"ColorRGB"===e||"Vector"===e||"Vector3D"===e||0===e.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[i]={type:e,type2:o,flag:a,value:s}):void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)}},{key:"parseProperty",value:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var r=e.getUint32(),n=e.getUint32(),o=e.getUint32();if(0===n)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}void 0===i&&console.error("THREE.FBXLoader: External library fflate.min.js required."),n=Su(new Uint8Array(e.getArrayBuffer(o)));var a=new gc(n.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}]),e}(),gc=function(){function e(t,r){sc(this,e),this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===r||r}return uc(e,[{key:"getOffset",value:function(){return this.offset}},{key:"size",value:function(){return this.dv.buffer.byteLength}},{key:"skip",value:function(e){this.offset+=e}},{key:"getBoolean",value:function(){return 1==(1&this.getUint8())}},{key:"getBooleanArray",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getBoolean());return t}},{key:"getUint8",value:function(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e}},{key:"getInt16",value:function(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}},{key:"getInt32",value:function(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getInt32Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getInt32());return t}},{key:"getUint32",value:function(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getInt64",value:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,-(4294967296*(t=4294967295==(e=4294967295&~e)?t+1&4294967295:t)+(e=e+1&4294967295))):4294967296*t+e}},{key:"getInt64Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getInt64());return t}},{key:"getUint64",value:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}},{key:"getFloat32",value:function(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getFloat32Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getFloat32());return t}},{key:"getFloat64",value:function(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}},{key:"getFloat64Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getFloat64());return t}},{key:"getArrayBuffer",value:function(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}},{key:"getString",value:function(e){for(var t=[],r=0;r<e;r++)t[r]=this.getUint8();var n=t.indexOf(0);return 0<=n&&(t=t.slice(0,n)),c.LoaderUtils.decodeText(new Uint8Array(t))}}]),e}(),bc=function(){function e(){sc(this,e)}return uc(e,[{key:"add",value:function(e,t){this[e]=t}}]),e}();function xc(e){if(e=e.match(/FBXVersion: (\d+)/))return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function wc(e){return e/46186158e3}var Sc=[];function Tc(e,t,r,n){var i;switch(n.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=r;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}for(var o=(i="IndexToDirect"===n.referenceType?n.indices[i]:i)*n.dataSize,a=o+n.dataSize,s=Sc,l=n.buffer,u=a,c=o,h=0;c<u;c++,h++)s[h]=l[c];return s}var _c=new c.Euler,Mc=new c.Vector3;function Ec(e){var t=new c.Matrix4,r=new c.Matrix4,n=new c.Matrix4,i=new c.Matrix4,o=new c.Matrix4,a=new c.Matrix4,s=new c.Matrix4,l=new c.Matrix4,u=new c.Matrix4,h=new c.Matrix4,p=new c.Matrix4,f=new c.Matrix4,d=e.inheritType||0,m=(e.translation&&t.setPosition(Mc.fromArray(e.translation)),e.preRotation&&((m=e.preRotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),r.makeRotationFromEuler(_c.fromArray(m))),e.rotation&&((m=e.rotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),n.makeRotationFromEuler(_c.fromArray(m))),e.postRotation&&((m=e.postRotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),i.makeRotationFromEuler(_c.fromArray(m)),i.invert()),e.scale&&o.scale(Mc.fromArray(e.scale)),e.scalingOffset&&s.setPosition(Mc.fromArray(e.scalingOffset)),e.scalingPivot&&a.setPosition(Mc.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(Mc.fromArray(e.rotationOffset)),e.rotationPivot&&u.setPosition(Mc.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),h.copy(e.parentMatrixWorld)),r.clone().multiply(n).multiply(i)),v=(((e=new c.Matrix4).extractRotation(h),v=new c.Matrix4).copyPosition(h),v.clone().invert().multiply(h)),y=(v=e.clone().invert().multiply(v),o),g=new c.Matrix4;return 0===d?g.copy(e).multiply(m).multiply(v).multiply(y):1===d?g.copy(e).multiply(v).multiply(m).multiply(y):(d=(new c.Matrix4).scale((new c.Vector3).setFromMatrixScale(p)).clone().invert(),p=v.clone().multiply(d),g.copy(e).multiply(m).multiply(p).multiply(y)),v=u.clone().invert(),d=a.clone().invert(),e=t.clone().multiply(l).multiply(u).multiply(r).multiply(n).multiply(i).multiply(v).multiply(s).multiply(a).multiply(o).multiply(d),m=(new c.Matrix4).copyPosition(e),p=h.clone().multiply(m),f.copyPosition(p),(e=f.clone().multiply(g)).premultiply(h.invert()),e}function Pc(e){var t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function Oc(e){return e.split(",").map((function(e){return parseFloat(e)}))}function Rc(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),c.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function kc(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}function Ac(e){return(Ac="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Cc(e,t){return(Cc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Lc(e){return(Lc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Dc=/^[og]\s*(.+)?/,Ic=/^mtllib /,jc=/^usemtl /,Uc=/^usemap /,Bc=new c.Vector3,zc=new c.Vector3,Nc=new c.Vector3,Fc=new c.Vector3,Vc=new c.Vector3,Hc=new c.Color;function Gc(){var e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);return r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1),e={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&0<t.length?t[t.length-1]:"",smooth:(void 0!==r?r:this).smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){return(e={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1}).clone=this.clone.bind(e),e}},this.materials.push(e),e},currentMaterial:function(){if(0<this.materials.length)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&1<this.materials.length)for(var r=this.materials.length-1;0<=r;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone&&((e=r.clone(0)).inherited=!0,this.object.materials.push(e)),this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){return 3*(0<=(e=parseInt(e,10))?e-1:e+t/3)},parseNormalIndex:function(e,t){return 3*(0<=(e=parseInt(e,10))?e-1:e+t/3)},parseUVIndex:function(e,t){return 2*(0<=(e=parseInt(e,10))?e-1:e+t/2)},addVertex:function(e,t,r){var n=this.vertices,i=this.object.geometry.vertices;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[r+0],n[r+1],n[r+2])},addVertexPoint:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,r){var n=this.normals,i=this.object.geometry.normals;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[r+0],n[r+1],n[r+2])},addFaceNormal:function(e,t,r){var n=this.vertices,i=this.object.geometry.normals;Bc.fromArray(n,e),zc.fromArray(n,t),Nc.fromArray(n,r),Vc.subVectors(Nc,zc),Fc.subVectors(Bc,zc),Vc.cross(Fc),Vc.normalize(),i.push(Vc.x,Vc.y,Vc.z),i.push(Vc.x,Vc.y,Vc.z),i.push(Vc.x,Vc.y,Vc.z)},addColor:function(e,t,r){var n=this.colors,i=this.object.geometry.colors;void 0!==n[e]&&i.push(n[e+0],n[e+1],n[e+2]),void 0!==n[t]&&i.push(n[t+0],n[t+1],n[t+2]),void 0!==n[r]&&i.push(n[r+0],n[r+1],n[r+2])},addUV:function(e,t,r){var n=this.uvs,i=this.object.geometry.uvs;i.push(n[e+0],n[e+1]),i.push(n[t+0],n[t+1]),i.push(n[r+0],n[r+1])},addDefaultUV:function(){var e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){var t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,r,n,i,o,a,s,l){var u=this.vertices.length;e=this.parseVertexIndex(e,u),t=this.parseVertexIndex(t,u),r=this.parseVertexIndex(r,u),this.addVertex(e,t,r),this.addColor(e,t,r),void 0!==a&&""!==a?(u=this.normals.length,e=this.parseNormalIndex(a,u),t=this.parseNormalIndex(s,u),r=this.parseNormalIndex(l,u),this.addNormal(e,t,r)):this.addFaceNormal(e,t,r),void 0!==n&&""!==n?(a=this.uvs.length,e=this.parseUVIndex(n,a),t=this.parseUVIndex(i,a),r=this.parseUVIndex(o,a),this.addUV(e,t,r),this.object.geometry.hasUVIndices=!0):this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";for(var t=this.vertices.length,r=0,n=e.length;r<n;r++){var i=this.parseVertexIndex(e[r],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,n=this.uvs.length,i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],r));for(var a=0,s=t.length;a<s;a++)this.addUVLine(this.parseUVIndex(t[a],n))}};return e.startObject("",!1),e}var Wc=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Cc(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Lc(e);if(r=t?(r=Lc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ac(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return(e=r.call(this,e)).materials=null,e;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"load",value:function(e,t,r,n){var i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(r){try{t(i.parse(r))}catch(r){n?n(r):console.error(r),i.manager.itemError(e)}}),r,n)}},{key:"setMaterials",value:function(e){return this.materials=e,this}},{key:"parse",value:function(e){for(var t,r,n,i=new Gc,o=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n"),a="",s=[],l="function"==typeof"".trimLeft,u=0,h=o.length;u<h;u++)if(a=o[u],0!==(a=l?a.trimLeft():a.trim()).length&&"#"!==(t=a.charAt(0)))if("v"===t){var p=a.split(/\s+/);switch(p[0]){case"v":i.vertices.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),7<=p.length?(Hc.setRGB(parseFloat(p[4]),parseFloat(p[5]),parseFloat(p[6])).convertSRGBToLinear(),i.colors.push(Hc.r,Hc.g,Hc.b)):i.colors.push(void 0,void 0,void 0);break;case"vn":i.normals.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));break;case"vt":i.uvs.push(parseFloat(p[1]),parseFloat(p[2]))}}else if("f"===t){for(var f=a.slice(1).trim().split(/\s+/),d=[],m=0,v=f.length;m<v;m++){var y=f[m];0<y.length&&(y=y.split("/"),d.push(y))}for(var g=d[0],b=1,x=d.length-1;b<x;b++){var w=d[b],S=d[b+1];i.addFace(g[0],w[0],S[0],g[1],w[1],S[1],g[2],w[2],S[2])}}else if("l"===t){var T=a.substring(1).trim().split(" "),_=[],M=[];if(-1===a.indexOf("/"))_=T;else for(var E=0,P=T.length;E<P;E++){var O=T[E].split("/");""!==O[0]&&_.push(O[0]),""!==O[1]&&M.push(O[1])}i.addLineGeometry(_,M)}else"p"===t?(r=a.slice(1).trim().split(" "),i.addPointGeometry(r)):null!==(s=Dc.exec(a))?(r=(" "+s[0].slice(1).trim()).slice(1),i.startObject(r)):jc.test(a)?i.object.startMaterial(a.substring(7).trim(),i.materialLibraries):Ic.test(a)?i.materialLibraries.push(a.substring(7).trim()):Uc.test(a)?console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.'):"s"===t?(1<(s=a.split(" ")).length?(n=s[1].trim().toLowerCase(),i.object.smooth="0"!==n&&"off"!==n):i.object.smooth=!0,(n=i.object.currentMaterial())&&(n.smooth=i.object.smooth)):"\0"!==a&&console.warn('THREE.OBJLoader: Unexpected line: "'+a+'"');i.finalize();var R,k=new c.Group;if(1==(k.materialLibraries=[].concat(i.materialLibraries),e=!(1===i.objects.length&&0===i.objects[0].geometry.vertices.length)))for(var A=0,C=i.objects.length;A<C;A++){var L=i.objects[A],D=L.geometry,I=L.materials,j="Line"===D.type,U="Points"===D.type,B=!1;if(0!==D.vertices.length){for(var z=new c.BufferGeometry,N=(z.setAttribute("position",new c.Float32BufferAttribute(D.vertices,3)),0<D.normals.length&&z.setAttribute("normal",new c.Float32BufferAttribute(D.normals,3)),0<D.colors.length&&(B=!0,z.setAttribute("color",new c.Float32BufferAttribute(D.colors,3))),!0===D.hasUVIndices&&z.setAttribute("uv",new c.Float32BufferAttribute(D.uvs,2)),[]),F=0,V=I.length;F<V;F++){var H,G=I[F],W=G.name+"_"+G.smooth+"_"+B,X=i.materials[W];null!==this.materials&&(X=this.materials.create(G.name),!j||!X||X instanceof c.LineBasicMaterial?!U||!X||X instanceof c.PointsMaterial||(H=new c.PointsMaterial({size:10,sizeAttenuation:!1}),c.Material.prototype.copy.call(H,X),H.color.copy(X.color),H.map=X.map,X=H):(H=new c.LineBasicMaterial,c.Material.prototype.copy.call(H,X),H.color.copy(X.color),X=H)),void 0===X&&((X=j?new c.LineBasicMaterial:U?new c.PointsMaterial({size:1,sizeAttenuation:!1}):new c.MeshPhongMaterial).name=G.name,X.flatShading=!G.smooth,X.vertexColors=B,i.materials[W]=X),N.push(X)}if(D=void 0,1<N.length){for(var q=0,Y=I.length;q<Y;q++){var Z=I[q];z.addGroup(Z.groupStart,Z.groupCount,q)}D=new(j?c.LineSegments:U?c.Points:c.Mesh)(z,N)}else D=new(j?c.LineSegments:U?c.Points:c.Mesh)(z,N[0]);D.name=L.name,k.add(D)}}else 0<i.vertices.length&&(e=new c.PointsMaterial({size:1,sizeAttenuation:!1}),(R=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute(i.vertices,3)),0<i.colors.length&&void 0!==i.colors[0]&&(R.setAttribute("color",new c.Float32BufferAttribute(i.colors,3)),e.vertexColors=!0),R=new c.Points(R,e),k.add(R));return k}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Loader),Xc=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class qc{constructor(e){this.parses={fbx:new pc,obj:new Wc,object:new c.ObjectLoader},this.runScene=e}getBack(e){return e.name.substring(e.name.lastIndexOf(".")+1).toLowerCase()}parse(e){if(e instanceof Array)return e.map((e=>this.parse(e)));if(-1!==e.type.indexOf("image"))return this.img(e);let t;switch(this.getBack(e).toLowerCase()){case"gltf":case"glb":t=this.glb(e);break;case"fbx":t=this.fbx(e);break;case"obj":t=this.obj(e);break;case"json":t=this.json(e)}return t}img(e){console.log(e,"file")}glb(e){return Xc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"arrayBuffer");return this.runScene.loaderer.gltf.parse(t)}))}fbx(e){return Xc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"arrayBuffer");const r=this.parses.fbx.parse(t,"");r.traverse((e=>{e.material&&(e.material=this.runScene.materialEx.create())})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}obj(e){return Xc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"text");const r=this.parses.obj.parse(t);r.traverse((e=>{e.material&&(e.material=this.runScene.materialEx.create())})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}json(e){return Xc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"text");const r=yield this.parses.object.parseAsync(JSON.parse(t));r.traverse((e=>{this.runScene.uniqueEx.material.add(e.material)})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}}function Yc(e){return(Yc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Zc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qc(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Kc(e,t,r){t&&Qc(e.prototype,t),r&&Qc(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function Jc(){return(Jc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=nh(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function $c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&eh(e,t)}function eh(e,t){return(eh=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function th(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=nh(e);if(r=t?(r=nh(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Yc(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return rh(n)}}function rh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function nh(e){return(nh=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ih=new c.Raycaster,oh=new c.Vector3,ah=new c.Vector3,sh=new c.Quaternion,lh={X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)},uh={type:"change"},ch={type:"mouseDown"},hh={type:"mouseUp",mode:null},ph={type:"objectChange"};function fh(e,t,r){for(var n=t.intersectObject(e,!0),i=0;i<n.length;i++)if(n[i].object.visible||r)return n[i];return!1}bs=function(){$c(t,c.Object3D);var e=th(t);function t(r,n){Zc(this,t),i=e.call(this),void 0===n&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),n=document),i.visible=!1,i.domElement=n,i.domElement.style.touchAction="none";var i,o=new Oh,a=(i._gizmo=o,i.add(o),new Rh),s=(i._plane=a,i.add(a),rh(i));function l(e,t){var r=t;Object.defineProperty(s,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,a[e]=t,o[e]=t,s.dispatchEvent({type:e+"-changed",value:t}),s.dispatchEvent(uh))}}),s[e]=t,a[e]=t,o[e]=t}l("camera",r),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),n=new c.Vector3,r=new c.Vector3;var u=new c.Quaternion,h=new c.Quaternion,p=new c.Vector3,f=new c.Quaternion,d=new c.Vector3,m=new c.Vector3,v=new c.Vector3,y=new c.Vector3;return l("worldPosition",n),l("worldPositionStart",r),l("worldQuaternion",u),l("worldQuaternionStart",h),l("cameraPosition",p),l("cameraQuaternion",f),l("pointStart",d),l("pointEnd",m),l("rotationAxis",v),l("rotationAngle",0),l("eye",y),i._offset=new c.Vector3,i._startNorm=new c.Vector3,i._endNorm=new c.Vector3,i._cameraScale=new c.Vector3,i._parentPosition=new c.Vector3,i._parentQuaternion=new c.Quaternion,i._parentQuaternionInv=new c.Quaternion,i._parentScale=new c.Vector3,i._worldScaleStart=new c.Vector3,i._worldQuaternionInv=new c.Quaternion,i._worldScale=new c.Vector3,i._positionStart=new c.Vector3,i._quaternionStart=new c.Quaternion,i._scaleStart=new c.Vector3,i._getPointer=function(e){var t;return this.domElement.ownerDocument.pointerLockElement?{x:0,y:0,button:e.button}:(t=this.domElement.getBoundingClientRect(),{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button})}.bind(rh(i)),i._onPointerDown=function(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}.bind(rh(i)),i._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(rh(i)),i._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(rh(i)),i._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(rh(i)),i.domElement.addEventListener("pointerdown",i._onPointerDown),i.domElement.addEventListener("pointermove",i._onPointerHover),i.domElement.addEventListener("pointerup",i._onPointerUp),i}return Kc(t,[{key:"updateMatrixWorld",value:function(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),Jc(nh(t.prototype),"updateMatrixWorld",this).call(this,this)}},{key:"pointerHover",value:function(e){void 0!==this.object&&!0!==this.dragging&&(ih.setFromCamera(e,this.camera),e=fh(this._gizmo.picker[this.mode],ih),this.axis=e?e.object.name:null)}},{key:"pointerDown",value:function(e){void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis&&(ih.setFromCamera(e,this.camera),(e=fh(this._plane,ih,!0))&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,ch.mode=this.mode,this.dispatchEvent(ch))}},{key:"pointerMove",value:function(e){var t=this.axis,r=this.mode,n=this.object,i=this.space;"scale"===r?i="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(i="world"),void 0!==n&&null!==t&&!1!==this.dragging&&-1===e.button&&(ih.setFromCamera(e,this.camera),(e=fh(this._plane,ih,!0))&&(this.pointEnd.copy(e.point).sub(this.worldPositionStart),"translate"===r?(this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===i&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),("local"===i&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart):this._offset.applyQuaternion(this._parentQuaternionInv)).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===i&&(n.position.applyQuaternion(sh.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===i&&(n.parent&&n.position.add(oh.setFromMatrixPosition(n.parent.matrixWorld)),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(oh.setFromMatrixPosition(n.parent.matrixWorld))))):"scale"===r?(-1!==t.search("XYZ")?(e=this.pointEnd.length()/this.pointStart.length(),this.pointEnd.dot(this.pointStart)<0&&(e*=-1),ah.set(e,e,e)):(oh.copy(this.pointStart),ah.copy(this.pointEnd),oh.applyQuaternion(this._worldQuaternionInv),ah.applyQuaternion(this._worldQuaternionInv),ah.divide(oh),-1===t.search("X")&&(ah.x=1),-1===t.search("Y")&&(ah.y=1),-1===t.search("Z")&&(ah.z=1)),n.scale.copy(this._scaleStart).multiply(ah),this.scaleSnap&&(-1!==t.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))):"rotate"===r&&(this._offset.copy(this.pointEnd).sub(this.pointStart),e=20/this.worldPosition.distanceTo(oh.setFromMatrixPosition(this.camera.matrixWorld)),"E"===t?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(oh.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(lh[t]),oh.copy(lh[t]),"local"===i&&oh.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(oh.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===i&&"E"!==t&&"XYZE"!==t?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(sh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(sh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())),this.dispatchEvent(uh),this.dispatchEvent(ph)))}},{key:"pointerUp",value:function(e){0===e.button&&(this.dragging&&null!==this.axis&&(hh.mode=this.mode,this.dispatchEvent(hh)),this.dragging=!1,this.axis=null)}},{key:"dispose",value:function(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}},{key:"attach",value:function(e){return this.object=e,this.visible=!0,this}},{key:"detach",value:function(){return this.object=void 0,this.visible=!1,this.axis=null,this}},{key:"reset",value:function(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(uh),this.dispatchEvent(ph),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return ih}},{key:"getMode",value:function(){return this.mode}},{key:"setMode",value:function(e){this.mode=e}},{key:"setTranslationSnap",value:function(e){this.translationSnap=e}},{key:"setRotationSnap",value:function(e){this.rotationSnap=e}},{key:"setScaleSnap",value:function(e){this.scaleSnap=e}},{key:"setSize",value:function(e){this.size=e}},{key:"setSpace",value:function(e){this.space=e}},{key:"update",value:function(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}]),t}(),bs.prototype.isTransformControls=!0;var dh=new c.Euler,mh=new c.Vector3(0,1,0),vh=new c.Vector3(0,0,0),yh=new c.Matrix4,gh=new c.Quaternion,bh=new c.Quaternion,xh=new c.Vector3,wh=new c.Matrix4,Sh=new c.Vector3(1,0,0),Th=new c.Vector3(0,1,0),_h=new c.Vector3(0,0,1),Mh=new c.Vector3,Eh=new c.Vector3,Ph=new c.Vector3,Oh=function(){$c(t,c.Object3D);var e=th(t);function t(){Zc(this,t),(r=e.call(this)).type="TransformControlsGizmo";var r,n=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=n.clone(),a=((((o.opacity=.15,i=i.clone()).opacity=.5,x=n.clone()).color.setHex(16711680),w=n.clone()).color.setHex(65280),n.clone()),s=(a.color.setHex(255),n.clone()),l=(s.color.setHex(16711680),s.opacity=.5,n.clone()),u=(l.color.setHex(65280),l.opacity=.5,n.clone()),h=(u.color.setHex(255),u.opacity=.5,n.clone());(h.opacity=.25,g=n.clone()).color.setHex(16776960),g.opacity=.25,n.clone().color.setHex(16776960);var p=(((n=n.clone()).color.setHex(7895160),m=new c.CylinderGeometry(0,.04,.1,12)).translate(0,.05,0),new c.BoxGeometry(.08,.08,.08)),f=(p.translate(0,.04,0),new c.BufferGeometry);function d(e,t){return(e=new c.TorusGeometry(e,.0075,3,64,t*Math.PI*2)).rotateY(Math.PI/2),e.rotateX(Math.PI/2),e}(f.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3)),S=new c.CylinderGeometry(.0075,.0075,.5,3)).translate(0,.25,0);var m={X:[[new c.Mesh(m,x),[.5,0,0],[0,0,-Math.PI/2]],[new c.Mesh(m,x),[-.5,0,0],[0,0,Math.PI/2]],[new c.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(m,w),[0,.5,0]],[new c.Mesh(m,w),[0,-.5,0],[Math.PI,0,0]],[new c.Mesh(S,w)]],Z:[[new c.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new c.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new c.Mesh(S,a),null,[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),h.clone()),[0,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),s.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),o)]],XY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]]},y={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new c.Line(((y=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),y),i),null,null,null,"helper"]],X:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},g=(n={XYZE:[[new c.Mesh(d(.5,1),n),null,[0,Math.PI/2,0]]],X:[[new c.Mesh(d(.5,.5),x)]],Y:[[new c.Mesh(d(.5,.5),w),null,[0,0,-Math.PI/2]]],Z:[[new c.Mesh(d(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new c.Mesh(d(.75,1),g),null,[0,Math.PI/2,0]]]},{AXIS:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]}),b={XYZE:[[new c.Mesh(new c.SphereGeometry(.25,10,8),o)]],X:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(.75,.1,2,24),o)]]},x={X:[[new c.Mesh(p,x),[.5,0,0],[0,0,-Math.PI/2]],[new c.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]],[new c.Mesh(p,x),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(p,w),[0,.5,0]],[new c.Mesh(S,w)],[new c.Mesh(p,w),[0,-.5,0],[0,0,Math.PI]]],Z:[[new c.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new c.Mesh(S,a),[0,0,0],[Math.PI/2,0,0]],[new c.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.BoxGeometry(.1,.1,.1),h.clone())]]},w={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),o),[0,0,0]]]},S={X:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(e){var t,r=new c.Object3D;for(t in e)for(var n=e[t].length;n--;){var i=e[t][n][0].clone(),o=e[t][n][1],a=e[t][n][2],s=e[t][n][3],l=e[t][n][4];(i.name=t,i.tag=l,o&&i.position.set(o[0],o[1],o[2]),a&&i.rotation.set(a[0],a[1],a[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix(),l=i.geometry.clone()).applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),r.add(i)}return r}return r.gizmo={},r.picker={},r.helper={},r.add(r.gizmo.translate=T(m)),r.add(r.gizmo.rotate=T(n)),r.add(r.gizmo.scale=T(x)),r.add(r.picker.translate=T(v)),r.add(r.picker.rotate=T(b)),r.add(r.picker.scale=T(w)),r.add(r.helper.translate=T(y)),r.add(r.helper.rotate=T(g)),r.add(r.helper.scale=T(S)),r.picker.translate.visible=!1,r.picker.rotate.visible=!1,r.picker.scale.visible=!1,r}return Kc(t,[{key:"updateMatrixWorld",value:function(e){var r=this,n="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:bh,i=(this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode,[]);i=(i=(i=i.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(var o=0;o<i.length;o++)!function(e){var t=i[e];if(t.visible=!0,t.rotation.set(0,0,0),e=void t.position.copy(r.worldPosition),e=r.camera.isOrthographicCamera?(r.camera.top-r.camera.bottom)/r.camera.zoom:r.worldPosition.distanceTo(r.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*r.camera.fov/360)/r.camera.zoom,7),t.scale.set(1,1,1).multiplyScalar(e*r.size/4),"helper"===t.tag)return t.visible=!1,"AXIS"===t.name?(t.position.copy(r.worldPositionStart),t.visible=!!r.axis,"X"===r.axis&&(sh.setFromEuler(dh.set(0,0,0)),t.quaternion.copy(n).multiply(sh),.9<Math.abs(mh.copy(Sh).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Y"===r.axis&&(sh.setFromEuler(dh.set(0,0,Math.PI/2)),t.quaternion.copy(n).multiply(sh),.9<Math.abs(mh.copy(Th).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Z"===r.axis&&(sh.setFromEuler(dh.set(0,Math.PI/2,0)),t.quaternion.copy(n).multiply(sh),.9<Math.abs(mh.copy(_h).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"XYZE"===r.axis&&(sh.setFromEuler(dh.set(0,Math.PI/2,0)),mh.copy(r.rotationAxis),t.quaternion.setFromRotationMatrix(yh.lookAt(vh,mh,Th)),t.quaternion.multiply(sh),t.visible=r.dragging),"E"===r.axis&&(t.visible=!1)):"START"===t.name?(t.position.copy(r.worldPositionStart),t.visible=r.dragging):"END"===t.name?(t.position.copy(r.worldPosition),t.visible=r.dragging):"DELTA"===t.name?(t.position.copy(r.worldPositionStart),t.quaternion.copy(r.worldQuaternionStart),oh.set(1e-10,1e-10,1e-10).add(r.worldPositionStart).sub(r.worldPosition).multiplyScalar(-1),oh.applyQuaternion(r.worldQuaternionStart.clone().invert()),t.scale.copy(oh),t.visible=r.dragging):(t.quaternion.copy(n),r.dragging?t.position.copy(r.worldPositionStart):t.position.copy(r.worldPosition),r.axis&&(t.visible=-1!==r.axis.search(t.name)));t.quaternion.copy(n),"translate"===r.mode||"scale"===r.mode?("X"===t.name&&.99<Math.abs(mh.copy(Sh).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Y"===t.name&&.99<Math.abs(mh.copy(Th).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Z"===t.name&&.99<Math.abs(mh.copy(_h).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XY"===t.name&&Math.abs(mh.copy(_h).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"YZ"===t.name&&Math.abs(mh.copy(Sh).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XZ"===t.name&&Math.abs(mh.copy(Th).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1)):"rotate"===r.mode&&(gh.copy(n),mh.copy(r.eye).applyQuaternion(sh.copy(n).invert()),-1!==t.name.search("E")&&t.quaternion.setFromRotationMatrix(yh.lookAt(r.eye,vh,Th)),"X"===t.name&&(sh.setFromAxisAngle(Sh,Math.atan2(-mh.y,mh.z)),sh.multiplyQuaternions(gh,sh),t.quaternion.copy(sh)),"Y"===t.name&&(sh.setFromAxisAngle(Th,Math.atan2(mh.x,mh.z)),sh.multiplyQuaternions(gh,sh),t.quaternion.copy(sh)),"Z"===t.name&&(sh.setFromAxisAngle(_h,Math.atan2(mh.y,mh.x)),sh.multiplyQuaternions(gh,sh),t.quaternion.copy(sh))),t.visible=t.visible&&(-1===t.name.indexOf("X")||r.showX),t.visible=t.visible&&(-1===t.name.indexOf("Y")||r.showY),t.visible=t.visible&&(-1===t.name.indexOf("Z")||r.showZ),t.visible=t.visible&&(-1===t.name.indexOf("E")||r.showX&&r.showY&&r.showZ),t.material._color=t.material._color||t.material.color.clone(),t.material._opacity=t.material._opacity||t.material.opacity,t.material.color.copy(t.material._color),t.material.opacity=t.material._opacity,r.enabled&&r.axis&&(t.name===r.axis||r.axis.split("").some((function(e){return t.name===e})))&&(t.material.color.setHex(16776960),t.material.opacity=1)}(o);Jc(nh(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}(),Rh=(Oh.prototype.isTransformControlsGizmo=!0,function(){$c(t,c.Mesh);var e=th(t);function t(){var r;return Zc(this,t),(r=e.call(this,new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1}))).type="TransformControlsPlane",r}return Kc(t,[{key:"updateMatrixWorld",value:function(e){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),Mh.copy(Sh).applyQuaternion("local"===r?this.worldQuaternion:bh),Eh.copy(Th).applyQuaternion("local"===r?this.worldQuaternion:bh),Ph.copy(_h).applyQuaternion("local"===r?this.worldQuaternion:bh),mh.copy(Eh),this.mode){case"translate":case"scale":switch(this.axis){case"X":mh.copy(this.eye).cross(Mh),xh.copy(Mh).cross(mh);break;case"Y":mh.copy(this.eye).cross(Eh),xh.copy(Eh).cross(mh);break;case"Z":mh.copy(this.eye).cross(Ph),xh.copy(Ph).cross(mh);break;case"XY":xh.copy(Ph);break;case"YZ":xh.copy(Mh);break;case"XZ":mh.copy(Ph),xh.copy(Eh);break;case"XYZ":case"E":xh.set(0,0,0)}break;default:xh.set(0,0,0)}0===xh.length()?this.quaternion.copy(this.cameraQuaternion):(wh.lookAt(oh.set(0,0,0),xh,mh),this.quaternion.setFromRotationMatrix(wh)),Jc(nh(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}());Rh.prototype.isTransformControlsPlane=!0;class kh extends bs{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new c.Vector3,this.beginScale=new c.Vector3,this.posStart=new c.Vector2,this.posEnd=new c.Vector2,this.deleteRedundantParts()}deleteRedundantParts(){this.transGizmo.gizmo.translate.children.splice(1,1),this.transGizmo.gizmo.translate.children.splice(3,1),this.transGizmo.gizmo.translate.children.splice(5,1),this.transGizmo.gizmo.scale.children.splice(0,1),this.transGizmo.gizmo.scale.children.splice(2,1),this.transGizmo.gizmo.scale.children.splice(4,1)}pointerDown(e){void 0===this.object||null===this.axis||this.dragging||0!==e.button||(this.posStart.set(e.x,e.y),this.beginScale.set(this.object.scale.x,this.object.scale.y,this.object.scale.z),super.pointerDown(e))}pointerMove(e){if(super.pointerMove(e),void 0!==this.object&&null!==this.axis&&this.dragging&&-1===e.button&&"scale"===this.mode&&-1!==this.axis.search("XYZ")){this.posEnd.set(e.x,e.y),e=(Math.abs(this.beginScale.x)+Math.abs(this.beginScale.y)+Math.abs(this.beginScale.z))/3;let t=12*this.pointStart.distanceTo(this.pointEnd)/e;this.posEnd.x>this.posStart.x&&(t*=-1),(t=-1.1<t&&t<1.1?1:t)<0&&(t=-1.1/t),this.scaleCoefficient.set(t,t,t),this.object.scale.copy(this._scaleStart).multiply(this.scaleCoefficient)}}}class Ah{constructor(e){this.grid=null,this.transContro=null,this.boxHelper=null,this.deepIsHelper=e=>"Scene"===e.type||!this.isHelper(e)&&!!e.parent&&this.deepIsHelper(e.parent),this.getBoxHelper=e=>(e=new c.BoxHelper(e),this.setHelper(e),this.runScene.assetsEx.get().scene.add(e),e),this.runScene=e,"running"!==this.runScene.optionsEx.options.mode&&(this.transContro=new class{constructor(e){this.tansControls=null,this.controlsMode="position",this.isDraggingChange=!1,this.modelNewVal=new vi.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new vi.Vector3,this.draggingChanged=e=>{const t=this.runScene.assetsEx.get().controls;var r=this.controlsMode;let n=this.runScene.modelEx.select;if(e.value){if(!this.runScene.multipSelector.isEmpty()){t.enabled=!1;const e=this.runScene.multipSelector.getLast();this.multipSelectLast=e,this.worldOldVal=Mo(e,this.runScene.sceneEx.get())}}else if(!t.enabled&&!this.runScene.multipSelector.isEmpty()&&this.multipSelectLast){const e=this.multipSelectLast;this.multipObj=e,this.runScene.events.mouse.enableUp=!1,this.runScene.helperEx.boxHelper.setFromObject(this.runScene.assetsEx.get().scene);var i=Mo(e,this.runScene.sceneEx.get());this.runScene.multipSelector.setInfo(e,r,this.modelNewVal,e[r],i,this.worldOldVal),this.runScene.modelEx.selectNull(),this.multipSelectLast=void 0}if(this.runScene.multipSelector.isEmpty()?this.runScene.events.mouse.enableUp=!0:this.runScene.events.mouse.enableUp=!1,!n){if(this.runScene.multipSelector.isEmpty())return;n=this.runScene.multipSelector.getLast()}t.enabled?(this.modelNewVal=this.runScene.modelEx.cloneV3(n[r]),this.isDraggingChange=!0,this.worldOldVal=Mo(n,this.runScene.sceneEx.get())):(this.runScene.multipSelector.isEmpty()?this.runScene.modelEx.setV3({model:n,info:r,newV3:this.runScene.modelEx.cloneV3(n[r]),oldV3:this.modelNewVal},!0,!1):(this.multipObj=n,this.runScene.events.mouse.enableUp=!1,this.runScene.helperEx.boxHelper.setFromObject(this.runScene.assetsEx.get().scene),i=Mo(n,this.runScene.sceneEx.get()),this.runScene.multipSelector.setInfo(n,r,this.modelNewVal,n[r],i,this.worldOldVal)),this.isDraggingChange=!1),this.runScene.assetsEx.get().controls.enabled=!e.value},this.runScene=e}init(){const{camera:e,renderer:t,scene:r}=this.runScene.assetsEx;this.tansControls=new kh(e,t.domElement),this.tansControls.addEventListener("dragging-changed",this.draggingChanged),this.tansControls.addEventListener("change",this.transChangeFn.bind(this)),this.tansControls.name="helper",r.add(this.tansControls),this.tansControls.traverse((e=>e.isHelper=!0))}changeMode(e){this.controlsMode=e,this.tansControls.setMode(this.transControlsStatusMap[e])}transControSize(e){this.tansControls.setSize(e?this.tansControls.size+.1:Math.max(this.tansControls.size-.1,.1))}changeState(e){this.tansControls.enabled=e}addObject(e){this.removeFocus(),this.tansControls.attach(e)}removeFocus(){this.tansControls.detach()}changeSpaceState(){this.tansControls.setSpace("local"===this.tansControls.space?"world":"local"),this.tansControls.detach()}transChangeFn(e){var t=this.runScene.modelEx.select;t&&(this.runScene.lightEx.update(t),this.runScene.helperEx.boxHelper.setFromObject(t))}close(){this.tansControls.enabled=!1}open(){this.tansControls.enabled=!0}reset(){this.dispose(),this.init()}dispose(){this.tansControls&&(this.tansControls.removeEventListener("dragging-changed",this.draggingChanged),this.tansControls.removeEventListener("change",this.transChangeFn),this.tansControls.dispose(),this.runScene.assetsEx.get().scene.remove(this.tansControls))}}(e),this.grid=this.createGrid(),this.init())}init(){this.transContro.init(),this.runScene.assetsEx.get().scene.add(this.grid)}createGrid(){const e=new vi.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof c.Material&&(e.material.opacity=.75,e.material.transparent=!0),e}dispose(){}reset(){"running"!==this.runScene.optionsEx.options.mode&&this.transContro.reset()}isHelper(e){return"GridHelper"===e.type||"CubeCamera"===e.type||e.isTransformControls||e.userData.isHelper}setHelper(e,t=!1,r){return e.userData.isHelper=!0,t&&e.traverse((e=>{e.userData.isHelper=!0,r&&r(e)})),e}focus(e){"running"!==this.runScene.optionsEx.options.mode&&(this.boxHelper||(this.boxHelper=this.getBoxHelper(e)),this.transContro.addObject(e),this.boxHelper.setFromObject(e),this.focusModelId=this.runScene.uniqueEx.getId(e))}unfocus(){var e;"running"!==this.runScene.optionsEx.options.mode&&(this.transContro.removeFocus(),null!=(e=this.boxHelper)&&e.setFromObject(this.runScene.assetsEx.get().scene),this.focusModelId=void 0)}}function Ch(e){return(Ch="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Lh(e,t){return(Lh=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Dh(e){return(Dh=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ih=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Lh(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Dh(e);if(r=t?(r=Dh(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ch(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");var i=new c.BufferGeometry,o=(i.setAttribute("position",new c.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),new c.LineBasicMaterial({fog:!1}));return((i=r.call(this,i,o)).light=e,i.color=t,i.type="RectAreaLightHelper",o=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),i.add(new c.Mesh(o,new c.MeshBasicMaterial({side:c.BackSide,fog:!1}))),i}return t=n,(e=[{key:"updateMatrixWorld",value:function(){var e,t;this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color?(this.material.color.set(this.color),this.children[0].material.color.set(this.color)):(this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),e=this.material.color,1<(t=Math.max(e.r,e.g,e.b))&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)),this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Line);class jh{constructor(e){this.runScene=e}}class Uh extends jh{get(){}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o}=e;return{type:t,intensity:r,name:n,visible:i,color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("AmbientLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o}=e;return t.intensity=r,t.type=e,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t}}class Bh extends jh{get(){throw new Error("Method not implemented.")}toJSON(e){const{intensity:t,name:r,type:n,position:i,visible:o,color:a,castShadow:s,shadow:l,rotation:u,target:c}=e;var{mapSize:e,camera:h}=l,{scale:h,near:p,far:f}=h;return{type:n,intensity:t,name:r,visible:o,color:a.getHexString(),castShadow:s,shadow:{mapSize:e.x,camera:{near:p,far:f,scale:h.x}},position:{x:i.x,y:i.y,z:i.z},rotation:{x:u.x,y:u.y,z:u.z},targetPosition:{x:c.position.x,y:c.position.y,z:c.position.z}}}parseJSON(e){const t=this.runScene.lightEx.get("DirectionalLight",{addUndo:!1});var{targetPosition:e,intensity:r,name:n,position:i,visible:o,color:a,castShadow:s,shadow:l,rotation:u,type:c}=e,{mapSize:l,camera:h}=l,{scale:h,near:p,far:f}=h;return t.intensity=r,t.type=c,t.name=n,t.visible=o,t.castShadow=s,t.color=new vi.Color("#"+a),t.position.set(i.x,i.y,i.z),t.rotation.set(u.x,u.y,u.z),t.target.position.set(e.x,e.y,e.z),t.shadow.mapSize.x=l,t.shadow.mapSize.y=l,t.shadow.camera.scale.x=h,t.shadow.camera.scale.y=h,t.shadow.camera.scale.z=h,t.shadow.camera.near=p,t.shadow.camera.far=f,t.shadow.camera.updateProjectionMatrix(),null!=(r=t.cameraHelper)&&r.update(),t}}class zh extends jh{get(){throw new Error("Method not implemented.")}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o,groundColor:a,position:s}=e;return{name:n,type:t,intensity:r,visible:i,position:{x:s.x,y:s.y,z:s.z},groundColor:a.getHexString(),color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("HemisphereLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o,groundColor:a,position:s}=e;return t.type=e,t.intensity=r,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t.groundColor=new vi.Color("#"+a),t.position.set(s.x,s.y,s.z),t}}class Nh extends jh{get(){throw new Error("Method not implemented.")}toJSON(e){const{name:t,type:r,intensity:n,distance:i,decay:o,renderOrder:a,color:s,visible:l,castShadow:u,shadow:c,position:h}=e;var{mapSize:e,camera:p,bias:f,radius:d}=c,{scale:p,near:m,far:v}=p;return{name:t,type:r,intensity:n,visible:l,color:s.getHexString(),castShadow:u,distance:i,decay:o,renderOrder:a,shadow:{mapSize:e.x,camera:{near:m,far:v,scale:p.x},radius:d,bias:f},position:{x:h.x,y:h.y,z:h.z}}}parseJSON(e){const t=this.runScene.lightEx.get("PointLight",{addUndo:!1});var{name:e,type:r,intensity:n,distance:i,decay:o,renderOrder:a,color:s,visible:l,castShadow:u,shadow:c,position:h}=e,{mapSize:c,camera:p,bias:f,radius:d}=c,{scale:p,near:m,far:v}=p;return t.intensity=n,t.type=r,t.name=e,t.visible=l,t.castShadow=u,t.distance=i,t.renderOrder=a,t.color=new vi.Color("#"+s),t.position.set(h.x,h.y,h.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=f,t.decay=o,t.shadow.radius=d,t.shadow.camera.scale.x=p,t.shadow.camera.scale.y=p,t.shadow.camera.scale.z=p,t.shadow.camera.near=m,t.shadow.camera.far=v,t.shadow.camera.updateProjectionMatrix(),t}}class Fh{constructor(e){this.runScene=e}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o,position:a}=e;return{name:n,type:t,intensity:r,visible:i,position:{x:a.x,y:a.y,z:a.z},color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("RectAreaLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o,position:a}=e;return t.type=e,t.intensity=r,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t.position.set(a.x,a.y,a.z),t}}class Vh{constructor(e){this.runScene=e}toJSON(e){const{name:t,type:r,color:n,distance:i,decay:o,intensity:a,angle:s,penumbra:l,visible:u,castShadow:c,shadow:h,renderOrder:p,position:f,target:d}=e;var{bias:e,camera:m,normalBias:v,mapSize:y,radius:g}=h,m=m.near;return{type:r,intensity:a,name:t,visible:u,distance:i,angle:s,decay:o,penumbra:l,renderOrder:p,color:n.getHexString(),castShadow:c,shadow:{bias:e,normalBias:v,mapSize:y.x,camera:{near:m},radius:g},position:{x:f.x,y:f.y,z:f.z},targetPosition:{x:d.position.x,y:d.position.y,z:d.position.z}}}parseJSON(e){const t=this.runScene.lightEx.get("SpotLight",{addUndo:!1});var{name:e,type:r,color:n,distance:i,decay:o,intensity:a,angle:s,penumbra:l,visible:u,castShadow:c,shadow:h,renderOrder:p,position:f,targetPosition:d}=e,{bias:h,camera:m,normalBias:v,mapSize:y,radius:g}=h,m=m.near;return t.intensity=a,t.type=r,t.name=e,t.visible=u,t.distance=i,t.decay=o,t.angle=s,t.penumbra=l,t.renderOrder=p,t.castShadow=c,t.color=new vi.Color("#"+n),t.position.set(f.x,f.y,f.z),t.shadow.mapSize.x=y,t.shadow.mapSize.y=y,t.shadow.camera.near=m,t.target.position.set(d.x,d.y,d.z),t.shadow.bias=h,t.shadow.normalBias=v,t.shadow.radius=g,t.shadow.camera.updateProjectionMatrix(),t}}class Hh{constructor(e){this.shadowList=["DirectionalLight","PointLight","SpotLight"],this.helperList=["DirectionalLight","PointLight","SpotLight","RectAreaLight","HemisphereLight"],this.lightDom=void 0,this.helperUpdateList=["DirectionalLight","PointLight","SpotLight","HemisphereLight"],this.runScene=e,this.lightExMap={DirectionalLight:new Bh(e),PointLight:new Nh(e),SpotLight:new Vh(e),RectAreaLight:new Fh(e),HemisphereLight:new zh(e),AmbientLight:new Uh(e)}}getLightsByScene(e=this.runScene.sceneEx.get()){return e.children.filter((e=>e.isLight))}get(e,t){var{isClone:t,id:r,addUndo:n,addToScene:i}=$o({isClone:!1,id:(0,l.getId)(),addUndo:!0,addToScene:!0},t);let o=new vi[e];if(o.position.y=10,o.name=e,o.userData.id=r,this.shadowList.includes(e)&&(o.castShadow=!0),this.setLight(o),!i)return o;if(this.helperList.includes(o.type)){const t=this.setLightHelper(o);t.push({model:o,parent:this.runScene.sceneEx.get(),addTree:!0}),r=t.map((e=>new Qa(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute())),n&&this.runScene.undoEx.addUndo(r),null!=(e=null==o?void 0:o.lightHelper)&&e.update()}else this.runScene.modelEx.add(o,void 0,{addUndo:n});return this.runScene.modelEx.setSelectByModel(o,{isClone:t}),o}setNull(e){e.userData.light&&this.setNull(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper&&(e.cameraHelper.visible=!1):"SpotLight"===e.type&&(e.cameraHelper&&(e.cameraHelper.visible=!1),e.helper&&(e.helper.visible=!0)))}setSelect(e){e.userData.light&&this.setSelect(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper&&(e.cameraHelper.visible=!0):"SpotLight"===e.type&&(e.cameraHelper&&(e.cameraHelper.visible=!0),e.helper&&(e.helper.visible=!0)))}update(e){var t;e.userData.isLightTarget&&e.userData.light&&(e=e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type||"SpotLight"===e.type?(e.helper.update(),null!=(t=e.cameraHelper)&&t.update()):null!=(e=null==(t=e.helper)?void 0:t.update)&&e.call(t))}remove(e,t=!0){let r;return this.runScene.helperEx.unfocus(),r="DirectionalLight"===e.type||"SpotLight"===e.type?[e,e.cameraHelper,e.helper].map((t=>{if(t)return new Ja({addTree:t===e,runScene:this.runScene,model:t,parent:t.parent||this.runScene.sceneEx.get()}).execute()})).filter((e=>e)):[e,e.helper].map((t=>{if(t)return new Ja({addTree:t===e,runScene:this.runScene,model:t,parent:t.parent||this.runScene.sceneEx.get()}).execute()})).filter((e=>e)),t&&r&&this.runScene.undoEx.addUndo(r),r}getLightHelper(e,t){this.runScene.uniqueEx.model.add(t);const r=this.runScene.uniqueEx.getId(t);let n,i=[];switch(e){case"RectAreaLight":n=new Ih(t,16773120);break;case"DirectionalLight":if(n=new vi.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new vi.Object3D;(t.target=e).name="helperModel",e.position.y=-10,t.shadow.autoUpdate=!0,e.userData.isLightTarget=!0,(e.userData.light=t).add(e)}t.shadow.camera.layers.set(1),t.shadow.camera.far=1e5,t.shadowCameraLeft=-5,t.shadowCameraRight=5,t.shadowCameraTop=5,t.shadowCameraBottom=-5,t.shadow.camera.updateProjectionMatrix();const e=new vi.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,this.runScene.helperEx.setHelper(e,!0,(e=>{e.userData.id=r,e.userData.unClick=!0})),e.userData.id=r,e.userData.unClick=!0,t.cameraHelper=e,i.push({model:e,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"PointLight":n=new vi.PointLightHelper(t,1,16711935);break;case"SpotLight":n=new vi.SpotLightHelper(t);let o=new vi.Object3D;(t.target=o).name="helperModel",o.userData.isLightTarget=!0,o.userData.light=t,o.position.y=-10,t.shadow.autoUpdate=!0,t.add(o);const a=new vi.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,this.runScene.helperEx.setHelper(a,!0,(e=>{e.userData.id=r})),a.userData.id=r,t.cameraHelper=a,i.push({model:a,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"HemisphereLight":n=new vi.HemisphereLightHelper(t,1,16773135)}return n.name="helperModel",this.runScene.helperEx.setHelper(n,!0,(e=>{e.userData.id=r})),n.userData.id=r,(n.light=t).helper=n,i.push({model:n,parent:this.runScene.sceneEx.get(),addTree:!1}),i}setLightHelper(e){return"editor"!==this.runScene.optionsEx.options.mode?[]:this.getLightHelper(e.type,e)}isUpdateHelper(e){return this.helperUpdateList.includes(e)}initLight(e){console.log("初始化灯光helper:",e),e.forEach((e=>this.setLightHelper(e)))}setNormal(e,t=0){var{model:e,info:r,val:n,cb:i}=e;return new za({target:e,runScene:this.runScene,info:r,oldVal:e[r],newVal:n,cb:i}).execute()}setMultip(e,t,r=!0,n=!0){if(e instanceof Array)return i=e.map((e=>{var{model:e,typeList:n,newVal:i}=e;const o=new Oa({target:e,typeList:n,newVal:i,cb:t});return r?o.execute():o})),n&&this.runScene.undoEx.addUndo(i),i;{var{model:i,typeList:e,newVal:o}=e;const a=new Oa({target:i,typeList:e,newVal:o,cb:t});return n&&this.runScene.undoEx.addUndo(a),r?a.execute():a}}isLight(e){return null==(e=e.userData)?void 0:e.isLight}setLight(e){e.userData.isLight=!0}isHelperTarget(e){return e.userData.isLightTarget}clone(e){return this.runScene.modelEx.selectNull(),this.get(e.type,{isClone:!0,id:(0,l.getId)()})}}function Gh(e){return(Gh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Wh(e,t){return(Wh=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Xh(e){return(Xh=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var qh=new WeakMap,Yh=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wh(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Xh(e);if(r=t?(r=Xh(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Gh(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return(e=r.call(this,e)).decoderPath="",e.decoderConfig={},e.decoderBinary=null,e.decoderPending=null,e.workerLimit=4,e.workerPool=[],e.workerNextTaskID=1,e.workerSourceURL="",e.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},e.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"},e;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"setDecoderPath",value:function(e){return this.decoderPath=e,this}},{key:"setDecoderConfig",value:function(e){return this.decoderConfig=e,this}},{key:"setWorkerLimit",value:function(e){return this.workerLimit=e,this}},{key:"load",value:function(e,t,r,n){var i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(e){var r={attributeIDs:i.defaultAttributeIDs,attributeTypes:i.defaultAttributeTypes,useUniqueIDs:!1};i.decodeGeometry(e,r).then(t).catch(n)}),r,n)}},{key:"decodeDracoFile",value:function(e,t,r,n){n={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r},this.decodeGeometry(e,n).then(t)}},{key:"decodeGeometry",value:function(e,t){var r,n=this;for(r in t.attributeTypes){var i=t.attributeTypes[r];void 0!==i.BYTES_PER_ELEMENT&&(t.attributeTypes[r]=i.name)}var o,a=JSON.stringify(t);if(qh.has(e)){if((l=qh.get(e)).key===a)return l.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var s=this.workerNextTaskID++,l=e.byteLength;return l=this._getWorker(s,l).then((function(r){return o=r,new Promise((function(r,n){o._callbacks[s]={resolve:r,reject:n},o.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))})).then((function(e){return n._createGeometry(e.geometry)})),l.catch((function(){return!0})).then((function(){o&&s&&n._releaseTask(o,s)})),qh.set(e,{key:a,promise:l}),l}},{key:"_createGeometry",value:function(e){var t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(var r=0;r<e.attributes.length;r++){var n=(o=e.attributes[r]).name,i=o.array,o=o.itemSize;t.setAttribute(n,new c.BufferAttribute(i,o))}return t}},{key:"_loadLibrary",value:function(e,t){var r=new c.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((function(t,n){r.load(e,t,void 0,n)}))}},{key:"preload",value:function(){return this._initDecoder(),this}},{key:"_initDecoder",value:function(){var e=this;if(this.decoderPending)return this.decoderPending;var t="object"!==("undefined"==typeof WebAssembly?"undefined":Gh(WebAssembly))||"js"===this.decoderConfig.type,r=[];return t?r.push(this._loadLibrary("draco_decoder.js","text")):(r.push(this._loadLibrary("draco_wasm_wrapper.js","text")),r.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(r).then((function(r){var n=r[0];t||(e.decoderConfig.wasmBinary=r[1]),r=function(){var e,t;onmessage=function(r){var n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":var i=n.buffer,o=n.taskConfig;t.then((function(e){var t=new(e=e.draco).Decoder,r=new e.DecoderBuffer;r.Init(new Int8Array(i),i.byteLength);try{var a=function(e,t,r,n){var i,o=n.attributeIDs,a=n.attributeTypes,s=t.GetEncodedGeometryType(r);if(s===e.TRIANGULAR_MESH)i=new e.Mesh,y=t.DecodeBufferToMesh(r,i);else{if(s!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");i=new e.PointCloud,y=t.DecodeBufferToPointCloud(r,i)}if(!y.ok()||0===i.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());var l,u,c,h,p,f,d,m,v,y,g,b,x,w={index:null,attributes:[]};for(l in o){var S=self[a[l]],T=void 0,_=void 0;if(n.useUniqueIDs)_=o[l],T=t.GetAttributeByUniqueId(i,_);else{if(-1===(_=t.GetAttributeId(i,e[o[l]])))continue;T=t.GetAttribute(i,_)}w.attributes.push((_=e,u=t,c=i,h=l,p=T.num_components(),d=(f=c.num_points()*p)*S.BYTES_PER_ELEMENT,m=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(_,S),v=_._malloc(d),u.GetAttributeDataArrayForAllPoints(c,T,m,d,v),u=new S(_.HEAPF32.buffer,v,f).slice(),_._free(v),{name:h,array:u,itemSize:p}))}return s===e.TRIANGULAR_MESH&&(w.index=(r=e,y=t,b=4*(g=3*(s=i).num_faces()),x=r._malloc(b),y.GetTrianglesUInt32Array(s,b,x),y=new Uint32Array(r.HEAPF32.buffer,x,g).slice(),r._free(x),{array:y,itemSize:1})),e.destroy(i),w}(e,t,r,o),s=a.attributes.map((function(e){return e.array.buffer}));a.index&&s.push(a.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:a},s)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{e.destroy(r),e.destroy(t)}}))}}}.toString(),n=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n"),e.workerSourceURL=URL.createObjectURL(new Blob([n]))})),this.decoderPending}},{key:"_getWorker",value:function(e,t){var r=this;return this._initDecoder().then((function(){r.workerPool.length<r.workerLimit?((n=new Worker(r.workerSourceURL))._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:r.decoderConfig}),n.onmessage=function(e){var t=e.data;switch(t.type){case"decode":n._callbacks[t.id].resolve(t);break;case"error":n._callbacks[t.id].reject(t);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+t.type+'"')}},r.workerPool.push(n)):r.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n,i=r.workerPool[r.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}},{key:"_releaseTask",value:function(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}},{key:"debug",value:function(){console.log("Task load: ",this.workerPool.map((function(e){return e._taskLoad})))}},{key:"dispose",value:function(){for(var e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Loader),Zh={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};var Qh=new(function(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(t,r,n){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var i=this,o=!1,a=0,s=0,l=void 0,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=r,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==i.onStart&&i.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,s),a===s&&(o=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return l?l(e):e},this.setURLModifier=function(e){return l=e,this},this.addHandler=function(e,t){return u.push(e,t),this},this.removeHandler=function(e){return-1!==(e=u.indexOf(e))&&u.splice(e,2),this},this.getHandler=function(e){for(var t=0,r=u.length;t<r;t+=2){var n=u[t],i=u[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}})));var Kh=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.manager=void 0!==t?t:Qh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}var t,r;return t=e,(r=[{key:"load",value:function(){}},{key:"loadAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.load(e,n,t,i)}))}},{key:"parse",value:function(){}},{key:"setCrossOrigin",value:function(e){return this.crossOrigin=e,this}},{key:"setWithCredentials",value:function(e){return this.withCredentials=e,this}},{key:"setPath",value:function(e){return this.path=e,this}},{key:"setResourcePath",value:function(e){return this.resourcePath=e,this}},{key:"setRequestHeader",value:function(e){return this.requestHeader=e,this}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Jh(e){return(Jh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function $h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ep(e,t){return(ep=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tp(e){return(tp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var rp=function(){var e=n,t=Kh;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ep(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=tp(e);if(r=t?(r=tp(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Jh(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return e=r.call(this,e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),e.options={premultiplyAlpha:"none"},e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"setOptions",value:function(e){return this.options=e,this}},{key:"load",value:function(e,t,r,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var i=this,o=Zh.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;var a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return Promise.all([createImageBitmap(e,Object.assign(i.options,{imageOrientation:"flipY"})),Promise.resolve(e)])})).then((function(r){r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),2!==o.length);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e)||function(e,t){if(e){if("string"==typeof e)return $h(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$h(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r);var n=r[0];r=r[1],Zh.add(e,n),t&&t(n,r),i.manager.itemEnd(e)})).catch((function(t){n&&n(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function np(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||op(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ip(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=op(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),r=0,{s:t=function(){},n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function op(e,t){if(e){if("string"==typeof e)return ap(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ap(e,t):void 0}}function ap(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function sp(e){return(sp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function lp(){return(lp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=vp(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function up(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cp(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function hp(e,t,r){return t&&cp(e.prototype,t),r&&cp(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function pp(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fp(e,t)}function fp(e,t){return(fp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function dp(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=vp(e);if(r=t?(r=vp(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===sp(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return mp(n)}}function mp(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vp(e){return(vp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}rp.prototype.isImageBitmapLoader=!0;var yp=function(){pp(t,c.Loader);var e=dp(t);function t(r){return up(this,t),(r=e.call(this,r)).dracoLoader=null,r.ktx2Loader=null,r.meshoptDecoder=null,r.pluginCallbacks=[],r.register((function(e){return new Sp(e)})),r.register((function(e){return new Op(e)})),r.register((function(e){return new Rp(e)})),r.register((function(e){return new Tp(e)})),r.register((function(e){return new _p(e)})),r.register((function(e){return new Mp(e)})),r.register((function(e){return new Ep(e)})),r.register((function(e){return new Pp(e)})),r.register((function(e){return new xp(e)})),r.register((function(e){return new kp(e)})),r}return hp(t,[{key:"load",value:function(e,t,r,n){function i(t){n?n(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)}var o=this,a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:c.LoaderUtils.extractUrlBase(e),s=(this.manager.itemStart(e),new c.FileLoader(this.manager));s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(r){try{o.parse(r,a,(function(r){t(r),o.manager.itemEnd(e)}),i)}catch(r){i(r)}}),r,i)}},{key:"setDRACOLoader",value:function(e){return this.dracoLoader=e,this}},{key:"setDDSLoader",value:function(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}},{key:"setKTX2Loader",value:function(e){return this.ktx2Loader=e,this}},{key:"setMeshoptDecoder",value:function(e){return this.meshoptDecoder=e,this}},{key:"register",value:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}},{key:"unregister",value:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}},{key:"parse",value:function(e,t,r,n,i){var o,a={},s={};if("string"==typeof e)o=e;else if(c.LoaderUtils.decodeText(new Uint8Array(e,0,4))===Ap){try{a[bp.KHR_BINARY_GLTF]=new Cp(e)}catch(e){return void(n&&n(e))}o=a[bp.KHR_BINARY_GLTF].content}else o=c.LoaderUtils.decodeText(new Uint8Array(e));var l=JSON.parse(o);if(void 0===l.asset||l.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{i.helper.beforeLoader(l);var u=new Jp(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:i});u.fileLoader.setRequestHeader(this.requestHeader);for(var h=0;h<this.pluginCallbacks.length;h++){var p=this.pluginCallbacks[h](u);a[(s[p.name]=p).name]=!0}if(l.extensionsUsed)for(var f=0;f<l.extensionsUsed.length;++f){var d=l.extensionsUsed[f],m=l.extensionsRequired||[];switch(d){case bp.KHR_MATERIALS_UNLIT:a[d]=new wp;break;case bp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:a[d]=new jp;break;case bp.KHR_DRACO_MESH_COMPRESSION:a[d]=new Lp(l,this.dracoLoader);break;case bp.KHR_TEXTURE_TRANSFORM:a[d]=new Dp;break;case bp.KHR_MESH_QUANTIZATION:a[d]=new Up;break;default:0<=m.indexOf(d)&&void 0===s[d]&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}u.setExtensions(a),u.setPlugins(s),u.parse(r,n)}}},{key:"parseAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.parse(e,t,n,i)}))}}]),t}();function gp(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var bp={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"},xp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}return hp(e,[{key:"_markDefs",value:function(){for(var e=this.parser,t=this.parser.json.nodes||[],r=0,n=t.length;r<n;r++){var i=t[r];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}},{key:"_loadLight",value:function(e){var t=this.parser,r="light:"+e,n=t.cache.get(r);if(n)return n;var i,o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e],s=new c.Color(16777215),l=(void 0!==a.color&&s.fromArray(a.color),void 0!==a.range?a.range:0);switch(a.type){case"directional":(i=new c.DirectionalLight(s)).target.position.set(0,0,-1),i.add(i.target);break;case"point":(i=new c.PointLight(s)).distance=l;break;case"spot":(i=new c.SpotLight(s)).distance=l,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,i.angle=a.spot.outerConeAngle,i.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return i.position.set(0,0,0),i.decay=2,void 0!==a.intensity&&(i.intensity=a.intensity),i.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(i),t.cache.add(r,n),n}},{key:"createNodeAttachment",value:function(e){var t=this,r=this.parser,n=((e=r.json.nodes[e]).extensions&&e.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return r._getNodeRef(t.cache,n,e)}))}}]),e}(),wp=function(){function e(){up(this,e),this.name=bp.KHR_MATERIALS_UNLIT}return hp(e,[{key:"getMaterialType",value:function(){return c.MeshBasicMaterial}},{key:"extendParams",value:function(e,t,r){var n,i=[];return e.color=new c.Color(1,1,1),e.opacity=1,(t=t.pbrMetallicRoughness)&&(Array.isArray(t.baseColorFactor)&&(n=t.baseColorFactor,e.color.fromArray(n),e.opacity=n[3]),void 0!==t.baseColorTexture&&i.push(r.assignTexture(e,"map",t.baseColorTexture))),Promise.all(i)}}]),e}(),Sp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_CLEARCOAT}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(e=e.extensions[this.name]).clearcoatFactor&&(t.clearcoat=e.clearcoatFactor),void 0!==e.clearcoatTexture&&n.push(r.assignTexture(t,"clearcoatMap",e.clearcoatTexture)),void 0!==e.clearcoatRoughnessFactor&&(t.clearcoatRoughness=e.clearcoatRoughnessFactor),void 0!==e.clearcoatRoughnessTexture&&n.push(r.assignTexture(t,"clearcoatRoughnessMap",e.clearcoatRoughnessTexture)),void 0!==e.clearcoatNormalTexture&&(n.push(r.assignTexture(t,"clearcoatNormalMap",e.clearcoatNormalTexture)),void 0!==e.clearcoatNormalTexture.scale&&(r=e.clearcoatNormalTexture.scale,t.clearcoatNormalScale=new c.Vector2(r,r))),Promise.all(n)}}]),e}(),Tp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_SHEEN}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,e=e.extensions[this.name]).sheenColorFactor&&t.sheenColor.fromArray(e.sheenColorFactor),void 0!==e.sheenRoughnessFactor&&(t.sheenRoughness=e.sheenRoughnessFactor),void 0!==e.sheenColorTexture&&n.push(r.assignTexture(t,"sheenColorMap",e.sheenColorTexture)),void 0!==e.sheenRoughnessTexture&&n.push(r.assignTexture(t,"sheenRoughnessMap",e.sheenRoughnessTexture)),Promise.all(n)}}]),e}(),_p=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_TRANSMISSION}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(e=e.extensions[this.name]).transmissionFactor&&(t.transmission=e.transmissionFactor),void 0!==e.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",e.transmissionTexture)),Promise.all(n)}}]),e}(),Mp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_VOLUME}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){if(!(e=(n=this.parser).json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var r=[],n=(e=e.extensions[this.name],t.thickness=void 0!==e.thicknessFactor?e.thicknessFactor:0,void 0!==e.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",e.thicknessTexture)),t.attenuationDistance=e.attenuationDistance||0,e.attenuationColor||[1,1,1]);return t.attenuationColor=new c.Color(n[0],n[1],n[2]),Promise.all(r)}}]),e}(),Ep=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_IOR}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?(e=e.extensions[this.name],t.ior=void 0!==e.ior?e.ior:1.5,Promise.resolve()):Promise.resolve()}}]),e}(),Pp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_MATERIALS_SPECULAR}return hp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[],i=(e=e.extensions[this.name],t.specularIntensity=void 0!==e.specularFactor?e.specularFactor:1,void 0!==e.specularTexture&&n.push(r.assignTexture(t,"specularIntensityMap",e.specularTexture)),e.specularColorFactor||[1,1,1]);return t.specularColor=new c.Color(i[0],i[1],i[2]),void 0!==e.specularColorTexture&&n.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=c.sRGBEncoding}))),Promise.all(n)}}]),e}(),Op=function(){function e(t){up(this,e),this.parser=t,this.name=bp.KHR_TEXTURE_BASISU}return hp(e,[{key:"loadTexture",value:function(e){var t=this.parser,r=t.json;if(!(n=r.textures[e]).extensions||!n.extensions[this.name])return null;var n=n.extensions[this.name],i=t.options.ktx2Loader;if(i)return t.loadTextureImage(e,n.source,i);if(r.extensionsRequired&&0<=r.extensionsRequired.indexOf(this.name))throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}}]),e}(),Rp=function(){function e(t){up(this,e),this.parser=t,this.name=bp.EXT_TEXTURE_WEBP,this.isSupported=null}return hp(e,[{key:"loadTexture",value:function(e){var t=this.name,r=this.parser,n=r.json;if(!(i=n.textures[e]).extensions||!i.extensions[t])return null;var i=i.extensions[t],o=n.images[i.source],a=r.textureLoader;return o.uri&&null!==(i=r.options.manager.getHandler(o.uri))&&(a=i),this.detectSupport().then((function(i){if(i)return r.loadTextureImage(e,o,a);if(n.extensionsRequired&&0<=n.extensionsRequired.indexOf(t))throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))}},{key:"detectSupport",value:function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}]),e}(),kp=function(){function e(t){up(this,e),this.name=bp.EXT_MESHOPT_COMPRESSION,this.parser=t}return hp(e,[{key:"loadBufferView",value:function(e){var t=this.parser.json;if((e=t.bufferViews[e]).extensions&&e.extensions[this.name]){var r=e.extensions[this.name],n=(e=this.parser.getDependency("buffer",r.buffer),this.parser.options.meshoptDecoder);if(n&&n.supported)return Promise.all([e,n.ready]).then((function(e){var t=r.byteOffset||0,i=r.byteLength||0,o=r.count,a=r.byteStride,s=new ArrayBuffer(o*a);return e=new Uint8Array(e[0],t,i),n.decodeGltfBuffer(new Uint8Array(s),o,a,e,r.mode,r.filter),s}));if(t.extensionsRequired&&0<=t.extensionsRequired.indexOf(this.name))throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return null}}]),e}(),Ap="glTF",Cp=hp((function e(t){up(this,e),this.name=bp.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(t,0,12);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==Ap)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var n=this.header.length-12,i=new DataView(t,12),o=0;o<n;){var a,s=i.getUint32(o,!0),l=(o+=4,i.getUint32(o,!0));o+=4,1313821514===l?(a=new Uint8Array(t,12+o,s),this.content=c.LoaderUtils.decodeText(a)):5130562===l&&(this.body=t.slice(a=12+o,a+s)),o+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),Lp=function(){function e(t,r){if(up(this,e),!r)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=bp.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=r,this.dracoLoader.preload()}return hp(e,[{key:"decodePrimitive",value:function(e,t){var r,n,i=this.json,o=this.dracoLoader,a=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,l={},u={},c={};for(r in s){var h=Wp[r]||r.toLowerCase();l[h]=s[r]}for(n in e.attributes){var p,f,d=Wp[n]||n.toLowerCase();void 0!==s[n]&&(p=i.accessors[e.attributes[n]],f=Fp[p.componentType],c[d]=f,u[d]=!0===p.normalized)}return t.getDependency("bufferView",a).then((function(e){return new Promise((function(t){o.decodeDracoFile(e,(function(e){for(var r in e.attributes){var n=e.attributes[r];void 0!==(r=u[r])&&(n.normalized=r)}t(e)}),l,c)}))}))}}]),e}(),Dp=function(){function e(){up(this,e),this.name=bp.KHR_TEXTURE_TRANSFORM}return hp(e,[{key:"extendTexture",value:function(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}]),e}(),Ip=function(){pp(t,c.MeshStandardMaterial);var e=dp(t);function t(r){up(this,t),(n=e.call(this)).isGLTFSpecularGlossinessMaterial=!0;var n,i=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),o=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),a=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),s=["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"),l=["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"),u={specular:{value:(new c.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};return n._extraUniforms=u,n.onBeforeCompile=function(e){for(var t in u)e.uniforms[t]=u[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",i).replace("#include <metalnessmap_pars_fragment>",o).replace("#include <roughnessmap_fragment>",a).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",l)},Object.defineProperties(mp(n),{specular:{get:function(){return u.specular.value},set:function(e){u.specular.value=e}},specularMap:{get:function(){return u.specularMap.value},set:function(e){(u.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return u.glossiness.value},set:function(e){u.glossiness.value=e}},glossinessMap:{get:function(){return u.glossinessMap.value},set:function(e){(u.glossinessMap.value=e)?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete n.metalness,delete n.roughness,delete n.metalnessMap,delete n.roughnessMap,n.setValues(r),n}return hp(t,[{key:"copy",value:function(e){return lp(vp(t.prototype),"copy",this).call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}]),t}(),jp=function(){function e(){up(this,e),this.name=bp.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"]}return hp(e,[{key:"getMaterialType",value:function(){return Ip}},{key:"extendParams",value:function(e,t,r){t=t.extensions[this.name];var n,i=(e.color=new c.Color(1,1,1),e.opacity=1,[]);return Array.isArray(t.diffuseFactor)&&(n=t.diffuseFactor,e.color.fromArray(n),e.opacity=n[3]),void 0!==t.diffuseTexture&&i.push(r.assignTexture(e,"map",t.diffuseTexture)),e.emissive=new c.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new c.Color(1,1,1),Array.isArray(t.specularFactor)&&e.specular.fromArray(t.specularFactor),void 0!==t.specularGlossinessTexture&&(n=t.specularGlossinessTexture,i.push(r.assignTexture(e,"glossinessMap",n)),i.push(r.assignTexture(e,"specularMap",n))),Promise.all(i)}},{key:"createMaterial",value:function(e){var t=new Ip(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=c.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}]),e}(),Up=hp((function e(){up(this,e),this.name=bp.KHR_MESH_QUANTIZATION})),Bp=function(){pp(t,c.Interpolant);var e=dp(t);function t(r,n,i,o){return up(this,t),e.call(this,r,n,i,o)}return hp(t,[{key:"copySampleValue_",value:function(e){for(var t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=e*n*3+n,o=0;o!==n;o++)t[o]=r[i+o];return t}}]),t}(),zp=(Bp.prototype.beforeStart_=Bp.prototype.copySampleValue_,Bp.prototype.afterEnd_=Bp.prototype.copySampleValue_,Bp.prototype.interpolate_=function(e,t,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,u=n-t,c=e*l,h=c-l,p=-2*(t=(r=(n=(r-t)/u)*n)*n)+3*r,f=t-r,d=1-p,m=f-r+n,v=0;v!==a;v++){var y=o[h+v+a],g=o[h+v+s]*u,b=o[c+v+a],x=o[c+v]*u;i[v]=d*y+m*g+p*b+f*x}return i},new c.Quaternion),Np=function(){pp(t,Bp);var e=dp(t);function t(){return up(this,t),e.apply(this,arguments)}return hp(t,[{key:"interpolate_",value:function(e,r,n,i){return e=lp(vp(t.prototype),"interpolate_",this).call(this,e,r,n,i),zp.fromArray(e).normalize().toArray(e),e}}]),t}(),Fp={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Vp={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},Hp={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},Gp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wp={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xp={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qp={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete};function Yp(e,t,r){for(var n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function Zp(e,t){void 0!==t.extras&&("object"===sp(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Qp(e){for(var t="",r=Object.keys(e).sort(),n=0,i=r.length;n<i;n++)t+=r[n]+":"+e[r[n]]+";";return t}function Kp(e){switch(e){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.")}}var Jp=function(){function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};up(this,e),this.json=t,this.extensions={},this.plugins={},this.options=r,this.cache=new gp,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox|^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new rp(this.options.manager):this.textureLoader=new c.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}return hp(e,[{key:"setExtensions",value:function(e){this.extensions=e}},{key:"setPlugins",value:function(e){this.plugins=e}},{key:"parse",value:function(e,t){var r=this,n=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.options.myOptions.helper.processInput(n,this)].concat(function(e){return function(e){if(Array.isArray(e))return ap(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||op(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))))).then((function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])})).then((function(t){var o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:r,userData:{}};Yp(i,o,n),Zp(o,n),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){e(o)}))})).catch(t)}},{key:"_markDefs",value:function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],n=0,i=t.length;n<i;n++)for(var o=t[n].joints,a=0,s=o.length;a<s;a++)e[o[a]].isBone=!0;for(var l=0,u=e.length;l<u;l++){var c=e[l];void 0!==c.mesh&&(this._addNodeRef(this.meshCache,c.mesh),void 0!==c.skin&&(r[c.mesh].isSkinnedMesh=!0)),void 0!==c.camera&&this._addNodeRef(this.cameraCache,c.camera)}}},{key:"_addNodeRef",value:function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}},{key:"_getNodeRef",value:function(e,t,r){var n=this;if(e.refs[t]<=1)return r;var i=r.clone();return function e(t,r){var i,o=n.associations.get(t),a=(null!=o&&n.associations.set(r,o),ip(t.children.entries()));try{for(a.s();!(i=a.n()).done;){var s=np(i.value,2),l=s[0];e(s[1],r.children[l])}}catch(e){a.e(e)}finally{a.f()}}(r,i),i.name+="_instance_"+e.uses[t]++,i}},{key:"_invokeOne",value:function(e){var t=Object.values(this.plugins);t.push(this);for(var r=0;r<t.length;r++){var n=e(t[r]);if(n)return n}return null}},{key:"_invokeAll",value:function(e){for(var t=Object.values(this.plugins),r=(t.unshift(this),[]),n=0;n<t.length;n++){var i=e(t[n]);i&&r.push(i)}return r}},{key:"getDependency",value:function(e,t){var r=e+":"+t,n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this.loadNode(t);break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this.loadAnimation(t);break;case"camera":n=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,n)}return n}},{key:"getDependencies",value:function(e){var t,r,n=this.cache.get(e);return n||(r=(t=this).json[e+("mesh"===e?"es":"s")]||[],n=Promise.all(r.map((function(r,n){return t.getDependency(e,n)}))),this.cache.add(e,n)),n}},{key:"loadBuffer",value:function(e){var t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[bp.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(e,i){r.load(c.LoaderUtils.resolveURL(t.uri,n.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}},{key:"loadBufferView",value:function(e){var t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+r)}))}},{key:"loadAccessor",value:function(e){var t=this,r=this.json,n=this.json.accessors[e];return void 0===n.bufferView&&void 0===n.sparse?Promise.resolve(null):(e=[],void 0!==n.bufferView?e.push(this.getDependency("bufferView",n.bufferView)):e.push(null),void 0!==n.sparse&&(e.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),e.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(e).then((function(e){var i,o=e[0],a=Gp[n.type],s=Fp[n.componentType],l=s.BYTES_PER_ELEMENT,u=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized,f=h&&h!==l*a?(d=Math.floor(u/h),m="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+d+":"+n.count,(v=t.cache.get(m))||(i=new s(o,d*h,n.count*h/l),v=new c.InterleavedBuffer(i,h/l),t.cache.add(m,v)),new c.InterleavedBufferAttribute(v,a,u%h/l,p)):(i=null===o?new s(n.count*a):new s(o,u,n.count*a),new c.BufferAttribute(i,a,p));if(void 0!==n.sparse){var d=Fp[n.sparse.indices.componentType],m=n.sparse.indices.byteOffset||0,v=n.sparse.values.byteOffset||0,y=new d(e[1],m,n.sparse.count*Gp.SCALAR),g=new s(e[2],v,n.sparse.count*a);null!==o&&(f=new c.BufferAttribute(f.array.slice(),f.itemSize,f.normalized));for(var b=0,x=y.length;b<x;b++){var w=y[b];if(f.setX(w,g[b*a]),2<=a&&f.setY(w,g[b*a+1]),3<=a&&f.setZ(w,g[b*a+2]),4<=a&&f.setW(w,g[b*a+3]),5<=a)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})))}},{key:"loadTexture",value:function(e){var t=this.json,r=this.options,n=t.textures[e].source,i=(t=t.images[n],this.textureLoader);return t.uri&&null!==(r=r.manager.getHandler(t.uri))&&(i=r),this.loadTextureImage(e,n,i)}},{key:"loadTextureImage",value:function(e,t,r){var n=this,i=this.json,o=i.textures[e],a=((a=i.images[t]).uri||a.bufferView)+":"+o.sampler;return this.textureCache[a]?this.textureCache[a]:(t=this.loadImageSource(t,r).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);var r=(i.samplers||{})[o.sampler]||{};return t.magFilter=Vp[r.magFilter]||c.LinearFilter,t.minFilter=Vp[r.minFilter]||c.LinearMipmapLinearFilter,t.wrapS=Hp[r.wrapS]||c.RepeatWrapping,t.wrapT=Hp[r.wrapT]||c.RepeatWrapping,n.associations.set(t,{textures:e}),n.options.myOptions.helper.material.processTexture({texture:t,textureDef:o}),t})).catch((function(){return null})),this.textureCache[a]=t)}},{key:"loadImageSource",value:function(e,t){var r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((function(e){return e.clone()})).catch((function(e){throw e}));var i=r.images[e],o=self.URL||self.webkitURL,a=i.uri||"";if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){return e=new Blob([e],{type:i.mimeType}),a=o.createObjectURL(e)}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return r=Promise.resolve(a).then((function(e){return new Promise((function(r,i){var o=r;!0===t.isImageBitmapLoader&&(o=function(e,t){(e=new c.Texture(e)).needsUpdate=!0,r({texture:e,blob:t})}),t.load(c.LoaderUtils.resolveURL(e,n.path),o,void 0,i)}))})).then((function(e){var t=e.texture;return e=e.blob,t.userData.url=a,t.userData.blob=e,t.url=a,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e})),this.sourceCache[e]=r}},{key:"assignTexture",value:function(e,t,r){var n=this;return this.getDependency("texture",r.index).then((function(i){var o,a;return void 0===r.texCoord||0==r.texCoord||"aoMap"===t&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+t+" not yet supported."),n.extensions[bp.KHR_TEXTURE_TRANSFORM]&&(o=void 0!==r.extensions?r.extensions[bp.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=n.associations.get(i),i=n.extensions[bp.KHR_TEXTURE_TRANSFORM].extendTexture(i,o),n.associations.set(i,a)),e[t]=i}))}},{key:"assignFinalMaterial",value:function(e){var t,r,n=e.geometry,i=e.material,o=void 0===n.attributes.tangent,a=void 0!==n.attributes.color,s=void 0===n.attributes.normal;e.isPoints?(t="PointsMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new c.PointsMaterial,c.Material.prototype.copy.call(r,i),r.color.copy(i.color),r.map=i.map,r.sizeAttenuation=!1,this.cache.add(t,r)),i=r):e.isLine&&(t="LineBasicMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new c.LineBasicMaterial,c.Material.prototype.copy.call(r,i),r.color.copy(i.color),this.cache.add(t,r)),i=r),(o||a||s)&&(t="ClonedMaterial:"+i.uuid+":",i.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),o&&(t+="derivative-tangents:"),a&&(t+="vertex-colors:"),s&&(t+="flat-shading:"),(r=this.cache.get(t))||(r=i.clone(),a&&(r.vertexColors=!0),s&&(r.flatShading=!0),o&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(t,r),this.associations.set(r,this.associations.get(i))),i=r),i.aoMap&&void 0===n.attributes.uv2&&void 0!==n.attributes.uv&&n.setAttribute("uv2",n.attributes.uv),this.options.myOptions.helper.material.process({material:i,materialDef:i.userData,model:e}),e.material=i}},{key:"getMaterialType",value:function(){return c.MeshStandardMaterial}},{key:"loadMaterial",value:function(e){var t,r=this,n=this.json,i=this.extensions,o=n.materials[e],a={},s=[],l=((n=o.extensions||{})[bp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]?(l=i[bp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS],t=l.getMaterialType(),s.push(l.extendParams(a,o,r))):n[bp.KHR_MATERIALS_UNLIT]?(l=i[bp.KHR_MATERIALS_UNLIT],t=l.getMaterialType(),s.push(l.extendParams(a,o,r))):(n=o.pbrMetallicRoughness||{},a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)&&(l=n.baseColorFactor,a.color.fromArray(l),a.opacity=l[3]),void 0!==n.baseColorTexture&&s.push(r.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&&(s.push(r.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),s.push(r.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),s.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))),!0===o.doubleSided&&(a.side=c.DoubleSide),o.alphaMode||"OPAQUE");return"BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==c.MeshBasicMaterial&&(s.push(r.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new c.Vector2(1,1),void 0!==o.normalTexture.scale&&(n=o.normalTexture.scale,a.normalScale.set(n,n))),void 0!==o.occlusionTexture&&t!==c.MeshBasicMaterial&&(s.push(r.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==c.MeshBasicMaterial&&(a.emissive=(new c.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&t!==c.MeshBasicMaterial&&s.push(r.assignTexture(a,"emissiveMap",o.emissiveTexture)),Promise.all(s).then((function(){var n=t===Ip?i[bp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new t(a);return o.name&&(n.name=o.name),n.map&&(n.map.encoding=c.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=c.sRGBEncoding),Zp(n,o),r.associations.set(n,{materials:e}),o.extensions&&Yp(i,n,o),n}))}},{key:"createUniqueName",value:function(e){for(var t=c.PropertyBinding.sanitizeNodeName(e||""),r=t,n=1;this.nodeNamesUsed[r];++n)r=t+"_"+n;return this.nodeNamesUsed[r]=!0,r}},{key:"loadGeometries",value:function(e){for(var t=this,r=this.extensions,n=this.primitiveCache,i=[],o=0,a=e.length;o<a;o++){var s=e[o],l=(u=void 0,u=(u=(l=s).extensions&&l.extensions[bp.KHR_DRACO_MESH_COMPRESSION])?"draco:"+u.bufferView+":"+u.indices+":"+Qp(u.attributes):l.indices+":"+Qp(l.attributes)+":"+l.mode),u=n[l];u?i.push(u.promise):(u=void 0,u=s.extensions&&s.extensions[bp.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[bp.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return $p(r,e,t)}))}(s):$p(new c.BufferGeometry,s,t),n[l]={primitive:s,promise:u},i.push(u))}return Promise.all(i)}},{key:"loadMesh",value:function(e){for(var t=this,r=this.json,n=this.extensions,i=r.meshes[e],o=i.primitives,a=[],s=0,l=o.length;s<l;s++){var u=void 0===o[s].material?(void 0===(u=this.cache).DefaultMaterial&&(u.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),u.DefaultMaterial):this.getDependency("material",o[s].material);u.then((function(e){})),a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then((function(r){for(var a=r.slice(0,r.length-1),s=r[r.length-1],l=[],u=0,h=s.length;u<h;u++){var p=s[u],f=o[u],d=void 0,m=a[u];if(4===f.mode||5===f.mode||6===f.mode||void 0===f.mode)!0!==(d=new(!0===i.isSkinnedMesh?c.SkinnedMesh:c.Mesh)(p,m)).isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),5===f.mode?d.geometry=ef(d.geometry,c.TriangleStripDrawMode):6===f.mode&&(d.geometry=ef(d.geometry,c.TriangleFanDrawMode));else if(1===f.mode)d=new c.LineSegments(p,m);else if(3===f.mode)d=new c.Line(p,m);else if(2===f.mode)d=new c.LineLoop(p,m);else{if(0!==f.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);d=new c.Points(p,m)}if(0<Object.keys(d.geometry.morphAttributes).length){S=w=x=b=g=v=void 0;var v=d,y=i;if(v.updateMorphTargets(),void 0!==y.weights)for(var g=0,b=y.weights.length;g<b;g++)v.morphTargetInfluences[g]=y.weights[g];if(y.extras&&Array.isArray(y.extras.targetNames)){var x=y.extras.targetNames;if(v.morphTargetInfluences.length===x.length){v.morphTargetDictionary={};for(var w=0,S=x.length;w<S;w++)v.morphTargetDictionary[x[w]]=w}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}d.name=t.createUniqueName(i.name||"mesh_"+e),Zp(d,i),f.extensions&&Yp(n,d,f),t.assignFinalMaterial(d),l.push(d)}for(var T=0,_=l.length;T<_;T++)t.associations.set(l[T],{meshes:e,primitives:T});if(1===l.length)return l[0];var M=new c.Group;t.associations.set(M,{meshes:e});for(var E=0,P=l.length;E<P;E++)M.add(l[E]);return M}))}},{key:"loadCamera",value:function(e){var t,r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new c.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),Zp(t,e),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}},{key:"loadSkin",value:function(e){var t={joints:(e=this.json.skins[e]).joints};return void 0===e.inverseBindMatrices?Promise.resolve(t):this.getDependency("accessor",e.inverseBindMatrices).then((function(e){return t.inverseBindMatrices=e,t}))}},{key:"loadAnimation",value:function(e){for(var t=this.json.animations[e],r=[],n=[],i=[],o=[],a=[],s=0,l=t.channels.length;s<l;s++){var u=t.channels[s],h=t.samplers[u.sampler],p=void 0!==(u=u.target).node?u.node:u.id,f=void 0!==t.parameters?t.parameters[h.input]:h.input,d=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",p)),n.push(this.getDependency("accessor",f)),i.push(this.getDependency("accessor",d)),o.push(h),a.push(u)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(r){for(var n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=[],u=0,h=n.length;u<h;u++)!function(e){var t=n[e],r=i[e],u=o[e],h=a[e],p=s[e];if(void 0!==t){t.updateMatrix(),t.matrixAutoUpdate=!0;var f=void 0;switch(Xp[p.path]){case Xp.weights:f=c.NumberKeyframeTrack;break;case Xp.rotation:f=c.QuaternionKeyframeTrack;break;default:f=c.VectorKeyframeTrack}e=t.name||t.uuid;var d=void 0!==h.interpolation?qp[h.interpolation]:c.InterpolateLinear,m=[],v=(Xp[p.path]===Xp.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name||e.uuid)})):m.push(e),u.array);if(u.normalized){for(var y=Kp(v.constructor),g=new Float32Array(v.length),b=0,x=v.length;b<x;b++)g[b]=v[b]*y;v=g}for(var w=0,S=m.length;w<S;w++){var T=new f(m[w]+"."+Xp[p.path],r.array,v,d);"CUBICSPLINE"===h.interpolation&&(T.createInterpolant=function(e){return new(this instanceof c.QuaternionKeyframeTrack?Np:Bp)(this.times,this.values,this.getValueSize()/3,e)},T.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(T)}}}(u);return r=t.name||"animation_"+e,new c.AnimationClip(r,void 0,l)}))}},{key:"createNodeMesh",value:function(e){var t=this.json,r=this,n=t.nodes[e];return void 0===n.mesh?null:r.getDependency("mesh",n.mesh).then((function(e){return e=r._getNodeRef(r.meshCache,n.mesh,e),void 0!==n.weights&&e.traverse((function(e){if(e.isMesh)for(var t=0,r=n.weights.length;t<r;t++)e.morphTargetInfluences[t]=n.weights[t]})),e}))}},{key:"loadNode",value:function(e){var t,r=this.json,n=this.extensions,i=this,o=r.nodes[e],a=o.name?i.createUniqueName(o.name):"";return t=[],(r=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)})))&&t.push(r),void 0!==o.camera&&t.push(i.getDependency("camera",o.camera).then((function(e){return i._getNodeRef(i.cameraCache,o.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t).then((function(t){var r,s=!0===o.isBone?new c.Bone:1<t.length?new c.Group:1===t.length?t[0]:new c.Object3D;if(s!==t[0])for(var l=0,u=t.length;l<u;l++)s.add(t[l]);return o.name&&(s.userData.name=o.name,s.name=a),Zp(s,o),o.extensions&&Yp(n,s,o),void 0!==o.matrix?((r=new c.Matrix4).fromArray(o.matrix),s.applyMatrix4(r)):(void 0!==o.translation&&s.position.fromArray(o.translation),void 0!==o.rotation&&s.quaternion.fromArray(o.rotation),void 0!==o.scale&&s.scale.fromArray(o.scale)),i.associations.has(s)||i.associations.set(s,{}),i.associations.get(s).nodes=e,i.options.myOptions.helper.processNode({node:s,nodeDef:o})||s}))}},{key:"loadScene",value:function(e){for(var t=this.json,r=this.extensions,n=(e=this.json.scenes[e],this),i=new c.Group,o=(e.name&&(i.name=n.createUniqueName(e.name)),Zp(i,e),e.extensions&&Yp(r,i,e),e.nodes||[]),a=[],s=0,l=o.length;s<l;s++)a.push(function e(t,r,n,i){var o=n.nodes[t];return i.getDependency("node",t).then((function(e){return void 0===o.skin?e:i.getDependency("skin",o.skin).then((function(e){for(var r=[],n=0,o=(t=e).joints.length;n<o;n++)r.push(i.getDependency("node",t.joints[n]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){for(var n=[],i=[],o=0,a=r.length;o<a;o++){var s=r[o];s?(n.push(s),s=new c.Matrix4,void 0!==t.inverseBindMatrices&&s.fromArray(t.inverseBindMatrices.array,16*o),i.push(s)):console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[o])}e.bind(new c.Skeleton(n,i),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var a=[];if(o.children)for(var s=o.children,l=0,u=s.length;l<u;l++){var c=s[l];a.push(e(c,t,n,i))}return Promise.all(a)}))}(o[s],i,t,n));return Promise.all(a).then((function(){var e;return null!=(e=n.options.myOptions)&&e.models.push(i),n.associations=function(e){console.log(e,e.children,"node,node.children");var t,r=new Map,i=ip(n.associations);try{for(i.s();!(t=i.n()).done;){var o=np(t.value,2),a=o[0],s=o[1];(a instanceof c.Material||a instanceof c.Texture)&&r.set(a,s)}}catch(e){i.e(e)}finally{i.f()}return e.traverse((function(e){var t=n.associations.get(e);null!=t&&r.set(e,t)})),r}(i),i}))}}]),e}();function $p(e,t,r){var n,i=t.attributes,o=[];for(n in i){var a=Wp[n]||n.toLowerCase();a in e.attributes||o.push(function(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}(i[n],a))}void 0===t.indices||e.index||(s=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),o.push(s)),Zp(e,t);var s=e,l=t,u=r,h=l.attributes,p=new c.Box3;if(void 0!==h.POSITION){var f=(h=u.json.accessors[h.POSITION]).min,d=h.max;if(void 0===f||void 0===d)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{p.set(new c.Vector3(f[0],f[1],f[2]),new c.Vector3(d[0],d[1],d[2])),h.normalized&&(f=Kp(Fp[h.componentType]),p.min.multiplyScalar(f),p.max.multiplyScalar(f));var m=l.targets;if(void 0!==m){for(var v=new c.Vector3,y=new c.Vector3,g=0,b=m.length;g<b;g++){var x,w,S=m[g];void 0!==S.POSITION&&(w=(S=u.json.accessors[S.POSITION]).min,x=S.max,void 0!==w&&void 0!==x?(y.setX(Math.max(Math.abs(w[0]),Math.abs(x[0]))),y.setY(Math.max(Math.abs(w[1]),Math.abs(x[1]))),y.setZ(Math.max(Math.abs(w[2]),Math.abs(x[2]))),S.normalized&&(w=Kp(Fp[S.componentType]),y.multiplyScalar(w)),v.max(y)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}p.expandByVector(v)}s.boundingBox=p,d=new c.Sphere,p.getCenter(d.center),d.radius=p.min.distanceTo(p.max)/2,s.boundingSphere=d}}return Promise.all(o).then((function(){if(void 0===t.targets)return e;for(var n=e,i=t.targets,o=r,a=!1,s=!1,l=!1,u=0,c=i.length;u<c;u++){var h=i[u];if(void 0!==h.POSITION&&(a=!0),void 0!==h.NORMAL&&(s=!0),void 0!==h.COLOR_0&&(l=!0),a&&s&&l)break}if(!a&&!s&&!l)return Promise.resolve(n);for(var p=[],f=[],d=[],m=0,v=i.length;m<v;m++){var y,g=i[m];a&&(y=void 0!==g.POSITION?o.getDependency("accessor",g.POSITION):n.attributes.position,p.push(y)),s&&(y=void 0!==g.NORMAL?o.getDependency("accessor",g.NORMAL):n.attributes.normal,f.push(y)),l&&(g=void 0!==g.COLOR_0?o.getDependency("accessor",g.COLOR_0):n.attributes.color,d.push(g))}return Promise.all([Promise.all(p),Promise.all(f),Promise.all(d)]).then((function(e){var t=e[0],r=e[1];return e=e[2],a&&(n.morphAttributes.position=t),s&&(n.morphAttributes.normal=r),l&&(n.morphAttributes.color=e),n.morphTargetsRelative=!0,n}))}))}function ef(e,t){var r=e.getIndex();if(null===r){var n=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var o=0;o<i.count;o++)n.push(o);e.setIndex(n),r=e.getIndex()}var a=r.count-2,s=[];if(t===c.TriangleFanDrawMode)for(var l=1;l<=a;l++)s.push(r.getX(0)),s.push(r.getX(l)),s.push(r.getX(l+1));else for(var u=0;u<a;u++)u%2==0?(s.push(r.getX(u)),s.push(r.getX(u+1)),s.push(r.getX(u+2))):(s.push(r.getX(u+2)),s.push(r.getX(u+1)),s.push(r.getX(u)));return s.length/3!=a&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),(t=e.clone()).setIndex(s),t}class tf{constructor(e){this.materialMap={},this.textureMap={},this.materialIns={},this.textureIns={},this.pending=[],this.parser=null,this.processTextureMap=(()=>{const e=e=>{const{target:t,data:r}=e;var n;r&&(({x:e,y:n}="object"==typeof r?r:{x:r,y:r}),t.x=e,t.y=n)};return t=>{(0,Xe.js)(t,((t,r)=>{var{format:r,center:n,rotation:i,offset:o,repeat:a}=r;const s=this.textureIns[t];s&&(s.format=r,e({target:s.repeat,data:a}),e({target:s.center,data:n}),e({target:s.offset,data:o}),i&&(s.rotation=i),this.runScene.textureEx.initTextureAndAddtoAll(s))}))}})(),this.processMaterialMap=(()=>{const e=e=>{const{textures:t,normal:r,models:n,material:i}=e;this.runScene.optionsEx.options.texture.load&&this.processBaseMaterialTextures({material:i,textures:t}),this.runScene.materialEx.parseNromals(r,i),n.map((e=>e.material=i))},t=e=>{const{textures:t,normal:r,models:n,material:i}=e;e=(0,Xe.js)(t,((e,t)=>({type:e,texture:this.textureIns[t]})));const o=this.runScene.materialEx.getDataByType(r.type,{normal:r,textures:e,models:n,material:i});this.runScene.materialEx.parseNromals(r,o),o&&n.map((e=>e.material=o))};return r=>{(0,Xe.js)(r,((r,n)=>{const{material:i,models:o}=this.materialIns[r];i&&(({normal:r,textures:n}=n),(r.type?t:e)({textures:n,models:o,material:i,normal:r}),i.needsUpdate=!0)}))}})(),this.baseMaterialTextures=[],this.processBaseMaterialTextures=e=>{const{textures:t,material:r}=e;(0,Xe.js)(t,((e,t)=>{var n;(t=this.textureIns[t])&&(this.runScene.optionsEx.options.texture.lazyLoad.open&&"scene"===(null==(n=this.parser)?void 0:n.json.asset.ex.type)&&(null==(n=this.parser)?void 0:n.json.asset.ex.sceneEx.materialId)!==r.userData.id?this.baseMaterialTextures.push({material:r,type:e,texture:t}):(this.runScene.uniqueEx.texture.addMaterial(t,{material:r,type:e}),r[e]=t))}))},this.lazyLoad=(()=>{const e=()=>{this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),this.runScene.optionsEx.log("贴图懒加载完毕","base","success")},t=(r,n)=>{var i=this.baseMaterialTextures[r];if(!i)return n(),e();const{texture:o,type:a,material:s}=i;this.runScene.uniqueEx.texture.addMaterial(o,{material:s,type:a}),s[a]=o,s.needsUpdate=!0,setTimeout((()=>t(++r,n)),this.runScene.optionsEx.options.texture.lazyLoad.intervalTime)};return()=>new Promise((r=>{if(!this.runScene.optionsEx.options.texture.lazyLoad.open)return r(0),e();t(0,r)}))})(),this.runScene=e}processInput(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.parser=t}))}processTexture(e){const{textureDef:t,texture:r}=e;var{md5:e,format:n,size:i}=t;r.userData.md5=e,n&&(r.format=n,r.userData.format=n),r.userData.size=i,this.textureIns[t.id]=this.runScene.textureEx.getSameTexture(e,r)||r}process(e){var{materialDef:e,material:t,model:r}=e;this.materialIns[e.id]||(this.materialIns[e.id]={material:t,models:[]}),this.materialIns[e.id].models.push(r)}done(e){var{materialMap:e,textureMap:t}=e.asset.ex||{};return this.processTextureMap(t||{}),this.processMaterialMap(e||{}),this.pending.push(this.lazyLoad()),Promise.all(this.pending)}}class rf{constructor(e){this.runScene=e}done(e){var t,r,n,i;e.asset.ex&&(({camera:e,lights:t,sceneEx:r,options:n,controls:i}=e.asset.ex),this.camera(e),this.controls(i),this.lights(t),this.ex(r),this.options(n))}controls(e){var t,r;e&&(({x:e,y:t,z:r}=e),this.runScene.assetsEx.controls.target.set(e,t,r),this.runScene.assetsEx.controls.update())}camera(e){var{position:e,far:t,near:r,fov:n,name:i,userData:o}=this.runScene.loaderer.object.parse(e);const a=this.runScene.assetsEx.get().camera;a.position.copy(e),a.far=t,a.near=r,a.fov=n,a.name=i,a.updateProjectionMatrix(),a.userData.id=o.id,this.runScene.uniqueEx.model.add(a),this.runScene.assetsEx.get().controls.update()}lights(e){e.map((e=>{var t=e.type;(t=this.runScene.lightEx.lightExMap[t].parseJSON(e)).target&&this.runScene.modelEx.setSelectByModel(t.target),this.runScene.lightEx.setNull(t)}))}ex(e){var t,r;e=e.fog;const n=this.runScene.sceneEx.get();e&&(({color:e,near:t,far:r}=e),n.fog=new c.Fog(e,t,r),this.runScene.optionsEx.cb.setScene.cb({scene:n,type:"fog"}))}options(e){e.map((e=>{var{type:e,data:t}=e;const r=this.runScene.exporter.gltf.options.getParse(e);null!=r&&r.parse(t)}))}}class nf{constructor(e){this.runScene=e}setTextureLoader(e){this.textureLoader=e,this.initTextureLoader(e)}initTextureLoader(e){e instanceof rp&&e.setOptions({textureQuality:this.runScene.optionsEx.options.texture.quality})}}class of{constructor(e){this.parser=null,this.helperModels=[],this.pending=[],this.nodeType={MySpriteMaterial:Ya},this.cloneMap={},this.runScene=e,this.material=new tf(e),this.scene=new rf(e),this.options=new nf(e)}processInput(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.material.processInput(e,t)}))}beforeLoader(e){this.runScene.loaderer.gltf.beforeParse(null==(e=null==(e=e.asset)?void 0:e.ex)?void 0:e.type)}processNode(e){var t;let{node:r,nodeDef:n}=e;if((0,Xe.js)(this.runScene.modelEx.defNodeMap,((e,t)=>{var i=n[e];null!=i&&(r[e]=i)})),n.extras){const{layers:o,normal:a,local:s,cloneId:l,id:u}=n.extras;if(l&&(this.cloneMap[l]||(this.cloneMap[l]=new Set),u&&this.cloneMap[l].add(u)),s&&([e,t,i]=s.split(","),r.position.set(e,t,i)),o&&(r.layers.enable(1),this.runScene.optionsEx.cb.model.setLayers.cb({model:r,val:1})),n.extras.isHelper&&this.helperModels.push(r),a){const n=this.nodeType[null==a?void 0:a.type].modelTools.parseData(r,a);var i=null==(t=null==(e=null==r?void 0:r.material)?void 0:e.userData)?void 0:t.id;if(i){const e=this.material.materialIns[i];if(e){const t=[];e.models.map((e=>{e===r?t.push(n):t.push(e)})),e.models=t}}r=n}}return n.wireframe&&(r.material.wireframe=!0),r}done(e){var t;return this.pending.push(this.material.done(e)),"scene"===(null==(t=e.asset.ex)?void 0:t.type)&&(this.scene.done(e),this.sceneEx(e)),this.removeHelperModel(),Promise.all(this.pending)}mergeGeometry(){}mergeClone(){this.runScene.optionsEx.options.instanceClone&&(0,Xe.js)(this.cloneMap,((e,t)=>{const r=this.runScene.uniqueEx.model.get(e);(e=[...t].map((e=>{if((null==(e=this.runScene.uniqueEx.model.get(e))?void 0:e.material)===r.material)return this.runScene.modelEx.remove(e,!1),e})).filter((e=>e))).length&&(t=ns(r,e),this.runScene.modelEx.add(t,r.parent),this.runScene.modelEx.remove(r,!1))}))}sceneEx(e){const t=this.runScene.sceneEx.get();var r=this.material.materialIns,{materialId:e,backgroundMapping:n,backgroundColor:i,fog:o}=e.asset.ex.sceneEx;if(e&&(e=null==(r=r[e])?void 0:r.material)){const{map:r,envMap:i}=e;r&&(r.mapping=n||300,r.needsUpdate=!0,this.runScene.sceneEx.setBackground(r,!1),r.userData.isBackgroud=!0),i&&(t.environment=Li(i))}i&&(t.background=new c.Color("#"+i)),o&&(({color:r,far:e,near:n}=o),t.fog=new c.Fog("#"+r,n,e),t.fog.open="true"),this.runScene.optionsEx.cb.setScene.cb({scene:t,type:"any"})}removeHelperModel(){this.helperModels.map((e=>{var t;return null==(t=e.parent)?void 0:t.remove(e)}))}}class af{constructor(e){this.dracoPath="./draco/",this._gltf=new yp,this.runScene=e;const t=new Yh;t.setDecoderPath(this.runScene.optionsEx.options.decodePath),this._gltf.setDRACOLoader(t)}load(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var r=yield Jo(e);return r?this.parse(r,t):Promise.resolve()}))}parse(e,t){return new Promise((r=>{try{e instanceof ArrayBuffer&&this._gltf.parse(e,"",(e=>{e=this.afterParse(e.parser.options.myOptions,e,t),r(e)}),(e=>{}),{rootModel:this.runScene.assetsEx.get().scene,models:[],helper:new of(this.runScene),runScene:this.runScene})}catch(e){this.runScene.optionsEx.log("加载场景出错:"+e)}}))}beforeParse(e){"scene"===e&&this.runScene.optionsEx.sceneOptions.loaded&&this.runScene.sceneEx.clean()}afterParse(e,t,r){const n=e.helper.done(t);var{addToScene:r,cleanJSON:i}=$o({addToScene:!0,cleanJSON:!0},{config:r}),o=e.models;let a=[];return"material"===t.asset.ex.type?this.parseMaterial(o):("model"===t.asset.ex.type&&(a=this.parseModel(o[0],r)),"scene"===t.asset.ex.type&&(a=this.parseScene({model:o[0],json:t,addToScene:r})),this.runScene.modelEx.selectNull(),e.helper.mergeClone(),this.runScene.optionsEx.log(t,"detail"),n.then((()=>{this.runScene.optionsEx.cb.load.complete.cb("")}))),!1!==i&&this.disposeJSON(t),this.runScene.optionsEx.sceneOptions.loaded=!0,a}parseMaterial(e){var t,[e]=e;(e=this.runScene.sceneEx.cleanUnlessLevel(e).material)&&(this.runScene.materialEx.add(e),(t=this.runScene.modelEx.select)&&this.runScene.materialEx.resetMaterial(t,e))}parseModel(e,t){return e=e.children.filter((e=>{if(!this.runScene.modelEx.isUnless(e))return e.userData.id=(0,l.getId)(),e})),!1!==t&&this.runScene.modelEx.add(e,void 0,{addUndo:!1,select:!1}),e}parseScene(e){const{model:t,json:r,addToScene:n}=e;return e=t.children.filter((e=>this.runScene.modelEx.isUnless(e)?void 0:e)),!1!==n&&this.runScene.modelEx.add(e,void 0,{addUndo:!1,select:!1}),this.runScene.timeLineEx.parseSavedGroupMap(r.asset.ex.timeLine||{}),this.runScene.optionsEx.cb.load.loaded.cb(""),e}disposeJSON(e){(0,Xe.js)(e,(t=>delete e[t])),e=null}}class sf{constructor(e){this.imgBitMap=new c.ImageBitmapLoader,this.object=new c.ObjectLoader,this.runScene=e,this.gltf=new af(e)}}var lf=a(185);class uf{constructor(e){this.selectors={},this.boxHelperMap={},(this.runScene=e).events.mouse.bindEvent({type:"up",local:"local",name:"MultipSelector",fn:t=>{e.events.key.ctrl||this.setEmpty()}})}add(e,t=!1){if("array"===(0,lf.getType)(e))return e.map((e=>this.add(e)));var r=this.runScene.modelEx.select;if(r&&(this.runScene.modelEx.selectNull(),delete this.selectors[e.uuid],this.add(r)),"BoxHelper"!==e.type){if(this.selectors[e.uuid]){if(this.remove(e),this.removeBoxHelper(e),!t)return;this.add(e)}this.addBoxHelper(e),this.selectors[e.uuid]=e,this.runScene.optionsEx.cb.model.focus.cb({model:e,status:!0,domActive:!0}),this.runScene.helperEx.focus(e)}}setInfo(e,t,r,n,i,o){"position"!==t&&(i=n,o=r);const a=this.getSelectedList("value");var{x:i,y:s,z:l}=i;const u=i-o.x,c=s-o.y,h=l-o.z,p=[new $a({target:e,info:t,oldV3:this.runScene.modelEx.cloneV3(r),newV3:n,runScene:this.runScene}).execute()];a.map((r=>{if(r!==e){var{x:n,y:i,z:o}=r[t],n=n+=u,i=i+=c,o=o+=h;let e=r[t].clone();e.x=n,e.y=i,e.z=o,n=new $a({target:r,info:t,oldV3:this.runScene.modelEx.cloneV3(r[t]),newV3:e,runScene:this.runScene}).execute(),p.push(n),this.boxHelperMap[r.uuid].setFromObject(r)}})),this.runScene.undoEx.addUndo(p)}getLast(){var e=this.getSelectedList("value");return e[e.length-1]}addBoxHelper(e){var t=this.runScene.helperEx.getBoxHelper(e);this.boxHelperMap[e.uuid]=t}removeBoxHelper(e){this.runScene.assetsEx.get().scene.remove(this.boxHelperMap[e.uuid]),this.boxHelperMap[e.uuid]=null,delete this.selectors[e.uuid]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));this.runScene.optionsEx.cb.model.unFocus.cb(e),this.selectors[e.uuid]=null,delete this.selectors[e.uuid]}isEmpty(){return 0===this.getSelectedList("key").length}getSelectedList(e){return"key"===e?Object.keys(this.selectors):Object.values(this.selectors)}getSelect(){var e=Object.values(this.selectors);return 0!==e.length?e:void 0}selectedLoop(e){return Object.keys(this.selectors).map((t=>e(t,this.selectors[t])))}delete(){this.setBoxHelperEmpty(),this.setEmpty(),this.runScene.helperEx.unfocus()}setBoxHelperEmpty(){var e=Object.values(this.boxHelperMap);this.runScene.assetsEx.get().scene.remove(...e),this.boxHelperMap={}}setEmpty(){this.getSelectedList("value").map((e=>{this.runScene.optionsEx.cb.model.unFocus.cb(e)})),this.setBoxHelperEmpty(),this.selectors={}}createGroup(){this.runScene.helperEx.unfocus(),this.runScene.modelEx.selectNull();var e=new c.Group;const t=new c.Group;this.runScene.modelEx.add(e,void 0,{addUndo:!1}),this.runScene.modelEx.add(t);var r=[...this.getSelectedList("value")],n=(this.runScene.optionsEx.cb.model.multipDrop.cb(this.getSelectedList("value"),e),Sa().group.getCenter(e));t.position.copy(n),this.runScene.optionsEx.cb.model.multipDrop.cb(r,t),this.runScene.modelEx.remove(e,!1),this.runScene.modelEx.select=t}getSelectorGroup(){const e=this.getSelectedList("value"),t=new c.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}}class cf{constructor(){this.cbs=[]}cb(e,t){return Promise.all(this.cbs.map((r=>r.fn(e,t))))}add(e,t){return this.cbs.push({fn:t,name:e})}}class hf{constructor(){this.resize=new cf,this.setSelectMaterial=new cf,this.setScene=new cf,this.reset=new cf,this.render=new cf,this.baseLog=new cf,this.inited=new cf,this.texture={add:new cf,remove:new cf},this.model={setSelect:new cf,add:new cf,remove:new cf,multipDrop:new cf,focus:new cf,unFocus:new cf,changeName:new cf,setOpen:new cf,setMainStatue:new cf,setVisible:new cf,setParent:new cf,setLayers:new cf,clone:new cf,dispose:new cf},this.material={add:new cf,dispose:new cf,setName:new cf},this.unique={material:{add:new cf}},this.undo={addUndos:new cf,removeUndos:new cf,undoByIndex:new cf,reset:new cf},this.scene={save:new cf,saveNet:new cf},this.timeLine={setProgress:new cf,playGroup:new cf,setGroupMap:new cf,reset:new cf,closeGroup:new cf},this.events={key:{g:new cf},mouse:{move:new cf,down:new cf,up:new cf},pointer:{down:new cf,up:new cf}},this.bloom={glow:{setData:new cf,setStatus:new cf}},this.load={lazyLoadedTexture:new cf,loaded:new cf,models:new cf,progress:new cf,getArrayBuffer:new cf,complete:new cf}}}function pf(){var e=0,t=document.createElement("div");function r(e){return t.appendChild(e.dom),e}function n(r){for(var n=0;n<t.children.length;n++)t.children[n].style.display=n===r?"block":"none";e=r}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(r){r.preventDefault(),n(++e%t.children.length)}),!1);var i,o=(performance||Date).now(),a=o,s=0,l=r(new pf.Panel("FPS","#0ff","#002")),u=r(new pf.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=r(new pf.Panel("MB","#f08","#201"))),n(0),{REVISION:16,dom:t,addPanel:r,showPanel:n,begin:function(){o=(performance||Date).now()},end:function(){s++;var e,t=(performance||Date).now();return u.update(t-o,200),a+1e3<=t&&(l.update(1e3*s/(t-a),100),a=t,s=0,i&&(e=performance.memory,i.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){o=this.end()},domElement:t,setMode:n}}pf.Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),s=80*a,l=48*a,u=3*a,c=2*a,h=3*a,p=15*a,f=74*a,d=30*a,m=document.createElement("canvas"),v=(m.width=s,m.height=l,m.style.cssText="width:80px;height:48px",m.getContext("2d"));return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,s,l),v.fillStyle=t,v.fillText(e,u,c),v.fillRect(h,p,f,d),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h,p,f,d),{dom:m,update:function(l,y){n=Math.min(n,l),i=Math.max(i,l),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,s,p),v.fillStyle=t,v.fillText(o(l)+" "+e+" ("+o(n)+"-"+o(i)+")",u,c),v.drawImage(m,h+a,p,f-a,d,h,p,f-a,d),v.fillRect(h+f-a,p,a,d),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h+f-a,p,a,o((1-l/y)*d))}}};const ff=pf;class df{constructor(e){this.options={msg:{show:!1,level:"base"},run:!0,decodePath:"./draco/",showFps:!1,loadInterval:2e3,mode:"running",hideLocal:!1,instanceClone:!1,render2:!1,render3:!1,texture:{load:!0,lazyLoad:{open:!1,intervalTime:16.6},quality:1}},this.exporterOptions={compressTexture:!1,notMaterial:!1},this.sceneOptions={loaded:!1},this.setLoadInterval=(()=>{let e=null;return t=>{const{inputInterval:r,cb:n}=t;e&&clearTimeout(e),e=setTimeout((()=>{n(),e=null,clearTimeout(e)}),r)}})(),this.cb=new hf,this.runScene=e}init(e){this.options=ba(this.options,e||{}),this.options.showFps&&(this.addFps(),this.cb.render.add("optionx-ex-render",this.render.bind(this)))}addFps(){this.stats=ff(),this.stats.showPanel(0),this.runScene.assetsEx.engineDom.appendChild(this.stats.dom)}render(){var e;null!=(e=this.stats)&&e.update()}log(e,t="detail",r="success"){var n;null!=(n=null==(n=this.options)?void 0:n.msg)&&n.show&&("base"===this.options.msg.level&&"base"===t&&this.cb.baseLog.cb(e,r),console.log(e))}}class mf{constructor(e){this.setSize=(e,t)=>{var{w:r,h:n}=this.getDomSize();this.runScene.setSize(e||r,t||n)},this.runScene=e}create(e){let t=new c.WebGLRenderer({antialias:!0,alpha:!0,powerPreference:"high-performance"});return t.domElement.style.position="absolute",t.setPixelRatio(window.devicePixelRatio),t.shadowMap.enabled=!0,t.shadowMap.type=c.PCFSoftShadowMap,t.physicallyCorrectLights=!0,t.localClippingEnabled=!0,e.appendChild(t.domElement),t}getDomSize(){var{clientWidth:e,clientHeight:t}=this.runScene.assetsEx.get().engineDom;return{w:e,h:t}}}const vf=(e,t)=>{t=(t||{}).removeDom,!(e.render=()=>{})!==t&&e.domElement.remove(),e.setAnimationLoop(null),e.dispose(),e.renderLists&&e.renderLists.dispose()};class yf{constructor(e){this.oldFog=null,this.removeMap={light:{valid:e=>this.runScene.lightEx.isLight(e),remove:e=>this.runScene.lightEx.remove(e)}},this.runScene=e}each(e){return this.runScene.assetsEx.get().scene.traverseAncestors(e)}get(){return new Proxy(this.runScene.assetsEx.get().scene,{set:(e,t,r)=>(e[t]=r,!0)})}getNromal(){return this.get().children.filter((e=>!this.runScene.helperEx.isHelper(e)))}remove(e){var t;if(e){if(e instanceof Array){const t=[];return e.map((e=>{for(const r in this.removeMap){const{valid:n,remove:i}=this.removeMap[r];if(n(e))return t.push(...(0,Ta.multiArrToArr)(i(e)))}t.push(new Ja({model:e,runScene:this.runScene,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(t),t}for(const t in this.removeMap){const{valid:r,remove:n}=this.removeMap[t];if(r(e))return n(e)}this.runScene.modelEx.remove(e),null!=(t=this.runScene.helperEx.boxHelper)&&t.setFromObject(this.get())}}cleanUnlessLevel(e){return this.runScene.modelEx.isUnlessLevel(e)&&!this.runScene.helperEx.isHelper(e)&&0!==e.children.length&&1===e.children.length?this.cleanUnlessLevel(e.children[0]):e}getClearModels(){return this.get().children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e)))}getClear(){const e=this.get(),t=new c.Group;return e.children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e))).map((e=>{t.add(e.clone())})),this.runScene.helperEx.setHelper(t),this.cleanUnlessLevel(t)}cleanNormal(){this.getNromal().map((e=>this.remove(e)))}cleanSceneInfo(e){e.background=null,e.environment=null,e.fog=null}setBackground(e,t=!0){e instanceof c.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),n=new za({target:r,info:"background",newVal:e,oldVal:r.background,runScene:this.runScene,cb:e=>{this.runScene.bloom.glow.setBackground(e.background)}}).execute();return t&&this.runScene.undoEx.addUndo(n),this.runScene.optionsEx.cb.setScene.cb({scene:r,type:"background"}),this.runScene.bloom.glow.setBackground(e),e}isBackground(e){return e.userData.isBackgroud}clean(){this.runScene.helperEx.unfocus();const e=this.getClearModels();let t=[];e.map((e=>{e.traverse((e=>t.push(e)))})),t.map((e=>{rs(e,{remove:!1}),this.runScene.optionsEx.cb.model.dispose.cb(e)})),vf(this.runScene.assetsEx.get().renderer),this.runScene.assetsEx.get().controls.dispose(),this.runScene.assetsEx.reset(),this.runScene.modelEx.selectNull(),this.cleanSceneInfo(this.get()),this.runScene.cameraEx.reset(this.runScene.assetsEx.get().camera),this.cleanNormal(),this.runScene.assetsEx.get().renderer.resetState(),this.runScene.assetsEx.get().controls.update(),this.runScene.uniqueEx.dispose(),this.runScene.materialEx.dispose(),this.runScene.undoEx.reset(),this.runScene.timeLineEx.reset(),this.runScene.bloom.glow.dispose(),this.runScene.bloom.glow.init(this.runScene.assetsEx.get()),this.runScene.helperEx.reset(),this.runScene.optionsEx.cb.reset.cb(this.get())}dispose(){const{renderer:e,controls:t}=this.runScene.assetsEx.get();this.clean(),vf(e),t.dispose(),this.runScene.bloom.glow.dispose(),c.Cache.clear()}render(){}create(){return new c.Scene}setEnv(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){let r;return t instanceof File&&(r=Li(yield this.runScene.textureEx.parse(t))),null!=t&&t.isTexture&&(r=Li(this.runScene.textureEx.clone(t))),this.setNormal({model:e,info:"environment",val:r}),this.runScene.optionsEx.cb.setScene.cb({scene:e,type:"environment"}),r}))}setNormal(e,t=!0){var{model:e,info:r,val:n}=e;e=new za({target:e,info:r,oldVal:e[r],newVal:n,runScene:this.runScene}).execute(),t&&this.runScene.undoEx.addUndo(e)}setFogShow(e){var{show:e,color:t,scene:r}=e;e?this.setNormal({model:r,info:"fog",val:this.oldFog||new c.Fog(t)}):(this.oldFog=r.fog,this.setNormal({model:r,info:"fog",val:null})),this.runScene.optionsEx.cb.setScene.cb({scene:r,type:"fog"})}setFog(e){var{scene:e,type:t,val:r}=e;e=new Oa({target:e,typeList:["fog",t],newVal:r}).execute(),this.runScene.undoEx.addUndo(e)}getFogJson(e){const{color:t,far:r,near:n}=e;return{color:t.getHexString(),far:r,near:n}}sreenShotDefFile(){this.runScene.helperEx.unfocus();var{w:e,h:t}=this.runScene.renderEx.getDomSize();const r=this.runScene.assetsEx.get().renderer.domElement,{renderer:n,scene:i,camera:o}=(r.width=1920,r.height=1080,this.runScene.renderEx.setSize(1920,1080),this.runScene.assetsEx.get());n.render(i,o);var a=r.toDataURL("image/webp",1);return a=(0,Ye.base64ToFile)(a,"screenShot.jpg"),r.width=e,r.height=t,this.runScene.renderEx.setSize(),n.render(i,o),a}}class gf{constructor(e,t){this.showTransform=!1,this.data=new Proxy({},{set:(e,t,r)=>(e[t]=r,!0)}),this.uuid="",this.getAnimaByModelData=(()=>{const e=(e,t,r,n)=>{const i={},o={};if(e=gf.isNotNow(e)?this.getAllData():e,(0,Xe.js)(n,((r,n)=>{void 0!==e[r]&&("number"===(n=n.type)?(i[r]=t[r],o[r]=e[r]):"color"===n&&(0,Xe.js)(e[r],((e,n)=>{var a=r+e;i[a]=t[r][e],o[a]=n})))})),!(0,Xe.CV)(i))return{begin:i,end:o}};return(t,r,n,i=!1,o)=>{let a=i?n.time:0;const s=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var l=(0,Ta.lastArrayEle)(s),u=i?"0.00":String(n.time);return l!==u&&(t[u]=Object.assign({},l),s.push(u)),s.map((s=>{var l=t[String(s)],u=.001*((u=i?a-s:s-a)<=0?.001:u)*n.speed;a=s;{var c=r,h=l,p=u,f=o;const t={color(e){const{animaData:t,defType:r}=e,n={};(0,Xe.js)(t,(e=>{var i;-1!==e.indexOf(r)&&(i=e.substring(r.length),["r","g","b"].includes(i)&&(n[i]=t[e]))}));var{r:e,g:i,b:o}=n;if((0,lf.isTrue)(e)&&(0,lf.isTrue)(i)&&(0,lf.isTrue)(o))return n}};return()=>{let r;return{promise:new Promise((n=>{var i;if(!(i=e(h,c,0,f)))return n(0);var{begin:i,end:o}=i;return r=_o(i,o,p,(e=>{(0,Xe.js)(f,((r,n)=>{n=n.type;var i,o=e[r];"number"===n?c[r]=o:"color"===n&&(o=t.color({animaData:e,defType:r}))&&(({r:n,g:o,b:i}=o),c[r].setRGB(n,o,i))}))}),n)})),anima:r}}}}))}})(),this.runScene=t,this.target=e,this.target.userData.isTimeLineUsed=!0,this.uuid=this.getId(e)}toJSON(){var{data:e,type:t}=this;return{data:e,type:t}}addData(e,t,r=!1){return 1e3<Number(e)&&(e="1000.00"),r?this.data[e]=this.getAllData():(this.data[e]||(this.data[e]={}),this.data[e][t]=this.getData(t)),this.data[e]}addTriggerNowData(e){return this.data[e]=this.getAllData(!0)}removeData(e){delete this.data[e]}static isNotNow(e){return"notNow"===Object.values(e)[0]}static getAllDefValByType(e,t,r=!1){const n={};return(0,Xe.js)(e,(i=>{n[i]=r?"notNow":gf.getValByType(t,i,e)})),n}static getValByType(e,t,r){var n,i;return r=r[t].type,e=e[t],"number"===r?e:"color"===r?(({r:t,g:n,b:i}=e),{r:t,g:n,b:i}):"V3"===r?Sa().model.v3ToMap(e):""}static SetTargetByData(e){const{baseType:t,data:r,defType:n,target:i}=e;var o,a;"number"===t?i[n]=r:"color"===t&&(({r:e,g:o,b:a}=r),i[n].setRGB(e,o,a))}getAllData(e=!1){return gf.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return gf.getValByType(this.target,e,this.defOptions)}static getTarget(e,t){}getAnima(e,t){return this.getAnimaByModelData(this.data,this.target,e,t,this.defOptions)}setTargetByBetween(e,t,r){gf.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const n=new(0,xf[r])(e);return n.data=t,n}reset(){(0,Xe.js)(this.defOptions,((e,t)=>{gf.SetTargetByData({baseType:t.type,data:gf.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}remove(){delete this.target.userData.isTimeLineUsed}}gf.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,n,i,o)=>{(0,Xe.js)(i,((i,a)=>{var s,l,u,c,h,p;a=a.type,void 0!==t[i]&&void 0!==r[i]&&gf.SetTargetByData({baseType:a,data:(s=t[i],l=r[i],u=n,"number"===a?e(s,l,u):"color"===a?(({r:a,g:s,b:c}=s),({r:l,g:h,b:p}=l),{r:e(a,l,u),g:e(s,h,u),b:e(c,p,u)}):void 0),defType:i,target:o})}))}})();const bf=gf,xf={model:class extends bf{constructor(e,t){super(e,t),this.type="model",this.defOptions={position:{type:"V3"},scale:{type:"V3"},rotation:{type:"V3"}},this.setTargetByBetween=(()=>{const e=(e,t,r)=>{var{x:e,y:n,z:i}=e,{x:t,y:o,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:n!==o?(o-n)*r+n:n,z:i!==a?(a-i)*r+i:i}};return(t,r,n)=>{var i,{position:t,scale:o,rotation:a}=t,{position:r,scale:s,rotation:l}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,n)),this.target.position.set(t,r,i)),o&&s&&(({x:t,y:r,z:i}=e(o,s,n)),this.target.scale.set(t,r,i)),a&&l&&(({x:o,y:s,z:t}=e(a,l,n)),this.target.rotation.set(o,s,t))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:n,rotation:i}=t,{position:e,scale:o,rotation:a}=bf.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},o?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:i.x,ry:i.y,rz:i.z}:{}),end:Object.assign({},r.curve?{ease:"none"}:{},e?{px:e.x,py:e.y,pz:e.z}:{},o?{sx:o.x,sy:o.y,sz:o.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{})}};return(t,r,n,i=!1)=>{let o=i?n.time:0;const a=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var s=(0,Ta.lastArrayEle)(a),l=i?"0.00":String(n.time)+".00";return s!==l&&(t[l]={position:"notNow",rotation:"notNow",scale:"notNow"},a.push(l)),a.map((a=>{var s,l,u,c,h=t[String(a)],p=.001*((p=i?o-a:a-o)<=0?.001:p)*n.speed;return o=a,s=r,l=h,u=p,c=n,()=>{let t;return{promise:new Promise((r=>{var{begin:n,end:i}=e(l,s,c);return t=_o(n,i,u,(e=>{var{px:e,py:t,pz:r,sx:n,sy:i,sz:o,rx:a,ry:u,rz:c}=e;l.position&&s.position.set(e,t,r),l.scale&&s.scale.set(n,i,o),l.rotation&&s.rotation.set(a,u,c)}),r)})),anima:t}}}))}})(),this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.model.get(e)}isRemoved(){return!(this.target&&this.target.parent)}getAnima(e,t=!1){return this.getAnimaByModelData(this.data,this.target,e,t)}getId(){return this.runScene.uniqueEx.getId(this.target)}reset(){var{position:e,scale:t,rotation:r}=this.beginData;this.target.position.set(e.x,e.y,e.z),this.target.scale.set(t.x,t.y,t.z),this.target.rotation.set(r.x,r.y,r.z)}},camera:class extends bf{constructor(e,t){super(e,t),this.type="camera",this.defOptions={position:{type:"V3"},scale:{type:"V3"},rotation:{type:"V3"},target:{type:"V3"}},this.setTargetByBetween=(()=>{const e=(e,t,r)=>{var{x:e,y:n,z:i}=e,{x:t,y:o,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:n!==o?(o-n)*r+n:n,z:i!==a?(a-i)*r+i:i}};return(t,r,n)=>{var i,{position:t,scale:o,rotation:a,target:s}=t,{position:r,scale:l,rotation:u,target:c}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,n)),this.target.position.set(t,r,i)),o&&l&&(({x:t,y:r,z:i}=e(o,l,n)),this.target.scale.set(t,r,i)),a&&u&&(({x:o,y:l,z:t}=e(a,u,n)),this.target.rotation.set(o,l,t)),s&&c&&(({x:r,y:i,z:a}=e(s,c,n)),this.controls.target.set(r,i,a))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:n,rotation:i}=t,{position:e,scale:o,rotation:a,target:s}=bf.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},o?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:i.x,ry:i.y,rz:i.z}:{},s?{tx:this.controls.target.x,ty:this.controls.target.y,tz:this.controls.target.z}:{}),end:Object.assign({},r.curve?{ease:"none"}:{},e?{px:e.x,py:e.y,pz:e.z}:{},o?{sx:o.x,sy:o.y,sz:o.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{},s?{tx:s.x,ty:s.y,tz:s.z}:{})}},t=(t,r,n,i)=>()=>{let o;return{promise:new Promise((a=>{var{begin:s,end:l}=e(r,t,i);return o=_o(s,l,n,(e=>{var{px:e,py:n,pz:i,sx:o,sy:a,sz:s,rx:l,ry:u,rz:c,tx:h,ty:p,tz:f}=e;r.position&&t.position.set(e,n,i),r.scale&&t.scale.set(o,a,s),r.rotation&&t.rotation.set(l,u,c),r.target&&this.controls.target.set(h,p,f)}),a)})),anima:_o}};return(e,r,n,i=!1)=>{let o=i?n.time:0;const a=Object.keys(e).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var s=(0,Ta.lastArrayEle)(a),l=i?"0.00":String(n.time);return s!==l&&(e[l]=Object.assign({},s),a.push(l)),a.map((a=>{var s=e[String(a)],l=.001*((l=i?o-a:a-o)<=0?.001:l)*n.speed;return o=a,t(r,s,l,n)}))}})(),this.controls=this.runScene.assetsEx.get().controls,this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.model.get(e)}getBeginData(e){return this.getAllData()}isRemoved(){return!this.target}getAllData(e=!1){var{position:t,scale:r,rotation:n}=this.target;return{position:e?"notNow":Sa().model.v3ToMap(t),scale:e?"notNow":Sa().model.v3ToMap(r),rotation:e?"notNow":Sa().model.v3ToMap(n),target:e?"notNow":Sa().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:n}=this.target;let i;if("position"===e)i=Sa().model.v3ToMap(t);else if("scale"===e)i=Sa().model.v3ToMap(r);else if("rotation"===e)i=Sa().model.v3ToMap(n);else{if("target"!==e)throw TypeError("输入值不存在");i=Sa().model.v3ToMap(this.controls.target)}return i}getAnima(e,t=!1){return this.getAnimaByModelData(this.data,this.target,e,t)}getId(){return this.runScene.uniqueEx.getId(this.target)}reset(){var{position:e,scale:t,rotation:r,target:n}=this.beginData;this.target.position.set(e.x,e.y,e.z),this.target.scale.set(t.x,t.y,t.z),this.target.rotation.set(r.x,r.y,r.z),this.controls.target.set(n.x,n.y,n.z)}},material:class extends bf{constructor(e,t){super(e,t),this.type="material",this.defOptions={roughness:{type:"number"},metalness:{type:"number"},opacity:{type:"number"},emissive:{type:"color"},color:{type:"color"}},this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.material.get(e)}isRemoved(){return!0}getId(){return this.runScene.uniqueEx.getId(this.target)}}};class wf{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){if(e&&e.userData){let n=e.userData.id;n||(n=(0,l.getId)(),e.userData.id=n),this.map[n]||(this.map[n]={material:e,models:new Set},this.unique.runScene.optionsEx.cb.unique.material.add.cb(e),t&&this.addModel(t,e,r))}}addModel(e,t,r){t&&t.userData&&(t=t.userData.id,null!=(t=this.map[t])&&t.models.add(e)),r&&null!=(t=this.map[r.userData.id])&&t.models.delete(e)}get(e){return null==(e=this.map[e])?void 0:e.material}remove(e){delete this.map[e]}addRemoved(e){this.map[e.uuid]&&this.removes.push(e.uuid)}dispose(){(0,Xe.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var Sf=a(1);class Tf extends class{constructor(e){this.map={},this.unique=e}add(e){if(e instanceof Array)return e.map((e=>this.add(e)));let t=e.userData.id;return t||(t=(0,l.getId)(),e.userData.id=t),this.map[t]?void 0:(this.map[t]=e,t)}get(e){return this.map[e]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));delete this.map[e.userData.id]}}{constructor(){super(...arguments),this.nameMap={},this.parseName=(()=>{const e=e=>{var t=e.lastIndexOf("_");return-1===t?-1:(e=e.slice(t+1),Sf.type.isNumber(e)?Number.parseInt(e):-1)},t=(r,n)=>{var i=(t=>{if(-1===e(t))return t;var r=t.lastIndexOf("_");return-1===r?t:t.slice(0,r)})(r)+"_"+n++;return this.nameMap[i]?t(r,n):i},r=e=>Object.keys(this.nameMap).find((t=>this.nameMap[t]===e)),n=["PerspectiveCamera"];return i=>{if(n.includes(i.type))return i.name=i.type;let o=i.name;if(Sf.valid.isTrue(o)||(o=i.type),!this.nameMap[o])return a=this.unique.getId(i),(s=r(a))&&delete this.nameMap[s],void(this.nameMap[o]=a);var a,s=this.nameMap[o];return this.unique.model.get(s)!==i?(a=e(o),a=t(o,s=-1===a?0:a),this.nameMap[a]=this.unique.getId(i),i.name=a):void 0}})()}add(e,t){var{reset:r,hasReset:n}=t||{};if(e instanceof Array)return e.map((e=>this.add(e,t)));if(e){let i=e.userData.id;if(i&&!r||(i=(0,l.getId)(),e.userData.id=i),this.map[i]){if(!n)return;i=(0,l.getId)(),e.userData.id=i}return this.map[i]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):i}}get(e){return this.map[e]}getByName(e){return this.nameMap[e]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));e.traverse((e=>{delete this.nameMap[e.name]})),delete this.map[e.userData.id]}dispose(){this.map={},this.nameMap={}}}class _f{constructor(e){this.map={},this.unique=e}add(e){if(e instanceof Array)return e.map((e=>this.add(e)));let t=e.userData.id;return t||(t=(0,l.getId)(),e.userData.id=t),this.map[t]?void 0:(this.map[t]={texture:e,materialMap:{}},t)}getLength(){return Object.keys(this.map).length}addMaterial(e,t,r){var n=e.userData.id;this.map[n]||this.add(e),t&&(({material:e,type:t}=t),this.map[n].materialMap[e.userData.id]||(this.map[n].materialMap[e.userData.id]=new Set),this.map[n].materialMap[e.userData.id].add(t)),r&&(({material:e,type:t}=r),this.map[n].materialMap[e.userData.id]&&this.map[n].materialMap[e.userData.id].delete(t))}get(e){return null==(e=this.map[e])?void 0:e.texture}getMaterials(e){return null==(e=this.map[e])?void 0:e.materialMap}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));delete this.map[e.userData.id]}dispose(){(0,Xe.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}class Mf{constructor(e){this.runScene=e,this.model=new Tf(this),this.material=new wf(this),this.texture=new _f(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}}const Ef={RunScene:class{constructor(e){this.uniqueEx=new Mf(this),this.fileEx=new qc(this),this.optionsEx=new df(this),this.undoEx=new Ea(this),this.textureEx=new Si(this),this.controlsEx=new Ge,this.assetsEx=new V(this),this.renderEx=new mf(this),this.events=new class{constructor(e){this.key=new xa(this),this.mouse=new wa(this),this.drag=new We(this),this.mouseEventMap={move:{timeLineMove:e=>{}},down:{},up:{timeLineUp:e=>{}}},this.mouseDown=e=>{},this.mouseUp=e=>{this.runScene.optionsEx.cb.events.mouse.up.cb(e),Object.values(this.mouseEventMap.up).map((t=>t(e)))},this.mouseMove=e=>{this.runScene.optionsEx.cb.events.mouse.move.cb(e),Object.values(this.mouseEventMap.move).map((t=>t(e)))},this.runScene=e}init(e){this.key.init(e),this.mouse.init(e),window.addEventListener("resize",(()=>{this.runScene.renderEx.setSize(),this.runScene.optionsEx.cb.resize.cb("")})),window.addEventListener("mousemove",this.mouseMove),window.addEventListener("mousedown",this.mouseDown),window.addEventListener("mouseup",this.mouseUp)}}(this),this.multipSelector=new uf(this),this.helperEx=null,this.materialEx=new Va(this),this.cameraEx=new De(this),this.sceneEx=new yf(this),this.modelEx=new es(this),this.loaderer=new sf(this),this.exporter=new Us(this),this.lightEx=new Hh(this),this.timeLineEx=new class{constructor(e){this.timerMap={},this.animaMap={},this.groupMap={},this.setModelLocal=(e,t)=>{Object.values(e.data).map((e=>{var r,n,i=((e,t)=>{let r=-1,n=1e3;const i=Object.keys(e).sort(((e,t)=>Number(e)-Number(t)));if(1!==i.length&&(i.map(((e,i)=>{e=Number(e),0<(e=t-e)&&e<n&&(n=e,r=i)})),-1!==r)){var o=i[r],a=i[r+1],s=e[o];if(e=e[a],s&&e){var l=Object.values(s)[0],u=Object.values(e)[0];if("notNow"!==l&&"notNow"!==u)return{left:s,right:e,progress:(t-Number(o))/(Number(a)-Number(o))}}}})(e.data,t);i&&(({left:i,right:r,progress:n}=i),e.setTargetByBetween(i,r,n))}))},this.runScene=e}reset(){this.timerMap={},this.animaMap={},this.groupMap={},this.runScene.optionsEx.cb.timeLine.reset.cb("")}closeGroup(e){var t,r;this.timerMap[e]&&(({setProgressTime:t,awaitRuned:r}=this.timerMap[e]),t&&clearInterval(t),r&&clearInterval(r)),this.groupMap[e].run=!1,this.runScene.optionsEx.cb.timeLine.closeGroup.cb(e);const n=this.animaMap[e];n&&n.length&&n.map((e=>{e.controls.clean=!0}))}resetGroup(e){var t=this.groupMap[e];t&&(this.closeGroup(e),this.runScene.optionsEx.cb.timeLine.setProgress.cb(0),Object.values(t.data).map((e=>e.reset())))}getSavedData(){return(0,Xe.js)(this.groupMap,((e,t)=>{t.run=!1})),this.groupMap}parseSavedGroupMap(e){Object.keys(e).map((t=>{const r=e[t],n={};(0,Xe.js)(r.data,((e,t)=>{var{type:t,data:r}=t;const i=xf[t];if(t=i.getTarget(e,this.runScene)){const o=new i(t,this.runScene);o.data=r,n[e]=o}})),r.data=n,this.groupMap[t]=r,this.runScene.optionsEx.cb.timeLine.setGroupMap.cb({group:r,groupName:t})}))}playGroup(e){this.runScene.helperEx.unfocus();const t=this.groupMap[e];if(t&&!t.run){t.run=!0;const n=Object.keys(t.data).map((e=>{const r=t.data[e],n=(r.data=new Proxy(r.data,{set:(e,t,r)=>(e[t]=r,!0)}),r.getAnima(t));return t.reverse&&(e=r.getAnima(t,!0),n.push(...e)),n})),i=(this.animaMap[e]||(this.animaMap[e]=[]),this.animaMap[e]=n.map((e=>(0,Ta.eachTriggerArrGetControls)(e))),t.time*t.speed*(t.reverse?2:1)),o=(new Date).valueOf(),a=i;var r=setInterval((()=>{var t=((new Date).valueOf()-o)/a;this.runScene.optionsEx.cb.timeLine.playGroup.cb({groupName:e,progress:t})}),16.6);let s;const l=new Promise((e=>s=setTimeout(e,i)));return this.timerMap[e]={setProgressTime:r,awaitRuned:s},l.then((()=>{if(clearInterval(this.timerMap[e].setProgressTime),t.run)return t.run=!1,t.loop?this.playGroup(e):void 0}))}}}(this),this.bloom={glow:new Le(this)};var{rootDom:t,options:r}=e;if(!t)throw TypeError("根节点或路径不可为空");this.optionsEx.init(r),(t=(r||{}).loadInterval)?this.optionsEx.setLoadInterval({inputInterval:t,cb:this.load.bind(this,e)}):this.load(e)}load(e){var{path:e,rootDom:t}=e;this.events.init(t),this.assetsEx.init(t),this.helperEx=new Ah(this);const{camera:r,controls:n}=this.assetsEx.get();this.uniqueEx.model.add(r),this.renderEx.setSize(),n.update(),this.bloom.glow.init(this.assetsEx.get()),this.optionsEx.cb.inited.cb(0),this.cameraEx.reset(r),this.loadScene(e)}loadScene(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){if(e instanceof ArrayBuffer)return this.optionsEx.log("正在解析二进制文件","base","info"),this.loaderer.gltf.parse(e);this.optionsEx.log("正在拉取场景","base","info");var t=yield s().get(e,{responseType:"arraybuffer",onUploadProgress:e=>{var{total:e,loaded:t}=e;let r=t/e;1<(r=r<0?0:r)&&(r=1),t=100*Number(r.toFixed(2)),this.optionsEx.log("下载场景进度:"+t,"detail"),this.optionsEx.cb.load.progress.cb(t)}}).then((e=>e.data)).catch((e=>{this.optionsEx.log("下载场景失败:",e)}));return t?(this.optionsEx.cb.load.getArrayBuffer.cb(t),this.optionsEx.log("拉取场景成功、正在解析","base","success"),this.loaderer.gltf.parse(t)):void 0}))}render(){var e;if(null!=(e=this.optionsEx.options)&&e.run){const{render2:e,render3:t,scene:r,camera:n}=this.assetsEx;this.optionsEx.cb.render.cb(""),this.bloom.glow.update(),null!=t&&t.render(r,n),null!=e&&e.render(r,n)}}dispose(){this.assetsEx.dispose(),this.sceneEx.clean()}on(e,t){return null!=(e=this.optionsEx.cb.load[e])&&e.add("load-callback"+(0,l.getId)(),t),this}setSize(e,t){const{camera:r,render3:n,render2:i,renderer:o}=this.assetsEx;r.aspect=e/t,r.updateProjectionMatrix(),null!=n&&n.setSize(e,t),null!=i&&i.setSize(e,t),o.setSize(e,t),this.bloom.glow.setSize(e,t)}},Utils:t,ModelEx:n,MaterialEx:r,TextureEx:e}})(),u.default;function a(e){var t=l[e];return void 0!==t||(t=l[e]={exports:{}},s[e].call(t.exports,t,t.exports,a)),t.exports}var s,l,u}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("uuid1"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):"function"==typeof define&&define.amd?define(["axios","uuid1","three","@allex/md5","js-funcs-three","js-funcs"],t):"object"==typeof exports?exports.RunScene=t(require("axios"),require("uuid1"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):e.RunScene=t(e.axios,e.uuid1,e.three,e["@allex/md5"],e["js-funcs-three"],e["js-funcs"])}(self,((e,t,r,n,i,o)=>{return s={685:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(t,"__esModule",{value:!0}),t.downloadFile=t.getFileName=t.urlToBase64=t.toResult=t.getPrefixWord=t.getBackWord=t.bToMB=t.arrayBufferToStr=t.strToArrayBuffer=t.toUrl=t.blobToDataUrl=t.bufferToArrayBuffer=t.base64ToFile=void 0,n(r(300)));t.base64ToFile=function(e,t){for(var r=(e=e.split(","))[0].match(/:(.*?);/)[1],n=atob(e[1]),i=n.length,o=new Uint8Array(i);i--;)o[i]=n.charCodeAt(i);return new File([o],t,{type:r})},t.bufferToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;++n)r[n]=e[n];return t},t.blobToDataUrl=function(e){return i.default.get(e,{baseURL:"",responseType:"blob",timeout:5e3}).then((function(e){return(0,t.toResult)(e.data)})).catch((function(e){return!1}))},t.toUrl=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"any.json";return e=e instanceof File?e:(e=JSON.stringify(e),new File([e],t)),window.URL.createObjectURL(e)},t.strToArrayBuffer=function(e){for(var t="",r=0;r<e.length;r++)""===t?t=e.charCodeAt(r).toString(16):t+=","+e.charCodeAt(r).toString(16);return new Uint8Array(t.match(/[\da-f]{2}/gi).map((function(e){return parseInt(e,16)}))).buffer},t.arrayBufferToStr=function(e){return new Promise((function(t){var r=new Blob([e]),n=new FileReader;n.readAsText(r,"utf-8"),n.onload=function(){t(n.result)}}))},t.bToMB=function(e){return e=e/1024/1024,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?e:e.toFixed(2)+"MB"},t.getBackWord=function(e){return e.substr(e.lastIndexOf(".")+1).toLowerCase()},t.getPrefixWord=function(e){return e.substr(0,e.lastIndexOf("."))},t.toResult=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"text",r=new FileReader;return"text"===t?r.readAsText(e):"arrayBuffer"===t?r.readAsArrayBuffer(e):"base64"===t&&r.readAsDataURL(e),new Promise((function(e){r.onload=function(t){return e(t.target.result)}}))},t.urlToBase64=function(e){return i.default.get(e,{responseType:"arraybuffer"}).then((function(e){var t=e.headers["content-type"];return e=new Buffer(e.data,"binary").toString("base64"),"data:".concat(t,";base64,")+e}))},t.getFileName=function(e){return e.substring(e.lastIndexOf("-")+1)},t.downloadFile=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"any.text",r=document.createElement("a");e instanceof File||e instanceof Blob?r.setAttribute("href",window.URL.createObjectURL(e)):r.setAttribute("href",e),r.setAttribute("download",t),document.body.insertAdjacentElement("beforeend",r),r.click(),r.remove()}},298:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(){i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=(m="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",a=m.asyncIterator||"@@asyncIterator",s=m.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(t){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i,o,a,s;return t=t&&t.prototype instanceof p?t:p,t=Object.create(t.prototype),n=new S(n||[]),t._invoke=(i=e,o=r,a=n,s="suspendedStart",function(e,t){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===e)throw t;return{value:void 0,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r&&(r=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return h;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}return"throw"===(n=c(n,t.iterator,r.arg)).type?(r.method="throw",r.arg=n.arg,r.delegate=null,h):(n=n.arg)?n.done?(r[t.resultName]=n.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,h):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}(r,a),r)){if(r===h)continue;return r}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===s)throw s="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);if(s="executing","normal"===(r=c(i,o,a)).type){if(s=a.done?"completed":"suspendedYield",r.arg===h)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(s="completed",a.method="throw",a.arg=r.arg)}}),t}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h={};function p(){}function f(){}function d(){}var m,v,y=(l(m={},o,(function(){return this})),(v=(v=Object.getPrototypeOf)&&v(v(T([]))))&&v!==t&&r.call(v,o)&&(m=v),d.prototype=p.prototype=Object.create(m));function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var i;this._invoke=function(o,a){function s(){return new t((function(i,s){!function i(o,a,s,l){var u;if("throw"!==(o=c(e[o],e,a)).type)return(a=(u=o.arg).value)&&"object"==n(a)&&r.call(a,"__await")?t.resolve(a.__await).then((function(e){i("next",e,s,l)}),(function(e){i("throw",e,s,l)})):t.resolve(a).then((function(e){u.value=e,s(u)}),(function(e){return i("throw",e,s,l)}));l(o.arg)}(o,a,i,s)}))}return i=i?i.then(s,s):s()}}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function T(e){if(e){var t,n=e[o];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return t=-1,(n=function n(){for(;++t<e.length;)if(r.call(e,t))return n.value=e[t],n.done=!1,n;return n.value=void 0,n.done=!0,n}).next=n}return{next:_}}function _(){return{value:void 0,done:!0}}return l(y,"constructor",f.prototype=d),l(d,"constructor",f),f.displayName=l(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(b.prototype),l(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new b(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),l(y,s,"Generator"),l(y,o,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t,r=[];for(t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;0<=i;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),l=r.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}var a=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,i=this.tryEntries[t];if(i.tryLoc===e)return"throw"===(r=i.completion).type&&(n=r.arg,w(i)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var s=this&&this.__awaiter||function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))},l=(Object.defineProperty(t,"__esModule",{value:!0}),t.deepArrByMaps=t.map=t.multiArrToArr=t.eachTriggerArray=t.eachTriggerArrGetControls=t.emptyArray=t.delArrEle=t.lastArrayEle=void 0,r(185));function u(e,t,r,n){return s(void 0,void 0,void 0,i().mark((function o(){var a,s,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=e[t++]){i.next=3;break}return i.abrupt("return",r());case 3:if((s=a())instanceof Promise)return i.next=7,s;i.next=11;break;case 7:l=i.sent,null!=n&&n.eachCb(l,t),i.next=18;break;case 11:if(s.promise&&s.promise instanceof Promise)return null!=n&&n.eachCb(s,t),i.next=15,s.promise;i.next=17;break;case 15:i.next=18;break;case 17:null!=n&&n.eachCb(s,t);case 18:u(e,t,r,n);case 19:case"end":return i.stop()}}),o)})))}function c(e,t){e.map((function(e){if("array"===(0,l.getType)(e))return c(e,t);t.push(e)}))}t.lastArrayEle=function(e){return e.slice(-1)[0]},t.delArrEle=function(e,t){var r=e.slice(0,t);return e=e.slice(t+1),[].concat(o(r),o(e))},t.emptyArray=function(e){return 0===e.length},t.eachTriggerArrGetControls=function(e){var r=new Proxy({run:!0,clean:!1,target:e,index:0,runningAnima:null,eachCb:function(e,t){e.anima&&(r.runningAnima=e.anima),r.index=t}},{set:function(e,t,n){return"clean"===t&&!0===n&&!1===e[t]&&(r.run=!1,r.target.splice(0)),"run"===t&&!1===n&&!0===e[t]&&(console.log(r,"controls"),r.runningAnima&&r.runningAnima.pause()),"run"===t&&!0===n&&!1===e[t]&&r.runningAnima&&r.runningAnima.resume(),e[t]=n,!0}});return e=(0,t.eachTriggerArray)(e,r),{controls:r,promise:e}},t.eachTriggerArray=function(e,t){return new Promise((function(r){return u(e,0,r,t)}))},t.multiArrToArr=function(e){var t=[];return c(e,t),t},t.map=function(e,t){return e.map((function(r,n){return t(r,n,e)})).filter((function(e){return e}))},t.deepArrByMaps=function(e){var r=e.arr,n=e.typeList,i=e.findType;if(e=e.mapType,!r||!n||!i)return r;var a=o(n),s=r.find((function(e){return e[i]===n[0]}));return s?1!==n.length&&s[e]instanceof Array?(a.shift(),(0,t.deepArrByMaps)({arr:s[e],typeList:a,findType:i,mapType:e})):s:r}},594:(e,t,r)=>{"use strict";t.qR=t.js=t.CV=void 0,r(185),t.CV=function(e){return 0===Object.values(e).length},t.js=function(e,t){return Object.keys(e).map((function(r,n){var i=e[r];return t(r,i,n)}))},t.qR=function(e,t){var r=-1;return function e(n){return r++,t.length===r+1?n:e(n[t[r]])}(e)}},251:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(t,"__esModule",{value:!0}),t.getId=t.getMacro=t.getUuid=void 0,n(r(937))),o=n(r(181));t.getUuid=function(){return i.default.UUID1()},t.getMacro=function(e){var t=setTimeout((function(){return clearTimeout(t),t=null,e()}),1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)},t.getId=function(){return(0,o.default)()}},185:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTrue=t.getType=void 0,t.getType=function(e){if(void 0!==e){if(null===e)return null;var t;switch(e.constructor){case Array:t="Array";break;case Object:t="Object";break;case String:t="String";break;case Number:t="Number";break;case Boolean:t="Boolean";break;case Function:t="Function"}return t&&t.toLowerCase()||"Object"}},t.isTrue=function(e){return!(null==e||!1===e)}},326:e=>{e.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*n*r/t.length),o="";;)for(var a=e(i),s=i;s--;)if((o+=t[a[s]&n]||"").length===+r)return o}},181:(e,t,r)=>{"use strict";e.exports=r(882)},488:(e,t,r)=>{"use strict";var n,i,o,a=r(87),s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function l(){o=!1}function u(e){if(e){if(e!==n){if(e.length!==s.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+s.length+" unique characters. These characters were not unique: "+t.join(", "));n=e,l()}}else n!==s&&(n=s,l())}function c(){return o=o||function(){n||u(s);var e,t=n.split(""),r=[];for(a.nextValue();0<t.length;)e=a.nextValue(),e=Math.floor(e*t.length),r.push(t.splice(e,1)[0]);return r.join("")}()}e.exports={get:function(){return n||s},characters:function(e){return u(e),n},seed:function(e){a.seed(e),i!==e&&(l(),i=e)},lookup:function(e){return c()[e]},shuffled:c}},239:(e,t,r)=>{"use strict";var n,i,o=r(253);r(488),e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===i?n++:(n=0,i=r),t=(t+=o(7))+o(e),0<n&&(t+=o(n)),t+o(r)}},253:(e,t,r)=>{"use strict";var n=r(488),i=r(19),o=r(326);e.exports=function(e){for(var t,r=0,a="";!t;)a+=o(i,n.get(),1),t=e<Math.pow(16,r+1),r++;return a}},882:(e,t,r)=>{"use strict";var n=r(488),i=r(239),o=r(40),a=r(595)||0;function s(){return i(a)}e.exports=s,e.exports.generate=s,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return a=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=o},40:(e,t,r)=>{"use strict";var n=r(488);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},19:e=>{"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r="object"===("undefined"==typeof window?"undefined":t(window))&&(window.crypto||window.msCrypto),n=r&&r.getRandomValues?function(e){return r.getRandomValues(new Uint8Array(e))}:function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(256*Math.random()));return t};e.exports=n},87:e=>{"use strict";var t=1;e.exports={nextValue:function(){return(t=(9301*t+49297)%233280)/233280},seed:function(e){t=e}}},595:e=>{"use strict";e.exports=0},129:e=>{"use strict";e.exports=n},300:t=>{"use strict";t.exports=e},1:e=>{"use strict";e.exports=o},356:e=>{"use strict";e.exports=i},881:e=>{"use strict";e.exports=r},937:e=>{"use strict";e.exports=t}},l={},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u={},(()=>{"use strict";a.d(u,{default:()=>Pf});var e={},t=(a.r(e),a.d(e,{bindTextureBaseData:()=>Pi,default:()=>Si,disposeTexture:()=>Ei,getBlobByTexture:()=>Oi,getMimeByTexture:()=>_i,getSizeByTexture:()=>Di,getTextureGpuMemory:()=>Mi,getUrlByTexture:()=>Ci,initTexture:()=>Ri,loadTexture:()=>Ai,parseImageBitMapByBlob:()=>ki,setTextureMapping:()=>Li,textureNameMap:()=>Ti}),{}),r=(a.r(t),a.d(t,{angleToNum:()=>ya,anima:()=>_o,arrayBufferToBase64:()=>Do,arrayBufferToBlobUr:()=>Co,arrayToVector3:()=>da,base64ToArrayBuffer:()=>ko,base64ToBlob:()=>jo,bitMapToCanvas:()=>Ho,blobToFile:()=>Bo,canvasToBlob:()=>Qo,changeModelOpc:()=>sa,changeModelOpcs:()=>la,clone:()=>aa,compressImgToUrl:()=>Go,deepMergeObject:()=>ba,domTo2Dui:()=>na,domTo3DSprite:()=>ia,domTo3Dui:()=>ra,fileAndBlobToCanvas:()=>Vo,fileToBlob:()=>Uo,getArrIndexByItem:()=>xa,getCamAnimaData:()=>ta,getCurve:()=>fa,getDistance:()=>ea,getFilesByDataTransfer:()=>Zo,getImgPixels:()=>Yo,getImgPixels1:()=>qo,getLine2:()=>ma,getMacro:()=>oa,getMd5:()=>Fo,getNamesByNum:()=>ua,getRes:()=>Jo,getTruthBase64:()=>Ao,getType:()=>ga,getTypeByBase64:()=>zo,getVideoTexture:()=>pa,getWorldLocal:()=>Mo,hslToRgb:()=>Xo,imgArrayBufferToBlobUrl:()=>Lo,imgBitMapToBase64:()=>Eo,imgBitMapToBlob:()=>Po,imgBitMapToBlobAndBase64:()=>Ro,mergeObject:()=>$o,removeUnLess:()=>ha,reverseImg:()=>Oo,rgbToHsl:()=>Wo,setDynamic:()=>va,textureToThreeD:()=>ca,transByte:()=>No,urlToBlob:()=>Io,vector:()=>Ko}),{}),n=(a.r(r),a.d(r,{createDefMaterial:()=>Ga,defAllMaterialMap:()=>Va,defBaseMaterialMap:()=>Fa,default:()=>Ha,disposeMaterial:()=>Xa,getTextures:()=>Ya,getTexturesByMaterial:()=>qa,mergeMaterial:()=>Wa}),{}),i=(a.r(n),a.d(n,{createDefModel:()=>rs,default:()=>ts,disposeModel:()=>ns,instanceModel:()=>is}),{}),o=(a.r(i),a.d(i,{AsyncCompress:()=>cu,AsyncDecompress:()=>Mu,AsyncDeflate:()=>ru,AsyncGunzip:()=>du,AsyncGzip:()=>cu,AsyncInflate:()=>au,AsyncUnzipInflate:()=>Yu,AsyncUnzlib:()=>wu,AsyncZipDeflate:()=>Gu,AsyncZlib:()=>gu,Compress:()=>uu,DecodeUTF8:()=>Au,Decompress:()=>_u,Deflate:()=>tu,EncodeUTF8:()=>Cu,Gunzip:()=>fu,Gzip:()=>uu,Inflate:()=>ou,Unzip:()=>Zu,UnzipInflate:()=>qu,UnzipPassThrough:()=>Xu,Unzlib:()=>xu,Zip:()=>Wu,ZipDeflate:()=>Hu,ZipPassThrough:()=>Vu,Zlib:()=>yu,compress:()=>hu,compressSync:()=>pu,decompress:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return(31==e[0]&&139==e[1]&&8==e[2]?mu:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?su:Su)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?vu:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?lu:Tu)(e,t)},deflate:()=>nu,deflateSync:()=>iu,gunzip:()=>mu,gunzipSync:()=>vu,gzip:()=>hu,gzipSync:()=>pu,inflate:()=>su,inflateSync:()=>lu,strFromU8:()=>Du,strToU8:()=>Lu,unzip:()=>function(e,t){if("function"!=typeof t)throw"no callback";for(var r=[],n=function(){for(var e=0;e<r.length;++e)r[e]()},i={},o=e.length-22;101010256!=Xl(e,o);--o)if(!o||65558<e.length-o)return void t("invalid zip file",null);var a=Wl(e,o+8);a||t(null,{});var s=a,l=Xl(e,o+16),u=4294967295==l;if(u){if(o=Xl(e,o-12),101075792!=Xl(e,o))return void t("invalid zip file",null);s=a=Xl(e,o+32),l=Xl(e,o+48)}for(var c=function(o){function s(e,r){e?(n(),t(e,null)):(i[f]=r,--a||t(null,i))}var c=(m=Uu(e,l,u))[0],h=m[1],p=m[2],f=m[3],d=m[4],m=m[5];if(m=ju(e,m),l=d,c)if(8==c)if(d=e.subarray(m,m+h),h<32e4)try{s(null,lu(d,new Vs(p)))}catch(o){s(o,null)}else r.push(su(d,{size:p},s));else s("unknown compression type "+c,null);else s(null,ml(e,m,m+h))},h=0;h<s;++h)c();return n},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=Xl(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var n=Wl(e,r+8);if(!n)return{};var i=Xl(e,r+16),o=4294967295==i;if(o){if(r=Xl(e,r-12),101075792!=Xl(e,r))throw"invalid zip file";n=Xl(e,r+32),i=Xl(e,r+48)}for(var a=0;a<n;++a){var s=(p=Uu(e,i,o))[0],l=p[1],u=p[2],c=p[3],h=p[4],p=p[5];if(p=ju(e,p),i=h,s){if(8!=s)throw"unknown compression type "+s;t[c]=lu(e.subarray(p,p+l),new Vs(u))}else t[c]=ml(e,p,p+l)}return t},unzlib:()=>Su,unzlibSync:()=>Tu,zip:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";function n(){for(var e=0;e<p.length;++e)p[e]()}function i(){for(var e=new Vs(u+22),t=l,n=u-l,i=u=0;i<c;++i){var o=h[i];try{var a=o.c.length,s=(Nu(e,u,o,o.f,o.u,a),30+o.f.length+zu(o.extra)),p=u+s;e.set(o.c,p),Nu(e,l,o,o.f,o.u,a,u,o.m),l+=16+s+(o.m?o.m.length:0),u=p+a}catch(e){return r(e,null)}}Fu(e,l,h.length,n,t),r(null,e)}var o={},a=(Eu(e,"",o,t),Object.keys(o)),s=a.length,l=0,u=0,c=s,h=new Array(s),p=[];s||i();for(var f=function(e){function t(t,o){t?(n(),r(t,null)):(t=o.length,h[e]=Cl(m,{size:y,crc:v.d(),c:o,f:g,m:w,u:b!=c.length||w&&x.length!=S,compression:_}),l+=30+b+T+t,u+=76+2*(b+T)+(S||0)+t,--s||i())}var c=a[e],f=o[c],d=f[0],m=f[1],v=Rl(),y=d.length,g=(v.p(d),Lu(c)),b=g.length,x=m.comment,w=x&&Lu(x),S=w&&w.length,T=zu(m.extra),_=0==m.level?0:8;if(65535<b&&t("filename too long",null),_)if(y<16e4)try{t(null,iu(d,m))}catch(f){t(f,null)}else p.push(nu(d,m,t));else t(null,d)},d=0;d<c;++d)f(d);return n},zipSync:()=>function(e,t){var r,n={},i=[],o=(Eu(e,"",n,t=t||{}),0),a=0;for(r in n){var s,l=(s=n[r])[0],u=0==(s=s[1]).level?0:8,c=(x=Lu(r)).length,h=s.comment,p=h&&Lu(h),f=p&&p.length,d=zu(s.extra);if(65535<c)throw"filename too long";var m=u?iu(l,s):l,v=m.length,y=Rl();y.p(l),i.push(Cl(s,{size:l.length,crc:y.d(),c:m,f:x,m:p,u:c!=r.length||p&&h.length!=f,o,compression:u})),o+=30+c+d+v,a+=76+2*(c+d)+(f||0)+v}for(var g=new Vs(a+22),b=(e=o,t=a-o,0);b<i.length;++b){var x=i[b],w=(Nu(g,x.o,x,x.f,x.u,x.c.length),30+x.f.length+zu(x.extra));g.set(x.c,x.o+w),Nu(g,o,x,x.f,x.u,x.c.length,x.o,x.m),o+=16+w+(x.m?x.m.length:0)}return Fu(g,o,i.length,t,e),g},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[Ul,Nl,function(){return[bu]}],(function(e){return Vl(bu(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>bu}),a(300)),s=a.n(o),l=a(251),c=a(881);function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=b(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(r=t?(r=b(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===h(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var x=new c.Vector3,w=new c.Quaternion,S=new c.Vector3,T=function(){v(t,c.Object3D);var e=g(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return p(this,t),(r=e.call(this)).element=n,r.element.style.position="absolute",r.element.style.pointerEvents="auto",r.element.style.userSelect="none",r.element.setAttribute("draggable",!1),r.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))})),r}return d(t,[{key:"copy",value:function(e,r){return m(b(t.prototype),"copy",this).call(this,e,r),this.element=e.element.cloneNode(!0),this}}]),t}(),_=(T.prototype.isCSS3DObject=!0,function(){v(t,T);var e=g(t);function t(r){return p(this,t),(r=e.call(this,r)).rotation2D=0,r}return d(t,[{key:"copy",value:function(e,r){return m(b(t.prototype),"copy",this).call(this,e,r),this.rotation2D=e.rotation2D,this}}]),t}()),M=(_.prototype.isCSS3DSprite=!0,new c.Matrix4),E=new c.Matrix4,P=d((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(p(this,e),this),s={camera:{fov:0,style:""},objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div"),u=(l.style.overflow="hidden",this.domElement=l,document.createElement("div"));function c(e){return Math.abs(e)<1e-10?0:e}function h(e){return"matrix3d("+c((e=e.elements)[0])+","+c(-e[1])+","+c(e[2])+","+c(e[3])+","+c(e[4])+","+c(-e[5])+","+c(e[6])+","+c(e[7])+","+c(e[8])+","+c(-e[9])+","+c(e[10])+","+c(e[11])+","+c(e[12])+","+c(-e[13])+","+c(e[14])+","+c(e[15])+")"}function f(e){return"translate(-50%,-50%)matrix3d("+c((e=e.elements)[0])+","+c(e[1])+","+c(e[2])+","+c(e[3])+","+c(-e[4])+","+c(-e[5])+","+c(-e[6])+","+c(-e[7])+","+c(e[8])+","+c(e[9])+","+c(e[10])+","+c(e[11])+","+c(e[12])+","+c(e[13])+","+c(e[14])+","+c(e[15])+")"}u.style.transformStyle="preserve-3d",u.style.pointerEvents="none",l.appendChild(u),this.getSize=function(){return{width:t,height:r}},this.render=function(e,t){var r=t.projectionMatrix.elements[5]*i,o=(s.camera.fov!==r&&(l.style.perspective=t.isPerspectiveCamera?r+"px":"",s.camera.fov=r),!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.isOrthographicCamera&&(o=-(t.right+t.left)/2,p=(t.top+t.bottom)/2),t.isOrthographicCamera?"scale("+r+")translate("+c(o)+"px,"+c(p)+"px)"+h(t.matrixWorldInverse):"translateZ("+r+"px)"+h(t.matrixWorldInverse)),p=o+"translate("+n+"px,"+i+"px)";s.camera.style!==p&&(u.style.transform=p,s.camera.style=p),function e(t,r,n,i){var o,l,c;t.isCSS3DObject&&(o=!0===t.visible&&!0===t.layers.test(n.layers),t.element.style.display=1==o?"":"none",1==o&&(t.onBeforeRender(a,r,n),o=t.isCSS3DSprite?(M.copy(n.matrixWorldInverse),M.transpose(),0!==t.rotation2D&&M.multiply(E.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(x,w,S),M.setPosition(x),M.scale(S),M.elements[3]=0,M.elements[7]=0,M.elements[11]=0,M.elements[15]=1,f(M)):f(t.matrixWorld),l=t.element,void 0!==(c=s.objects.get(t))&&c.style===o||(c={style:l.style.transform=o},s.objects.set(t,c)),l.parentNode!==u&&u.appendChild(l),t.onAfterRender(a,r,n)));for(var h=0,p=t.children.length;h<p;h++)e(t.children[h],r,n,i)}(e,e,t,o)},this.setSize=function(e,o){n=(t=e)/2,i=(r=o)/2,l.style.width=e+"px",l.style.height=o+"px",u.style.width=e+"px",u.style.height=o+"px"}}));function O(e){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,t,r){return t&&k(e.prototype,t),r&&k(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function C(){return(C="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=D(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var I=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&L(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=D(e);if(r=t?(r=D(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===O(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return R(this,n),(e=r.call(this)).element=t,e.element.style.position="absolute",e.element.style.userSelect="none",e.element.setAttribute("draggable",!1),e.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))})),e}return A(n,[{key:"copy",value:function(e,t){return C(D(n.prototype),"copy",this).call(this,e,t),this.element=e.element.cloneNode(!0),this}}]),n}(c.Object3D),j=(I.prototype.isCSS2DObject=!0,new c.Vector3),U=new c.Matrix4,B=new c.Matrix4,z=new c.Vector3,N=new c.Vector3,F=A((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(R(this,e),this),s={objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div");function u(e,t){return z.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(t.matrixWorld),z.distanceToSquared(N)}l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:t,height:r}},this.render=function(e,t){!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),U.copy(t.matrixWorldInverse),B.multiplyMatrices(t.projectionMatrix,U),function e(t,r,o){var c;t.isCSS2DObject&&(j.setFromMatrixPosition(t.matrixWorld),j.applyMatrix4(B),c=!0===t.visible&&-1<=j.z&&j.z<=1&&!0===t.layers.test(o.layers),t.element.style.display=1==c?"":"none",1==c&&(t.onBeforeRender(a,r,o),c=t.element,/apple/i.test(navigator.vendor)?c.style.transform="translate(-50%,-50%) translate("+Math.round(j.x*n+n)+"px,"+Math.round(-j.y*i+i)+"px)":c.style.transform="translate(-50%,-50%) translate("+(j.x*n+n)+"px,"+(-j.y*i+i)+"px)",c.parentNode!==l&&l.appendChild(c),t.onAfterRender(a,r,o)),c={distanceToCameraSquared:u(o,t)},s.objects.set(t,c));for(var h=0,p=t.children.length;h<p;h++)e(t.children[h],r,o)}(e,e,t);for(var r=function(e){var t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){return e.renderOrder!==t.renderOrder?t.renderOrder-e.renderOrder:s.objects.get(e).distanceToCameraSquared-s.objects.get(t).distanceToCameraSquared})),o=r.length,c=0,h=r.length;c<h;c++)r[c].element.style.zIndex=o-c},this.setSize=function(e,o){n=(t=e)/2,i=(r=o)/2,l.style.width=e+"px",l.style.height=o+"px"}}));class V{constructor(e){this.scene=null,this.camera=null,this.controls=null,this.renderer=null,this.engineDom=null,this.disposeRender=e=>{e&&(e.render=()=>{},e.domElement.remove())},this.runScene=e}initRender3(){const e=new P;return e.setSize(this.engineDom.clientWidth,this.engineDom.clientHeight),e.domElement.style.position="absolute",e.domElement.style.top=String(0),e.domElement.className="css3dRenderer",this.engineDom.appendChild(e.domElement),e}initRender2(){const e=new F;return e.setSize(this.engineDom.clientWidth,this.engineDom.clientHeight),e.domElement.style.position="absolute",e.domElement.classList.add("css2dRenderer"),e.domElement.style.top="0px",e.domElement.style.left="0px",this.engineDom.insertBefore(e.domElement,this.engineDom.childNodes[0]),e}reset(){this.renderer=this.runScene.renderEx.create(this.engineDom),this.runScene.renderEx.setSize(),this.renderer.setAnimationLoop(this.runScene.render.bind(this.runScene));var e=this.camera;this.controls=this.runScene.controlsEx.create(e,this.renderer.domElement)}dispose(){this.disposeRender(this.render2),this.disposeRender(this.render3)}init(e){var t=this.runScene.sceneEx.create(),r=this.runScene.cameraEx.create();const n=this.runScene.renderEx.create(e);var i=this.runScene.controlsEx.create(r,e),{render2:o,render3:a}=this.runScene.optionsEx.options;return this.camera=r,this.scene=t,this.renderer=n,this.controls=i,this.engineDom=e,this.runScene.renderEx.setSize(),o&&(this.render2=this.initRender2()),a&&(this.render3=this.initRender3()),n.setAnimationLoop(this.runScene.render.bind(this.runScene)),{scene:t,camera:r,render:n,controls:i,engineDom:e}}get(){var{scene:e,camera:t,renderer:r,controls:n,engineDom:i}=this;return{scene:e,camera:t,renderer:r,controls:n,engineDom:i}}}var H={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\tgl_FragColor = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor.a *= opacity;\n\n\n\t\t}"};function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function W(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function X(e,t,r){t&&W(e.prototype,t),r&&W(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var q=function(){function e(){G(this,e),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}return X(e,[{key:"setSize",value:function(){}},{key:"render",value:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}]),e}(),Y=new c.OrthographicCamera(-1,1,1,-1,0,1),Z=new c.BufferGeometry,Q=(Z.setAttribute("position",new c.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),Z.setAttribute("uv",new c.Float32BufferAttribute([0,2,0,0,2,0],2)),function(){function e(t){G(this,e),this._mesh=new c.Mesh(Z,t)}return X(e,[{key:"dispose",value:function(){this._mesh.geometry.dispose()}},{key:"render",value:function(e){e.render(this._mesh,Y)}},{key:"material",get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}]),e}());function K(e){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ee=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&J(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=$(e);if(r=t?(r=$(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===K(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t){var i;if(this instanceof n)return(i=r.call(this)).textureID=void 0!==t?t:"tDiffuse",e instanceof c.ShaderMaterial?(i.uniforms=e.uniforms,i.material=e):e&&(i.uniforms=c.UniformsUtils.clone(e.uniforms),i.material=new c.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:i.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),i.fsQuad=new Q(i.material),i;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"render",value:function(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),te={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new c.Color(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}"};function re(e){return(re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ne(e,t){return(ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){return(ie=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var oe=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ne(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ie(e);if(r=t?(r=ie(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===re(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){var a;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(a=r.call(this)).strength=void 0!==t?t:1,a.radius=i,a.threshold=o,a.resolution=void 0!==e?new c.Vector2(e.x,e.y):new c.Vector2(256,256),a.clearColor=new c.Color(0,0,0),a.renderTargetsHorizontal=[],a.renderTargetsVertical=[],a.nMips=5;var s=Math.round(a.resolution.x/2),l=Math.round(a.resolution.y/2);a.renderTargetBright=new c.WebGLRenderTarget(s,l),a.renderTargetBright.texture.name="UnrealBloomPass.bright",a.renderTargetBright.texture.generateMipmaps=!1;for(var u=0;u<a.nMips;u++){var h;((h=new c.WebGLRenderTarget(s,l)).texture.name="UnrealBloomPass.h"+u,h.texture.generateMipmaps=!1,a.renderTargetsHorizontal.push(h),h=new c.WebGLRenderTarget(s,l)).texture.name="UnrealBloomPass.v"+u,h.texture.generateMipmaps=!1,a.renderTargetsVertical.push(h),s=Math.round(s/2),l=Math.round(l/2)}i=te;for(var p=(a.highPassUniforms=c.UniformsUtils.clone(i.uniforms),a.highPassUniforms.luminosityThreshold.value=o,a.highPassUniforms.smoothWidth.value=.01,a.materialHighPassFilter=new c.ShaderMaterial({uniforms:a.highPassUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,defines:{}}),a.separableBlurMaterials=[],[3,5,7,9,11]),f=(s=Math.round(a.resolution.x/2),l=Math.round(a.resolution.y/2),0);f<a.nMips;f++)a.separableBlurMaterials.push(a.getSeperableBlurMaterial(p[f])),a.separableBlurMaterials[f].uniforms.texSize.value=new c.Vector2(s,l),s=Math.round(s/2),l=Math.round(l/2);return a.compositeMaterial=a.getCompositeMaterial(a.nMips),a.compositeMaterial.uniforms.blurTexture1.value=a.renderTargetsVertical[0].texture,a.compositeMaterial.uniforms.blurTexture2.value=a.renderTargetsVertical[1].texture,a.compositeMaterial.uniforms.blurTexture3.value=a.renderTargetsVertical[2].texture,a.compositeMaterial.uniforms.blurTexture4.value=a.renderTargetsVertical[3].texture,a.compositeMaterial.uniforms.blurTexture5.value=a.renderTargetsVertical[4].texture,a.compositeMaterial.uniforms.bloomStrength.value=t,a.compositeMaterial.uniforms.bloomRadius.value=.1,a.compositeMaterial.needsUpdate=!0,a.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],a.bloomTintColors=[new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1),new c.Vector3(1,1,1)],a.compositeMaterial.uniforms.bloomTintColors.value=a.bloomTintColors,e=H,a.copyUniforms=c.UniformsUtils.clone(e.uniforms),a.copyUniforms.opacity.value=1,a.materialCopy=new c.ShaderMaterial({uniforms:a.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:c.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),a.enabled=!0,a.needsSwap=!1,a._oldClearColor=new c.Color,a.oldClearAlpha=1,a.basic=new c.MeshBasicMaterial,a.fsQuad=new Q(null),a}return e=n,(t=[{key:"dispose",value:function(){for(var e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(var t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()}},{key:"setSize",value:function(e,t){var r=Math.round(e/2),n=Math.round(t/2);this.renderTargetBright.setSize(r,n);for(var i=0;i<this.nMips;i++)this.renderTargetsHorizontal[i].setSize(r,n),this.renderTargetsVertical[i].setSize(r,n),this.separableBlurMaterials[i].uniforms.texSize.value=new c.Vector2(r,n),r=Math.round(r/2),n=Math.round(n/2)}},{key:"render",value:function(e,t,r,i,o){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();for(var a=e.autoClear,s=(e.autoClear=!1,e.setClearColor(this.clearColor,0),o&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=r.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e),this.renderTargetBright),l=0;l<this.nMips;l++)this.fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[l].uniforms.direction.value=n.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=n.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this.fsQuad.render(e),s=this.renderTargetsVertical[l];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,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,o&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(r),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}},{key:"getSeperableBlurMaterial",value:function(e){return new c.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new c.Vector2(.5,.5)},direction:{value:new c.Vector2(.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}"})}},{key:"getCompositeMaterial",value:function(e){return new c.ShaderMaterial({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{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 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}"})}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function ae(e){return(ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function le(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ue(e,t,r){t&&le(e.prototype,t),r&&le(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function ce(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&he(e,t)}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=fe(e);if(r=t?(r=fe(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ae(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function fe(e){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}oe.BlurDirectionX=new c.Vector2(1,0),oe.BlurDirectionY=new c.Vector2(0,1);var de=function(){ce(t,q);var e=pe(t);function t(r,n){var i;return se(this,t),(i=e.call(this)).scene=r,i.camera=n,i.clear=!0,i.needsSwap=!1,i.inverse=!1,i}return ue(t,[{key:"render",value:function(e,t,r){var n,i,o=e.getContext(),a=e.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0),i=this.inverse?(n=0,1):(n=1,0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(o.REPLACE,o.REPLACE,o.REPLACE),a.buffers.stencil.setFunc(o.ALWAYS,n,4294967295),a.buffers.stencil.setClear(i),a.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(o.EQUAL,1,4294967295),a.buffers.stencil.setOp(o.KEEP,o.KEEP,o.KEEP),a.buffers.stencil.setLocked(!0)}}]),t}(),me=function(){ce(t,q);var e=pe(t);function t(){var r;return se(this,t),(r=e.call(this)).needsSwap=!1,r}return ue(t,[{key:"render",value:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}]),t}();function ve(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var ye=function(){function e(t,r){var n;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.renderer=t,void 0===r?(n=t.getSize(new c.Vector2),this._pixelRatio=t.getPixelRatio(),this._width=n.width,this._height=n.height,(r=new c.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio)).texture.name="EffectComposer.rt1"):(this._pixelRatio=1,this._width=r.width,this._height=r.height),this.renderTarget1=r,this.renderTarget2=r.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===ee&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new ee(H),this.clock=new c.Clock}return function(e,t,r){t&&ve(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"swapBuffers",value:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}},{key:"addPass",value:function(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}},{key:"insertPass",value:function(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}},{key:"removePass",value:function(e){-1!==(e=this.passes.indexOf(e))&&this.passes.splice(e,1)}},{key:"isLastEnabledPass",value:function(e){for(var t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}},{key:"render",value:function(e){void 0===e&&(e=this.clock.getDelta());for(var t=this.renderer.getRenderTarget(),r=!1,n=0,i=this.passes.length;n<i;n++){var o,a,s=this.passes[n];!1!==s.enabled&&(s.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(n),s.render(this.renderer,this.writeBuffer,this.readBuffer,e,r),s.needsSwap&&(r&&(o=this.renderer.getContext(),(a=this.renderer.state.buffers.stencil).setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),a.setFunc(o.EQUAL,1,4294967295)),this.swapBuffers()),void 0!==de&&(s instanceof de?r=!0:s instanceof me&&(r=!1)))}this.renderer.setRenderTarget(t)}},{key:"reset",value:function(e){var t;void 0===e&&(t=this.renderer.getSize(new c.Vector2),this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,(e=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}},{key:"setSize",value:function(e,t){this._width=e,this._height=t;var r=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(r,n),this.renderTarget2.setSize(r,n);for(var i=0;i<this.passes.length;i++)this.passes[i].setSize(r,n)}},{key:"setPixelRatio",value:function(e){this._pixelRatio=e,this.setSize(this._width,this._height)}}]),e}();function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function be(e,t){return(be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function xe(e){return(xe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}new c.OrthographicCamera(-1,1,1,-1,0,1),(o=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new c.Float32BufferAttribute([0,2,0,0,2,0],2));var we=function(){var e=n,t=q;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&be(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=xe(e);if(r=t?(r=xe(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ge(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){var a;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(a=r.call(this)).scene=e,a.camera=t,a.sampleLevel=4,a.unbiased=!0,a.clearColor=void 0!==i?i:0,a.clearAlpha=void 0!==o?o:0,a._oldClearColor=new c.Color,e=H,a.copyUniforms=c.UniformsUtils.clone(e.uniforms),a.copyMaterial=new c.ShaderMaterial({uniforms:a.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:c.AdditiveBlending,depthTest:!1,depthWrite:!1}),a.fsQuad=new Q(a.copyMaterial),a}return e=n,(t=[{key:"dispose",value:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}},{key:"setSize",value:function(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}},{key:"render",value:function(e,t,r){this.sampleRenderTarget||(this.sampleRenderTarget=new c.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var n=Se[Math.max(0,Math.min(this.sampleLevel,5))],i=e.autoClear,o=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),a=1/n.length,s=(this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,{fullWidth:r.width,fullHeight:r.height,offsetX:0,offsetY:0,width:r.width,height:r.height});(r=Object.assign({},this.camera.view)).enabled&&Object.assign(s,r);for(var l=0;l<n.length;l++){var u=n[l];this.camera.setViewOffset&&this.camera.setViewOffset(s.fullWidth,s.fullHeight,s.offsetX+.0625*u[0],s.offsetY+.0625*u[1],s.width,s.height),u=a,this.unbiased&&(u+=1/32*((l+.5)/n.length-.5)),this.copyUniforms.opacity.value=u,e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(this.renderToScreen?null:t),0===l&&(e.setClearColor(0,0),e.clear()),this.fsQuad.render(e)}this.camera.setViewOffset&&r.enabled?this.camera.setViewOffset(r.fullWidth,r.fullHeight,r.offsetX,r.offsetY,r.width,r.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),e.autoClear=i,e.setClearColor(this._oldClearColor,o)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),Se=[[[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]]];function Te(e){return(Te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _e(){return(_e="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ee(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function Me(e,t){return(Me=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ee(e){return(Ee=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Pe=function(){var e=n,t=we;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Me(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Ee(e);if(r=t?(r=Ee(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Te(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o){if(this instanceof n)return(e=r.call(this,e,t,i,o)).sampleLevel=0,e.accumulate=!1,e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"render",value:function(e,t,r,i){if(!1===this.accumulate)return _e(Ee(n.prototype),"render",this).call(this,e,t,r,i),void(this.accumulateIndex=-1);var o=Oe[5],a=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new c.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new c.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(_e(Ee(n.prototype),"render",this).call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0),i=e.autoClear,e.autoClear=!1,1/o.length);if(0<=this.accumulateIndex&&this.accumulateIndex<o.length){this.copyUniforms.opacity.value=a,this.copyUniforms.tDiffuse.value=t.texture;for(var s=Math.pow(2,this.sampleLevel),l=0;l<s;l++){var u=o[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*u[0],.0625*u[1],r.width,r.height),e.setRenderTarget(t),e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(this.sampleRenderTarget),0===this.accumulateIndex&&e.clear(),this.fsQuad.render(e),this.accumulateIndex++,this.accumulateIndex>=o.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(a=this.accumulateIndex*a)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),a<1&&(this.copyUniforms.opacity.value=1-a,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==a&&e.clear(),this.fsQuad.render(e)),e.autoClear=i}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}(),Oe=[[[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]]];class Re extends q{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof c.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=c.UniformsUtils.clone(e.uniforms),this.material=new c.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Q(this.material)}render(e,t,r){this.uniforms[this.baseTextureID]&&(this.uniforms[this.baseTextureID].value=t.texture),this.uniforms[this.effectTextureID]&&(this.uniforms[this.effectTextureID].value=r.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)}}class ke extends q{constructor(e,t,r,n,i){super(),this.scene=e,this.camera=t,this.layerIndex=0,this.overrideMaterial=r,this.clearColor=n,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.oldClearColor=new c.Color,this.oldCameraLayer=t.layers.mask}render(e,t,r){var n=e.autoClear;let i,o;e.autoClear=!1,void 0!==this.overrideMaterial&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this.oldClearColor),i=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.sceneBg&&(this.scene.background=null),e.setRenderTarget(this.renderToScreen?null:r),this.clear&&e.clear(e.autoClearColor,this.clearDepth,e.autoClearStencil),this.camera.layers.set(this.layerIndex),e.render(this.scene,this.camera),this.camera.layers.mask=this.oldCameraLayer,this.clearColor&&e.setClearColor(this.oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=o),this.scene.background=this.sceneBg,e.autoClear=n}}const Ae={uniforms:{baseTexture:{value:null},bloomTexture:{value:null}},vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D baseTexture;\n uniform sampler2D bloomTexture;\n \n varying vec2 vUv;\n \n void main() {\n vec4 lastColor = texture2D(baseTexture, vUv);\n \n // gl_FragColor = lastColor;\n // gl_FragColor = texture2D(bloomTexture, vUv);\n gl_FragColor = lastColor + texture2D(bloomTexture, vUv);\n }\n "};class Ce{constructor(e){this.modelLength=new Set,this.runScene=e,this.init()}init(){const{setLayers:e,add:t,remove:r}=this.runScene.optionsEx.cb.model;e.add("glow-set-layers",(e=>{var{model:e,val:t}=e;0===t&&0===this.modelLength.size||this[0===t?"remove":"add"](e)})),r.add("glow-set-layers",(({model:e})=>{1!==e.layers.mask&&this.remove(e)})),t.add("glow-set-layers",(({model:e})=>{1!==e.layers.mask&&this.add(e)}))}add(e){this.modelLength.add(e.userData.id),0<this.modelLength.size&&(this.runScene.optionsEx.cb.bloom.glow.setStatus.cb(!0),this.runScene.bloom.glow.bloomParams.isBloom=!0)}remove(e){this.modelLength.delete(e.userData.id),this.modelLength.size<=0&&(this.runScene.optionsEx.cb.bloom.glow.setStatus.cb(!1),this.runScene.bloom.glow.bloomParams.isBloom=!1)}}class Le{constructor(e){this.bloomParams={isBloom:!1,bloomStrength:2,bloomThreshold:0,bloomRadius:0},this.runScene=e,this.info=new Ce(this.runScene),this.BLOOM_SCENE=1,this.bloomParams.isBloom=!1,this.isUpdate=!0,this.sceneBackground=null,this.runScene.exporter.gltf.options.addOption({type:"bloom-glow",process:e=>this.toJSON(),parse:e=>{e=JSON.parse(e),this.setData(e)}})}static getInstance(e){return Le.instance||(Le.instance=new Le(e)),Le.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?c.ACESFilmicToneMapping:c.NoToneMapping)}init(e){var{camera:e,scene:t,renderer:r}=e;this.mainScene=t,this.mainCamera=e,this.renderer=r,this.renderer&&(t=this.renderer.getDrawingBufferSize(new c.Vector2),this.rtSize={width:t.width,height:t.height},this.postProcessing())}setData(e){e=e.bloomParams;var{bloomRadius:e,bloomStrength:t,bloomThreshold:r,isBloom:n}=e;this.bloomParams.isBloom=n,this.bloomParams.bloomRadius=e,this.bloomParams.bloomStrength=t,this.bloomParams.bloomThreshold=r,this.bloomPass&&(this.bloomPass.strength=t,this.bloomPass.radius=e,this.bloomPass.threshold=r),this.runScene.optionsEx.cb.bloom.glow.setData.cb(this.bloomParams)}setSize(e,t){this.renderer&&(this.rtSize={width:e,height:t},this.effectComposer&&this.effectComposer.setSize(this.rtSize.width,this.rtSize.height))}setBackground(e){this.sceneBackground&&this.sceneBackground instanceof c.Texture&&this.sceneBackground.dispose(),this.sceneBackground=e,this.bloomRenderPass&&(this.bloomRenderPass.sceneBg=this.sceneBackground)}setUpdate(e){this.isUpdate=e}postProcessing(){this.renderer&&(this.renderer.autoClear=!1),this.effectRT?(this.effectRT.setSize(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.dispose()):(this.effectRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=c.FloatType,this.effectRT.texture.format=c.RGBAFormat,this.effectRT.texture.encoding=c.sRGBEncoding,this.effectRT.texture.minFilter=c.LinearFilter,this.effectRT.texture.magFilter=c.LinearFilter),this.effectRT.depthTexture=new c.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=c.DepthFormat,this.effectRT.depthTexture.type=c.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new Pe(this.mainScene,this.mainCamera,0,0),this.taaRenderPass.unbiased=!1,this.taaRenderPass.sampleLevel=1,this.taaRenderPass.accumulate=!1),this.sampleRT?this.sampleRT.setSize(this.rtSize.width,this.rtSize.height):(this.sampleRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=c.FloatType,this.sampleRT.texture.format=c.RGBAFormat,this.sampleRT.texture.encoding=c.sRGBEncoding,this.sampleRT.texture.minFilter=c.LinearFilter,this.sampleRT.texture.magFilter=c.LinearFilter,this.sampleRT.depthTexture=this.effectRT.depthTexture,this.taaRenderPass.sampleRenderTarget=this.sampleRT),this.holdRT?this.holdRT.setSize(this.rtSize.width,this.rtSize.height):(this.holdRT=new c.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=c.FloatType,this.holdRT.texture.format=c.RGBAFormat,this.holdRT.texture.encoding=c.sRGBEncoding,this.holdRT.texture.minFilter=c.LinearFilter,this.holdRT.texture.magFilter=c.LinearFilter,this.holdRT.depthTexture=this.effectRT.depthTexture,this.taaRenderPass.holdRenderTarget=this.holdRT),this.bloomRenderPass?(this.bloomRenderPass.scene=this.mainScene,this.bloomRenderPass.camera=this.mainCamera):(this.bloomRenderPass=new ke(this.mainScene,this.mainCamera),this.bloomRenderPass.layerIndex=this.BLOOM_SCENE,this.bloomRenderPass.clearDepth=!1,this.bloomRenderPass.sceneBg=this.sceneBackground),this.bloomPass?this.bloomPass.setSize(this.rtSize.width,this.rtSize.height):this.bloomPass=new oe(new c.Vector2(this.rtSize.width,this.rtSize.height),1.5,.4,.85),this.bloomPass.strength=this.bloomParams.bloomStrength,this.bloomPass.radius=this.bloomParams.bloomRadius,this.bloomPass.threshold=this.bloomParams.bloomThreshold,this.mixingPass||(this.mixingPass=new Re(Ae,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new ee(H),this.effectCopy.clear=!1,this.effectCopy.renderToScreen=!1,this.effectCopy.needsSwap=!1,this.effectCopy.material.depthWrite=!1),this.effectComposer?this.effectComposer.renderer=this.renderer:(this.effectComposer=new ye(this.renderer,this.effectRT),this.effectComposer.addPass(this.taaRenderPass),this.effectComposer.addPass(this.effectCopy),this.effectComposer.addPass(this.bloomRenderPass),this.effectComposer.addPass(this.bloomPass),this.effectComposer.addPass(this.mixingPass))}dispose(){this.mainScene=null,this.mainCamera=null,this.setBackground(null),this.effectRT&&(this.effectRT.depthTexture.dispose(),this.effectRT.depthTexture=null,this.effectRT.dispose(),this.effectRT=null),this.sampleRT&&(this.sampleRT.depthTexture.dispose(),this.sampleRT.depthTexture=null,this.sampleRT.dispose(),this.sampleRT=null),this.holdRT&&(this.holdRT.depthTexture.dispose(),this.holdRT.depthTexture=null,this.holdRT.dispose(),this.holdRT=null),this.taaRenderPass&&(this.taaRenderPass.dispose(),this.taaRenderPass=null),this.bloomPass&&(this.bloomPass.dispose(),this.bloomPass=null),this.mixingPass=null,this.effectCopy=null,this.effectComposer&&(this.effectComposer.renderTarget1&&(this.effectComposer.renderTarget1.dispose(),this.effectComposer.renderTarget1=null),this.effectComposer.renderTarget2&&(this.effectComposer.renderTarget2.dispose(),this.effectComposer.renderTarget2=null),this.effectComposer=null)}update(){this.isUpdate&&this.mainCamera&&this.mainScene&&this.renderer&&(this.renderer.clear(),this.bloomParams.isBloom?this.effectComposer.render():this.renderer.render(this.mainScene,this.mainCamera))}toJSON(){const e={};var t=this.bloomParams;return e.bloomParams=Object.assign({},t),JSON.stringify(e)}reset(){this.bloomParams.isBloom=!1,this.rendererTone=!1,this.setBackground(null)}}class De{constructor(e){this.runScene=e}create(){return new c.PerspectiveCamera}reset(e){e.position.set(0,20,20);const t=this.runScene.assetsEx.get().controls;t.target.set(0,0,0),t.update()}get(){return this.runScene.assetsEx.get().camera}}function Ie(e){return(Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ue(e,t)}function Ue(e,t){return(Ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Be(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ze(e){return(ze=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ne={type:"change"},Fe={type:"start"},Ve={type:"end"},He=function(){je(t,c.EventDispatcher);var e=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ze(e);if(r=t?(r=ze(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ie(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return Be(n)}}(t);function t(r,n){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,t),i=e.call(this),void 0===n&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),n===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),i.object=r,i.domElement=n,i.domElement.style.touchAction="none",i.enabled=!0,i.target=new c.Vector3,i.minDistance=0,i.maxDistance=1/0,i.minZoom=0,i.maxZoom=1/0,i.minPolarAngle=0,i.maxPolarAngle=Math.PI,i.minAzimuthAngle=-1/0,i.maxAzimuthAngle=1/0,i.enableDamping=!1,i.dampingFactor=.05,i.enableZoom=!0,i.zoomSpeed=1,i.enableRotate=!0,i.rotateSpeed=1,i.enablePan=!0,i.panSpeed=1,i.screenSpacePanning=!0,i.keyPanSpeed=7,i.autoRotate=!1,i.autoRotateSpeed=2,i.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},i.mouseButtons={LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN},i.touches={ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN},i.target0=i.target.clone(),i.position0=i.object.position.clone(),i.zoom0=i.object.zoom,i._domElementKeyEvents=null,i.getPolarAngle=function(){return v.phi},i.getAzimuthalAngle=function(){return v.theta},i.getDistance=function(){return this.object.position.distanceTo(this.target)},i.listenToKeyEvents=function(e){e.addEventListener("keydown",re),this._domElementKeyEvents=e},i.saveState=function(){p.target0.copy(p.target),p.position0.copy(p.object.position),p.zoom0=p.object.zoom},i.reset=function(){p.target.copy(p.target0),p.object.position.copy(p.position0),p.object.zoom=p.zoom0,p.object.updateProjectionMatrix(),p.dispatchEvent(Ne),p.update(),d=f.NONE},i.update=(o=new c.Vector3,a=(new c.Quaternion).setFromUnitVectors(r.up,new c.Vector3(0,1,0)),s=a.clone().invert(),l=new c.Vector3,u=new c.Quaternion,h=2*Math.PI,function(){var e=p.object.position,t=(o.copy(e).sub(p.target),o.applyQuaternion(a),v.setFromVector3(o),p.autoRotate&&d===f.NONE&&L(2*Math.PI/60/60*p.autoRotateSpeed),p.enableDamping?(v.theta+=y.theta*p.dampingFactor,v.phi+=y.phi*p.dampingFactor):(v.theta+=y.theta,v.phi+=y.phi),p.minAzimuthAngle),r=p.maxAzimuthAngle;return isFinite(t)&&isFinite(r)&&(t<-Math.PI?t+=h:t>Math.PI&&(t-=h),r<-Math.PI?r+=h:r>Math.PI&&(r-=h),v.theta=t<=r?Math.max(t,Math.min(r,v.theta)):v.theta>(t+r)/2?Math.max(t,v.theta):Math.min(r,v.theta)),v.phi=Math.max(p.minPolarAngle,Math.min(p.maxPolarAngle,v.phi)),v.makeSafe(),v.radius*=g,v.radius=Math.max(p.minDistance,Math.min(p.maxDistance,v.radius)),!0===p.enableDamping?p.target.addScaledVector(b,p.dampingFactor):p.target.add(b),o.setFromSpherical(v),o.applyQuaternion(s),e.copy(p.target).add(o),p.object.lookAt(p.target),!0===p.enableDamping?(y.theta*=1-p.dampingFactor,y.phi*=1-p.dampingFactor,b.multiplyScalar(1-p.dampingFactor)):(y.set(0,0,0),b.set(0,0,0)),g=1,!(!(x||l.distanceToSquared(p.object.position)>m||8*(1-u.dot(p.object.quaternion))>m)||(p.dispatchEvent(Ne),l.copy(p.object.position),u.copy(p.object.quaternion),x=!1))}),i.dispose=function(){p.domElement.removeEventListener("contextmenu",ne),p.domElement.removeEventListener("pointerdown",K),p.domElement.removeEventListener("pointercancel",ee),p.domElement.removeEventListener("wheel",te),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$),null!==p._domElementKeyEvents&&p._domElementKeyEvents.removeEventListener("keydown",re)};var i,o,a,s,l,u,h,p=Be(i),f={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},d=f.NONE,m=1e-6,v=new c.Spherical,y=new c.Spherical,g=1,b=new c.Vector3,x=!1,w=new c.Vector2,S=new c.Vector2,T=new c.Vector2,_=new c.Vector2,M=new c.Vector2,E=new c.Vector2,P=new c.Vector2,O=new c.Vector2,R=new c.Vector2,k=[],A={};function C(){return Math.pow(.95,p.zoomSpeed)}function L(e){y.theta-=e}function D(e){y.phi-=e}I=new c.Vector3;var I,j,U,B=function(e,t){I.setFromMatrixColumn(t,0),I.multiplyScalar(-e),b.add(I)},z=(j=new c.Vector3,function(e,t){!0===p.screenSpacePanning?j.setFromMatrixColumn(t,1):(j.setFromMatrixColumn(t,0),j.crossVectors(p.object.up,j)),j.multiplyScalar(e),b.add(j)}),N=(U=new c.Vector3,function(e,t){var r,n=p.domElement;p.object.isPerspectiveCamera?(r=p.object.position,U.copy(r).sub(p.target),r=U.length(),r*=Math.tan(p.object.fov/2*Math.PI/180),B(2*e*r/n.clientHeight,p.object.matrix),z(2*t*r/n.clientHeight,p.object.matrix)):p.object.isOrthographicCamera?(B(e*(p.object.right-p.object.left)/p.object.zoom/n.clientWidth,p.object.matrix),z(t*(p.object.top-p.object.bottom)/p.object.zoom/n.clientHeight,p.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),p.enablePan=!1)});function F(e){p.object.isPerspectiveCamera?g/=e:p.object.isOrthographicCamera?(p.object.zoom=Math.max(p.minZoom,Math.min(p.maxZoom,p.object.zoom*e)),p.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),p.enableZoom=!1)}function V(e){p.object.isPerspectiveCamera?g*=e:p.object.isOrthographicCamera?(p.object.zoom=Math.max(p.minZoom,Math.min(p.maxZoom,p.object.zoom/e)),p.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),p.enableZoom=!1)}function H(e){w.set(e.clientX,e.clientY)}function G(e){_.set(e.clientX,e.clientY)}function W(){var e,t;1===k.length?w.set(k[0].pageX,k[0].pageY):(e=.5*(k[0].pageX+k[1].pageX),t=.5*(k[0].pageY+k[1].pageY),w.set(e,t))}function X(){var e,t;1===k.length?_.set(k[0].pageX,k[0].pageY):(e=.5*(k[0].pageX+k[1].pageX),t=.5*(k[0].pageY+k[1].pageY),_.set(e,t))}function q(){var e=k[0].pageX-k[1].pageX,t=k[0].pageY-k[1].pageY;e=Math.sqrt(e*e+t*t),P.set(0,e)}function Y(e){1==k.length?S.set(e.pageX,e.pageY):(r=ae(e),t=.5*(e.pageX+r.x),e=.5*(e.pageY+r.y),S.set(t,e)),T.subVectors(S,w).multiplyScalar(p.rotateSpeed);var t,r=p.domElement;L(2*Math.PI*T.x/r.clientHeight),D(2*Math.PI*T.y/r.clientHeight),w.copy(S)}function Z(e){var t,r;1===k.length?M.set(e.pageX,e.pageY):(t=ae(e),r=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),M.set(r,e)),E.subVectors(M,_).multiplyScalar(p.panSpeed),N(E.x,E.y),_.copy(M)}function Q(e){var t=ae(e),r=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(r*r+e*e),O.set(0,t),R.set(0,Math.pow(O.y/P.y,p.zoomSpeed)),F(R.y),P.copy(O)}function K(e){if(!1!==p.enabled)if(0===k.length&&(p.domElement.setPointerCapture(e.pointerId),p.domElement.addEventListener("pointermove",J),p.domElement.addEventListener("pointerup",$)),k.push(e),"touch"===e.pointerType){switch(oe(e),k.length){case 1:switch(p.touches.ONE){case c.TOUCH.ROTATE:if(!1===p.enableRotate)return;W(),d=f.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(!1===p.enablePan)return;X(),d=f.TOUCH_PAN;break;default:d=f.NONE}break;case 2:switch(p.touches.TWO){case c.TOUCH.DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;p.enableZoom&&q(),p.enablePan&&X(),d=f.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;p.enableZoom&&q(),p.enableRotate&&W(),d=f.TOUCH_DOLLY_ROTATE;break;default:d=f.NONE}break;default:d=f.NONE}d!==f.NONE&&p.dispatchEvent(Fe)}else{var t,r=e;switch(r.button){case 0:t=p.mouseButtons.LEFT;break;case 1:t=p.mouseButtons.MIDDLE;break;case 2:t=p.mouseButtons.RIGHT;break;default:t=-1}switch(t){case c.MOUSE.DOLLY:if(!1===p.enableZoom)return;!function(e){P.set(e.clientX,e.clientY)}(r),d=f.DOLLY;break;case c.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enablePan)return;G(r),d=f.PAN}else{if(!1===p.enableRotate)return;H(r),d=f.ROTATE}break;case c.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enableRotate)return;H(r),d=f.ROTATE}else{if(!1===p.enablePan)return;G(r),d=f.PAN}break;default:d=f.NONE}d!==f.NONE&&p.dispatchEvent(Fe)}}function J(e){if(!1!==p.enabled)if("touch"===e.pointerType){var t=e;switch(oe(t),d){case f.TOUCH_ROTATE:if(!1===p.enableRotate)return;Y(t),p.update();break;case f.TOUCH_PAN:if(!1===p.enablePan)return;Z(t),p.update();break;case f.TOUCH_DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;!function(e){p.enableZoom&&Q(e),p.enablePan&&Z(e)}(t),p.update();break;case f.TOUCH_DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;!function(e){p.enableZoom&&Q(e),p.enableRotate&&Y(e)}(t),p.update();break;default:d=f.NONE}}else{var r=e;if(!1!==p.enabled)switch(d){case f.ROTATE:if(!1===p.enableRotate)return;!function(e){S.set(e.clientX,e.clientY),T.subVectors(S,w).multiplyScalar(p.rotateSpeed),e=p.domElement,L(2*Math.PI*T.x/e.clientHeight),D(2*Math.PI*T.y/e.clientHeight),w.copy(S),p.update()}(r);break;case f.DOLLY:if(!1===p.enableZoom)return;!function(e){O.set(e.clientX,e.clientY),R.subVectors(O,P),0<R.y?F(C()):R.y<0&&V(C()),P.copy(O),p.update()}(r);break;case f.PAN:if(!1===p.enablePan)return;!function(e){M.set(e.clientX,e.clientY),E.subVectors(M,_).multiplyScalar(p.panSpeed),N(E.x,E.y),_.copy(M),p.update()}(r)}}}function $(e){ie(e),0===k.length&&(p.domElement.releasePointerCapture(e.pointerId),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$)),p.dispatchEvent(Ve),d=f.NONE}function ee(e){ie(e)}function te(e){!1!==p.enabled&&!1!==p.enableZoom&&d===f.NONE&&(e.preventDefault(),p.dispatchEvent(Fe),e.deltaY<0?V(C()):0<e.deltaY&&F(C()),p.update(),p.dispatchEvent(Ve))}function re(e){if(!1!==p.enabled&&!1!==p.enablePan){var t=!1;switch(e.code){case p.keys.UP:N(0,p.keyPanSpeed),t=!0;break;case p.keys.BOTTOM:N(0,-p.keyPanSpeed),t=!0;break;case p.keys.LEFT:N(p.keyPanSpeed,0),t=!0;break;case p.keys.RIGHT:N(-p.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),p.update())}}function ne(e){!1!==p.enabled&&e.preventDefault()}function ie(e){delete A[e.pointerId];for(var t=0;t<k.length;t++)if(k[t].pointerId==e.pointerId)return void k.splice(t,1)}function oe(e){var t=A[e.pointerId];void 0===t&&(t=new c.Vector2,A[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ae(e){return e=e.pointerId===k[0].pointerId?k[1]:k[0],A[e.pointerId]}return p.domElement.addEventListener("contextmenu",ne),p.domElement.addEventListener("pointerdown",K),p.domElement.addEventListener("pointercancel",ee),p.domElement.addEventListener("wheel",te,{passive:!1}),i.update(),i}return function(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}(t)}();class Ge{create(e,t){return new He(e,t)}}class We{constructor(e){this._state=!1,this._libsState=!1,this.map={val:"Box",type:"base-model"},this.libsMap={data:"Box",type:"texture"},this.events=e}get state(){return this._state}set state(e){this._state=e}setVal(e){this.state=!0,this.map=e}getVal(){if(this.state)return this.state=!1,this.map}setLibsVal(e){this._libsState=!0,this.libsMap=e}getLibsVal(){if(this._libsState)return this._libsState=!1,this.libsMap}}var Xe=a(594),qe=a(129),Ye=a(685);function Ze(){return(Ze="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=et(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function Qe(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ke(e,t)}function Ke(e,t){return(Ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Je(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=et(e);if(r=t?(r=et(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===at(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return $e(n)}}function $e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function et(e){return(et=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rt(e,t,r){return t&&tt(e.prototype,t),r&&tt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function nt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function it(e){return function(e){if(Array.isArray(e))return ot(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ot(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ot(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function at(e){return(at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function st(e){return void 0===e}function lt(){return"undefined"!=typeof window}function ut(e){return Ir(e)||Dr(e)}function ct(e){return(Zr=bt(e,Yr))&&mi}function ht(e,t){return!t&&console.warn(e)}function pt(e,t){return e&&(Yr[e]=t)&&Zr&&(Zr[e]=t)||Yr}function ft(){return 0}function dt(e,t,r){return(r=e[t])&&Ir(r)?e[t]():st(r)&&e.getAttribute&&e.getAttribute(t)||r}function mt(e,t){(e=e.split(",")).forEach(t)}function vt(e,t,r,n){Jr.length&&un(),e.render(t,r,n),Jr.length&&un()}function yt(e){var t=parseFloat(e);return(t||0===t)&&(e+"").match(Xr).length<2?t:Dr(e)?e.trim():e}function gt(e){return e}function bt(e,t){for(var r in t)e[r]=t[r];return e}function xt(e,t){for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=Ur(t[r])?xt(e[r]||(e[r]={}),t[r]):t[r]);return e}function wt(e){var t,r=e.parent||er,n=e.keyframes?(t=Nr(e.keyframes),function(e,r){for(var n in r)n in e||"duration"===n&&t||"ease"===n||(e[n]=r[n])}):cn;if(Br(e.inherit))for(;r;)n(e,r.vars.defaults),r=r.parent||r._dp;return e}function St(e){return!e||e._ts&&St(e.parent)}function Tt(e){return e._repeat?_t(e._tTime,e=e.duration()+e._rDelay)*e:0}function _t(e,t){return t=Math.floor(e/=t),e&&t===e?t-1:t}function Mt(e,t){return(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur)}function Et(e,t){var r;if((t._time||t._initted&&!t._dur)&&(r=Mt(e.rawTime(),t),(!t._dur||jt(0,t.totalDuration(),r)-t._tTime>Pr)&&t.render(r,!0)),dn(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur<e.duration())for(r=e;r._dp;)0<=r.rawTime()&&r.totalTime(r._tTime),r=r._dp;e._zTime=-Pr}}function Pt(e,t,r,n){return t.parent&&fn(t),t._start=ln((jr(r)?r:r||e!==er?Dt(e,r,t):e._time)+t._delay),t._end=ln(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),function(e,t){var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"_first",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_last",o=4<arguments.length?arguments[4]:void 0,a=e[i];if(o)for(r=t[o];a&&a[o]>r;)a=a._prev;a?(t._next=a._next,a._next=t):(t._next=e[n],e[n]=t),t._next?t._next._prev=t:e[i]=t,t._prev=a,t.parent=t._dp=e}(e,t,"_first","_last",e._sort?"_start":0),At(t)||(e._recent=t),n||Et(e,t),e}function Ot(e,t){(Yr.ScrollTrigger||Qr("scrollTrigger",t))&&Yr.ScrollTrigger.create(t,e)}function Rt(e,t,r,n){return Nn(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&or!==An.frame?(Jr.push(e),e._lazy=[t,n]):void 0:1}function kt(e){return(e=e.parent)&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||kt(e))}function At(e){return"isFromStart"===(e=e.data)||"isStart"===e}function Ct(e,t,r,n){var i=e._repeat,o=ln(t)||0;return(t=e._tTime/e._tDur)&&!n&&(e._time*=o/e._dur),e._dur=o,e._tDur=i?i<0?1e10:ln(o*(i+1)+e._rDelay*i):o,0<t&&!n?vn(e,e._tTime=e._tDur*t):e.parent&&mn(e),r||dn(e.parent,e),e}function Lt(e){return e instanceof Jn?dn(e):Ct(e,e._dur)}function Dt(e,t,r){var n,i,o,a=e.labels,s=e._recent||yn,l=e.duration()>=Er?s.endTime(!1):e._dur;return Dr(t)&&(isNaN(t)||t in a)?(i=t.charAt(0),o="%"===t.substr(-1),n=t.indexOf("="),"<"===i||">"===i?(0<=n&&(t=t.replace(/=/,"")),("<"===i?s._start:s.endTime(0<=s._repeat))+(parseFloat(t.substr(1))||0)*(o?(n<0?s:r).totalDuration()/100:1)):n<0?(t in a||(a[t]=l),a[t]):(i=parseFloat(t.charAt(n-1)+t.substr(n+1)),o&&r&&(i=i/100*(Nr(r)?r[0]:r).totalDuration()),1<n?Dt(e,t.substr(0,n-1),r)+i:l+i)):null==t?l:+t}function It(e,t,r){var n,i,o=jr(t[1]),a=(o?2:1)+(e<2?0:1),s=t[a];if(o&&(s.duration=t[1]),s.parent=r,e){for(n=s,i=r;i&&!("immediateRender"in n);)n=i.vars.defaults||{},i=Br(i.vars.inherit)&&i.parent;s.immediateRender=Br(n.immediateRender),e<2?s.runBackwards=1:s.startAt=t[a-1]}return new ii(t[0],s,t[1+a])}function jt(e,t,r){return r<e?e:t<r?t:r}function Ut(e){if(Ir(e))return e;var t=Ur(e)?e:{each:e},r=Un(t.ease),n=t.from||0,i=parseFloat(t.base)||0,o={},a=(e=0<n&&n<1,isNaN(n)||e),s=t.axis,l=n,u=n;return Dr(n)?l=u={center:.5,edges:.5,end:1}[n]||0:!e&&a&&(l=n[0],u=n[1]),function(e,c,h){var p,f,d,m,v,y,g,b,x=(h||t).length,w=o[x];if(!w){if(!(b="auto"===t.grid?0:(t.grid||[1,Er])[1])){for(y=-Er;y<(y=h[b++].getBoundingClientRect().left)&&b<x;);b--}for(w=o[x]=[],p=a?Math.min(b,x)*l-.5:n%b,f=b===Er?0:a?x*u/b-.5:n/b|0,g=Er,v=y=0;v<x;v++)m=v%b-p,d=f-(v/b|0),w[v]=m=s?Math.abs("y"===s?d:m):Ar(m*m+d*d),y<m&&(y=m),m<g&&(g=m);"random"===n&&Tn(w),w.max=y-g,w.min=g,w.v=x=(parseFloat(t.amount)||parseFloat(t.each)*(x<b?x-1:s?"y"===s?x/b:b:Math.max(b,x/b))||0)*("edges"===n?-1:1),w.b=x<0?i-x:i,w.u=bn(t.amount||t.each)||0,r=r&&x<0?jn(r):r}return x=(w[e]-w.min)/w.max||0,ln(w.b+(r?r(x):x)*w.v)+w.u}}function Bt(e){var t=Math.pow(10,((e+"").split(".")[1]||"").length);return function(r){var n=Math.round(parseFloat(r)/e)*e*t;return(n-n%1)/t+(jr(r)?0:bn(r))}}function zt(e,t){var r,n,i=Nr(e);return!i&&Ur(e)&&(r=i=e.radius||Er,e.values?(e=Sn(e.values),(n=!jr(e[0]))&&(r*=r)):e=Bt(e.increment)),gn(t,i?Ir(e)?function(t){return n=e(t),Math.abs(n-t)<=r?n:t}:function(t){for(var i,o,a=parseFloat(n?t.x:t),s=parseFloat(n?t.y:0),l=Er,u=0,c=e.length;c--;)(i=n?(i=e[c].x-a)*i+(o=e[c].y-s)*o:Math.abs(e[c]-a))<l&&(l=i,u=c);return u=!r||l<=r?e[u]:t,n||u===t||jr(t)?u:u+bn(t)}:Bt(e))}function Nt(e,t,r,n){return gn(Nr(e)?!t:!0===r?!!(r=0):!n,(function(){return Nr(e)?e[~~(Math.random()*e.length)]:(r=r||1e-5)&&(n=r<1?Math.pow(10,(r+"").length-2):1)&&Math.floor(Math.round((e-r/2+Math.random()*(t-e+.99*r))/r)*r*n)/n}))}function Ft(e,t,r){return gn(r,(function(r){return e[~~t(r)]}))}function Vt(e,t,r,n,i){var o=t-e,a=n-r;return gn(i,(function(t){return r+((t-e)/o*a||0)}))}function Ht(e,t,r){var n,i,o,a=e.labels,s=Er;for(n in a)(i=a[n]-t)<0==!!r&&i&&s>(i=Math.abs(i))&&(o=n,s=i);return o}function Gt(e,t,r){var n=e.vars,i=n[t];i&&(t=n[t+"Params"],n=n.callbackScope||e,r&&Jr.length&&un(),t?i.apply(n,t):i.call(n))}function Wt(e){return fn(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&Gt(e,"onInterrupt"),e}function Xt(e,t,r){return(6*(e+=e<0?1:1<e?-1:0)<1?t+(r-t)*e*6:e<.5?r:3*e<2?t+(r-t)*(2/3-e)*6:t)*Mn+.5|0}function qt(e,t,r){var n,i,o,a,s="",l=(e+s).match(Rn),u=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((function(e){return(e=Pn(e,t,1))&&u+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")"})),r&&(o=On(e),(n=r.c).join(s)!==o.c.join(s)))for(a=(i=e.replace(Rn,"1").split(Hr)).length-1;c<a;c++)s+=i[c]+(~n.indexOf(c)?l.shift()||u+"0,0,0,0)":(o.length?o:l.length?l:r).shift());if(!i)for(a=(i=e.split(Rn)).length-1;c<a;c++)s+=i[c]+l[c];return s+i[a]}function Yt(e,t){for(var r,n=e._first;n;)n instanceof Jn?Yt(n,t):!n.vars.yoyoEase||n._yoyo&&n._repeat||n._yoyo===t||(n.timeline?Yt(n.timeline,t):(r=n._ease,n._ease=n._yEase,n._yEase=r,n._yoyo=t)),n=n._next}function Zt(e,t){var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(e){return 1-t(1-e)},i={easeIn:t,easeOut:n,easeInOut:3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(e){return e<.5?t(2*e)/2:1-t(2*(1-e))/2}};mt(e,(function(e){for(var t in Ln[e]=Yr[e]=i,Ln[r=e.toLowerCase()]=n,i)Ln[r+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Ln[e+"."+t]=i[t]}))}function Qt(e){return function(t){return t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2}}function Kt(e,t,r){function n(e){return 1===e?1:i*Math.pow(2,-10*e)*Lr((e-o)*a)+1}var i=1<=t?t:1,o=(a=(r||(e?.3:.45))/(t<1?t:1))/Or*(Math.asin(1/i)||0),a=(r="out"===e?n:"in"===e?function(e){return 1-n(1-e)}:Qt(n),Or/a);return r.config=function(t,r){return Kt(e,t,r)},r}function Jt(e){function t(e){return e?--e*e*((r+1)*e+r)+1:0}var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1.70158,n="out"===e?t:"in"===e?function(e){return 1-t(1-e)}:Qt(t);return n.config=function(t){return Jt(e,t)},n}var $t,er,tr,rr,nr,ir,or,ar,sr,lr,ur,cr,hr,pr,fr,dr,mr,vr,yr,gr,br,xr,wr,Sr,Tr,_r={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},Mr={duration:.5,overwrite:!1,delay:0},Er=1e8,Pr=1/Er,Or=2*Math.PI,Rr=Or/4,kr=0,Ar=Math.sqrt,Cr=Math.cos,Lr=Math.sin,Dr=function(e){return"string"==typeof e},Ir=function(e){return"function"==typeof e},jr=function(e){return"number"==typeof e},Ur=function(e){return"object"==at(e)},Br=function(e){return!1!==e},zr="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},Nr=Array.isArray,Fr=/(?:-?\.?\d|\.)+/gi,Vr=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Hr=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,Gr=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,Wr=/[+-]=-?[.\d]+/,Xr=/[^,'"\[\]\s]+/gi,qr=/[\d.+\-=]+(?:e[-+]\d*)*/i,Yr={},Zr={},Qr=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Kr={},Jr=[],$r={},en={},tn={},rn=30,nn=[],on="",an=function(e){var t,r,n=e[0];if(Ur(n)||Ir(n)||(e=[e]),!(t=(n._gsap||{}).harness)){for(r=nn.length;r--&&!nn[r].targetTest(n););t=nn[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new Qn(e[r],t)))||e.splice(r,1);return e},sn=function(e){return e._gsap||an(Sn(e))[0]._gsap},ln=function(e){return Math.round(1e7*e)/1e7||0},un=function(){var e,t,r=Jr.length,n=Jr.slice(0);for($r={},e=Jr.length=0;e<r;e++)(t=n[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},cn=function(e,t){for(var r in t)r in e||(e[r]=t[r]);return e},hn=function(e,t){var r,n={};for(r in e)r in t||(n[r]=e[r]);return n},pn=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"_first",n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_last",i=t._prev,o=t._next;i?i._next=o:e[r]===t&&(e[r]=o),o?o._prev=i:e[n]===t&&(e[n]=i),t._next=t._prev=t.parent=null},fn=function(e,t){!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},dn=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var r=e;r;)r._dirty=1,r=r.parent;return e},mn=function(e){return e._end=ln(e._start+(e._tDur/Math.abs(e._ts||e._rts||Pr)||0))},vn=function(e,t){var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=ln(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),mn(e),r._dirty||dn(r,e)),e},yn={_start:0,endTime:ft,totalDuration:ft},gn=function(e,t){return e||0===e?t(e):t},bn=function(e,t){return Dr(e)&&(t=qr.exec(e))?e.substr(t.index+t[0].length):""},xn=[].slice,wn=function(e,t){return e&&Ur(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Ur(e[0]))&&!e.nodeType&&e!==tr},Sn=function(e,t,r){return!Dr(e)||r||!rr&&Cn()?Nr(e)?function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return e.forEach((function(e){return Dr(e)&&!t||wn(e,1)?r.push.apply(r,it(Sn(e))):r.push(e)}))||r}(e,r):wn(e)?xn.call(e,0):e?[e]:[]:xn.call((t||nr).querySelectorAll(e),0)},Tn=function(e){return e.sort((function(){return.5-Math.random()}))},_n=function(e){for(var t,r,n,i,o=0,a="";~(t=e.indexOf("random(",o));)n=e.indexOf(")",t),i="["===e.charAt(t+7),r=e.substr(t+7,n-t-7).match(i?Xr:Fr),a+=e.substr(o,t-o)+Nt(i?r:+r[0],i?0:+r[1],+r[2]||1e-5),o=n+1;return a+e.substr(o,e.length-o)},Mn=255,En={aqua:[0,Mn,Mn],lime:[0,Mn,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,Mn],navy:[0,0,128],white:[Mn,Mn,Mn],olive:[128,128,0],yellow:[Mn,Mn,0],orange:[Mn,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[Mn,0,0],pink:[Mn,192,203],cyan:[0,Mn,Mn],transparent:[Mn,Mn,Mn,0]},Pn=function(e,t,r){var n,i,o,a,s,l,u,c=e?jr(e)?[e>>16,e>>8&Mn,e&Mn]:0:En.black;if(!c){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),En[e])c=En[e];else if("#"===e.charAt(0)){if(9===(e=e.length<6?"#"+(n=e.charAt(1))+n+(i=e.charAt(2))+i+(o=e.charAt(3))+o+(5===e.length?e.charAt(4)+e.charAt(4):""):e).length)return[(c=parseInt(e.substr(1,6),16))>>16,c>>8&Mn,c&Mn,parseInt(e.substr(7),16)/255];c=[(e=parseInt(e.substr(1),16))>>16,e>>8&Mn,e&Mn]}else if("hsl"===e.substr(0,3))if(c=u=e.match(Fr),t){if(~e.indexOf("="))return c=e.match(Vr),r&&c.length<4&&(c[3]=1),c}else a=+c[0]%360/360,s=+c[1]/100,n=2*(l=+c[2]/100)-(i=l<=.5?l*(s+1):l+s-l*s),3<c.length&&(c[3]*=1),c[0]=Xt(a+1/3,n,i),c[1]=Xt(a,n,i),c[2]=Xt(a-1/3,n,i);else c=e.match(Fr)||En.transparent;c=c.map(Number)}return t&&!u&&(n=c[0]/Mn,i=c[1]/Mn,o=c[2]/Mn,l=((e=Math.max(n,i,o))+(t=Math.min(n,i,o)))/2,e===t?a=s=0:(u=e-t,s=.5<l?u/(2-e-t):u/(e+t),a=e===n?(i-o)/u+(i<o?6:0):e===i?(o-n)/u+2:(n-i)/u+4,a*=60),c[0]=~~(a+.5),c[1]=~~(100*s+.5),c[2]=~~(100*l+.5)),r&&c.length<4&&(c[3]=1),c},On=function(e){var t=[],r=[],n=-1;return e.split(Rn).forEach((function(e){e=e.match(Hr)||[],t.push.apply(t,it(e)),r.push(n+=e.length+1)})),t.c=r,t},Rn=function(){var e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in En)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),kn=/hsl[a]?\(/,An=(fr=Date.now,dr=500,mr=33,vr=fr(),yr=vr,br=gr=1e3/240,wr={time:0,frame:0,tick:function(){Bn(!0)},deltaRatio:function(e){return hr/(1e3/(e||60))},wake:function(){ir&&(!rr&&lt()&&(tr=rr=window,nr=tr.document||{},Yr.gsap=mi,(tr.gsapVersions||(tr.gsapVersions=[])).push(mi.version),ct(Zr||tr.GreenSockGlobals||!tr.gsap&&tr||{}),cr=tr.requestAnimationFrame),lr&&wr.sleep(),ur=cr||function(e){return setTimeout(e,br-1e3*wr.time+1|0)},sr=1,Bn(2))},sleep:function(){(cr?tr.cancelAnimationFrame:clearTimeout)(lr),sr=0,ur=ft},lagSmoothing:function(e,t){dr=e||1/Pr,mr=Math.min(t,dr,0)},fps:function(e){gr=1e3/(e||240),br=1e3*wr.time+gr},add:function(e){xr.indexOf(e)<0&&xr.push(e),Cn()},remove:function(e,t){~(t=xr.indexOf(e))&&xr.splice(t,1)&&t<=pr&&pr--},_listeners:xr=[]}),Cn=function(){return!sr&&An.wake()},Ln={},Dn=/^[\d.\-M][\d.\-,\s]/,In=/["']/g,jn=function(e){return function(t){return 1-e(1-t)}},Un=function(e,t){return e&&(Ir(e)?e:Ln[e]||function(e){var t,r,n,i=(e+"").split("("),o=Ln[i[0]];return o&&1<i.length&&o.config?o.config.apply(null,~e.indexOf("{")?[function(e){for(var t,r,n,i={},o=e.substr(1,e.length-3).split(":"),a=o[0],s=1,l=o.length;s<l;s++)r=o[s],t=s!==l-1?r.lastIndexOf(","):r.length,n=r.substr(0,t),i[a]=isNaN(n)?n.replace(In,"").trim():+n,a=r.substr(t+1).trim();return i}(i[1])]:(t=(i=e).indexOf("(")+1,r=i.indexOf(")"),n=i.indexOf("(",t),i.substring(t,~n&&n<r?i.indexOf(")",r+1):r).split(",").map(yt))):Ln._CE&&Dn.test(e)?Ln._CE("",e):o}(e))||t};function Bn(e){var t,r,n,i=fr()-yr,o=!0===e;if(dr<i&&(vr+=i-mr),(0<(i=(r=(yr+=i)-vr)-br)||o)&&(n=++wr.frame,hr=r-1e3*wr.time,wr.time=r/=1e3,br+=i+(gr<=i?4:gr-i),t=1),o||(lr=ur(Bn)),t)for(pr=0;pr<xr.length;pr++)xr[pr](r,hr,n,e)}function zn(e){return e<Tr?Sr*e*e:e<.7272727272727273?Sr*Math.pow(e-1.5/2.75,2)+.75:e<.9090909090909092?Sr*(e-=2.25/2.75)*e+.9375:Sr*Math.pow(e-2.625/2.75,2)+.984375}function Nn(e,t){var r,n,i,o,a,s,l,u,c,h,p,f,d,m=e.vars,v=m.ease,y=m.startAt,g=m.immediateRender,b=m.lazy,x=m.onUpdate,w=m.onUpdateParams,S=m.callbackScope,T=m.runBackwards,_=m.yoyoEase,M=m.keyframes,E=m.autoRevert,P=e._dur,O=e._startAt,R=e._targets,k=e.parent,A=k&&"nested"===k.data?k.parent._targets:R,C="auto"===e._overwrite&&!$t,L=e.timeline;if(e._ease=Un(v=!L||M&&v?v:"none",Mr.ease),e._yEase=_?jn(Un(!0===_?v:_,Mr.ease)):0,_&&e._yoyo&&!e._repeat&&(_=e._yEase,e._yEase=e._ease,e._ease=_),e._from=!L&&!!m.runBackwards,!L||M&&!m.stagger){if(f=(u=R[0]?sn(R[0]).harness:0)&&m[u.prop],r=hn(m,Kr),O&&fn(O.render(-1,!0)),y)if(fn(e._startAt=ii.set(R,cn({data:"isStart",overwrite:!1,parent:k,immediateRender:!0,lazy:Br(b),startAt:null,delay:0,onUpdate:x,onUpdateParams:w,callbackScope:S,stagger:0},y))),t<0&&!g&&!E&&e._startAt.render(-1,!0),g){if(0<t&&!E&&(e._startAt=0),P&&t<=0)return void(t&&(e._zTime=t))}else!1===E&&(e._startAt=0);else if(T&&P)if(O)E||(e._startAt=0);else if(i=cn({overwrite:!1,data:"isFromStart",lazy:(g=!t&&g)&&Br(b),immediateRender:g,stagger:0,parent:k},r),f&&(i[u.prop]=f),fn(e._startAt=ii.set(R,i)),t<0&&e._startAt.render(-1,!0),e._zTime=t,g){if(!t)return}else Nn(e._startAt,Pr);for(e._pt=0,b=P&&Br(b)||b&&!P,n=0;n<R.length;n++){if(l=(a=R[n])._gsap||an(R)[n]._gsap,e._ptLookup[n]=h={},$r[l.id]&&Jr.length&&un(),p=A===R?n:A.indexOf(a),u&&!1!==(c=new u).init(a,f||r,e,p,A)&&(e._pt=o=new pi(e._pt,a,c.name,0,1,c.render,c,0,c.priority),c._props.forEach((function(e){h[e]=o})),c.priority&&(s=1)),!u||f)for(i in r)en[i]&&(c=ti(i,r,e,p,a,A))?c.priority&&(s=1):h[i]=o=ei.call(e,a,i,"get",r[i],p,A,0,m.stringFilter);e._op&&e._op[n]&&e.kill(a,e._op[n]),C&&e._pt&&(Zn=e,er.killTweensOf(a,h,e.globalTime(t)),d=!e.parent,Zn=0),e._pt&&b&&($r[l.id]=1)}s&&hi(e),e._onInit&&e._onInit(e)}e._onUpdate=x,e._initted=(!e._op||e._pt)&&!d,M&&t<=0&&L.render(Er,!0,!0)}function Fn(e,t,r,n,i){return Ir(e)?e.call(t,r,n,i):Dr(e)&&~e.indexOf("random(")?_n(e):e}function Vn(e,t,r){return e.setAttribute(t,r)}function Hn(e,t){var r=t._pt,n="";if(!e&&t.b)n=t.b;else if(1===e&&t.e)n=t.e;else{for(;r;)n=r.p+(r.m?r.m(r.s+r.c*e):Math.round(1e4*(r.s+r.c*e))/1e4)+n,r=r._next;n+=t.c}t.set(t.t,t.p,n,t)}function Gn(e,t){for(var r=t._pt;r;)r.r(e,r.d),r=r._next}function Wn(e,t,r,n){for(var i,o=this._pt;o;)i=o._next,o.p===n&&o.modifier(e,t,r),o=i}function Xn(e){for(var t,r,n=this._pt;n;)r=n._next,n.p===e&&!n.op||n.op===e?pn(this,n,"_pt"):n.dep||(t=1),n=r;return!t}function qn(e,t,r,n){n.mSet(e,t,n.m.call(n.tween,r,n.mt),n)}function Yn(e,t){return{name:e,rawVars:1,init:function(e,r,n){n._onInit=function(e){var n,i;if(Dr(r)&&(n={},mt(r,(function(e){return n[e]=1})),r=n),t){for(i in n={},r)n[i]=t(r[i]);r=n}var o,a,s,l=e,u=r,c=l._targets;for(o in u)for(a=c.length;a--;)(s=(s=l._ptLookup[a][o])&&s.d)&&(s=s._pt?di(s,o):s)&&s.modifier&&s.modifier(u[o],l,c[a],o)}}}}mt("Linear,Quad,Cubic,Quart,Quint,Strong",(function(e,t){var r=t<5?t+1:t;Zt(e+",Power"+(r-1),t?function(e){return Math.pow(e,r)}:function(e){return e},(function(e){return 1-Math.pow(1-e,r)}),(function(e){return e<.5?Math.pow(2*e,r)/2:1-Math.pow(2*(1-e),r)/2}))})),Ln.Linear.easeNone=Ln.none=Ln.Linear.easeIn,Zt("Elastic",Kt("in"),Kt("out"),Kt()),Sr=7.5625,Tr=1/2.75,Zt("Bounce",(function(e){return 1-zn(1-e)}),zn),Zt("Expo",(function(e){return e?Math.pow(2,10*(e-1)):0})),Zt("Circ",(function(e){return-(Ar(1-e*e)-1)})),Zt("Sine",(function(e){return 1===e?1:1-Cr(e*Rr)})),Zt("Back",Jt("in"),Jt("out"),Jt()),Ln.SteppedEase=Ln.steps=Yr.SteppedEase={config:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,t=1<arguments.length?arguments[1]:void 0,r=1/e,n=e+(t?0:1),i=t?1:0,o=1-Pr;return function(e){return((n*jt(0,o,e)|0)+i)*r}}},Mr.ease=Ln["quad.out"],mt("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(function(e){return on+=e+","+e+"Params,"}));var Zn,Qn=rt((function e(t,r){nt(this,e),this.id=kr++,(t._gsap=this).target=t,this.harness=r,this.get=r?r.get:dt,this.set=r?r.getSetter:li})),Kn=function(){function e(t){nt(this,e),this.vars=t,this._delay=+t.delay||0,(this._repeat=t.repeat===1/0?-2:t.repeat||0)&&(this._rDelay=t.repeatDelay||0,this._yoyo=!!t.yoyo||!!t.yoyoEase),this._ts=1,Ct(this,+t.duration,1,1),this.data=t.data,sr||An.wake()}return rt(e,[{key:"delay",value:function(e){return e||0===e?(this.parent&&this.parent.smoothChildTiming&&this.startTime(this._start+e-this._delay),this._delay=e,this):this._delay}},{key:"duration",value:function(e){return arguments.length?this.totalDuration(0<this._repeat?e+(e+this._rDelay)*this._repeat:e):this.totalDuration()&&this._dur}},{key:"totalDuration",value:function(e){return arguments.length?(this._dirty=0,Ct(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}},{key:"totalTime",value:function(e,t){if(Cn(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(vn(this,e),r._dp&&!r.parent&&Et(r,this);r&&r.parent;)r.parent._time!==r._start+(0<=r._ts?r._tTime/r._ts:(r.totalDuration()-r._tTime)/-r._ts)&&r.totalTime(r._tTime,!0),r=r.parent;!this.parent&&this._dp.autoRemoveChildren&&(0<this._ts&&e<this._tDur||this._ts<0&&0<e||!this._tDur&&!e)&&Pt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===Pr||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),vt(this,e,t)),this}},{key:"time",value:function(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+Tt(this))%(this._dur+this._rDelay)||(e?this._dur:0),t):this._time}},{key:"totalProgress",value:function(e,t){return arguments.length?this.totalTime(this.totalDuration()*e,t):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.ratio}},{key:"progress",value:function(e,t){return arguments.length?this.totalTime(this.duration()*(!this._yoyo||1&this.iteration()?e:1-e)+Tt(this),t):this.duration()?Math.min(1,this._time/this._dur):this.ratio}},{key:"iteration",value:function(e,t){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(e-1)*r,t):this._repeat?_t(this._tTime,r)+1:1}},{key:"timeScale",value:function(e){if(!arguments.length)return this._rts===-Pr?0:this._rts;if(this._rts===e)return this;for(var t=this.parent&&this._ts?Mt(this.parent._time,this):this._tTime,r=(this._rts=+e||0,this._ts=this._ps||e===-Pr?0:this._rts,e=this.totalTime(jt(-this._delay,this._tDur,t),!0)).parent;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent;return mn(this),this}},{key:"paused",value:function(e){return arguments.length?(this._ps!==e&&((this._ps=e)?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(Cn(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==Pr&&(this._tTime-=Pr)))),this):this._ps}},{key:"startTime",value:function(e){var t;return arguments.length?(this._start=e,!(t=this.parent||this._dp)||!t._sort&&this.parent||Pt(t,this,e-this._delay),this):this._start}},{key:"endTime",value:function(e){return this._start+(Br(e)?this.totalDuration():this.duration())/Math.abs(this._ts||1)}},{key:"rawTime",value:function(e){var t=this.parent||this._dp;return t?e&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?Mt(t.rawTime(e),this):this._tTime:this._tTime}},{key:"globalTime",value:function(e){for(var t=this,r=arguments.length?e:t.rawTime();t;)r=t._start+r/(t._ts||1),t=t._dp;return r}},{key:"repeat",value:function(e){return arguments.length?(this._repeat=e===1/0?-2:e,Lt(this)):-2===this._repeat?1/0:this._repeat}},{key:"repeatDelay",value:function(e){var t;return arguments.length?(t=this._time,this._rDelay=e,Lt(this),t?this.time(t):this):this._rDelay}},{key:"yoyo",value:function(e){return arguments.length?(this._yoyo=e,this):this._yoyo}},{key:"seek",value:function(e,t){return this.totalTime(Dt(this,e),Br(t))}},{key:"restart",value:function(e,t){return this.play().totalTime(e?-this._delay:0,Br(t))}},{key:"play",value:function(e,t){return null!=e&&this.seek(e,t),this.reversed(!1).paused(!1)}},{key:"reverse",value:function(e,t){return null!=e&&this.seek(e||this.totalDuration(),t),this.reversed(!0).paused(!1)}},{key:"pause",value:function(e,t){return null!=e&&this.seek(e,t),this.paused(!0)}},{key:"resume",value:function(){return this.paused(!1)}},{key:"reversed",value:function(e){return arguments.length?(!!e!==this.reversed()&&this.timeScale(-this._rts||(e?-Pr:0)),this):this._rts<0}},{key:"invalidate",value:function(){return this._initted=this._act=0,this._zTime=-Pr,this}},{key:"isActive",value:function(){var e=this.parent||this._dp,t=this._start;return!(e&&!(this._ts&&this._initted&&e.isActive()&&(e=e.rawTime(!0))>=t&&e<this.endTime(!0)-Pr))}},{key:"eventCallback",value:function(e,t,r){var n=this.vars;return 1<arguments.length?(t?(n[e]=t,r&&(n[e+"Params"]=r),"onUpdate"===e&&(this._onUpdate=t)):delete n[e],this):n[e]}},{key:"then",value:function(e){var t=this;return new Promise((function(r){function n(){var e=t.then;t.then=null,Ir(i)&&(i=i(t))&&(i.then||i===t)&&(t.then=e),r(i),t.then=e}var i=Ir(e)?e:gt;t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?n():t._prom=n}))}},{key:"kill",value:function(){Wt(this)}}]),e}(),Jn=(cn(Kn.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-Pr,_prom:0,_ps:!1,_rts:1}),function(){Qe(t,Kn);var e=Je(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=1<arguments.length?arguments[1]:void 0;return nt(this,t),(r=e.call(this,n)).labels={},r.smoothChildTiming=!!n.smoothChildTiming,r.autoRemoveChildren=!!n.autoRemoveChildren,r._sort=Br(n.sortChildren),er&&Pt(n.parent||er,$e(r),i),n.reversed&&r.reverse(),n.paused&&r.paused(!0),n.scrollTrigger&&Ot($e(r),n.scrollTrigger),r}return rt(t,[{key:"to",value:function(e,t,r){return It(0,arguments,this),this}},{key:"from",value:function(e,t,r){return It(1,arguments,this),this}},{key:"fromTo",value:function(e,t,r,n){return It(2,arguments,this),this}},{key:"set",value:function(e,t,r){return t.duration=0,t.parent=this,wt(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new ii(e,t,Dt(this,r),1),this}},{key:"call",value:function(e,t,r){return Pt(this,ii.delayedCall(0,e,t),r)}},{key:"staggerTo",value:function(e,t,r,n,i,o,a){return r.duration=t,r.stagger=r.stagger||n,r.onComplete=o,r.onCompleteParams=a,r.parent=this,new ii(e,r,Dt(this,i)),this}},{key:"staggerFrom",value:function(e,t,r,n,i,o,a){return r.runBackwards=1,wt(r).immediateRender=Br(r.immediateRender),this.staggerTo(e,t,r,n,i,o,a)}},{key:"staggerFromTo",value:function(e,t,r,n,i,o,a,s){return n.startAt=r,wt(n).immediateRender=Br(n.immediateRender),this.staggerTo(e,t,n,i,o,a,s)}},{key:"render",value:function(e,t,r){var n,i,o,a,s,l,u,c,h,p,f=this._time,d=this._dirty?this.totalDuration():this._tDur,m=this._dur,v=e<=0?0:ln(e),y=this._zTime<0!=e<0&&(this._initted||!m);if((v=this!==er&&d<v&&0<=e?d:v)!==this._tTime||r||y){if(f!==this._time&&m&&(v+=this._time-f,e+=this._time-f),n=v,c=this._start,s=!(u=this._ts),y&&(m||(f=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(y=this._yoyo,a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(n=ln(v%a),v===d?(o=this._repeat,n=m):((o=~~(v/a))&&o===v/a&&(n=m,o--),m<n&&(n=m)),h=_t(this._tTime,a),y&&1&o&&(n=m-n,p=1),o!==(h=!f&&this._tTime&&h!==o?o:h)&&!this._lock){var g=y&&1&h;if(y=g===(y&&1&o),f=(g=o<h?!g:g)?0:m,this._lock=1,this.render(f||(p?0:ln(o*a)),t,!m)._lock=0,this._tTime=v,!t&&this.parent&&Gt(this,"onRepeat"),this.vars.repeatRefresh&&!p&&(this.invalidate()._lock=1),f&&f!==this._time||s!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(m=this._dur,d=this._tDur,y&&(this._lock=2,this.render(f=g?m:-1e-4,!0),this.vars.repeatRefresh&&!p&&this.invalidate()),this._lock=0,!this._ts&&!s)return this;Yt(this,p)}}if(this._hasPause&&!this._forcing&&this._lock<2&&(l=function(e,t,r){var n;if(t<r)for(n=e._first;n&&n._start<=r;){if("isPause"===n.data&&n._start>t)return n;n=n._next}else for(n=e._last;n&&n._start>=r;){if("isPause"===n.data&&n._start<t)return n;n=n._prev}}(this,ln(f),ln(n)))&&(v-=n-(n=l._start)),this._tTime=v,this._time=n,this._act=!u,this._initted||(this._onUpdate=this.vars.onUpdate,this._initted=1,this._zTime=e,f=0),!f&&n&&!t&&(Gt(this,"onStart"),this._tTime!==v))return this;if(f<=n&&0<=e)for(b=this._first;b;){if(i=b._next,(b._act||n>=b._start)&&b._ts&&l!==b){if(b.parent!==this)return this.render(e,t,r);if(b.render(0<b._ts?(n-b._start)*b._ts:(b._dirty?b.totalDuration():b._tDur)+(n-b._start)*b._ts,t,r),n!==this._time||!this._ts&&!s){l=0,i&&(v+=this._zTime=-Pr);break}}b=i}else for(var b=this._last,x=e<0?e:n;b;){if(i=b._prev,(b._act||x<=b._end)&&b._ts&&l!==b){if(b.parent!==this)return this.render(e,t,r);if(b.render(0<b._ts?(x-b._start)*b._ts:(b._dirty?b.totalDuration():b._tDur)+(x-b._start)*b._ts,t,r),n!==this._time||!this._ts&&!s){l=0,i&&(v+=this._zTime=x?-Pr:Pr);break}}b=i}if(l&&!t&&(this.pause(),l.render(f<=n?0:-Pr)._zTime=f<=n?1:-1,this._ts))return this._start=c,mn(this),this.render(e,t,r);this._onUpdate&&!t&&Gt(this,"onUpdate",!0),!(v===d&&d>=this.totalDuration()||!v&&f)||c!==this._start&&Math.abs(u)===Math.abs(this._ts)||this._lock||(!e&&m||!(v===d&&0<this._ts||!v&&this._ts<0)||fn(this,1),t||e<0&&!f||!v&&!f&&d||(Gt(this,v===d&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||v<d&&0<this.timeScale()||this._prom()))}return this}},{key:"add",value:function(e,t){var r=this;if(jr(t)||(t=Dt(this,t,e)),!(e instanceof Kn)){if(Nr(e))return e.forEach((function(e){return r.add(e,t)})),this;if(Dr(e))return this.addLabel(e,t);if(!Ir(e))return this;e=ii.delayedCall(0,e)}return this!==e?Pt(this,e,t):this}},{key:"getChildren",value:function(){for(var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:-Er,i=[],o=this._first;o;)o._start>=n&&(o instanceof ii?t&&i.push(o):(r&&i.push(o),e&&i.push.apply(i,it(o.getChildren(!0,t,r))))),o=o._next;return i}},{key:"getById",value:function(e){for(var t=this.getChildren(1,1,1),r=t.length;r--;)if(t[r].vars.id===e)return t[r]}},{key:"remove",value:function(e){return Dr(e)?this.removeLabel(e):Ir(e)?this.killTweensOf(e):(pn(this,e),e===this._recent&&(this._recent=this._last),dn(this))}},{key:"totalTime",value:function(e,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ln(An.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),Ze(et(t.prototype),"totalTime",this).call(this,e,r),this._forcing=0,this):this._tTime}},{key:"addLabel",value:function(e,t){return this.labels[e]=Dt(this,t),this}},{key:"removeLabel",value:function(e){return delete this.labels[e],this}},{key:"addPause",value:function(e,t,r){return(t=ii.delayedCall(0,t||ft,r)).data="isPause",this._hasPause=1,Pt(this,t,Dt(this,e))}},{key:"removePause",value:function(e){var t=this._first;for(e=Dt(this,e);t;)t._start===e&&"isPause"===t.data&&fn(t),t=t._next}},{key:"killTweensOf",value:function(e,t,r){for(var n=this.getTweensOf(e,r),i=n.length;i--;)Zn!==n[i]&&n[i].kill(e,t);return this}},{key:"getTweensOf",value:function(e,t){for(var r,n=[],i=Sn(e),o=this._first,a=jr(t);o;)o instanceof ii?function(e,t){for(var r=t.length,n=0;e.indexOf(t[n])<0&&++n<r;);return n<r}(o._targets,i)&&(a?(!Zn||o._initted&&o._ts)&&o.globalTime(0)<=t&&o.globalTime(o.totalDuration())>t:!t||o.isActive())&&n.push(o):(r=o.getTweensOf(i,t)).length&&n.push.apply(n,it(r)),o=o._next;return n}},{key:"tweenTo",value:function(e,t){t=t||{};var r,n=this,i=Dt(n,e),o=(e=t).startAt,a=e.onStart,s=e.onStartParams,l=(e=e.immediateRender,ii.to(n,cn({ease:t.ease||"none",lazy:!1,immediateRender:!1,time:i,overwrite:"auto",duration:t.duration||Math.abs((i-(o&&"time"in o?o.time:n._time))/n.timeScale())||Pr,onStart:function(){var e;n.pause(),r||(e=t.duration||Math.abs((i-(o&&"time"in o?o.time:n._time))/n.timeScale()),l._dur!==e&&Ct(l,e,0,1).render(l._time,!0,!0),r=1),a&&a.apply(l,s||[])}},t)));return e?l.render(0):l}},{key:"tweenFromTo",value:function(e,t,r){return this.tweenTo(t,cn({startAt:{time:Dt(this,e)}},r))}},{key:"recent",value:function(){return this._recent}},{key:"nextLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ht(this,Dt(this,e))}},{key:"previousLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ht(this,Dt(this,e),1)}},{key:"currentLabel",value:function(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+Pr)}},{key:"shiftChildren",value:function(e,t){for(var r,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=this._first,o=this.labels;i;)i._start>=n&&(i._start+=e,i._end+=e),i=i._next;if(t)for(r in o)o[r]>=n&&(o[r]+=e);return dn(this)}},{key:"invalidate",value:function(){var e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return Ze(et(t.prototype),"invalidate",this).call(this)}},{key:"clear",value:function(){for(var e,t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],r=this._first;r;)e=r._next,this.remove(r),r=e;return this._dp&&(this._time=this._tTime=this._pTime=0),t&&(this.labels={}),dn(this)}},{key:"totalDuration",value:function(e){var t,r,n,i=0,o=this,a=o._last,s=Er;if(arguments.length)return o.timeScale((o._repeat<0?o.duration():o.totalDuration())/(o.reversed()?-e:e));if(o._dirty){for(n=o.parent;a;)t=a._prev,a._dirty&&a.totalDuration(),(r=a._start)>s&&o._sort&&a._ts&&!o._lock?(o._lock=1,Pt(o,a,r-a._delay,1)._lock=0):s=r,r<0&&a._ts&&(i-=r,(!n&&!o._dp||n&&n.smoothChildTiming)&&(o._start+=r/o._ts,o._time-=r,o._tTime-=r),o.shiftChildren(-r,!1,-1/0),s=0),a._end>i&&a._ts&&(i=a._end),a=t;Ct(o,o===er&&o._time>i?o._time:i,1,1),o._dirty=0}return o._tDur}}],[{key:"updateRoot",value:function(e){if(er._ts&&(vt(er,Mt(e,er)),or=An.frame),An.frame>=rn){rn+=_r.autoSleep||120;var t=er._first;if((!t||!t._ts)&&_r.autoSleep&&An._listeners.length<2){for(;t&&!t._ts;)t=t._next;t||An.sleep()}}}}]),t}()),$n=(cn(Jn.prototype,{_lock:0,_hasPause:0,_forcing:0}),function(e,t,r,n,i,o,a){var s,l,u,c,h,p=new pi(this._pt,e,t,0,1,Hn,null,i),f=0,d=0;for(p.b=r,p.e=n,r+="",(i=~(n+="").indexOf("random("))&&(n=_n(n)),o&&(o(o=[r,n],e,t),r=o[0],n=o[1]),s=r.match(Gr)||[];c=Gr.exec(n);)u=c[0],c=n.substring(f,c.index),l?l=(l+1)%5:"rgba("===c.substr(-5)&&(l=1),u!==s[d++]&&(h=parseFloat(s[d-1])||0,p._pt={_next:p._pt,p:c||1===d?c:",",s:h,c:"="===u.charAt(1)?parseFloat(u.substr(2))*("-"===u.charAt(0)?-1:1):parseFloat(u)-h,m:l&&l<4?Math.round:0},f=Gr.lastIndex);return p.c=f<n.length?n.substring(f,n.length):"",p.fp=a,(Wr.test(n)||i)&&(p.e=0),this._pt=p}),ei=function(e,t,r,n,i,o,a,s,l){var u;if(Ir(n)&&(n=n(i||0,e,o)),i=e[t],o="get"!==r?r:Ir(i)?l?e[t.indexOf("set")||!Ir(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():i,r=Ir(i)?l?si:ai:oi,Dr(n)&&"="===(n=~n.indexOf("random(")?_n(n):n).charAt(1)&&(!(u=parseFloat(o)+parseFloat(n.substr(2))*("-"===n.charAt(0)?-1:1)+(bn(o)||0))&&0!==u||(n=u)),o!==n)return isNaN(o*n)||""===n?(i||t in e||Qr(t,n),$n.call(this,e,t,o,n,r,s||_r.stringFilter,l)):(u=new pi(this._pt,e,t,+o||0,n-(o||0),"boolean"==typeof i?ci:ui,0,r),l&&(u.fp=l),a&&u.modifier(a,this,e),this._pt=u)},ti=function(e,t,r,n,i,o){var a,s,l,u;if(en[e]&&!1!==(a=new en[e]).init(i,a.rawVars?t[e]:function(e,t,r,n,i){if(Ir(e)&&(e=Fn(e,i,t,r,n)),!Ur(e)||e.style&&e.nodeType||Nr(e)||zr(e))return Dr(e)?Fn(e,i,t,r,n):e;var o,a={};for(o in e)a[o]=Fn(e[o],i,t,r,n);return a}(t[e],n,i,o,r),r,n,o)&&(r._pt=s=new pi(r._pt,i,e,0,1,a.render,a,0,a.priority),r!==ar))for(l=r._ptLookup[r._targets.indexOf(i)],u=a._props.length;u--;)l[a._props[u]]=s;return a},ri=on+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",ni={},ii=(mt(ri+",id,stagger,delay,duration,paused,scrollTrigger",(function(e){return ni[e]=1})),function(){Qe(t,Kn);var e=Je(t);function t(r,n,i,o){nt(this,t),"number"==typeof n&&(i.duration=n,n=i,i=null);var a,s,l,u,c,h,p,f,d,m=(o=(a=e.call(this,o?n:wt(n))).vars).duration,v=o.delay,y=o.immediateRender,g=o.stagger,b=o.overwrite,x=o.keyframes,w=o.defaults,S=o.scrollTrigger,T=o.yoyoEase,_=(o=n.parent||er,(Nr(r)||zr(r)?jr(r[0]):"length"in n)?[r]:Sn(r));if(a._targets=_.length?an(_):ht("GSAP target "+r+" not found. https://greensock.com",!_r.nullTargetWarn)||[],a._ptLookup=[],a._overwrite=b,x||g||ut(m)||ut(v)){if(n=a.vars,(s=a.timeline=new Jn({data:"nested",defaults:w||{}})).kill(),s.parent=s._dp=$e(a),s._start=0,g||ut(m)||ut(v)){if(c=_.length,f=g&&Ut(g),Ur(g))for(h in g)~ri.indexOf(h)&&((d=d||{})[h]=g[h]);for(l=0;l<c;l++)(u=hn(n,ni)).stagger=0,T&&(u.yoyoEase=T),d&&bt(u,d),p=_[l],u.duration=+Fn(m,$e(a),l,p,_),u.delay=(+Fn(v,$e(a),l,p,_)||0)-a._delay,!g&&1===c&&u.delay&&(a._delay=v=u.delay,a._start+=v,u.delay=0),s.to(p,u,f?f(l,p,_):0),s._ease=Ln.none;s.duration()?m=v=0:a.timeline=0}else if(x){wt(cn(s.vars.defaults,{ease:"none"})),s._ease=Un(x.ease||n.ease||"none");var M,E,P,O=0;if(Nr(x))x.forEach((function(e){return s.to(_,e,">")}));else{for(h in u={},x)"ease"!==h&&"easeEach"!==h&&function(e,t,r,n){var i,o,a=t.ease||n||"power1.inOut";if(Nr(t))o=r[e]||(r[e]=[]),t.forEach((function(e,r){return o.push({t:r/(t.length-1)*100,v:e,e:a})}));else for(i in t)o=r[i]||(r[i]=[]),"ease"!==i&&o.push({t:parseFloat(e),v:t[i],e:a})}(h,x[h],u,x.easeEach);for(h in u)for(M=u[h].sort((function(e,t){return e.t-t.t})),l=O=0;l<M.length;l++)(P={ease:(E=M[l]).e,duration:(E.t-(l?M[l-1].t:0))/100*m})[h]=E.v,s.to(_,P,O),O+=P.duration;s.duration()<m&&s.to({},{duration:m-s.duration()})}}m||a.duration(m=s.duration())}else a.timeline=0;return!0!==b||$t||(Zn=$e(a),er.killTweensOf(_),Zn=0),Pt(o,$e(a),i),n.reversed&&a.reverse(),n.paused&&a.paused(!0),(y||!m&&!x&&a._start===ln(o._time)&&Br(y)&&St($e(a))&&"nested"!==o.data)&&(a._tTime=-Pr,a.render(Math.max(0,-v))),S&&Ot($e(a),S),a}return rt(t,[{key:"render",value:function(e,t,r){var n,i,o=this._time,a=this._tDur,s=this._dur,l=a-Pr<e&&0<=e?a:e<Pr?0:e;if(s){if(l!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(m=l,d=this.timeline,this._repeat){if(h=s+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*h+e,t,r);if(m=ln(l%h),l===a?(y=this._repeat,m=s):((y=~~(l/h))&&y===l/h&&(m=s,y--),s<m&&(m=s)),(f=this._yoyo&&1&y)&&(p=this._yEase,m=s-m),g=_t(this._tTime,h),m===o&&!r&&this._initted)return this;y!==g&&(d&&this._yEase&&Yt(d,f),!this.vars.repeatRefresh||f||this._lock||(this._lock=r=1,this.render(ln(h*y),!0).invalidate()._lock=0))}if(!this._initted){if(Rt(this,e<0?e:m,r,t))return this._tTime=0,this;if(s!==this._dur)return this.render(e,t,r)}if(this._tTime=l,this._time=m,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=i=(p||this._ease)(m/s),this._from&&(this.ratio=i=1-i),m&&!o&&!t&&(Gt(this,"onStart"),this._tTime!==l))return this;for(n=this._pt;n;)n.r(i,n.d),n=n._next;d&&d.render(e<0?e:!m&&f?-Pr:d._dur*d._ease(m/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),Gt(this,"onUpdate")),this._repeat&&y!==g&&this.vars.onRepeat&&!t&&this.parent&&Gt(this,"onRepeat"),l!==this._tDur&&l||this._tTime!==l||(e<0&&this._startAt&&!this._onUpdate&&this._startAt.render(e,!0,!0),!e&&s||!(l===this._tDur&&0<this._ts||!l&&this._ts<0)||fn(this,1),t||e<0&&!o||!l&&!o||(Gt(this,l===a?"onComplete":"onReverseComplete",!0),!this._prom||l<a&&0<this.timeScale()||this._prom()))}}else{var u,c,h=this,p=e,f=t,d=r,m=h.ratio,v=p<0||!p&&(!h._start&&kt(h)&&(h._initted||!At(h))||(h._ts<0||h._dp._ts<0)&&!At(h))?0:1,y=h._rDelay,g=0;if(y&&h._repeat&&(c=_t(g=jt(0,h._tDur,p),y),h._yoyo&&1&c&&(v=1-v),c!==_t(h._tTime,y)&&(m=1-v,h.vars.repeatRefresh&&h._initted&&h.invalidate())),v!==m||d||h._zTime===Pr||!p&&h._zTime){if(h._initted||!Rt(h,p,d,f)){for(c=h._zTime,h._zTime=p||(f?Pr:0),f=f||p&&!c,h.ratio=v,h._from&&(v=1-v),h._time=0,h._tTime=g,u=h._pt;u;)u.r(v,u.d),u=u._next;h._startAt&&p<0&&h._startAt.render(p,!0,!0),h._onUpdate&&!f&&Gt(h,"onUpdate"),g&&h._repeat&&!f&&h.parent&&Gt(h,"onRepeat"),(p>=h._tDur||p<0)&&h.ratio===v&&(v&&fn(h,1),f||(Gt(h,v?"onComplete":"onReverseComplete",!0),h._prom&&h._prom()))}}else h._zTime||(h._zTime=p)}return this}},{key:"targets",value:function(){return this._targets}},{key:"invalidate",value:function(){return this._pt=this._op=this._startAt=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(),Ze(et(t.prototype),"invalidate",this).call(this)}},{key:"kill",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";if(!(e||t&&"all"!==t))return this._lazy=this._pt=0,this.parent?Wt(this):this;if(this.timeline)return p=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,Zn&&!0!==Zn.vars.overwrite)._first||Wt(this),this.parent&&p!==this.timeline.totalDuration()&&Ct(this,this._dur*this.timeline._tDur/p,0,1),this;var r,n,i,o,a,s,l,u=this._targets,c=e?Sn(e):u,h=this._ptLookup,p=this._pt;if((!t||"all"===t)&&function(e,t){for(var r=e.length,n=r===t.length;n&&r--&&e[r]===t[r];);return r<0}(u,c))return"all"===t&&(this._pt=0),Wt(this);for(r=this._op=this._op||[],"all"!==t&&(Dr(t)&&(a={},mt(t,(function(e){return a[e]=1})),t=a),t=function(e,t){var r,n,i,o,a=(e=e[0]?sn(e[0]).harness:0)&&e.aliases;if(!a)return t;for(n in r=bt({},t),a)if(n in r)for(i=(o=a[n].split(",")).length;i--;)r[o[i]]=r[n];return r}(u,t)),l=u.length;l--;)if(~c.indexOf(u[l]))for(a in n=h[l],"all"===t?(r[l]=t,o=n,i={}):(i=r[l]=r[l]||{},o=t),o)(s=n&&n[a])&&("kill"in s.d&&!0!==s.d.kill(a)||pn(this,s,"_pt"),delete n[a]),"all"!==i&&(i[a]=1);return this._initted&&!this._pt&&p&&Wt(this),this}}],[{key:"to",value:function(e,r){return new t(e,r,arguments[2])}},{key:"from",value:function(e,t){return It(1,arguments)}},{key:"delayedCall",value:function(e,r,n,i){return new t(r,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:e,onComplete:r,onReverseComplete:r,onCompleteParams:n,onReverseCompleteParams:n,callbackScope:i})}},{key:"fromTo",value:function(e,t,r){return It(2,arguments)}},{key:"set",value:function(e,r){return r.duration=0,r.repeatDelay||(r.repeat=0),new t(e,r)}},{key:"killTweensOf",value:function(e,t,r){return er.killTweensOf(e,t,r)}}]),t}()),oi=(cn(ii.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),mt("staggerTo,staggerFrom,staggerFromTo",(function(e){ii[e]=function(){var t=new Jn,r=xn.call(arguments,0);return r.splice("staggerFromTo"===e?5:4,0,0),t[e].apply(t,r)}})),function(e,t,r){return e[t]=r}),ai=function(e,t,r){return e[t](r)},si=function(e,t,r,n){return e[t](n.fp,r)},li=function(e,t){return Ir(e[t])?ai:st(e[t])&&e.setAttribute?Vn:oi},ui=function(e,t){return t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t)},ci=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},hi=function(e){for(var t,r,n,i,o=e._pt;o;){for(t=o._next,r=n;r&&r.pr>o.pr;)r=r._next;(o._prev=r?r._prev:i)?o._prev._next=o:n=o,(o._next=r)?r._prev=o:i=o,o=t}e._pt=n},pi=function(){function e(t,r,n,i,o,a,s,l,u){nt(this,e),this.t=r,this.s=i,this.c=o,this.p=n,this.r=a||ui,this.d=s||this,this.set=l||oi,this.pr=u||0,(this._next=t)&&(t._prev=this)}return rt(e,[{key:"modifier",value:function(e,t,r){this.mSet=this.mSet||this.set,this.set=qn,this.m=e,this.mt=r,this.tween=t}}]),e}(),fi=(mt(on+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",(function(e){return Kr[e]=1})),Yr.TweenMax=Yr.TweenLite=ii,Yr.TimelineLite=Yr.TimelineMax=Jn,er=new Jn({sortChildren:!1,defaults:Mr,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),_r.stringFilter=function(e){var t=e.join(" ");if(Rn.lastIndex=0,Rn.test(t))return t=kn.test(t),e[1]=qt(e[1],t),e[0]=qt(e[0],t,On(e[1])),!0},{registerPlugin:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((function(e){var t=(e=!e.name&&e.default||e).name,r=Ir(e),n=(r=t&&!r&&e.init?function(){this._props=[]}:e,{init:ft,render:Gn,add:ei,kill:Xn,modifier:Wn,rawVars:0}),i={targetTest:0,get:0,getSetter:li,aliases:{},register:0};if(Cn(),e!==r){if(en[t])return;cn(r,cn(hn(e,n),i)),bt(r.prototype,bt(n,hn(e,i))),en[r.prop=t]=r,e.targetTest&&(nn.push(r),Kr[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}pt(t,r),e.register&&e.register(mi,r,pi)}))},timeline:function(e){return new Jn(e)},getTweensOf:function(e,t){return er.getTweensOf(e,t)},getProperty:function(e,t,r,n){Dr(e)&&(e=Sn(e)[0]);var i=sn(e||{}).get,o=r?gt:yt;return"native"===r&&(r=""),e&&(t?o((en[t]&&en[t].get||i)(e,t,r,n)):function(t,r,n){return o((en[t]&&en[t].get||i)(e,t,r,n))})},quickSetter:function(e,t,r){var n,i;if(1<(e=Sn(e)).length)return n=e.map((function(e){return mi.quickSetter(e,t,r)})),i=n.length,function(e){for(var t=i;t--;)n[t](e)};e=e[0]||{};var o=en[t],a=sn(e),s=a.harness&&(a.harness.aliases||{})[t]||t,l=o?function(t){var n=new o;ar._pt=0,n.init(e,r?t+r:t,ar,0,[e]),n.render(1,n),ar._pt&&Gn(1,ar)}:a.set(e,s);return o?l:function(t){return l(e,s,r?t+r:t,a,1)}},isTweening:function(e){return 0<er.getTweensOf(e,!0).length},defaults:function(e){return e&&e.ease&&(e.ease=Un(e.ease,Mr.ease)),xt(Mr,e||{})},config:function(e){return xt(_r,e||{})},registerEffect:function(e){var t=e.name,r=e.effect,n=e.plugins,i=e.defaults;e=e.extendTimeline,(n||"").split(",").forEach((function(e){return e&&!en[e]&&!Yr[e]&&ht(t+" effect requires "+e+" plugin.")})),tn[t]=function(e,t,n){return r(Sn(e),cn(t||{},i),n)},e&&(Jn.prototype[t]=function(e,r,n){return this.add(tn[t](e,Ur(r)?r:(n=r)&&{},this),n)})},registerEase:function(e,t){Ln[e]=Un(t)},parseEase:function(e,t){return arguments.length?Un(e,t):Ln},getById:function(e){return er.getById(e)},exportRoot:function(){var e,t,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=1<arguments.length?arguments[1]:void 0,i=new Jn(r);for(i.smoothChildTiming=Br(r.smoothChildTiming),er.remove(i),i._dp=0,i._time=i._tTime=er._time,e=er._first;e;)t=e._next,!n&&!e._dur&&e instanceof ii&&e.vars.onComplete===e._targets[0]||Pt(i,e,e._start-e._delay),e=t;return Pt(er,i,0),i},utils:{wrap:function e(t,r,n){var i=r-t;return Nr(t)?Ft(t,e(0,t.length),r):gn(n,(function(e){return(i+(e-t)%i)%i+t}))},wrapYoyo:function e(t,r,n){var i=r-t,o=2*i;return Nr(t)?Ft(t,e(0,t.length-1),r):gn(n,(function(e){return t+(i<(e=(o+(e-t)%o)%o||0)?o-e:e)}))},distribute:Ut,random:Nt,snap:zt,normalize:function(e,t,r){return Vt(e,t,0,1,r)},getUnit:bn,clamp:function(e,t,r){return gn(r,(function(r){return jt(e,t,r)}))},splitColor:Pn,toArray:Sn,selector:function(e){return e=Sn(e)[0]||ht("Invalid scope")||{},function(t){var r=e.current||e.nativeElement||e;return Sn(t,r.querySelectorAll?r:r===e?ht("Invalid scope")||nr.createElement("div"):e)}},mapRange:Vt,pipe:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.reduce((function(e,t){return t(e)}),e)}},unitize:function(e,t){return function(r){return e(parseFloat(r))+(t||bn(r))}},interpolate:function e(t,r,n,i){var o=isNaN(t+r)?0:function(e){return(1-e)*t+e*r};if(!o){var a,s,l,u,c,h=Dr(t),p={};if(!0===n&&(i=1)&&(n=null),h)t={p:t},r={p:r};else if(Nr(t)&&!Nr(r)){for(l=[],u=t.length,c=u-2,s=1;s<u;s++)l.push(e(t[s-1],t[s]));u--,o=function(e){e*=u;var t=Math.min(c,~~e);return l[t](e-t)},n=r}else i||(t=bt(Nr(t)?[]:{},t));if(!l){for(a in r)ei.call(p,t,a,"get",r[a]);o=function(e){return Gn(e,p),h?t.p:t}}}return gn(n,o)},shuffle:Tn},install:ct,effects:tn,ticker:An,updateRoot:Jn.updateRoot,plugins:en,globalTimeline:er,core:{PropTween:pi,globals:pt,Tween:ii,Timeline:Jn,Animation:Kn,getCache:sn,_removeLinkedListItem:pn,suppressOverwrites:function(e){return $t=e}}}),di=(mt("to,from,fromTo,delayedCall,set,killTweensOf",(function(e){return fi[e]=ii[e]})),An.add(Jn.updateRoot),ar=fi.to({},{duration:0}),function(e,t){for(var r=e._pt;r&&r.p!==t&&r.op!==t&&r.fp!==t;)r=r._next;return r}),mi=fi.registerPlugin({name:"attr",init:function(e,t,r,n,i){var o,a;for(o in t)(a=this.add(e,"setAttribute",(e.getAttribute(o)||0)+"",t[o],n,i,0,0,o))&&(a.op=o),this._props.push(o)}},{name:"endArray",init:function(e,t){for(var r=t.length;r--;)this.add(e,r,e[r]||0,t[r])}},Yn("roundProps",Bt),Yn("modifiers"),Yn("snap",zt))||fi;ii.version=Jn.version=mi.version="3.9.1",ir=1,lt()&&Cn(),Ln.Power0,Ln.Power1,Ln.Power2,Ln.Power3,Ln.Power4,Ln.Linear,Ln.Quad,Ln.Cubic,Ln.Quart,Ln.Quint,Ln.Strong,Ln.Elastic,Ln.Back,Ln.SteppedEase,Ln.Bounce,Ln.Sine,Ln.Expo,Ln.Circ;const vi=c,yi=["map","normalMap","aoMap"],gi=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"];class bi{}const xi=class extends bi{constructor(e){super(),this.type="修改材质";var{target:e,info:t,newVal:r,oldVal:n,runScene:i}=e;this.runScene=i,this.target=e,this.info=t,this.newVal=r,this.oldVal=n}_execute(e,t){this.target[this.info]=e,this.target.needsUpdate=!0,gi.includes(this.info)&&e&&this.runScene.uniqueEx.texture.addMaterial(e,{material:this.target,type:this.info})}execute(){return this.redo(),this}undo(){this._execute(this.oldVal,this.newVal)}redo(){this._execute(this.newVal,this.oldVal)}};var wi=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class Si{constructor(e){this.allTextures=new Set,this.runScene=e}load(e){return wi(this,void 0,void 0,(function*(){var t=yield Io(e);return this.parse(t)}))}parse(e){return wi(this,void 0,void 0,(function*(){var t="Blob"===ga(e)?e:yield Uo(e);return this.afterLoad(t,yield Ai(t))}))}clone(e){const t=new c.Texture(e.image);return t.userData=Object.assign(Object.assign({},e.userData),{id:(0,l.getId)()}),Pi(t),this.getSameAndAddtoAll(t)}getDef(e){return e=new c.Texture(e),Pi(e),this.getSameAndAddtoAll(e)}getSameAndAddtoAll(e){var t=e.userData.md5;return(t=this.getSameTexture(t,e))?(Ei(e),t):(this.initTextureAndAddtoAll(e),e)}afterLoad(e,t){return wi(this,void 0,void 0,(function*(){return this.getSameAndAddtoAll(yield Pi(t,e))}))}getSameTexture(e,t){for(const n in this.runScene.uniqueEx.texture.map){var r=this.runScene.uniqueEx.texture.get(n);if(r.userData.md5===e&&r.mapping===t.mapping)return r}}initTextureAndAddtoAll(e){return wi(this,void 0,void 0,(function*(){return Ri(e),Pi(e),this.addTextureToAll(e),e}))}addTextureToAll(e){var t=this.runScene.uniqueEx.texture.getLength();this.runScene.uniqueEx.texture.add(e),this.runScene.uniqueEx.texture.getLength()!==t&&this.runScene.optionsEx.cb.texture.add.cb(e)}getBlobAndBase64(e){return e.userData.blob?e.userData:Ro(e)}coverByImage(e,t){return wi(this,void 0,void 0,(function*(){let r;r=t instanceof c.Texture?t:t?yield this.parse(t):null;var n=this.runScene.uniqueEx.texture.getMaterials(this.runScene.uniqueEx.getId(e));if(n){const t=[];(0,Xe.js)(n,((n,i)=>{const o=this.runScene.uniqueEx.material.get(n);o&&i.forEach((n=>{t.push(new xi({target:o,info:n,newVal:r,oldVal:e,runScene:this.runScene}).execute())}))})),this.runScene.undoEx.addUndo(t)}}))}removeTexture(e){this.runScene.optionsEx.cb.texture.remove.cb(e),this.runScene.uniqueEx.texture.remove(e)}}const Ti={环境遮蔽:"aoMap",法线:"normalMap",金属度:"metalnessMap",粗糙度:"roughnessMap",自发光:"emissiveMap",颜色:"map",置换:"displacementMap",光照贴图:"lightMap",环境:"envMap",透明度:"alphaMap"},_i=e=>1023===e.format?"image/png":"image/jpeg",Mi=e=>{var{width:e,height:t}=e.image;return e*t*4*1.33},Ei=e=>{if(e){const r=e.image;var t=e.userData.url;r.close(),URL.revokeObjectURL(t),e.dispose()}},Pi=(e,t)=>wi(void 0,void 0,void 0,(function*(){const r=t||e.userData.blob||(yield Oi(e));var{md5:n,url:i}=e.userData;return e.userData.blob=r,n||(e.userData.md5=Fo(yield r.arrayBuffer())),i||(e.userData.url=URL.createObjectURL(r)),e.userData.gm=Mi(e),e.format=e.userData.format||-1!==r.type.indexOf("png")?1023:1022,e})),Oi=e=>e.userData.blob||Po(e.image),Ri=e=>(e.magFilter=1003,e.wrapS=vi.RepeatWrapping,e.wrapT=vi.RepeatWrapping,e.encoding=3e3,e.version=3,e.flipY=!1,e.minFilter=vi.LinearMipmapLinearFilter,e.needsUpdate=!0,e),ki=e=>createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"}),Ai=e=>wi(void 0,void 0,void 0,(function*(){var t=yield ki(e instanceof Blob?e:yield Io(e));return new c.Texture(t)})),Ci=e=>e.userData.url,Li=(e,t="repeat")=>(e.mapping="repeat"===t?vi.EquirectangularReflectionMapping:300,e.needsUpdate=!0,e),Di=e=>{var{width:e,height:t}=e.image;return{width:e,height:t}};function Ii(e){return(Ii="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ji(e,t){return(ji=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ui(e){return(Ui=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Bi=new c.Box3,zi=new c.Vector3,Ni=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ji(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Ui(e);if(r=t?(r=Ui(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ii(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(e=r.call(this)).type="LineSegmentsGeometry",e.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),e.setAttribute("position",new c.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),e.setAttribute("uv",new c.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2)),e}return t=n,(e=[{key:"applyMatrix4",value:function(e){var t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),r.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}},{key:"setPositions",value:function(e){var t;return e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e)),e=new c.InstancedInterleavedBuffer(t,6,1),this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(e,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(e,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}},{key:"setColors",value:function(e){var t;return e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e)),e=new c.InstancedInterleavedBuffer(t,6,1),this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(e,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(e,3,3)),this}},{key:"fromWireframeGeometry",value:function(e){return this.setPositions(e.attributes.position.array),this}},{key:"fromEdgesGeometry",value:function(e){return this.setPositions(e.attributes.position.array),this}},{key:"fromMesh",value:function(e){return this.fromWireframeGeometry(new c.WireframeGeometry(e.geometry)),this}},{key:"fromLineSegments",value:function(e){if(!(e=e.geometry).isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}},{key:"computeBoundingBox",value:function(){null===this.boundingBox&&(this.boundingBox=new c.Box3);var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),Bi.setFromBufferAttribute(t),this.boundingBox.union(Bi))}},{key:"computeBoundingSphere",value:function(){null===this.boundingSphere&&(this.boundingSphere=new c.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){for(var r=this.boundingSphere.center,n=(this.boundingBox.getCenter(r),0),i=0,o=e.count;i<o;i++)zi.fromBufferAttribute(e,i),n=Math.max(n,r.distanceToSquared(zi)),zi.fromBufferAttribute(t,i),n=Math.max(n,r.distanceToSquared(zi));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}},{key:"toJSON",value:function(){}},{key:"applyMatrix",value:function(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.InstancedBufferGeometry);function Fi(e){return(Fi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Vi(e,t){return(Vi=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Hi(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Gi(e){return(Gi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Ni.prototype.isLineSegmentsGeometry=!0,c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};var Wi=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vi(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Gi(e);if(r=t?(r=Gi(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Fi(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return Hi(n)}}(n);function n(e){var t;if(this instanceof n)return t=r.call(this,{type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(Hi(t),{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set:function(e){Boolean(e)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)},set:function(e){Boolean(e)!==Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),t.setValues(e),t;throw new TypeError("Cannot call a class as a function")}return t=n,Object.defineProperty(t,"prototype",{writable:!1}),t}(c.ShaderMaterial);function Xi(e){return(Xi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qi(e,t){return(qi=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Yi(e){return(Yi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Wi.prototype.isLineMaterial=!0;var Zi,Qi,Ki,Ji,$i=new c.Vector3,eo=new c.Vector3,to=new c.Vector4,ro=new c.Vector4,no=new c.Vector4,io=new c.Vector3,oo=new c.Matrix4,ao=new c.Line3,so=new c.Vector3,lo=new c.Box3,uo=new c.Sphere,co=new c.Vector4;function ho(e,t,r){return co.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),co.multiplyScalar(1/co.w),co.x=Ji/r.width,co.y=Ji/r.height,co.applyMatrix4(e.projectionMatrixInverse),co.multiplyScalar(1/co.w),Math.abs(Math.max(co.x,co.y))}var po=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&qi(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Yi(e);if(r=t?(r=Yi(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Xi(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ni,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Wi({color:16777215*Math.random()}),i=this,o=n;if(i instanceof o)return(i=r.call(this,e,t)).type="LineSegments2",i;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"computeLineDistances",value:function(){for(var e=this.geometry,t=e.attributes.instanceStart,r=e.attributes.instanceEnd,n=new Float32Array(2*t.count),i=0,o=0,a=t.count;i<a;i++,o+=2)$i.fromBufferAttribute(t,i),eo.fromBufferAttribute(r,i),n[o]=0===o?0:n[o-1],n[o+1]=n[o]+$i.distanceTo(eo);var s=new c.InstancedInterleavedBuffer(n,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(s,1,1)),this}},{key:"raycast",value:function(e,t){var r=this.material.worldUnits,n=e.camera,i=(null!==n||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),void 0!==e.params.Line2&&e.params.Line2.threshold||0),o=(Zi=e.ray,e=this.matrixWorld,this.geometry),a=this.material;if(Ji=a.linewidth+i,Qi=o.attributes.instanceStart,Ki=o.attributes.instanceEnd,null===o.boundingSphere&&o.computeBoundingSphere(),uo.copy(o.boundingSphere).applyMatrix4(e),i=r?.5*Ji:ho(n,Math.max(n.near,uo.distanceToPoint(Zi.origin)),a.resolution),uo.radius+=i,!1!==Zi.intersectsSphere(uo)&&(null===o.boundingBox&&o.computeBoundingBox(),lo.copy(o.boundingBox).applyMatrix4(e),i=r?.5*Ji:ho(n,Math.max(n.near,lo.distanceToPoint(Zi.origin)),a.resolution),lo.expandByScalar(i),!1!==Zi.intersectsBox(lo)))if(r)for(var s=t,l=0,u=Qi.count;l<u;l++){ao.start.fromBufferAttribute(Qi,l),ao.end.fromBufferAttribute(Ki,l);var h=new c.Vector3,p=new c.Vector3;Zi.distanceSqToSegment(ao.start,ao.end,p,h),p.distanceTo(h)<.5*Ji&&s.push({point:p,pointOnLine:h,distance:Zi.origin.distanceTo(p),object:this,face:null,faceIndex:l,uv:null,uv2:null})}else{var f=this,d=t,m=(o=n).projectionMatrix,v=f.material.resolution,y=f.matrixWorld,g=(e=f.geometry).attributes.instanceStart,b=e.attributes.instanceEnd,x=-o.near;Zi.at(1,no),no.w=1,no.applyMatrix4(o.matrixWorldInverse),no.applyMatrix4(m),no.multiplyScalar(1/no.w),no.x*=v.x/2,no.y*=v.y/2,no.z=0,io.copy(no),oo.multiplyMatrices(o.matrixWorldInverse,y);for(var w,S,T,_,M=0,E=g.count;M<E;M++)to.fromBufferAttribute(g,M),ro.fromBufferAttribute(b,M),to.w=1,ro.w=1,to.applyMatrix4(oo),ro.applyMatrix4(oo),to.z>x&&ro.z>x||(to.z>x?(w=to.z-ro.z,w=(to.z-x)/w,to.lerp(ro,w)):ro.z>x&&(w=ro.z-to.z,S=(ro.z-x)/w,ro.lerp(to,S)),to.applyMatrix4(m),ro.applyMatrix4(m),to.multiplyScalar(1/to.w),ro.multiplyScalar(1/ro.w),to.x*=v.x/2,to.y*=v.y/2,ro.x*=v.x/2,ro.y*=v.y/2,ao.start.copy(to),ao.start.z=0,ao.end.copy(ro),ao.end.z=0,S=ao.closestPointToPointParameter(io,!0),ao.at(S,so),T=-1<=(T=c.MathUtils.lerp(to.z,ro.z,S))&&T<=1,_=io.distanceTo(so)<.5*Ji,T&&_&&(ao.start.fromBufferAttribute(g,M),ao.end.fromBufferAttribute(b,M),ao.start.applyMatrix4(y),ao.end.applyMatrix4(y),T=new c.Vector3,_=new c.Vector3,Zi.distanceSqToSegment(ao.start,ao.end,_,T),d.push({point:_,pointOnLine:T,distance:Zi.origin.distanceTo(_),object:f,face:null,faceIndex:M,uv:null,uv2:null})))}}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Mesh);function fo(e){return(fo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mo(){return(mo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=yo(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function vo(e,t){return(vo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function yo(e){return(yo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}po.prototype.isLineSegments2=!0;var go=function(){var e=n,t=Ni;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vo(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=yo(e);if(r=t?(r=yo(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===fo(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e;if(this instanceof n)return(e=r.call(this)).type="LineGeometry",e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"setPositions",value:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return mo(yo(n.prototype),"setPositions",this).call(this,r),this}},{key:"setColors",value:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return mo(yo(n.prototype),"setColors",this).call(this,r),this}},{key:"fromLine",value:function(e){if(!(e=e.geometry).isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function bo(e){return(bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xo(e,t){return(xo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function wo(e){return(wo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}go.prototype.isLineGeometry=!0;var So=function(){var e=n,t=po;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&xo(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=wo(e);if(r=t?(r=wo(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===bo(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new go,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Wi({color:16777215*Math.random()}),i=this,o=n;if(i instanceof o)return(i=r.call(this,e,t)).type="Line2",i;throw new TypeError("Cannot call a class as a function")}return e=n,Object.defineProperty(e,"prototype",{writable:!1}),e}(),To=(So.prototype.isLine2=!0,function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))});const _o=(e,t,r,n,i)=>{let o=Object.assign({},e),a=new ii(o,r,t).eventCallback("onUpdate",(e=>n&&n(o))).eventCallback("onComplete",(e=>{i&&i(),ii.killTweensOf(a)}));return a},Mo=(e,t)=>(t.updateMatrixWorld(!0),t=new vi.Vector3,e.getWorldPosition(t),t),Eo=e=>{const t=document.createElement("canvas");return(t.width=e.width,t.height=e.height,t.getContext("2d")).drawImage(e,0,0,t.width,t.height),t.toDataURL()},Po=e=>To(void 0,void 0,void 0,(function*(){const t=document.createElement("canvas");return(t.width=e.width,t.height=e.height,t.getContext("2d")).drawImage(e,0,0,t.width,t.height),new Promise((e=>{t.toBlob((t=>{e(t)}))}))})),Oo=e=>{const t=document.createElement("canvas"),r=(t.width=e.width,t.height=e.height,t.getContext("2d"));r.translate(0,t.height),r.scale(1,-1),r.drawImage(e,0,0,t.width,t.height)},Ro=e=>To(void 0,void 0,void 0,(function*(){var t=e.image;const r=document.createElement("canvas"),n=(r.width=t.width,r.height=t.height,r.getContext("2d")),i=_i(e);return n.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(i)})}),i)}))})),ko=e=>To(void 0,void 0,void 0,(function*(){-1!==e.indexOf(",")&&(e=Ao(e));const t=window.atob(e);var r=t.length;const n=new Uint8Array(r);for(let e=0;e<r;e++)n[e]=t.charCodeAt(e);return n.buffer})),Ao=e=>e.substring(e.indexOf(",")+1),Co=e=>URL.createObjectURL(new Blob([e])),Lo=(e,t)=>URL.createObjectURL(new Blob([e],t)),Do=e=>{let t="";var r=new Uint8Array(e);for(let e=0,n=r.byteLength;e<n;e++)t+=String.fromCharCode(r[e]);return"data:image/jpg;base64,"+window.btoa(t)},Io=e=>To(void 0,void 0,void 0,(function*(){return(yield s().get(e,{responseType:"blob"})).data})),jo=e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]),i=n.length,o=new Uint8Array(i);for(;i--;)o[i]=n.charCodeAt(i);return new Blob([o],{type:r})},Uo=e=>To(void 0,void 0,void 0,(function*(){return jo(yield(0,Ye.toResult)(e,"base64"))})),Bo=(e,t)=>new File([e],t),zo=e=>e.substring(e.indexOf(":")+1,e.indexOf(";")),No=e=>{let t="";const r=t=e<102.4?e.toFixed(2)+"B":e<1048576?(e/1024).toFixed(2)+"KB":e<1073741824?(e/1048576).toFixed(2)+"M":(e/1073741824).toFixed(2)+"G";return e=r.indexOf("."),"00"==r.substr(e+1,2)?r.substring(0,e)+r.substr(e+3,2):t},Fo=e=>(0,qe.md5)(e),Vo=(e,t)=>{var{width:t,height:r}=t;let n=new Image,i=(n.src=e,n.width=t,n.height=r,document.createElement("canvas")),o=(i.width=t,i.height=r,i.getContext("2d"));return new Promise((e=>{n.onload=function(){o.drawImage(n,0,0,i.width,i.height),e({canvas:i,ctx:o})}}))},Ho=e=>{const t=document.createElement("canvas"),r=t.getContext("2d");return r.drawImage(e,0,0,e.width,e.height),{ctx:r,canvas:t}},Go=(e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d");return r.width=e.width,r.height=e.height,n.drawImage(e,0,0,e.width,e.height),new Promise((e=>{r.toBlob((t=>{t&&e(URL.createObjectURL(t))}),"image/webp",t)}))},Wo=(e,t,r)=>{e/=255,t/=255,r/=255;var n,i=Math.max(e,t,r),o=Math.min(e,t,r),a=(i+o)/2;if(i==o)n=l=0;else{var s=i-o,l=.5<a?s/(2-i-o):s/(i+o);switch(i){case e:n=(t-r)/s+(t<r?6:0);break;case t:n=(r-e)/s+2;break;case r:n=(e-t)/s+4}n/=6}return[100*n,100*l,100*a]},Xo=(e,t,r)=>{var n,i,o,a;return 0==t?i=o=a=r:(i=(n=function(e,t,r){return r<0&&(r+=1),1<r&&--r,r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e})(t=2*r-(r=r<.5?r*(1+t):r+t-r*t),r,e+1/3),o=n(t,r,e),a=n(t,r,e-1/3)),[255*i,255*o,255*a]},qo=e=>To(void 0,void 0,void 0,(function*(){var{bitmap:t,texture:r}=e;const{ctx:n,canvas:i}=yield Vo(URL.createObjectURL(r.userData.blob),{width:t.width,height:t.height});for(var o=n.getImageData(0,0,t.width,t.height,{colorSpace:"srgb"}),a=0,s=o.data.length;a<s;a+=4){var l=(c=Wo(o.data[a],o.data[a+1],o.data[a+2]))[0]/100,u=c[1]/100,c=c[2]/100;l=Xo(l,u,c),o.data[a]=l[0],o.data[a+1]=l[1],o.data[a+2]=l[2]}return n.putImageData(o,0,0),new vi.Texture(i)})),Yo=e=>{for(var t=(e=e.bitmap).width,r=e.height,n=Ho(e).ctx.getImageData(0,0,t,r).data,i=[],o=0;o<n/4;o+=1)i.push(n.slice(4*o,4*(o+1)))},Zo=e=>new Array(e.files.length).fill(0).map(((t,r)=>e.files.item(r))).filter((e=>null!==e)),Qo=e=>new Promise((t=>{e.toBlob((e=>{t(e)}))})),Ko={parse(e){var{x:e,y:t,z:r}=e;return void 0===r?new c.Vector2(e,t):new c.Vector3(e,t,r)},toJSON(e){var{x:t,y:r}=e;return e instanceof c.Vector2?{x:t,y:r}:{x:t,y:r,z:e.z}}},Jo=(e,t)=>s().get(e,{responseType:t||"arraybuffer"}).then((e=>e.data)).catch((e=>{console.log(e,"加载出错")})),$o=(e,t)=>Object.assign(e,t||{}),ea=(e,t)=>e.distanceTo(t),ta=(e,t,r,n,i,o)=>({cx:e,cy:t,cz:r,tx:n,ty:i,tz:o}),ra=e=>new T(e),na=e=>new I(e),ia=e=>new _(e),oa=(e,t=0)=>{let r=setTimeout((()=>(null!==r&&clearTimeout(r),r=null,e())),t)},aa=e=>{if(null===e)return null;if("object"!=typeof e)return e;var t,r,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]=r);return n},sa=(e,t=.5,r=!1)=>{if("Group"===e.type)throw TypeError("该模型为Group类型");if(!e.material)throw TypeError("该模型没有材质");if(void 0===e.material.oldOpc&&(e.material.oldOpc=e.material.opacity,e.material.oldTransparent=e.material.transparent),r)return e.material.opacity=e.material.oldOpc,void(e.material.transparent=e.material.oldTransparent);1===t?(e.material.transparent=!1,e.material.opacity=1):(e.material.transparent=!0,e.material.opacity=t)},la=(e,t,r)=>{"Group"===e.type||"Object3D"===e.type?e.children.forEach((e=>la(e,t,r))):sa(e,t,r)},ua=(e,t,r=1,n)=>new Array(t).fill("").map(((t,i)=>e+(i+r)+(n||""))),ca=e=>(e.mapping=c.EquirectangularReflectionMapping,e),ha=e=>{let t=e=>"Group"!==e.type&&"Object3D"!==e.type||1!==e.children.length?e:t(e.children[0]);return t(e)},pa=(e,t)=>{let r=document.createElement("video");return r.style="position:absolute;top:0;left:0;z-index:1000000;",r.src=e,r.loop="loop",r.muted="muted",r.play(),t.appendChild(r),new c.VideoTexture(r)},fa=(e,t=!1)=>{let r=new c.CatmullRomCurve3(e),n=new c.BufferGeometry;e=r.getSpacedPoints(100),n.setFromPoints(e),e=new c.LineBasicMaterial({color:26214});let i=new c.Line(n,e);return i.visible=t,{line:i,curve:r}},da=e=>{let t=0;const r=[],n={},i={0:"x",1:"y",2:"z"};return e.map((e=>{var o,a,s;3===t&&(t=0,({x:o,y:a,z:s}=n),r.push(new c.Vector3(o,a,s))),n[i[t]]=e,t++})),r},ma=e=>{var{pointArray:e,material:t,lineWidth:r,colorArray:n}=e;const i=new go,o=(i.setPositions(e),t||new Wi({transparent:!0,side:c.DoubleSide,linewidth:r||5,vertexColors:!0})),a=(i.setColors(n||[1,1,1]),o.resolution.set(window.innerWidth,window.innerHeight),new So(i,o));return a.name="gw",a.computeLineDistances(),a},va=(()=>{const e=(e,t,r)=>{e.matrixAutoUpdate=t,r&&(r(),t&&(e.matrixAutoUpdate=!t))};return(t,r,n)=>{if(0===t.children.length)return e(t,r,n);const i=[];t.traverse((e=>i.push(e))),i.map((t=>e(t,r,n)))}})(),ya=e=>3.1415926*e/180,ga=e=>e.toString().replace(/(\[object )([a-zA-Z]+)(])/,"$2"),ba=(e,t)=>((0,Xe.js)(e,((r,n)=>{let i=t[r];void 0!==i&&("Object"===ga(n)&&"Object"===ga(i)&&(i=ba(n,i)),e[r]=i)})),e),xa=(e,t)=>e.find((e=>e===t));class wa{constructor(e){this.alt=!1,this.ctrl=!1,this.shift=!1,this.eventsMap={down:{},up:{}},this.allFn={s_saveScene:()=>function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.events.runScene.optionsEx.log("正在保存","base","info"),yield this.events.runScene.optionsEx.cb.scene.saveNet.cb("")})),d_exporter_Gltf:()=>{this.events.runScene.exporter.gltf.scene()},alt_selectDom:()=>{console.log("多选dom")},r_runScript:()=>{console.log("运行脚本")},d_copyModel:()=>{console.log("复制模型")},g_createGroup:()=>{console.log("生成组")},meta_showMateriallLibrary:()=>{console.log("弹出材质库窗口")},f_focusModel:()=>{const e=this.events.runScene.modelEx.select;if(e){const{scene:r,camera:n,renderer:i,controls:o}=this.events.runScene.assetsEx.get(),a=new c.Vector3,s=new c.Vector3;if("Mesh"===e.type||"Group"===e.type||"Object3D"===e.type){const e=this.events.runScene.helperEx.boxHelper;if(e.update(),!e||!e.object)return;var t=i.domElement.getBoundingClientRect();let r=t.width/t.height;const o=new c.Vector3;t=e.geometry.attributes.position.array,o.set(Math.abs(t[0]-t[3]),Math.abs(t[1]-t[7]),Math.abs(t[2]-t[14])),s.x=.5*(t[0]+t[3]),s.y=.5*(t[1]+t[7]),s.z=.5*(t[2]+t[14]);let l=new c.Vector3;l.subVectors(n.position,s),l.projectOnPlane(new c.Vector3(0,1,0)),l.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*n.fov*Math.PI/180),t=o.length()/r/t,a.addVectors(s,l.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new c.Vector3,e.getWorldPosition(t),s.set(t.x,t.y,t.z);let i=new c.Vector3;i.subVectors(n.position,s),i.projectOnPlane(new c.Vector3(0,1,0)),i.normalize(),a.addVectors(s,i.multiplyScalar(3))}_o({positionX:n.position.x,positionY:n.position.y,positionZ:n.position.z,targetX:o.target.x,targetY:o.target.y,targetZ:o.target.z},{positionX:a.x,positionY:a.y,positionZ:a.z,targetX:s.x,targetY:s.y,targetZ:s.z},.5,(e=>{n.position.set(e.positionX,e.positionY,e.positionZ),n.lookAt(e.targetX,e.targetY,e.targetZ),o.target.set(e.targetX,e.targetY,e.targetZ),o.update()}))}},z_undo:e=>{this.events.runScene.undoEx.undo()},y_redo:e=>{this.events.runScene.undoEx.redo()}},this.events=e}bindEvent(e,t,r){if(void 0!==this.eventsMap[e][t])throw SyntaxError("该函数名已存在");this.eventsMap[e][t]=r}init(e){"running"!==this.events.runScene.optionsEx.options.mode&&(document.addEventListener("keydown",this.keyDown.bind(this)),document.addEventListener("keyup",this.keyUp.bind(this)))}keyDown(e){const t=e.key.toLowerCase();switch((0,Xe.js)(this.eventsMap.down,((r,n)=>{n(t,e)})),t){case"s":this.ctrl&&(e.preventDefault(),this.allFn.s_saveScene());break;case"d":if(this.ctrl){e.preventDefault();var r=this.events.runScene.modelEx.select;if(!r)return;this.events.runScene.modelEx.selectNull();var n=this.events.runScene.modelEx.clone(r);if(!n)return;this.events.runScene.modelEx.add(n,r.parent,{isClone:!0})}break;case"alt":this.ctrl&&(e.preventDefault(),this.allFn.alt_selectDom()),this.alt=!0;break;case"control":case"ctrl":this.ctrl=!0;break;case"shift":this.shift=!0;break;case"w":e.preventDefault(),e.stopPropagation(),this.events.runScene.helperEx.transContro.changeMode("position");break;case"e":this.events.runScene.helperEx.transContro.changeMode("rotation");break;case"r":if(this.events.runScene.helperEx.transContro.changeMode("scale"),!this.ctrl)return;e.preventDefault(),this.allFn.r_runScript();break;case"g":this.events.runScene.optionsEx.cb.events.key.g.cb({event:e,eventKey:this});break;case"f":this.allFn.f_focusModel();break;case"delete":console.log("删除"),this.events.runScene.helperEx.unfocus(),n=this.events.runScene.multipSelector.getSelectedList("value"),this.events.runScene.sceneEx.remove(this.events.runScene.modelEx.select||n),n&&this.events.runScene.multipSelector.delete();break;case"z":if(!this.ctrl)return;this.allFn.z_undo(e),console.log("撤销功能~~~~");break;case"y":if(!this.ctrl)return;this.allFn.y_redo(e),console.log("向前功能~~~~")}}keyUp(e){const t=e.key.toLowerCase();switch((0,Xe.js)(this.eventsMap.up,((r,n)=>{n(t,e)})),t){case"meta":if(!this.ctrl)return;this.allFn.meta_showMateriallLibrary();break;case"s":if(this.ctrl)break;return;case"alt":this.alt=!1;break;case"control":case"ctrl":this.ctrl=!1;break;case"shift":this.shift=!1}}}class Sa{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.down=e=>{(0,Xe.js)(this.fnMap.local.down,((t,r)=>{r(e)})),this.downPosition={x:e.offsetX,y:e.offsetY}},this.up=e=>{var t,r,n,i;2===e.button||null!=(t=this.events.runScene.helperEx.transContro)&&t.isDraggingChange||((0,Xe.js)(this.fnMap.local.up,((t,r)=>{r(e)})),t=e.offsetX,r=e.offsetY,({x:n,y:i}=this.downPosition),t===n&&r===i&&this.trigger(e))},this.events=e}bindEvent(e){var{type:e,name:t,fn:r,local:n}=e;this.fnMap[n][e][t]=r}init(e){e.addEventListener("pointerdown",this.down.bind(this)),e.addEventListener("pointerup",this.up.bind(this)),window.addEventListener("pointerdown",(e=>{this.events.runScene.optionsEx.cb.events.pointer.down.cb(e)})),window.addEventListener("pointerup",(e=>{this.events.runScene.optionsEx.cb.events.pointer.up.cb(e)}))}getTriggerModels(e){const t=new c.Raycaster,r=new c.Vector2,{engineDom:n,camera:i,scene:o}=this.events.runScene.assetsEx.get();return r.x=e.offsetX/n.clientWidth*2-1,r.y=-e.offsetY/n.clientHeight*2+1,t.setFromCamera(r,i),e=o.children.filter((e=>{if((!this.events.runScene.helperEx.isHelper(e)||e.userData.id)&&!e.userData.unClick)return e})),t.intersectObjects(e,!0).map((e=>e.object))}removeHideModel(e){return e.find((e=>this.events.runScene.modelEx.deepIsVisible(e)))}trigger(e){let t=this.removeHideModel(this.getTriggerModels(e));if(!t)return this.events.runScene.multipSelector.setEmpty(),void this.events.runScene.modelEx.selectNull();if(this.events.runScene.helperEx.isHelper(t)&&(e=this.events.runScene.uniqueEx.getId(t),t=this.events.runScene.uniqueEx.model.get(e)),!this.enableUp){if(t===this.events.runScene.helperEx.transContro.multipObj)return;this.enableUp=!0}if(console.log("鼠标按下选中的模型:",t),this.events.key.ctrl)return this.enableUp=!1,this.events.runScene.multipSelector.add(t);if(this.events.key.shift){const e=t.parent;return e?void e.children.map((e=>{this.events.runScene.multipSelector.add(e)})):void 0}this.events.runScene.modelEx.setSelectByModel(t),this.events.runScene.lightEx.isLight(t)&&this.events.runScene.lightEx.setSelect(t)}}o=a(356);var Ta=a.n(o),_a=a(298);const Ma=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"];class Ea{static create(){return new c.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],n=e[t];if(r instanceof c.Color){if(r.getHexString()!==n.getHexString())return!1}else if("object"==typeof r){if(n.x!==r.x)return!1}else if(n!==r)return!1}for(const t of gi)if(e[t])return!1;return!0}}Ea.defVal={color:new c.Color(16777215),emissive:new c.Color(0),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new c.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class Pa{constructor(e){this.undos=[],this.redos=[],this.dataMap={history:[],index:0},this.runScene=e}undo(){if(0!==this.undos.length){const e=this.removeUndos(-1)[0];e&&(e instanceof Array?e.reverse().map((e=>e.undo())):e.undo(),this.redos.push(e))}}addUndos(e){var t;return this.undos.push(e),t=this.dataMap.history.push(e),this.dataMap.index=this.undos.length-1,this.runScene.optionsEx.cb.undo.addUndos.cb(e,this.undos),t}removeUndos(e){var t;return this.undos.splice(e),t=this.dataMap.history.splice(e),this.dataMap.index=this.undos.length-1,this.runScene.optionsEx.cb.undo.removeUndos.cb(e),t}undoByIndex(e){e>this.dataMap.index?this.undos.slice(this.dataMap.index+1,e+1).map((e=>{e instanceof Array?e.map((e=>e.redo())):e.redo()})):e<this.dataMap.index&&this.undos.slice(e+1,this.dataMap.index+1).reverse().map((e=>{e instanceof Array?e.map((e=>e.undo())):e.undo()})),this.dataMap.index=e,this.runScene.optionsEx.cb.undo.undoByIndex.cb(e)}addUndo(e){this.dataMap.index!==this.undos.length&&this.removeUndos(this.dataMap.index+1),this.addUndos(e)}addRedo(e){this.redos.push(e)}redo(){if(0!==this.redos.length){const e=this.redos.splice(-1)[0];e&&(e instanceof Array?e.reverse().map((e=>e.redo())):e.redo(),this.addUndo(e))}}reset(){this.undos=[],this.redos=[],this.dataMap.history=[],this.dataMap.index=0,this.runScene.optionsEx.cb.undo.reset.cb("")}}function Oa(e){if("object"!=typeof e)return e;if(null===e)return null;if(e){var t,r,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=Oa(e[t]),n[t]=r);return n}}const Ra=class extends bi{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,Xe.qR)(e.target,this.typeList)[(0,_a.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,Xe.qR)(this.target,this.typeList);t[(0,_a.lastArrayEle)(this.typeList)]=e,this.cb&&this.cb(t),"shadow"!==this.typeList[0]&&this.typeList[1]}undo(){this._execute(this.old)}redo(){this._execute(this.new)}};class ka{constructor(e){this.tools={type:"FakeInterior",getTextures(e){const t=[];return e.uniforms.ceilingTex.value&&t.push({type:"ceilingTex",texture:e.uniforms.ceilingTex.value}),e.uniforms.floorTex.value&&t.push({type:"floorTex",texture:e.uniforms.floorTex.value}),e.uniforms.sideWallTex.value&&t.push({type:"sideWallTex",texture:e.uniforms.sideWallTex.value}),e.uniforms.backWallTex.value&&t.push({type:"backWallTex",texture:e.uniforms.backWallTex.value}),t},parseData:e=>{const{textures:t,normal:r}=e,n=new c.ShaderMaterial({uniforms:Oa(Aa.uniforms),vertexShader:Aa.vertexShader,fragmentShader:Aa.fragmentShader});return t.forEach((e=>{"ceilingTex"===e.type?n.uniforms.ceilingTex.value=e.texture||null:"floorTex"===e.type?n.uniforms.floorTex.value=e.texture||null:"sideWallTex"===e.type?n.uniforms.sideWallTex.value=e.texture||null:"backWallTex"===e.type&&(n.uniforms.backWallTex.value=e.texture||null)})),Object.keys(r.uniforms).filter((e=>!ka.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];n.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new c.Vector4(t.x,t.y,t.z,t.w):t})),n.userData.tools=this.tools,n},toNormal:e=>{const t=Ga(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),{}),n=e.uniforms,i=Aa.uniforms;return Object.keys(n).filter((e=>!ka.TextureNames.includes(e))).map((e=>{var t,o,a,s,l,u,h=n[e].value,p=i[e].value;h instanceof c.Vector4?(({x:t,y:o,z:a}=h),({x:s,y:l,z:u}=p),t===s&&o===l&&a===u||(r[e]=h)):h!==p&&(r[e]=h)})),t.userData.normal.uniforms=r,t},clone:function(e,t){return e}},this.runScene=e}create(){const e=new c.ShaderMaterial({uniforms:Oa(Aa.uniforms),vertexShader:Aa.vertexShader,fragmentShader:Aa.fragmentShader});return e.userData.tools=this.tools,e}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Ra({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}ka.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"];const Aa={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new c.Vector4(1,1,1,1)},sideWallTex:{value:null},backWallTex:{value:null},floorTex:{value:null},ceilingTex:{value:null},sideWallTexTiling:{value:.097},backWallTexTiling:{value:.097},floorTexTiling:{value:.15},ceilingTexTiling:{value:.15},roomTile:{value:.3},roomsXYZPropsW:{value:new c.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new c.Vector4(4.7,2,-11,-3)}},vertexShader:"\n varying vec2 vUv;\n varying vec3 vPos;\n varying mat4 vModelMatrix;\n \n void main() {\n vUv = uv;\n vPos = position;\n vModelMatrix = modelMatrix;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float roomIntensity;\n uniform vec4 roomColorTint;\n \n uniform sampler2D sideWallTex;\n uniform sampler2D backWallTex;\n uniform sampler2D floorTex;\n uniform sampler2D ceilingTex;\n \n uniform float sideWallTexTiling;\n uniform float backWallTexTiling;\n uniform float floorTexTiling;\n uniform float ceilingTexTiling;\n \n uniform float roomTile;\n uniform vec4 roomsXYZPropsW;\n uniform vec4 positionOffsetRoomsXYZPropsW;\n \n varying vec2 vUv;\n varying vec3 vPos;\n varying mat4 vModelMatrix;\n \n void main() {\n vec4 interpVertexPos = vec4(vPos.xyz, vPos.z);\n // 将相机世界空间坐标转换为对象空间坐标\n vec4 cameraObjectPos = inverse(vModelMatrix) * vec4(cameraPosition, 1.0);\n vec4 transCameraPos = vec4(cameraObjectPos.xyz, cameraObjectPos.z);\n \n vec4 temp1 = (interpVertexPos - positionOffsetRoomsXYZPropsW);\n vec4 temp2 = ((roomsXYZPropsW + vec4(-1E-05, -1E-05, -1E-05, -1E-05)) * roomTile);\n vec4 V2 = transCameraPos - positionOffsetRoomsXYZPropsW;\n vec4 V1 = temp1 - V2;\n vec4 middleman = ((floor(temp2 * temp1) + step(vec4(0, 0, 0, 0), V1)) / temp2 - V2) / V1;\n \n // Side Walls\n vec2 sideWallUv = (middleman.x * V1 + V2).zy * sideWallTexTiling;\n vec4 sideWallColor = texture2D(sideWallTex, sideWallUv);\n \n // Back Wall\n vec2 backWallUv = (middleman.z * V1 + V2).xy * backWallTexTiling;\n vec4 backWallColor = texture2D(backWallTex, backWallUv);\n \n // Floor Ceiling\n vec2 floorUv = ((middleman.y * V1) + V2).xz * floorTexTiling;\n vec2 ceilingUv = ((middleman.y * V1) + V2).xz * ceilingTexTiling;\n vec4 floorColor = texture2D(floorTex, floorUv);\n vec4 ceilingColor = texture2D(ceilingTex, ceilingUv);\n vec4 cfColor = mix(floorColor, ceilingColor, step(0.0, V1.y));\n \n // Mix\n float compareXZ = 0.0;\n float stepXZ = step(middleman.z, middleman.x);\n if(stepXZ <= 0.0)\n compareXZ = middleman.x;\n else\n compareXZ = middleman.z;\n \n vec4 wallColor = vec4(0);\n if(stepXZ <= 0.0)\n wallColor = sideWallColor;\n else\n wallColor = backWallColor;\n \n vec4 finalColor = vec4(0);\n if(middleman.y <= compareXZ)\n finalColor = cfColor;\n else\n finalColor = wallColor;\n \n // Tint Room\n vec4 tintColor = roomColorTint * finalColor * roomIntensity;\n \n gl_FragColor = tintColor;\n }\n "},Ca={uniforms:{tDiffuse:new c.Uniform(null),h:new c.Uniform(1/512)},vertexShader:"\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\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 sum = vec4( 0.0 );\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\t\n\t\t\tgl_FragColor = sum;\n\t\t}"},La={uniforms:{tDiffuse:new c.Uniform(null),v:new c.Uniform(1/512)},vertexShader:"\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\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 sum = vec4( 0.0 );\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\t\t\t\n\t\t\tgl_FragColor = sum;\n\t\t}"};new c.Uniform(null),new c.Uniform(null),new c.Uniform(0),new c.Uniform(0),new c.Uniform(0),new c.Uniform(new c.Vector2),new c.Uniform(.1),new c.Uniform(1e3);class Da{constructor(e){this.materials={},this.render=()=>{(0,Xe.js)(this.materials,((e,t)=>{const{model:r,material:n}=t;n.update(r)}))},this.tools={type:"Reflector",getTextures:e=>qa(e),parseData:e=>{const{textures:t,normal:r,models:n,material:i}=e,o=Wa(i,new Ia(void 0,void 0,this.runScene));return o.name=i.name,t.forEach((e=>{o[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!Da.TextureNames.includes(e))).map((e=>{o[e]=r.uniforms[e]})),o.setRTSize(o.resolution),o.setBlurPass(o.blurSize),o.insertReflectorShader(),o.userData.tools=this.tools,this.bindData({model:n[0],material:o}),o},toNormal:e=>{const t=Wa(e,Ga()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),n=ja.uniforms;return Object.keys(n).filter((e=>!Da.TextureNames.includes(e))).map((t=>{var i=e[t],o=n[t].value;"mirror"===t||"mixBlur"===t||"mixStrength"===t||"mixContrast"===t?i.value!==o&&(r[t]=i):i!==o&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>this.create(t)},this.runScene=e,this.init()}init(){this.runScene.optionsEx.cb.render.add("Reflector-render",this.render),this.runScene.optionsEx.cb.model.add.add("",(({model:e})=>{var t;e.material&&"Reflector"===(null==(t=null==(t=e.material.userData)?void 0:t.tools)?void 0:t.type)&&(t=e.material,this.materials[t.userData.id]||(this.materials[t.userData.id]={model:e,material:t}))})),this.runScene.optionsEx.cb.model.remove.add("",(({model:e})=>{var t;e.material&&"Reflector"===(null==(t=null==(t=e.material.userData)?void 0:t.tools)?void 0:t.type)&&(t=e.material,delete this.materials[t.userData.id])}))}bindData(e){const t=e.material;var r=(0,l.getId)();t.userData.id=r,this.materials[r]=e}create(e){const t=new Ia(void 0,void 0,this.runScene);return t.insertReflectorShader(),t.userData.tools=this.tools,(e=e||this.runScene.modelEx.select)&&(t.name=e.name),this.bindData({model:e,material:t}),t}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Ra({target:e,typeList:[...t],newVal:r}).execute())}dispose(){this.materials={}}}Da.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"];class Ia extends c.MeshStandardMaterial{constructor(e,t,r){e?super(e):(super(),this.opacity=ja.uniforms.opacity.value,this.transparent=ja.uniforms.transparent.value,this.roughness=ja.uniforms.roughness.value,this.metalness=ja.uniforms.metalness.value),this.runScene=r,t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new c.Uniform(t.mirror),this.mixBlur=new c.Uniform(t.mixBlur),this.mixStrength=new c.Uniform(t.mixStrength),this.mixContrast=new c.Uniform(t.mixContrast)):(this.resolution=ja.uniforms.resolution.value,this.blurSize=ja.uniforms.blurSize.value,this.mirror=new c.Uniform(ja.uniforms.mirror.value),this.mixBlur=new c.Uniform(ja.uniforms.mixBlur.value),this.mixStrength=new c.Uniform(ja.uniforms.mixStrength.value),this.mixContrast=new c.Uniform(ja.uniforms.mixContrast.value)),this.textureMatrix=new c.Uniform(new c.Matrix4),this.reflectorWorldPosition=new c.Vector3,this.cameraWorldPosition=new c.Vector3,this.rotationMatrix=new c.Matrix4,this.normal=new c.Vector3,this.view=new c.Vector3,this.lookAtPosition=new c.Vector3,this.target=new c.Vector3,this.tempQuaternion=new c.Vector4,this.virtualCamera=new c.PerspectiveCamera,this.reflectorPlane=new c.Plane,this.clipPlane=new c.Vector4,e={minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType,encoding:this.runScene.assetsEx.get().renderer.outputEncoding},this.glRT1=new c.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new c.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new c.Uniform(this.glRT1.texture),this.tDiffuseBlur=new c.Uniform(this.glRT2.texture),this.hBlurPass=new ee(Ca),this.hBlurPass.uniforms.h.value=1/this.blurSize,this.hBlurPass.clear=!1,this.hBlurPass.renderToScreen=!1,this.hBlurPass.enabled=0<this.blurSize,this.hBlurPass.material.depthWrite=!1,this.vBlurPass=new ee(La),this.vBlurPass.uniforms.v.value=1/this.blurSize,this.vBlurPass.clear=!1,this.vBlurPass.renderToScreen=!1,this.vBlurPass.enabled=0<this.blurSize,this.vBlurPass.material.depthWrite=!1}insertReflectorShader(){this.onBeforeCompile=e=>{var t;null!=(t=e.defines)&&t.USE_UV||(e.defines.USE_UV=""),null!=(t=e.defines)&&t.USE_BLUR||(e.defines.USE_BLUR=""),e.uniforms.tDiffuse=this.tDiffuse,e.uniforms.tDiffuseBlur=this.tDiffuseBlur,e.uniforms.textureMatrix=this.textureMatrix,e.uniforms.mirror=this.mirror,e.uniforms.mixBlur=this.mixBlur,e.uniforms.mixStrength=this.mixStrength,e.uniforms.mixContrast=this.mixContrast,e.vertexShader=ja.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",ja.vertexShader),e.fragmentShader=ja.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",ja.fragmentShader)}}setRTSize(e){this.glRT1.setSize(e,e),this.glRT2.setSize(e,e),this.hBlurPass.setSize(e,e),this.vBlurPass.setSize(e,e)}setBlurPass(e){this.hBlurPass.enabled=0<e,this.hBlurPass.enabled&&(this.hBlurPass.uniforms.h.value=1/e),this.vBlurPass.enabled=0<e,this.vBlurPass.enabled&&(this.vBlurPass.uniforms.v.value=1/e)}copy(e){return super.copy(e),this.resolution=e.resolution,this.blurSize=e.blurSize,this.mirror.value=e.mirror.value,this.mixBlur.value=e.mixBlur.value,this.mixStrength.value=e.mixStrength.value,this.mixContrast.value=e.mixContrast.value,this}swapBuffers(){var e=this.glRT1;this.glRT1=this.glRT2,this.glRT2=e}beforeRender(e){if(this.reflectorWorldPosition.setFromMatrixPosition(e.matrixWorld),this.cameraWorldPosition.setFromMatrixPosition(this.runScene.assetsEx.get().camera.matrixWorld),this.rotationMatrix.extractRotation(e.matrixWorld),this.normal.set(0,0,1),this.normal.applyMatrix4(this.rotationMatrix),this.reflectorWorldPosition.addScaledVector(this.normal,0),this.view.subVectors(this.reflectorWorldPosition,this.cameraWorldPosition),!(0<this.view.dot(this.normal))){this.view.reflect(this.normal).negate(),this.view.add(this.reflectorWorldPosition),this.rotationMatrix.extractRotation(this.runScene.assetsEx.get().camera.matrixWorld),this.lookAtPosition.set(0,0,-1),this.lookAtPosition.applyMatrix4(this.rotationMatrix),this.lookAtPosition.add(this.cameraWorldPosition),this.target.subVectors(this.reflectorWorldPosition,this.lookAtPosition),this.target.reflect(this.normal).negate(),this.target.add(this.reflectorWorldPosition),this.virtualCamera.position.copy(this.view),this.virtualCamera.up.set(0,1,0),this.virtualCamera.up.applyMatrix4(this.rotationMatrix),this.virtualCamera.up.reflect(this.normal),this.virtualCamera.lookAt(this.target),this.virtualCamera.far=this.runScene.assetsEx.get().camera.far,this.virtualCamera.updateMatrixWorld(),this.virtualCamera.projectionMatrix.copy(this.runScene.assetsEx.get().camera.projectionMatrix),this.textureMatrix.value.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.value.multiply(this.virtualCamera.projectionMatrix),this.textureMatrix.value.multiply(this.virtualCamera.matrixWorldInverse),this.textureMatrix.value.multiply(e.matrixWorld),this.reflectorPlane.setFromNormalAndCoplanarPoint(this.normal,this.reflectorWorldPosition),this.reflectorPlane.applyMatrix4(this.virtualCamera.matrixWorldInverse),this.clipPlane.set(this.reflectorPlane.normal.x,this.reflectorPlane.normal.y,this.reflectorPlane.normal.z,this.reflectorPlane.constant);const t=this.virtualCamera.projectionMatrix;this.tempQuaternion.x=(Math.sign(this.clipPlane.x)+t.elements[8])/t.elements[0],this.tempQuaternion.y=(Math.sign(this.clipPlane.y)+t.elements[9])/t.elements[5],this.tempQuaternion.z=-1,this.tempQuaternion.w=(1+t.elements[10])/t.elements[14],this.clipPlane.multiplyScalar(2/this.clipPlane.dot(this.tempQuaternion)),t.elements[2]=this.clipPlane.x,t.elements[6]=this.clipPlane.y,t.elements[10]=this.clipPlane.z+1,t.elements[14]=this.clipPlane.w}}update(e){e&&e.visible&&(this.beforeRender(e),e.visible=!1,this.runScene.assetsEx.get().renderer.setRenderTarget(this.glRT1),this.runScene.assetsEx.get().renderer.clear(),this.runScene.assetsEx.get().renderer.render(this.runScene.assetsEx.get().scene,this.virtualCamera),this.hBlurPass&&this.hBlurPass.enabled&&(this.hBlurPass.render(this.runScene.assetsEx.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),this.vBlurPass&&this.vBlurPass.enabled&&(this.vBlurPass.render(this.runScene.assetsEx.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),e.visible=!0,this.runScene.assetsEx.get().renderer.setRenderTarget(null))}}const ja={uniforms:{opacity:new c.Uniform(1),transparent:new c.Uniform(!1),roughness:new c.Uniform(1),metalness:new c.Uniform(.6),resolution:new c.Uniform(1024),blurSize:new c.Uniform(1024),mirror:new c.Uniform(0),mixBlur:new c.Uniform(10),mixStrength:new c.Uniform(2),mixContrast:new c.Uniform(1)},vertexParas:"\n uniform mat4 textureMatrix;\n varying vec4 my_vUv;\n ",vertexShader:"\n #include <project_vertex>\n my_vUv = textureMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n ",fragmentParas:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDiffuseBlur;\n uniform sampler2D tDepth;\n uniform sampler2D distortionMap;\n uniform float distortion;\n uniform float mirror;\n uniform float mixBlur;\n uniform float mixStrength;\n uniform float mixContrast;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec4 my_vUv;\n ",fragmentShader:"\n #include <emissivemap_fragment>\n float distortionFactor = 0.0;\n #ifdef USE_DISTORTION\n distortionFactor = texture2D(distortionMap, vUv).r * distortion;\n #endif\n \n vec4 new_vUv = my_vUv;\n new_vUv.x += distortionFactor;\n new_vUv.y += distortionFactor;\n \n vec4 base = texture2DProj(tDiffuse, new_vUv);\n vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);\n \n vec4 merge = base;\n \n #ifdef USE_NORMALMAP\n vec2 normal_uv = vec2(0.0);\n vec4 normalColor = texture2D(normalMap, vUv * normalScale);\n vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );\n vec3 coord = new_vUv.xyz / new_vUv.w;\n normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;\n vec4 base_normal = texture2D(tDiffuse, normal_uv);\n vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);\n merge = base_normal;\n blur = blur_normal;\n #endif\n \n float blurFactor = 0.0;\n float depthFactor = 0.0001;\n \n #ifdef USE_DEPTH\n vec4 depth = texture2DProj(tDepth, new_vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0001, min(1.0, depthFactor));\n #ifdef USE_BLUR\n blur = blur * min(1.0, depthFactor + depthToBlurRatioBias);\n merge = merge * min(1.0, depthFactor + 0.5);\n #else\n merge = merge * depthFactor;\n #endif\n #endif\n \n float reflectorRoughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv );\n reflectorRoughnessFactor *= reflectorTexelRoughness.g;\n #endif\n \n #ifdef USE_BLUR\n blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor);\n merge = mix(merge, blur, blurFactor);\n #endif\n \n vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0);\n newMerge.r = (merge.r - 0.5) * mixContrast + 0.5;\n newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;\n newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;\n \n diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);\n "};class Ua{constructor(e){this.tools={type:"Fresnel",getTextures(e){const t=[];return e.envMap&&t.push({type:"envMap",texture:e.envMap}),t},parseData:e=>{const{textures:t,normal:r,material:n}=e,i=Wa(n,new Ba(void 0,void 0,this.runScene));return i.name=n.name,t.forEach((e=>{i[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!Ua.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.insertFresnelShader(),i.userData.tools=this.tools,i},toNormal:e=>{const t=Wa(e,Ga()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),n=za.uniforms;return Object.keys(n).filter((e=>!Ua.TextureNames.includes(e))).map((t=>{var i=e[t],o=n[t].value;"fresnelBias"===t||"fresnelScale"===t||"fresnelPower"===t?i.value!==o&&(r[t]=i):i!==o&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>this.create(t)},this.runScene=e}create(e){const t=new Ba(void 0,void 0,this.runScene);return t.insertFresnelShader(),t.userData.tools=this.tools,(e=e||this.runScene.modelEx.select)&&(t.name=e.name),t}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new Ra({target:e,typeList:[...t],newVal:r}).execute())}}Ua.TextureNames=["envMap"];class Ba extends c.MeshPhysicalMaterial{constructor(e,t,r){if(e?super(e):(super(),this.emissive=new c.Color(65535),this.envMap=null,this.metalness=0,this.roughness=0,this.ior=1.5,this.transmission=1,this.opacity=1,this.transparent=!0,this.thickness=0),this.runScene=r,t?(this.fresnelBias=new c.Uniform(t.fresnelBias),this.fresnelScale=new c.Uniform(t.fresnelScale),this.fresnelPower=new c.Uniform(t.fresnelPower)):(this.fresnelBias=new c.Uniform(za.uniforms.fresnelBias.value),this.fresnelScale=new c.Uniform(za.uniforms.fresnelScale.value),this.fresnelPower=new c.Uniform(za.uniforms.fresnelPower.value)),!this.cubeCamera){const e=new c.WebGLCubeRenderTarget(2048);e.texture.mapping=c.CubeRefractionMapping,this.cubeCamera=new c.CubeCamera(.1,1e5,e),this.runScene.assetsEx.scene.add(this.cubeCamera),this.runScene.optionsEx.cb.render.add("Fresnel",(()=>{this.update()}))}}insertFresnelShader(){this.onBeforeCompile=e=>{e.uniforms.fresnelBias=this.fresnelBias,e.uniforms.fresnelScale=this.fresnelScale,e.uniforms.fresnelPower=this.fresnelPower,e.vertexShader=e.vertexShader.replace(/varying vec3 vWorldPosition;/g,za.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,za.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,za.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,za.fragmentShaderEmissive)}}update(){this.cubeCamera&&(this.cubeCamera.position.copy(this.runScene.assetsEx.camera.position),this.cubeCamera.update(this.runScene.assetsEx.renderer,this.runScene.assetsEx.scene))}}const za={uniforms:{fresnelBias:new c.Uniform(0),fresnelScale:new c.Uniform(1),fresnelPower:new c.Uniform(3)},vertexParas:"\n varying vec3 vWorldPosition;\n varying vec3 vWorldNormal;\n ",vertexShader:"\n vWorldPosition = worldPosition.xyz;\n vWorldNormal = normalize(vec3(modelMatrix * vec4(normal, 0.0)));\n ",fragmentParas:"\n #include <transmission_pars_fragment>\n varying vec3 vWorldNormal;\n uniform float fresnelBias;\n uniform float fresnelScale;\n uniform float fresnelPower;\n ",fragmentShaderEmissive:"\n vec3 viewDir = normalize(cameraPosition - vWorldPosition);\n float fresnelNdot = dot(viewDir, vWorldNormal);\n float fresnelValue = fresnelBias + fresnelScale * pow(1.0 - fresnelNdot, fresnelPower);\n // fresnelValue = [0, 1], 0=center,1=edge\n \n vec3 totalEmissiveRadiance = emissive * fresnelValue;\n "},Na=class extends bi{constructor(e){super(),this.type="修改属性",this.cb=e=>{};var{target:e,info:t,oldVal:r,newVal:n,runScene:i,cb:o,executeCb:a}=e;this.runScene=i,this.target=e,this.info=t,this.newVal=n,this.oldVal=r,o&&(this.cb=o),a&&(this.executeCb=a)}_execute(e){var{target:t,info:r}=this;if(this.executeCb)return this.executeCb({target:t,info:r,val:e});this.target[this.info]=e,"name"===this.info&&this.target.isObject3D?(t=this.runScene.uniqueEx.model.parseName(this.target),r=e,this.runScene.optionsEx.cb.model.changeName.cb({model:this.target,name:e=t||e,oldName:r})):"material"===this.info?this.runScene.uniqueEx.material.addModel(this.target,e,e===this.newVal?this.oldVal:this.newVal):"visible"===this.info&&this.runScene.optionsEx.cb.model.setVisible.cb({model:this.target,visible:e}),this.cb(this.target)}execute(){return this.redo(),this}undo(){this._execute(this.oldVal)}redo(){this._execute(this.newVal)}},Fa={depthTest:!0,depthWrite:!0,alphaTest:0,side:0,displacementScale:1,vertexColors:!0,visible:!0,normalScale:{x:1,y:1},aoMapIntensity:1,lightMapIntensity:1,envMapIntensity:1},Va=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];class Ha{constructor(e){this.defMaterialMap={BaseMaterial:Ea,SpriteMaterial:Za,FakeInterior:ka,Reflector:Da,Fresnel:Ua},this.defMaterial=Ga(),this.addCb=e=>{this.runScene.optionsEx.cb.material.add.cb(e)},this.setParses=[],this.runScene=e,this.runScene.optionsEx.cb.unique.material.add.add("engine-material-add",(e=>{"SpriteMaterial"!==e.type&&this.addCb(e)})),this.defMaterialMap={BaseMaterial:Ea,SpriteMaterial:Za,FakeInterior:new ka(e),Reflector:new Da(e),Fresnel:new Ua(e)},this.addSetParses((e=>{const{material:t,type:r,newVal:n}=e;"opacity"===r&&n<1&&(t.transparent=!0)}))}add(e,t,r){this.runScene.uniqueEx.material.add(e,t,r)}create(){var e=new c.MeshStandardMaterial;return this.add(e),e}clone(e){const t=e.clone();return t.userData.id=(0,l.getId)(),t}addSetParses(e){this.setParses.push(e)}set(e){const{material:t,type:r,val:n}=e,i=t[r];return t[r]=n,t.needsUpdate=!0,this.setParses.map((e=>e({material:t,type:r,newVal:n,oldVal:i})))}setNormal(e,t=!0){return e=new xi(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute(),t&&this.runScene.undoEx.addUndo(e),e}setTexture(e,t=!0){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{info:r,newVal:n}=e,n=(n instanceof File&&(e.newVal=yield this.runScene.textureEx.parse(n)),"envMap"===r&&Li(e.newVal),new xi(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute());return t&&this.runScene.undoEx.addUndo(n),e.newVal}))}resetMaterial(e,t,r=!0){var n;e&&t&&e.material&&(n=new Na({target:e,runScene:this.runScene,info:"material",newVal:t,oldVal:e.material}).execute(),this.runScene.modelEx.select===e&&this.runScene.optionsEx.cb.setSelectMaterial.cb(t),r&&this.runScene.undoEx.addUndo(n))}getBase(e){const t=this.defMaterialMap[e];if(("SpriteMaterial"!==e||"Sprite"===(null==(e=this.runScene.modelEx.select)?void 0:e.type))&&t)return t.create()}toNromal(e){var t;const r=(null==(t=e.userData.tools)?void 0:t.toNormal(e))||e.clone();return r.userData=Object.assign(Object.assign({},r.userData),e.userData),r}setSelect(e){this.runScene.optionsEx.cb.setSelectMaterial.cb(e)}getDataByType(e,t){return this.defMaterialMap[e].tools.parseData(t)}dispose(){this.defMaterialMap.Reflector.dispose(),this.runScene.optionsEx.cb.material.dispose.cb("")}remove(e){}getDefNromals(e){var t;if(null!=(t=null==(t=e.userData)?void 0:t.tools)&&t.type)return{};const r={};return(0,Xe.js)(Fa,((t,n)=>{const i=e[t];if("object"==typeof i)for(const e in i)if(i[e]!==n[e])return void(r[t]=i.clone());i!==n&&(r[t]=i)})),r}parseNromals(e,t){(0,Xe.js)(e,((e,r)=>{var n,i,o,a,s;void 0!==Fa[e]&&("object"==typeof r?(({x:o,y:a,z:s}=r),null!=(i=null==(n=t[e])?void 0:n.set)&&i.call(n,o,a,s)):t[e]=r)}))}isBaseMaterial(e){return"MeshStandardMaterial"===e.type&&!e.userData.isTimeLineUsed&&Ea.isDefval(e)}}const Ga=()=>{const e=new c.MeshStandardMaterial;return e.userData.id=(0,l.getId)(),e},Wa=(e,t)=>(Va.map((r=>{const n=e[r];"object"==typeof n&&(t[r]=n.clone()),t[r]=n})),t),Xa=e=>{e.dispose();const t=qa(e);0!==t.length&&t.map((e=>{e=e.texture,Ei(e)}))},qa=e=>{var t=e.userData.textures||gi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t},Ya=e=>{var t;return(null==(t=e.userData.tools)?void 0:t.getTextures(e))||gi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture))};class Za{static create(){const e=new c.SpriteMaterial;return e.userData.tools=this.tools,e}}Za.modelTools={merge(e,t){t.position.copy(e.position),t.rotation.copy(e.rotation),t.scale.copy(e.scale),t.renderOrder=e.renderOrder,t.castShadow=e.castShadow,t.receiveShadow=e.receiveShadow,1===e.layers.mask?t.layers.set(0):t.layers.enable(1)},toNormal:e=>{const t=rs("Box");return t.userData.normal={type:"MySpriteMaterial"},Za.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=rs("Sprite");return Za.modelTools.merge(e,r),r.material=e.material,r}},Za.tools={type:"SpriteMaterial",getTextures:function(e){return["map","alphaMap"].map((t=>{var r=e[t];if(r)return{type:t,texture:r}})).filter((e=>e))},parseData:function(e){const{textures:t,material:r}=e,n=Wa(r,Za.create());return t.map((e=>{var{type:e,texture:t}=e;n[e]=t})),n},toNormal:e=>{const t=Wa(e,Ga());return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Za.tools.type},textures:Za.tools.getTextures(e)}),t},clone:function(e,t){return e}};class Qa{constructor(e){this.addTree=!0,this.isClone=!1,this.cb=(e,t)=>{};var{model:e,parent:t,cb:r,addTree:n,isClone:i,runScene:o}=e;this.runScene=o,this.model=e,this.parent=t,!1===n&&(this.addTree=n),!0===i&&(this.isClone=i),r&&(this.cb=r)}remove(e){const{model:t,parent:r,addTree:n,runScene:i}=e;i.modelEx.select===t&&i.modelEx.selectNull(),r.remove(t),n&&i.uniqueEx.model.remove(t),n&&i.optionsEx.cb.model.remove.cb({model:t,parent:r}),this.cb(t,"remove"),i.uniqueEx.material.addModel(t,void 0,t.material)}add(e){const{model:t,parent:r,addTree:n,isClone:i,runScene:o}=e;r.add(t),n&&o.uniqueEx.model.add(t),n&&o.optionsEx.cb.model.add.cb({model:t,parent:r,isClone:i}),this.cb(t,"add"),o.uniqueEx.material.addModel(t,t.material)}}class Ka extends Qa{constructor(e){super(e),this.type="添加模型"}_execute(e){return Promise.reject()}undo(){this.remove({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone,runScene:this.runScene})}redo(){this.add({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone,runScene:this.runScene})}execute(){return this.redo(),this}}const Ja=class extends bi{constructor(e){super(),this.type="修改父元素",this.runScene=e.runScene,this.oldParent=e.oldParent,this.newParent=e.newParent,this.target=e.target}execute(){return this.redo(),this}_execute(e){e.attach(this.target),this.runScene.optionsEx.cb.model.setParent.cb({model:this.target,parent:e})}undo(){this._execute(this.oldParent)}redo(){this._execute(this.newParent)}};class $a extends Qa{constructor(e){super(e),this.type="移除模型"}undo(){this.add({model:this.model,parent:this.parent,addTree:this.addTree,runScene:this.runScene})}redo(){this.remove({model:this.model,parent:this.parent,addTree:this.addTree,runScene:this.runScene})}_execute(e){return Promise.reject()}execute(){return this.redo(),this}}const es=class extends bi{constructor(e){super(),this.type="三维矩阵修改";var{target:e,info:t,newV3:r,oldV3:n,runScene:i}=e;this.target=e,this.info=t,this.runScene=i,this.newV3=r,this.oldV3=n,this.target.uuid===(null==(e=this.runScene.modelEx.select)?void 0:e.uuid)&&(this.runScene.optionsEx.cb.model.setSelect.cb(null),this.runScene.optionsEx.cb.model.setSelect.cb(this.target))}_execute(e){this.target[this.info].copy(e),this.target.uuid===(null==(e=this.runScene.modelEx.select)?void 0:e.uuid)&&this.runScene.helperEx.focus(this.target)}execute(){return this.redo(),this}undo(){this._execute(this.oldV3)}redo(){this._execute(this.newV3)}};class ts{constructor(e){this._selectModel=void 0,this.defNodeMap={castShadow:!1,receiveShadow:!1,renderOrder:0,visible:!0},this.deepIsVisible=e=>"Scene"===e.type||!!e.visible&&!!e.parent&&this.deepIsVisible(e.parent),this.runScene=e}get select(){return this._selectModel}set select(e){this.setSelectByModel(e)}add(e,t,r){var{addUndo:n,isClone:i,select:o}=$o({addUndo:!0,isClone:!1,select:!0},r);if(e instanceof Array)return e.map((e=>this.add(e,t,r)));i&&(this.runScene.uniqueEx.model.add(e,{hasReset:!0}),this.runScene.optionsEx.cb.model.clone.cb(e));var a=new Ka({model:e,parent:t||this.runScene.sceneEx.get(),isClone:i,runScene:this.runScene}).execute();!0===n&&this.runScene.undoEx.addUndo(a),o&&this.setSelectByModel(e,{isDomTreeActive:!1,isClone:i})}setSelectByModel(e,t){var r,{isDomTreeActive:t,isClone:n}=t||{};if(this.runScene.events.key.shift&&this._selectModel)return(r=this.getBeTweenChildByTwoModel(this._selectModel,e))?void this.runScene.multipSelector.add([...r,e],!0):void 0;if(this.runScene.events.key.ctrl&&!n)this.runScene.multipSelector.add(e);else{if(this.runScene.multipSelector.isEmpty()||this.runScene.multipSelector.setEmpty(),this._selectModel){if(this._selectModel===e)return void(this.runScene.helperEx.focusModelId||this.runScene.helperEx.focus(e));this.runScene.lightEx.setNull(this._selectModel),this.runScene.optionsEx.cb.model.unFocus.cb(this._selectModel)}e&&(e.isCamera||(this.runScene.helperEx.focus(e),this.runScene.lightEx.setSelect(e)),this.runScene.optionsEx.cb.model.focus.cb({model:e,status:!0,domActive:!t}),this.runScene.materialEx.setSelect(e.material),this.runScene.optionsEx.cb.model.setSelect.cb(e),this._selectModel=e)}}setSelectById(e){(e=this.runScene.uniqueEx.model.get(e))&&this.setSelectByModel(e)}remove(e,t=!0){if(e instanceof Array)return e.map((e=>this.remove(e)));e=new $a({runScene:this.runScene,model:e,parent:e.parent||this.runScene.sceneEx.get()}).execute(),t&&this.runScene.undoEx.addUndo(e)}isNavieV3(e,t=0){var{x:e,y:r,z:n}=e;return e+r+n===t}isNavieV2(e,t=0){var{x:e,y:r}=e;return e===t&&r===t}isUnless(e){return!e.material&&this.isNavieV3(e.position)&&this.isNavieV3(e.rotation)&&this.isNavieV3(e.scale,3)&&0===e.children.length}isUnlessLevel(e){return this.isNavieV3(e.position)&&this.isNavieV3(e.rotation)&&this.isNavieV3(e.scale,3)&&1===e.children.length}create(){return Ta().model.getModelByType("Box")}clone(e){if(!this.runScene.lightEx.isLight(e)){let n=e.clone();n.userData.cloneId=e.userData.id;var t,r=null==e?void 0:e.material;return null!=(t=null==r?void 0:r.userData)&&t.tools&&(t=null==(t=r.userData.tools)?void 0:t.clone(r,n))&&t.uuid!==r.uuid&&(this.runScene.materialEx.resetMaterial(n,t,!0),this.runScene.materialEx.add(t,e,r)),this.runScene.uniqueEx.model.add(n,{reset:!0}),n}this.runScene.lightEx.clone(e)}getLevel(e,t=0){return e.parent&&"Scene"!==e.parent.type?this.getLevel(e.parent,++t):t}selectNull(){var e=this._selectModel;e&&(this.runScene.optionsEx.cb.model.unFocus.cb(e),this.runScene.materialEx.setSelect(null),this.runScene.lightEx.setNull(e)),this._selectModel=void 0,this.runScene.optionsEx.cb.model.setSelect.cb(null),this.runScene.helperEx.unfocus()}cloneV3(e){return e.clone()}setParent(e,t,r=!0){if(t=new Ja({oldParent:e.parent,newParent:t,target:e,runScene:this.runScene}).execute(),!r)return t;this.runScene.undoEx.addUndo(t)}setV3(e,t=!0,r=!0){var{model:e,info:n,newV3:i,oldV3:o}=e;const a=new es({target:e,info:n,oldV3:o,newV3:i,runScene:this.runScene});r&&a.execute(),t&&this.runScene.undoEx.addUndo(a)}setNormal(e,t=!0){var{model:e,info:r,val:n}=e;e=new Na({target:e,info:r,runScene:this.runScene,oldVal:e[r],newVal:n}).execute(),t&&this.runScene.undoEx.addUndo(e)}setMaterial(e,t,r=!0){var n=new Na({target:e,info:"material",runScene:this.runScene,oldVal:e.material,newVal:t}).execute();this.select===e&&this.runScene.optionsEx.cb.setSelectMaterial.cb(t),e.material.needsUpdate=!0,r&&this.runScene.undoEx.addUndo(n)}addDef(e){this.add(rs(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new c.MeshBasicMaterial,t=new c.SphereGeometry(.7,150,150);return new c.Mesh(t,e)}getIndexByModel(e){var t;return e.parent?null==(t=e.parent)?void 0:t.children.findIndex((t=>t===e)):-1}getBeTweenChildByTwoModel(e,t){if(e.parent.uuid===t.parent.uuid){var r=this.getIndexByModel(e);if(t=this.getIndexByModel(t),-1!==r&&-1!==t){const n=Math.max(r,t),i=r===n?t:r;return e.parent.children.map(((e,t)=>t>i&&t<n&&e)).filter((e=>e))}}}setMultip(e){var{model:e,typeList:t,newVal:r}=e;this.runScene.undoEx.addUndo(new Ra({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const n=t||new c.Group,i=[];i.push(new Ka({model:n,runScene:this.runScene,parent:r||this.runScene.assetsEx.get().scene}).execute()),e instanceof Array?i.push(...e.map((e=>new Ja({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()))):i.push(new Ja({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()),r&&this.runScene.optionsEx.cb.model.setOpen.cb({isOpen:!0,model:r}),this.runScene.optionsEx.cb.model.setOpen.cb({isOpen:!0,model:n}),this.runScene.optionsEx.cb.model.setMainStatue.cb({status:!0,model:n}),this.runScene.undoEx.addUndo(i),this.setSelectByModel(n)}cleanGroup(e,t=!0){if(e instanceof Array){const t=(0,_a.multiArrToArr)(e.map((e=>(this.runScene.optionsEx.cb.model.unFocus.cb(e),this.cleanGroup(e,!1)))).filter((e=>e)));return this.runScene.undoEx.addUndo(t),t}if(this.runScene.optionsEx.cb.model.unFocus.cb(e),0!==e.children.length){const r=[],n=e.children.map((e=>{if(e.parent.parent)return new Ja({target:e,oldParent:e.parent,newParent:e.parent.parent,runScene:this.runScene})})).filter((e=>e));return r.push(...n.map((e=>e.execute()))),r.push(new $a({runScene:this.runScene,model:e,parent:e.parent}).execute()),t&&this.runScene.undoEx.addUndo(r),r}}hideOther(e){const t=e.uuid,r=0<e.children.length,n=this.runScene.sceneEx.getClearModels(),i=[];n.map((n=>{n.traverse((n=>{r?!1===Ta().model.deepFindParentByUuid(n,t)&&n.uuid!==e.uuid&&i.push(n):n.uuid!==e.uuid&&i.push(n)}))}));var o=i.map((e=>new Na({target:e,info:"visible",newVal:!1,runScene:this.runScene,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(o),Ta().model.setParentVisible(e,!0)}showAll(){const e=this.runScene.sceneEx.getClearModels(),t=[];e.map((e=>{e.traverse((e=>{"materialHelper"!==e.name&&!1===e.visible&&t.push(e)}))}));var r=t.map((e=>new Na({target:e,info:"visible",runScene:this.runScene,newVal:!0,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(r)}removeHide(){const e=this.runScene.sceneEx.getClearModels(),t=new Set,r=[];e.map((e=>{e.traverse((e=>{e.visible||t.add(e)}))})),t.forEach((e=>{r.push(new $a({runScene:this.runScene,model:e,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(r)}_getModel(e){if(e=this.runScene.uniqueEx.model.nameMap[e])return this.runScene.uniqueEx.model.get(e)}getModel(e,t="array"){if(!(e instanceof Array))return this._getModel(e);if("array"===t)return e.map((e=>this._getModel(e)));if("map"===t){const t={};return e.map((e=>{t[e]=this.getModel(e)})),t}}getWorldLocal(e){this.runScene.assetsEx.scene.updateMatrixWorld(!0);var t=new c.Vector3;return e.getWorldPosition(t),t}getClickObj(e,t,r=!1){let n=new c.Raycaster,i=new c.Vector2,o=(i.x=e.offsetX/this.runScene.assetsEx.engineDom.clientWidth*2-1,i.y=-e.offsetY/this.runScene.assetsEx.engineDom.clientHeight*2+1,n.setFromCamera(i,this.runScene.assetsEx.camera),n.intersectObjects(t,!0)),a={intersects:null,obj:null};if(0===o.length)return a;if(r){if(0===(e=o.filter((e=>Ta().model.isVisible(e.object)))).length)return a;a={intersects:e,obj:e[0].object}}else a={intersects:o,obj:o[0].object};return a}getCamLocal(){var{x:e,y:t,z:r}=this.runScene.assetsEx.camera.position,{x:n,y:i,z:o}=this.runScene.assetsEx.controls.target;return{cx:e,cy:t,cz:r,tx:n,ty:i,tz:o}}camAnima(e,t,r=1,n,i){return _o(e,t,r,(e=>{i&&i(e),this.runScene.assetsEx.camera.position.set(e.cx,e.cy,e.cz),this.runScene.assetsEx.controls.target.set(e.tx,e.ty,e.tz),this.runScene.assetsEx.camera.lookAt(this.runScene.assetsEx.controls.target)}),(e=>{n&&n()}))}setGlow(e,t=!0){t=t?1:0,0==(e.userData.layers=t)?e.layers.set(0):e.layers.enable(1),this.runScene.optionsEx.cb.model.setLayers.cb({model:e,val:t})}}const rs=e=>{if(Ma.includes(e)){const t=Ta().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=Za.tools),t}throw TypeError("")},ns=(e,t)=>{t=(t||{}).remove;const{geomerty:r,material:n}=e;r&&(null!=r&&r.dispose(),delete e.geometry),n&&(Xa(e.material),e.material.dispose(),delete e.material),!1!==t&&e.parent&&e.parent.remove(e)},is=(e,t)=>{var{material:r,geometry:n}=e;const i=new vi.InstancedMesh(n,r,t.length+1);return[e,...t].map(((e,t)=>{i.setMatrixAt(t,e.matrix)})),i};class os{constructor(){this.optionsConfigs={}}getParse(e){return this.optionsConfigs[e]}addOption(e){var t=e.type;if(this.optionsConfigs[t])throw TypeError("该配置项已被挂载");this.optionsConfigs[t]=e}getOptions(e){return Object.values(this.optionsConfigs).map((t=>{const{process:r,type:n}=t;return{type:n,data:r(e)}}))}}class as{constructor(e){this.JsonMaterialMap={},this.materialMap={},this.textureMap={},this.runScene=e}setMaterialMap(e){var{materialMap:e,textureMap:t}=e;this.materialMap=e,this.textureMap=t}parseMaterial(e){const{material:t,materialDef:r}=e;r.id=t.userData.id,this.parseNormal(t)}parseNormal(e){this.materialMap[e.userData.id]||(this.materialMap[e.userData.id]={normal:{},textures:{}}),this.materialMap[e.userData.id].normal=Object.assign(Object.assign({},this.materialMap[e.userData.id].normal),this.runScene.materialEx.getDefNromals(e))}setMaterialDef(e){const{type:t,data:r,normal:n}=e;n[t]=r}processTexture(e){const{texture:t,textureDef:r}=e;e=t.userData.notCompress;var{width:e,height:n}=(e&&(r.notCompress=!0),r.md5=t.userData.md5,r.id=t.userData.id,r.format=t.userData.format,Di(t));r.size={w:e,h:n}}done(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{textureMap:t,materialMap:r}=this;e.asset.ex=Object.assign(Object.assign({},e.asset.ex),{textureMap:t,materialMap:r})}))}}class ss{constructor(e){this.runScene=e}init(){}done(e){var t=this.runScene.sceneEx.get();e.asset.ex=Object.assign(Object.assign({},e.asset.ex),{lights:this.getLights(),camera:this.getCamera(),sceneEx:this.getSceneEx(t),timeLine:this.runScene.timeLineEx.getSavedData(),controls:this.getControls(),options:this.runScene.exporter.gltf.options.getOptions(t)})}getSceneEx(e){const t=Object.assign({},e.userData.ex);return e.fog&&(t.fog=this.runScene.sceneEx.getFogJson(e.fog)),e.background instanceof c.Color&&(t.backgroundColor=e.background.getHexString()),t}getLights(){return this.runScene.lightEx.getLightsByScene().map((e=>{var t=e.type;return this.runScene.lightEx.lightExMap[t].toJSON(e)}))}getCamera(){return this.runScene.cameraEx.get().toJSON()}getControls(){return this.runScene.assetsEx.controls.target}}class ls{constructor(e,t){this.helperModels=[],this.runScene=t,this.type=e,this.material=new as(t),this.scene=new ss(t)}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,Xe.js)(this.runScene.modelEx.defNodeMap,((e,n)=>{t[e]!==n&&(r[e]=t[e])})),t.material&&t.material.wireframe&&(t.material.wireframe=!1,r.wireframe=!0)}parseSprite(){}done(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){e.asset.ex||(e.asset.ex={type:this.type}),"scene"===this.type&&(yield this.scene.done(e)),yield this.material.done(e)}))}}var us=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class cs{constructor(e,t){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.modelType={Sprite:Za},this.type=e,this.runScene=t}parse(e){return us(this,void 0,void 0,(function*(){const t=new c.Group;return t.name="back-texture-ex",t.userData.isHelper=!0,e.add(t),"scene"===this.type&&this.parseScene(t),this.parseMaterial(e),yield Promise.all(this.materialMapToJson()),this.setMultipMaterial(t,Object.keys(this.textureMap)),this.json}))}parseScene(e){const t=this.runScene.sceneEx.get();if(t.background instanceof c.Texture||t.environment instanceof c.Texture){t.userData.ex={},this.runScene.bloom.glow.setUpdate(!1);const{background:r,environment:n}=t,i=(this.runScene.bloom.glow.setUpdate(!0),this.runScene.modelEx.create()),o=Ga();i.material=o,e.add(i),e=(0,l.getId)(),t.userData.ex.materialId=e,o.userData.id=e,this.materialMap[e]={material:o},r instanceof c.Texture&&(r.userData.notCompress=!0,303===(o.map=r).mapping&&(t.userData.ex.backgroundMapping=303)),n instanceof c.Texture&&(n.userData.notCompress=!0,o.envMap=n)}}_processMaterial(e){if(e.material&&e.material.userData){var t=this.runScene.materialEx.isBaseMaterial(e.material),r=this.materialMap[e.material.userData.id];return r?(r.normalMaterial&&(e.material=r.normalMaterial),void(null!=(r=r.models)&&r.push(e))):(r=t||this.runScene.optionsEx.exporterOptions.notMaterial?this.runScene.materialEx.defMaterial:this.runScene.materialEx.toNromal(e.material),e.material=r,this.materialMap[r.userData.id]={material:r,normalMaterial:r,models:[e]},r)}}compressLocal(e){var{x:t,y:r,z:n}=e.position;0===t&&0===r&&0===n||(e.position.set(0,0,0),e.userData.local=t+","+r+","+n)}_processModel(e,t){const r=this.modelType[e.type];if(!r)return e;const n=r.modelTools.toNormal(e);return t&&(n.material=t),e.parent.add(n),e.parent.remove(e),n}parseMaterial(e){const t=new Set;e.traverse((e=>t.add(e))),t.forEach((e=>{var t=this._processMaterial(e);e=this._processModel(e,t),this.runScene.optionsEx.options.hideLocal&&this.compressLocal(e)}))}materialMapToJson(){return(0,Xe.js)(this.materialMap,((e,t)=>us(this,void 0,void 0,(function*(){var e=t.material,r=qa(e);return this.json.materialMap[e.userData.id]={normal:e.userData.normal||{},textures:{}},this.mergeAndRemoveTexture(r,e)}))))}mergeSame(e){var t=e.userData;for(const i in this.textureMap){var{md5:r,texture:n}=this.textureMap[i];if(t.md5===r&&e.mapping===n.mapping)return{isSame:!0,texture:n}}return this.textureMap[e.userData.id]=Object.assign(Object.assign({},t),{texture:e}),{isSame:!1,texture:e}}mergeAndRemoveTexture(e,t){return us(this,void 0,void 0,(function*(){return e.map((e=>{var{type:e,texture:r}=e;this.runScene.uniqueEx.texture.add(r),t[e]=null;const n=this.mergeSame(r).texture;if(!this.json.textureMap[n.userData.id]){var i,{format:r,repeat:o,center:a,rotation:s,offset:l}=n;const e={format:r};this.runScene.modelEx.isNavieV2(o,1)||(({x:r,y:i}=o),e.repeat=r===i?r:o),this.runScene.modelEx.isNavieV2(a,0)||(({x:i,y:r}=a),e.center=i===r?i:a),this.runScene.modelEx.isNavieV2(l,0)||(({x:o,y:r}=l),e.offset=o===r?o:l),0!==s&&(e.rotation=s),this.json.textureMap[n.userData.id]=e}"normalMap"!==e||n.userData.isNormalMap||(n.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[e]=n.userData.id}))}))}setMultipMaterial(e,t){const r=this.runScene.modelEx.create(),n=Ga();r.material=n,e.add(r);for(const e of yi){if(!t.length)return;var i=t.pop();if(!i)return;n[e]=this.textureMap[i].texture}t.length&&this.setMultipMaterial(e,t)}}function hs(){hs=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=(f="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",i=f.asyncIterator||"@@asyncIterator",o=f.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(t){a=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i,o,a,s;return t=t&&t.prototype instanceof c?t:c,t=Object.create(t.prototype),n=new x(n||[]),t._invoke=(i=e,o=r,a=n,s="suspendedStart",function(e,t){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===e)throw t;return{value:void 0,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r&&(r=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return u;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}return"throw"===(n=l(n,t.iterator,r.arg)).type?(r.method="throw",r.arg=n.arg,r.delegate=null,u):(n=n.arg)?n.done?(r[t.resultName]=n.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,u):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,u)}(r,a),r)){if(r===u)continue;return r}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===s)throw s="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);if(s="executing","normal"===(r=l(i,o,a)).type){if(s=a.done?"completed":"suspendedYield",r.arg===u)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(s="completed",a.method="throw",a.arg=r.arg)}}),t}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var u={};function c(){}function h(){}function p(){}var f,d,m=(a(f={},n,(function(){return this})),(d=(d=Object.getPrototypeOf)&&d(d(w([]))))&&d!==t&&r.call(d,n)&&(f=d),p.prototype=c.prototype=Object.create(f));function v(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u;if("throw"!==(i=l(e[i],e,o)).type)return(o=(u=i.arg).value)&&"object"==fs(o)&&r.call(o,"__await")?t.resolve(o.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(o).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}));s(i.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function g(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(g,this),this.reset(!0)}function w(e){if(e){var t,i=e[n];if(i)return i.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return t=-1,(i=function n(){for(;++t<e.length;)if(r.call(e,t))return n.value=e[t],n.done=!1,n;return n.value=void 0,n.done=!0,n}).next=i}return{next:S}}function S(){return{value:void 0,done:!0}}return a(m,"constructor",h.prototype=p),a(p,"constructor",h),h.displayName=a(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},v(y.prototype),a(y.prototype,i,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new y(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(m),a(m,o,"Generator"),a(m,n,(function(){return this})),a(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t,r=[];for(t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=w,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;0<=i;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),l=r.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}var a=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,i=this.tryEntries[t];if(i.tryLoc===e)return"throw"===(r=i.completion).type&&(n=r.arg,b(i)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:w(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}function ps(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function fs(e){return(fs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ds(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ms(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function vs(e,t,r){t&&ms(e.prototype,t),r&&ms(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var ys=function(){function e(){ds(this,e),this.pluginCallbacks=[],this.register((function(e){return new ks(e)})),this.register((function(e){return new As(e)})),this.register((function(e){return new Cs(e)})),this.register((function(e){return new Ds(e)})),this.register((function(e){return new Is(e)})),this.register((function(e){return new Ls(e)}))}return vs(e,[{key:"register",value:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}},{key:"unregister",value:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}},{key:"parse",value:function(e,t,r,n){"object"===fs(r)&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),n=r);for(var i=new Rs,o=[],a=0,s=this.pluginCallbacks.length;a<s;a++)o.push(this.pluginCallbacks[a](i));i.setPlugins(o),i.write(e,t,n).catch(r)}},{key:"parseAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.parse(e,n,i,t)}))}}]),e}(),gs=5121,bs=5123,xs=(o=9728,9729),ws=9984,Ss=9986,Ts={},_s=(Ts[c.NearestFilter]=o,Ts[c.NearestMipmapNearestFilter]=ws,Ts[c.NearestMipmapLinearFilter]=Ss,Ts[c.LinearFilter]=xs,Ts[c.LinearMipmapNearestFilter]=9985,Ts[c.LinearMipmapLinearFilter]=9987,Ts[c.ClampToEdgeWrapping]=33071,Ts[c.RepeatWrapping]=10497,Ts[c.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function Ms(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Es(e){return 4*Math.ceil(e/4)}function Ps(e,t){var r=1<arguments.length&&void 0!==t?t:0,n=Es(e.byteLength);if(n===e.byteLength)return e;var i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==r)for(var o=e.byteLength;o<n;o++)i[o]=r;return i.buffer}var Os=null,Rs=function(){function e(){ds(this,e),this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}var t,r;return vs(e,[{key:"setPlugins",value:function(e){this.plugins=e}},{key:"write",value:(t=hs().mark((function e(t,r,n){var i,o,a,s,l,u,c;return hs().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(t),e.next=5,Promise.all(this.pending);case 5:return o=(i=this).buffers,a=i.json,n=i.options,e.next=11,i.options.myOptions.helper.done(a);case 11:l=i.extensionsUsed,s=new Blob(o,{type:"application/octet-stream"}),0<(l=Object.keys(l)).length&&(a.extensionsUsed=l),a.buffers&&0<a.buffers.length&&(a.buffers[0].byteLength=s.size),!0===n.binary?((u=new window.FileReader).readAsArrayBuffer(s),u.onloadend=function(){var e=Ps(u.result),t=new DataView(new ArrayBuffer(8)),n=(t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0),Ps(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;for(var t=new Uint8Array(new ArrayBuffer(e.length)),r=0,n=e.length;r<n;r++){var i=e.charCodeAt(r);t[r]=255<i?32:i}return t.buffer}(JSON.stringify(a)),32)),i=new DataView(new ArrayBuffer(8)),o=(i.setUint32(0,n.byteLength,!0),i.setUint32(4,1313821514,!0),new ArrayBuffer(12)),s=((l=new DataView(o)).setUint32(0,1179937895,!0),l.setUint32(4,2,!0),12+i.byteLength+n.byteLength+t.byteLength+e.byteLength),l=(l.setUint32(8,s,!0),new Blob([o,i,n,t,e],{type:"application/octet-stream"})),c=new window.FileReader;c.readAsArrayBuffer(l),c.onloadend=function(){r(c.result)}}):a.buffers&&0<a.buffers.length?((c=new window.FileReader).readAsDataURL(s),c.onloadend=function(){var e=c.result;a.buffers[0].uri=e,r(a)}):r(a);case 17:case"end":return e.stop()}}),e,this)})),r=function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(e){ps(o,n,i,a,s,"next",e)}function s(e){ps(o,n,i,a,s,"throw",e)}a(void 0)}))},function(e,t,n){return r.apply(this,arguments)})},{key:"serializeUserData",value:function(e,t){if(0!==Object.keys(e.userData).length){var r=this.options,n=this.extensionsUsed;try{var i=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&i.gltfExtensions){for(var o in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[o]=i.gltfExtensions[o],n[o]=!0;delete i.gltfExtensions}0<Object.keys(i).length&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}}},{key:"getUID",value:function(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}},{key:"isNormalizedNormalAttribute",value:function(e){if(this.cache.attributesNormalized.has(e))return!1;for(var t=new c.Vector3,r=0,n=e.count;r<n;r++)if(5e-4<Math.abs(t.fromBufferAttribute(e,r).length()-1))return!1;return!0}},{key:"createNormalizedNormalAttribute",value:function(e){var t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);for(var r=e.clone(),n=new c.Vector3,i=0,o=r.count;i<o;i++)n.fromBufferAttribute(r,i),0===n.x&&0===n.y&&0===n.z?n.setX(1):n.normalize(),r.setXYZ(i,n.x,n.y,n.z);return t.attributesNormalized.set(e,r),r}},{key:"applyTextureTransform",value:function(e,t){var r=!1,n={};0===t.offset.x&&0===t.offset.y||(n.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(n.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(n.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}},{key:"buildORMTexture",value:function(e){var t=null==(t=e.aoMap)?void 0:t.image,r=null==(r=e.roughnessMap)?void 0:r.image,n=null==(n=e.metalnessMap)?void 0:n.image;if(t===r&&r===n)return e.aoMap;if(t||r||n){e=Math.max((null==t?void 0:t.width)||0,(null==r?void 0:r.width)||0,(null==n?void 0:n.width)||0);var i=Math.max((null==t?void 0:t.height)||0,(null==r?void 0:r.height)||0,(null==n?void 0:n.height)||0),o=document.createElement("canvas"),a=(o.width=e,o.height=i,o.getContext("2d")),s=(a.fillStyle="#ffffff",a.fillRect(0,0,e,i),a.getImageData(0,0,e,i));if(t){a.drawImage(t,0,0,e,i);for(var l=a.getImageData(0,0,e,i).data,u=0;u<l.length;u+=4)s.data[u]=l[u]}if(r){a.drawImage(r,0,0,e,i);for(var h=a.getImageData(0,0,e,i).data,p=1;p<h.length;p+=4)s.data[p]=h[p]}if(n){a.drawImage(n,0,0,e,i);for(var f=a.getImageData(0,0,e,i).data,d=2;d<f.length;d+=4)s.data[d]=f[d]}return a.putImageData(s,0,0),new c.Texture(o)}}},{key:"processBuffer",value:function(e){var t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}},{key:"processBufferView",value:function(e,t,r,n,i){for(var o,a=this.json,s=(a.bufferViews||(a.bufferViews=[]),o=t===gs?1:t===bs?2:4,Es(n*e.itemSize*o)),l=new DataView(new ArrayBuffer(s)),u=0,c=r;c<r+n;c++)for(var h=0;h<e.itemSize;h++){var p=void 0;4<e.itemSize?p=e.array[c*e.itemSize+h]:0===h?p=e.getX(c):1===h?p=e.getY(c):2===h?p=e.getZ(c):3===h&&(p=e.getW(c)),5126===t?l.setFloat32(u,p,!0):5125===t?l.setUint32(u,p,!0):t===bs?l.setUint16(u,p,!0):t===gs&&l.setUint8(u,p),u+=o}var f={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};return void 0!==i&&(f.target=i),34962===i&&(f.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(f),{id:a.bufferViews.length-1,byteLength:0}}},{key:"processBufferViewImage",value:function(e){var t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(n,i){var o=new window.FileReader;if(!(e instanceof Blob))return i();o.readAsArrayBuffer(e),o.onloadend=function(){var e=Ps(o.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,n(r.bufferViews.push(i)-1)}}))}},{key:"processAccessor",value:function(e,t,r,n){var i,o=this.options,a=this.json;if(e.array.constructor===Float32Array)i=5126;else if(e.array.constructor===Uint32Array)i=5125;else if(e.array.constructor===Uint16Array)i=bs;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");i=gs}if(void 0===r&&(r=0),void 0===n&&(n=e.count),o.truncateDrawRange&&void 0!==t&&null===t.index&&(o=r+n,l=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count,r=Math.max(r,t.drawRange.start),(n=Math.min(o,l)-r)<0&&(n=0)),0===n)return null;o=function(e,t,r){for(var n={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},i=t;i<t+r;i++)for(var o=0;o<e.itemSize;o++){var a=void 0;4<e.itemSize?a=e.array[i*e.itemSize+o]:0===o?a=e.getX(i):1===o?a=e.getY(i):2===o?a=e.getZ(i):3===o&&(a=e.getW(i)),n.min[o]=Math.min(n.min[o],a),n.max[o]=Math.max(n.max[o],a)}return n}(e,r,n);var s,l=(void 0!==t&&(s=e===t.index?34963:34962),this.processBufferView(e,i,r,n,s));return t={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:n,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]},!0===e.normalized&&(t.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(t)-1}},{key:"processImage",value:function(e,t,r,n){var i,o=this,a=o.cache,s=o.json,l=o.options,u=o.pending,h=(a.images.has(e)||a.images.set(e,{}),a=a.images.get(e),null==(h=n.userData)?void 0:h.blob),p=n.userData.isNormalMap,f=(i=o.options.myOptions.optionsEx.exporterOptions.compressTexture)?"image/webp":"image/png";if(void 0!==a[(i&&(h=!!p),i=f+":flipY/"+r.toString())])return a[i];s.images||(s.images=[]);var d={mimeType:f};if(!0===l.binary&&h)u.push(new Promise((function(e){o.processBufferViewImage(n.userData.blob).then((function(t){d.bufferView=t,e()}))})));else if(l.embedImages){var m=Os=Os||document.createElement("canvas");if((m.width=Math.min(e.width,l.maxTextureSize),m.height=Math.min(e.height,l.maxTextureSize),p=m.getContext("2d")).translate(0,m.height),p.scale(1,-1),"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)p.drawImage(e,0,0,m.width,m.height);else{t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);for(var v=new Uint8ClampedArray(e.height*e.width*4),y=0;y<v.length;y+=4)v[y+0]=e.data[y+0],v[y+1]=e.data[y+1],v[y+2]=e.data[y+2],v[y+3]=e.data[y+3];p.putImageData(new ImageData(v,e.width,e.height),0,0)}!0===l.binary?u.push(new Promise((function(e){m.toBlob((function(t){o.processBufferViewImage(t).then((function(t){d.bufferView=t,e()}))}),f)}))):d.uri=m.toDataURL(f)}else d.uri=e.src;return r=s.images.push(d)-1,a[i]=r}},{key:"processSampler",value:function(e){var t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:Ts[e.magFilter],minFilter:Ts[e.minFilter],wrapS:Ts[e.wrapS],wrapT:Ts[e.wrapT]},t.samplers.push(e)-1}},{key:"processTexture",value:function(e){var t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);var n={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,e)};return e.name&&(n.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,n)})),r=r.textures.push(n)-1,t.textures.set(e,r),this.options.myOptions.helper.material.processTexture({texture:e,textureDef:n}),r}},{key:"processMaterial",value:function(e){var t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);var n,i={pbrMetallicRoughness:{}},o=(Ms((this.options.myOptions.helper.material.parseMaterial({material:e,materialDef:i,options:this}),!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results."),o=e.color.toArray().concat([e.opacity])),[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(o={index:this.processTexture(null)},this.applyTextureTransform(o,e.metalnessMap||e.roughnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=o),e.map&&(o={index:this.processTexture(e.map)},this.applyTextureTransform(o,e.map),i.pbrMetallicRoughness.baseColorTexture=o),e.emissive&&(o=e.emissive.clone().multiplyScalar(e.emissiveIntensity),1<(n=Math.max(o.r,o.g,o.b))&&(o.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<n&&(i.emissiveFactor=o.toArray()),e.emissiveMap&&(n={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(n,e.emissiveMap),i.emissiveTexture=n)),e.normalMap&&(o={index:this.processTexture(e.normalMap)},e.normalScale&&1!==e.normalScale.x&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),i.normalTexture=o),e.aoMap&&(n={index:this.processTexture(e.aoMap),texCoord:1},1!==e.aoMapIntensity&&(n.strength=e.aoMapIntensity),this.applyTextureTransform(n,e.aoMap),i.occlusionTexture=n),e.transparent?i.alphaMode="BLEND":0<e.alphaTest&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)})),r.materials.push(i)-1);return t.materials.set(e,o),o}},{key:"processMesh",value:function(e){var t=this.cache,r=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(var i=0,o=e.material.length;i<o;i++)n.push(e.material[i].uuid);else n.push(e.material.uuid);var a=n.join(":");if(t.meshes.has(a))return t.meshes.get(a);var s=e.geometry,l=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4;if(!0!==s.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");var u,h,p,f={},d={},m=[],v=[],y={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},g=s.getAttribute("normal"),b=(void 0===g||this.isNormalizedNormalAttribute(g)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(g))),null);for(h in s.attributes)"morph"!==h.slice(0,5)&&(u=s.attributes[h],h=y[h]||h.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(h)||(h="_"+h),t.attributes.has(this.getUID(u))?d[h]=t.attributes.get(this.getUID(u)):(b=null,p=u.array,"JOINTS_0"!==h||p instanceof Uint16Array||p instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=new c.BufferAttribute(new Uint16Array(p),u.itemSize,u.normalized)),null!==(p=this.processAccessor(b||u,s))&&(d[h]=p,t.attributes.set(this.getUID(u),p))));if(void 0!==g&&s.setAttribute("normal",g),0===Object.keys(d).length)return null;if(void 0!==e.morphTargetInfluences&&0<e.morphTargetInfluences.length){var x=[],w=[],S={};if(void 0!==e.morphTargetDictionary)for(var T in e.morphTargetDictionary)S[e.morphTargetDictionary[T]]=T;for(var _=0;_<e.morphTargetInfluences.length;++_){var M,E={},P=!1;for(M in s.morphAttributes)if("position"!==M&&"normal"!==M)P||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),P=!0);else{var O=s.morphAttributes[M][_],R=M.toUpperCase(),k=s.attributes[M];if(t.attributes.has(this.getUID(O)))E[R]=t.attributes.get(this.getUID(O));else{var A=O.clone();if(!s.morphTargetsRelative)for(var C=0,L=O.count;C<L;C++)A.setXYZ(C,O.getX(C)-k.getX(C),O.getY(C)-k.getY(C),O.getZ(C)-k.getZ(C));E[R]=this.processAccessor(A,s),t.attributes.set(this.getUID(k),E[R])}}v.push(E),x.push(e.morphTargetInfluences[_]),void 0!==e.morphTargetDictionary&&w.push(S[_])}f.weights=x,0<w.length&&(f.extras={},f.extras.targetNames=w)}if((g=Array.isArray(e.material))&&0===s.groups.length)return null;for(var D=g?e.material:[e.material],I=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}],j=0,U=I.length;j<U;j++){var B={mode:l,attributes:d},z=(this.serializeUserData(s,B),0<v.length&&(B.targets=v),null!==s.index&&(z=this.getUID(s.index),void 0===I[j].start&&void 0===I[j].count||(z+=":"+I[j].start+":"+I[j].count),t.attributes.has(z)?B.indices=t.attributes.get(z):(B.indices=this.processAccessor(s.index,s,I[j].start,I[j].count),t.attributes.set(z,B.indices)),null===B.indices&&delete B.indices),this.processMaterial(D[I[j].materialIndex]));null!==z&&(B.material=z),m.push(B)}return f.primitives=m,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,f)})),g=r.meshes.push(f)-1,t.meshes.set(a,g),g}},{key:"processCamera",value:function(e){var t=this.json,r=(t.cameras||(t.cameras=[]),e.isOrthographicCamera),n={type:r?"orthographic":"perspective"};return r?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:c.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),t.cameras.push(n)-1}},{key:"processAnimation",value:function(e,t){for(var r=this.json,n=this.nodeMap,i=(r.animations||(r.animations=[]),(e=ys.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks),o=[],a=[],s=0;s<i.length;++s){var l=i[s],u=c.PropertyBinding.parseTrackName(l.name),h=c.PropertyBinding.findNode(t,u.nodeName),p=_s[u.propertyName];if(!(h="bones"===u.objectName?!0===h.isSkinnedMesh?h.skeleton.getBoneByName(u.objectIndex):void 0:h)||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name),null;u=l.values.length/l.times.length;var f=void(p===_s.morphTargetInfluences&&(u/=h.morphTargetInfluences.length));!0===l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(f="CUBICSPLINE",u/=3):f=l.getInterpolation()===c.InterpolateDiscrete?"STEP":"LINEAR",a.push({input:this.processAccessor(new c.BufferAttribute(l.times,1)),output:this.processAccessor(new c.BufferAttribute(l.values,u)),interpolation:f}),o.push({sampler:a.length-1,target:{node:n.get(h),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:a,channels:o}),r.animations.length-1}},{key:"processSkin",value:function(e){var t=this.json,r=this.nodeMap,n=t.nodes[r.get(e)],i=e.skeleton;if(void 0===i)return null;var o=e.skeleton.bones[0];if(void 0===o)return null;for(var a=[],s=new Float32Array(16*i.bones.length),l=new c.Matrix4,u=0;u<i.bones.length;++u)a.push(r.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(s,16*u);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(s,16)),joints:a,skeleton:r.get(o)}),n.skin=t.skins.length-1}},{key:"processNode",value:function(e){var t,r,n=this.json,i=this.options,o=this.nodeMap,a=(n.nodes||(n.nodes=[]),{});if(i.myOptions.helper.parseNode({object:e,nodeDef:a,options:this}),i.trs?(r=e.quaternion.toArray(),h=e.position.toArray(),t=e.scale.toArray(),Ms(r,[0,0,0,1])||(a.rotation=r),Ms(h,[0,0,0])||(a.translation=h),Ms(t,[1,1,1])||(a.scale=t)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===Ms(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(a.matrix=e.matrix.elements)),""!==e.name&&(a.name=String(e.name)),this.serializeUserData(e,a),e.isMesh||e.isLine||e.isPoints?null!==(r=this.processMesh(e))&&(a.mesh=r):e.isCamera&&(a.camera=this.processCamera(e)),e.isSkinnedMesh&&this.skins.push(e),0<e.children.length){for(var s=[],l=0,u=e.children.length;l<u;l++){var c=e.children[l];!c.visible&&!1!==i.onlyVisible||null!==(c=this.processNode(c))&&s.push(c)}0<s.length&&(a.children=s)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,a)}));var h=n.nodes.push(a)-1;return o.set(e,h),h}},{key:"processScene",value:function(e){for(var t=this.json,r=this.options,n=(t.scenes||(t.scenes=[],t.scene=0),{}),i=(""!==e.name&&(n.name=e.name),t.scenes.push(n),[]),o=0,a=e.children.length;o<a;o++){var s=e.children[o];!s.visible&&!1!==r.onlyVisible||null!==(s=this.processNode(s))&&i.push(s)}0<i.length&&(n.nodes=i),this.serializeUserData(e,n)}},{key:"processObjects",value:function(e){var t=new c.Scene;t.name="AuxScene";for(var r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}},{key:"processInput",value:function(e){for(var t,r,n=this.options,i=(e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)})),[]),o=0;o<e.length;o++)e[o]instanceof c.Scene?this.processScene(e[o]):i.push(e[o]);1===i.length?(t=i[0],["Group","Object3D"].includes(t.type)||((r=new c.Group).name="glb_model",r.add(t),t=r),this.processScene(t)):1<i.length&&this.processObjects(i);for(var a=0;a<this.skins.length;++a)this.processSkin(this.skins[a]);for(var s=0;s<n.animations.length;++s)this.processAnimation(n.animations[s],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}},{key:"_invokeAll",value:function(e){for(var t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}]),e}(),ks=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_lights_punctual"}return vs(e,[{key:"writeNode",value:function(e,t){var r,n,i;e.isLight&&(e.isDirectionalLight||e.isPointLight||e.isSpotLight?(r=(i=this.writer).json,i=i.extensionsUsed,n={},e.name&&(n.name=e.name),n.color=e.color.toArray(),n.intensity=e.intensity,e.isDirectionalLight?n.type="directional":e.isPointLight?(n.type="point",0<e.distance&&(n.range=e.distance)):e.isSpotLight&&(n.type="spot",0<e.distance&&(n.range=e.distance),n.spot={},n.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,n.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0),(i=r.extensions[this.name].lights).push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:i.length-1}):console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e))}}]),e}(),As=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_materials_unlit"}return vs(e,[{key:"writeMaterial",value:function(e,t){e.isMeshBasicMaterial&&(e=this.writer.extensionsUsed,t.extensions=t.extensions||{},t.extensions[this.name]={},e[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9)}}]),e}(),Cs=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_materials_pbrSpecularGlossiness"}return vs(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isGLTFSpecularGlossinessMaterial&&(n=(r=this.writer).extensionsUsed,i={},t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor),e.specular.toArray(o=[1,1,1],0),i.specularFactor=o,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap&&(o={index:r.processTexture(e.specularMap)},r.applyTextureTransform(o,e.specularMap),i.specularGlossinessTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Ls=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_materials_clearcoat"}return vs(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&(n=(r=this.writer).extensionsUsed,(i={}).clearcoatFactor=e.clearcoat,e.clearcoatMap&&(o={index:r.processTexture(e.clearcoatMap)},r.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o),i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap&&(o={index:r.processTexture(e.clearcoatRoughnessMap)},r.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o),e.clearcoatNormalMap&&(o={index:r.processTexture(e.clearcoatNormalMap)},r.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Ds=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_materials_transmission"}return vs(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&0!==e.transmission&&(n=(r=this.writer).extensionsUsed,(i={}).transmissionFactor=e.transmission,e.transmissionMap&&(o={index:r.processTexture(e.transmissionMap)},r.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),Is=function(){function e(t){ds(this,e),this.writer=t,this.name="KHR_materials_volume"}return vs(e,[{key:"writeMaterial",value:function(e,t){var r,n,i,o;e.isMeshPhysicalMaterial&&0!==e.transmission&&(n=(r=this.writer).extensionsUsed,(i={}).thicknessFactor=e.thickness,e.thicknessMap&&(o={index:r.processTexture(e.thicknessMap)},r.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o),i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0)}}]),e}(),js=(ys.Utils={insertKeyframe:function(e,t){var r,n=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),o=new e.ValueBufferType(e.values.length+n),a=e.createInterpolant(new e.ValueBufferType(n));if(0===e.times.length){i[0]=t;for(var s=0;s<n;s++)o[s]=0;r=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;i[0]=t,i.set(e.times,1),o.set(a.evaluate(t),0),o.set(e.values,n),r=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),o.set(e.values,0),o.set(a.evaluate(t),e.values.length),r=i.length-1}else for(var l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<.001)return l;if(e.times[l]<t&&e.times[l+1]>t){i.set(e.times.slice(0,l+1),0),i[l+1]=t,i.set(e.times.slice(l+1),l+2),o.set(e.values.slice(0,(l+1)*n),0),o.set(a.evaluate(t),(l+1)*n),o.set(e.values.slice((l+1)*n),(l+2)*n),r=l+1;break}}return e.times=i,e.values=o,r},mergeMorphTargetTracks:function(e,t){for(var r=[],n={},i=e.tracks,o=0;o<i.length;++o){var a=i[o],s=c.PropertyBinding.parseTrackName(a.name),l=c.PropertyBinding.findNode(t,s.nodeName);if("morphTargetInfluences"!==s.propertyName||void 0===s.propertyIndex)r.push(a);else{if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),(a=a.clone()).setInterpolation(c.InterpolateLinear)}var u=l.morphTargetInfluences.length,h=l.morphTargetDictionary[s.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+s.propertyIndex);var p=void 0;if(void 0===n[l.uuid]){for(var f=new((p=a.clone()).ValueBufferType)(u*p.times.length),d=0;d<p.times.length;d++)f[d*u+h]=p.values[d];p.name=(s.nodeName||"")+".morphTargetInfluences",p.values=f,n[l.uuid]=p,r.push(p)}else{var m=a.createInterpolant(new a.ValueBufferType(1));p=n[l.uuid];for(var v=0;v<p.times.length;v++)p.values[v*u+h]=m.evaluate(p.times[v]);for(var y=0;y<a.times.length;y++){var g=this.insertKeyframe(p,a.times[y]);p.values[g*u+h]=a.values[y]}}}}return e.tracks=r,e}},function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))});class Us{constructor(e){this._gltf=new ys,this.options=new os,this.runScene=e}getArrayBuffer(e=this.runScene.sceneEx.getClear(),t="scene"){return js(this,void 0,void 0,(function*(){const r=new ls(t,this.runScene),n=new cs(t,this.runScene);var i=yield n.parse(e);return r.material.setMaterialMap(i),new Promise((t=>{this._gltf.parse(e,(e=>{t(e)}),{binary:!0,onlyVisible:!1,includeCustomExtensions:!0,myOptions:{helper:r,optionsEx:this.runScene.optionsEx}})}))}))}export(e){return js(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,Ye.downloadFile)(new Blob([t]),"scene.glb")}))}model(e){return js(this,void 0,void 0,(function*(){const t=e||this.runScene.modelEx.select;var r,n;t&&(r=t.name||t.type,n=yield this.getArrayBuffer(t.clone(),"model"),(0,Ye.downloadFile)(new Blob([n]),r+".glb"))}))}material(e){var t;return js(this,void 0,void 0,(function*(){if(r=e||(null==(t=this.runScene.modelEx.select)?void 0:t.material)){const e=rs("Box");var r=(e.material=r).name||"material",n=yield this.getArrayBuffer(e,"material");(0,Ye.downloadFile)(new Blob([n]),r+".glb")}}))}scene(){return js(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,Ye.downloadFile)(new Blob([e]),"scene.glb")}))}}class Bs{constructor(e){this.runScene=e,this.gltf=new Us(e)}}var zs={},Ns=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Fs=function(e){return new Worker(e)};try{URL.revokeObjectURL(Ns(""))}catch($s){Ns=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Fs=function(e){return new Worker(e,{type:"module"})}}for(var Vs=Uint8Array,Hs=Uint16Array,Gs=Uint32Array,Ws=new Vs([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]),Xs=new Vs([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]),qs=new Vs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ys=(o=function(e,t){for(var r=new Hs(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new Gs(r[30]);for(n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return[r,i]},(ws=o(Ws,2))[0]),Zs=ws[1],Qs=(Ys[28]=258,Zs[258]=28,Ss=o(Xs,0))[0],Ks=Ss[1],Js=new Hs(32768),$s=0;$s<32768;++$s){var el=(43690&$s)>>>1|(21845&$s)<<1;Js[$s]=((65280&(el=(61680&(el=(52428&el)>>>2|(13107&el)<<2))>>>4|(3855&el)<<4))>>>8|(255&el)<<8)>>>1}var tl=function(e,t,r){for(var n=e.length,i=0,o=new Hs(t);i<n;++i)++o[e[i]-1];var a=new Hs(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(r){var s=new Hs(1<<t),l=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],h=a[e[i]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[Js[h]>>>l]=u}else for(s=new Hs(n),i=0;i<n;++i)e[i]&&(s[i]=Js[a[e[i]-1]++]>>>15-e[i]);return s},rl=new Vs(288);for($s=0;$s<144;++$s)rl[$s]=8;for($s=144;$s<256;++$s)rl[$s]=9;for($s=256;$s<280;++$s)rl[$s]=7;for($s=280;$s<288;++$s)rl[$s]=8;var nl=new Vs(32);for($s=0;$s<32;++$s)nl[$s]=5;function il(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}}function ol(e,t,r,n,i){var o,a=Il(e,n,i,(function(e,r){e?(a.terminate(),t.ondata.call(t,e)):(r[1]&&a.terminate(),t.ondata.call(t,e,r[0],r[1]))}));a.postMessage(r),t.push=function(e,r){if(o)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,o=r],[e.buffer])},t.terminate=function(){a.terminate()}}function al(e,t){return Xl(e,t)+4294967296*Xl(e,t+4)}var sl=tl(rl,9,0),ll=tl(rl,9,1),ul=tl(nl,5,0),cl=tl(nl,5,1),hl=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},pl=function(e,t,r){var n=t/8|0;return(e[n]|e[1+n]<<8)>>(7&t)&r},fl=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},dl=function(e){return(e/8|0)+(7&e&&1)},ml=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof Hs?Hs:e instanceof Gs?Gs:Vs)(r-(t=null==t||t<0?0:t));return n.set(e.subarray(t,r)),n},vl=function(e,t,r){var n=e.length;if(!n||r&&!r.l&&n<5)return t||new Vs(0);function i(e){var r=t.length;r<e&&((r=new Vs(Math.max(2*r,e))).set(t),t=r)}var o=!t||r,a=!r||r.i,s=(r=r||{},t=t||new Vs(3*n),r.f||0),l=r.p||0,u=r.b||0,c=r.l,h=r.d,p=r.m,f=r.n,d=8*n;do{if(!c){r.f=s=pl(e,l,1);var m=pl(e,l+1,3);if(l+=3,!m){var v=e[(M=dl(l)+4)-4]|e[M-3]<<8;if(n<(S=M+v)){if(a)throw"unexpected EOF";break}o&&i(u+v),t.set(e.subarray(M,S),u),r.b=u+=v,r.p=l=8*S;continue}if(1==m)c=ll,h=cl,p=9,f=5;else{if(2!=m)throw"invalid block type";v=pl(e,l,31)+257;for(var y=pl(e,l+10,15)+4,g=v+pl(e,l+5,31)+1,b=(l+=14,new Vs(g)),x=new Vs(19),w=0;w<y;++w)x[qs[w]]=pl(e,l+3*w,7);l+=3*y;var S,T=(1<<(S=hl(x)))-1,_=tl(x,S,1);for(w=0;w<g;){var M,E=_[pl(e,l,T)];if(l+=15&E,(M=E>>>4)<16)b[w++]=M;else{var P=0,O=0;for(16==M?(O=3+pl(e,l,3),l+=2,P=b[w-1]):17==M?(O=3+pl(e,l,7),l+=3):18==M&&(O=11+pl(e,l,127),l+=7);O--;)b[w++]=P}}m=b.subarray(0,v);var R=b.subarray(v);p=hl(m),f=hl(R),c=tl(m,p,1),h=tl(R,f,1)}if(d<l){if(a)throw"unexpected EOF";break}}o&&i(u+131072);for(var k=(1<<p)-1,A=(1<<f)-1,C=l;;C=l){var L=(P=c[fl(e,l)&k])>>>4;if(d<(l+=15&P)){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(L<256)t[u++]=L;else{if(256==L){C=l,c=null;break}var D,I=L-254,j=(264<L&&(D=Ws[w=L-257],I=pl(e,l,(1<<D)-1)+Ys[w],l+=D),(L=h[fl(e,l)&A])>>>4);if(!L)throw"invalid distance";if(l+=15&L,R=Qs[j],3<j&&(D=Xs[j],R+=fl(e,l)&(1<<D)-1,l+=D),d<l){if(a)throw"unexpected EOF";break}o&&i(u+131072);for(var U=u+I;u<U;u+=4)t[u]=t[u-R],t[u+1]=t[u+1-R],t[u+2]=t[u+2-R],t[u+3]=t[u+3-R];u=U}}r.l=c,r.p=C,r.b=u,c&&(s=1,r.m=p,r.d=h,r.n=f)}while(!s);return u==t.length?t:ml(t,0,u)},yl=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8},gl=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8,e[2+n]|=r>>>16},bl=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var i=r.length,o=r.slice();if(!i)return[El,0];if(1==i)return(m=new Vs(r[0].s+1))[r[0].s]=1,[m,1];r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var a=r[0],s=r[1],l=0,u=1,c=2;for(r[0]={s:-1,f:a.f+s.f,l:a,r:s};u!=i-1;)a=r[r[l].f<r[c].f?l++:c++],s=r[l!=u&&r[l].f<r[c].f?l++:c++],r[u++]={s:-1,f:a.f+s.f,l:a,r:s};var h=o[0].s;for(n=1;n<i;++n)o[n].s>h&&(h=o[n].s);var p=new Hs(h+1),f=xl(r[u-1],p,0);if(t<f){n=0;var d=0,m=f-t,v=1<<m;for(o.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));n<i;++n){var y=o[n].s;if(!(p[y]>t))break;d+=v-(1<<f-p[y]),p[y]=t}for(d>>>=m;0<d;){var g=o[n].s;p[g]<t?d-=1<<t-p[g]++-1:++n}for(;0<=n&&d;--n){var b=o[n].s;p[b]==t&&(--p[b],++d)}f=t}return[new Vs(p),f]},xl=function e(t,r,n){return-1==t.s?Math.max(e(t.l,r,n+1),e(t.r,r,n+1)):r[t.s]=n},wl=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Hs(++t),n=0,i=e[0],o=1,a=function(e){r[n++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++o;else{if(!i&&2<o){for(;138<o;o-=138)a(32754);2<o&&(a(10<o?o-11<<5|28690:o-3<<5|12305),o=0)}else if(3<o){for(a(i),--o;6<o;o-=6)a(8304);2<o&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=e[s]}return[r.subarray(0,n),t]},Sl=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},Tl=function(e,t,r){var n=r.length,i=dl(t+2);e[i]=255&n,e[i+1]=n>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var o=0;o<n;++o)e[i+o+4]=r[o];return 8*(i+4+n)},_l=function(e,t,r,n,i,o,a,s,l,u,c){yl(t,c++,r),++i[256];for(var h=(r=bl(i,15))[0],p=(r=r[1],(f=bl(o,15))[0]),f=f[1],d=(m=wl(h))[0],m=m[1],v=(y=wl(p))[0],y=y[1],g=new Hs(19),b=0;b<d.length;++b)g[31&d[b]]++;for(b=0;b<v.length;++b)g[31&v[b]]++;for(var x=(w=bl(g,7))[0],w=w[1],S=19;4<S&&!x[qs[S-1]];--S);var T,_=u+5<<3,M=Sl(i,rl)+Sl(o,nl)+a;if(i=Sl(i,h)+Sl(o,p)+a+14+3*S+Sl(g,x)+(2*g[16]+3*g[17]+7*g[18]),_<=M&&_<=i)return Tl(t,c,e.subarray(l,l+u));if(yl(t,c,1+(i<M)),c+=2,i<M){var E=tl(h,r,0),P=h,O=tl(p,f,0),R=p,k=tl(x,w,0);for(yl(t,c,m-257),yl(t,c+5,y-1),yl(t,c+10,S-4),c+=14,b=0;b<S;++b)yl(t,c+3*b,x[qs[b]]);c+=3*S;for(var A=[d,v],C=0;C<2;++C){var L=A[C];for(b=0;b<L.length;++b){var D=31&L[b];yl(t,c,k[D]),c+=x[D],15<D&&(yl(t,c,L[b]>>>5&127),c+=L[b]>>>12)}}}else E=sl,P=rl,O=ul,R=nl;for(b=0;b<s;++b)255<n[b]?(D=n[b]>>>18&31,gl(t,c,E[D+257]),c+=P[D+257],7<D&&(yl(t,c,n[b]>>>23&31),c+=Ws[D]),T=31&n[b],gl(t,c,O[T]),c+=R[T],3<T&&(gl(t,c,n[b]>>>5&8191),c+=Xs[T])):(gl(t,c,E[n[b]]),c+=P[n[b]]);return gl(t,c,E[256]),c+P[256]},Ml=new Gs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),El=new Vs(0),Pl=function(e,t,r,n,i,o){var a=e.length,s=new Vs(n+a+5*(1+Math.ceil(a/7e3))+i),l=s.subarray(n,s.length-i),u=0;if(!t||a<8)for(var c=0;c<=a;c+=65535){var h=c+65535;u=h<a?Tl(l,u,e.subarray(c,h)):(l[c]=o,Tl(l,u,e.subarray(c,a)))}else{for(var p=(t=Ml[t-1])>>>13,f=8191&t,d=(1<<r)-1,m=new Hs(32768),v=new Hs(1+d),y=Math.ceil(r/3),g=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<g)&d},x=new Gs(25e3),w=new Hs(288),S=new Hs(32),T=0,_=0,M=(c=0,0),E=0,P=0;c<a;++c){var O=b(c),R=32767&c,k=v[O];if(m[R]=k,v[O]=R,E<=c){var A=a-c;if((7e3<T||24576<M)&&423<A){u=_l(e,l,0,x,w,S,_,M,P,c-P,u),M=T=_=0,P=c;for(var C=0;C<286;++C)w[C]=0;for(C=0;C<30;++C)S[C]=0}var L=2,D=0,I=f,j=R-k&32767;if(2<A&&O==b(c-j))for(var U=Math.min(p,A)-1,B=Math.min(32767,c),z=Math.min(258,A);j<=B&&--I&&R!=k;){if(e[c+L]==e[c+L-j]){for(var N=0;N<z&&e[c+N]==e[c+N-j];++N);if(L<N){if(D=j,U<(L=N))break;var F=Math.min(j,N-2),V=0;for(C=0;C<F;++C){var H=c-j+C+32768&32767,G=H-m[H]+32768&32767;V<G&&(V=G,k=H)}}}j+=(R=k)-(k=m[R])+32768&32767}D?(x[M++]=268435456|Zs[L]<<18|Ks[D],O=31&Zs[L],A=31&Ks[D],_+=Ws[O]+Xs[A],++w[257+O],++S[A],E=c+L,++T):(x[M++]=e[c],++w[e[c]])}}u=_l(e,l,o,x,w,S,_,M,P,c-P,u),!o&&7&u&&(u=Tl(l,u+1,El))}return ml(s,0,n+dl(u)+i)},Ol=function(){for(var e=new Gs(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),Rl=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=Ol[255&r^t[n]]^r>>>8;e=r},d:function(){return~e}}},kl=function(){var e=1,t=0;return{p:function(r){for(var n=e,i=t,o=r.length,a=0;a!=o;){for(var s=Math.min(a+2655,o);a<s;++a)i+=n+=r[a];n=(65535&n)+15*(n>>16),i=(65535&i)+15*(i>>16)}e=n,t=i},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},Al=function(e,t,r,n,i){return Pl(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,n,!i)},Cl=function(e,t){var r,n={};for(r in e)n[r]=e[r];for(r in t)n[r]=t[r];return n},Ll=function(e,t,r){for(var n=e(),i=(e=e.toString()).slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<n.length;++o){var a=n[o],s=i[o];if("function"==typeof a){t+=";"+s+"=";var l=a.toString();if(a.prototype)if(-1!=l.indexOf("[native code]")){var u=l.indexOf(" ",8)+1;t+=l.slice(u,l.indexOf("(",u))}else for(var c in t+=l,a.prototype)t+=";"+s+".prototype."+c+"="+a.prototype[c].toString();else t+=l}else r[s]=a}return[t,r]},Dl=[],Il=function(e,t,r,n){var i;if(!Dl[r]){for(var o="",a={},s=e.length-1,l=0;l<s;++l)o=(i=Ll(e[l],o,a))[0],a=i[1];Dl[r]=Ll(e[s],o,a)}var u=Cl({},Dl[r][1]);return function(e,t,r,n,i){return(t=Fs(zs[t]||(zs[t]=Ns(e)))).onerror=function(e){return i(e.error,null)},t.onmessage=function(e){return i(null,e.data)},t.postMessage(r,n),t}(Dl[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,u,function(e){var t,r=[];for(t in e)(e[t]instanceof Vs||e[t]instanceof Hs||e[t]instanceof Gs)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(u),n)},jl=function(){return[Vs,Hs,Gs,Ws,Xs,qs,Ys,Qs,ll,cl,Js,tl,hl,pl,fl,dl,ml,vl,lu,Vl,Hl]},Ul=function(){return[Vs,Hs,Gs,Ws,Xs,qs,Zs,Ks,sl,rl,ul,nl,Js,Ml,El,tl,yl,gl,bl,xl,wl,Sl,Tl,_l,dl,ml,Pl,Al,iu,Vl]},Bl=function(){return[Yl,Kl,ql,Rl,Ol]},zl=function(){return[Zl,Ql]},Nl=function(){return[Jl,ql,kl]},Fl=function(){return[$l]},Vl=function(e){return postMessage(e,[e.buffer])},Hl=function(e){return e&&e.size&&new Vs(e.size)},Gl=function(e,t,r,n,i,o){var a=Il(r,n,i,(function(e,t){a.terminate(),o(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},Wl=function(e,t){return e[t]|e[t+1]<<8},Xl=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ql=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},Yl=function(e,t){var r=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&ql(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var n=0;n<=r.length;++n)e[n+10]=r.charCodeAt(n)}},Zl=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],r=10;4&t&&(r+=e[10]|2+(e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);0<n;n-=!e[r++]);return r+(2&t)},Ql=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Kl=function(e){return 10+(e.filename&&e.filename.length+1||0)},Jl=function(e,t){t=0==(t=t.level)?0:t<6?1:9==t?3:2,e[0]=120,e[1]=t<<6|(t?32-2*t:1)},$l=function(e){if(8!=(15&e[0])||7<e[0]>>>4||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function eu(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var tu=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(Al(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),ru=function(e,t){ol([Ul,function(){return[il,tu]}],this,eu.call(this,e,t),(function(e){e=new tu(e.data),onmessage=il(e)}),6)};function nu(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[Ul],(function(e){return Vl(iu(e.data[0],e.data[1]))}),0,r)}function iu(e,t){return Al(e,t||{},0,0)}var ou=function(){function e(e){this.s={},this.p=new Vs(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,r=new Vs(t+e.length);r.set(this.p),r.set(e,t),this.p=r},e.prototype.c=function(e){this.d=this.s.i=e||!1,e=this.s.b;var t=vl(this.p,this.o,this.s);this.ondata(ml(t,e,this.s.b),this.d),this.o=ml(t,this.s.b-32768),this.s.b=this.o.length,this.p=ml(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),au=function(e){this.ondata=e,ol([jl,function(){return[il,ou]}],this,0,(function(){var e=new ou;onmessage=il(e)}),7)};function su(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[jl],(function(e){return Vl(lu(e.data[0],Hl(e.data[1])))}),1,r)}function lu(e,t){return vl(e,t)}var uu=function(){function e(e,t){this.c=Rl(),this.l=0,this.v=1,tu.call(this,e,t)}return e.prototype.push=function(e,t){tu.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=Al(e,this.o,this.v&&Kl(this.o),t&&8,!t),this.v&&(Yl(e,this.o),this.v=0),t&&(ql(e,e.length-8,this.c.d()),ql(e,e.length-4,this.l)),this.ondata(e,t)},e}(),cu=function(e,t){ol([Ul,Bl,function(){return[il,tu,uu]}],this,eu.call(this,e,t),(function(e){e=new uu(e.data),onmessage=il(e)}),8)};function hu(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[Ul,Bl,function(){return[pu]}],(function(e){return Vl(pu(e.data[0],e.data[1]))}),2,r)}function pu(e,t){t=t||{};var r=Rl(),n=e.length,i=(r.p(e),e=Al(e,t,Kl(t),8)).length;return Yl(e,t),ql(e,i-8,r.d()),ql(e,i-4,n),e}var fu=function(){function e(e){this.v=1,ou.call(this,e)}return e.prototype.push=function(e,t){if(ou.prototype.e.call(this,e),this.v){if((e=3<this.p.length?Zl(this.p):4)>=this.p.length&&!t)return;this.p=this.p.subarray(e),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}ou.prototype.c.call(this,t)},e}(),du=function(e){this.ondata=e,ol([jl,zl,function(){return[il,ou,fu]}],this,0,(function(){var e=new fu;onmessage=il(e)}),9)};function mu(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[jl,zl,function(){return[vu]}],(function(e){return Vl(vu(e.data[0]))}),3,r)}function vu(e,t){return vl(e.subarray(Zl(e),-8),t||new Vs(Ql(e)))}var yu=function(){function e(e,t){this.c=kl(),this.v=1,tu.call(this,e,t)}return e.prototype.push=function(e,t){tu.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=Al(e,this.o,this.v&&2,t&&4,!t),this.v&&(Jl(e,this.o),this.v=0),t&&ql(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),gu=function(e,t){ol([Ul,Nl,function(){return[il,tu,yu]}],this,eu.call(this,e,t),(function(e){e=new yu(e.data),onmessage=il(e)}),10)};function bu(e,t){t=t||{};var r=kl();return r.p(e),e=Al(e,t,2,4),Jl(e,t),ql(e,e.length-4,r.d()),e}var xu=function(){function e(e){this.v=1,ou.call(this,e)}return e.prototype.push=function(e,t){if(ou.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}ou.prototype.c.call(this,t)},e}(),wu=function(e){this.ondata=e,ol([jl,Fl,function(){return[il,ou,xu]}],this,0,(function(){var e=new xu;onmessage=il(e)}),11)};function Su(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Gl(e,t,[jl,Fl,function(){return[Tu]}],(function(e){return Vl(Tu(e.data[0],Hl(e.data[1])))}),5,r)}function Tu(e,t){return vl(($l(e),e.subarray(2,-4)),t)}var _u=function(){function e(e){this.G=fu,this.I=ou,this.Z=xu,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";var r,n;this.s?this.s.push(e,t):(this.p&&this.p.length?((r=new Vs(this.p.length+e.length)).set(this.p),r.set(e,this.p.length)):this.p=e,2<this.p.length&&((n=this).s=new(31==this.p[0]&&139==this.p[1]&&8==this.p[2]?this.G:8!=(15&this.p[0])||7<this.p[0]>>4||(this.p[0]<<8|this.p[1])%31?this.I:this.Z)((function(){n.ondata.apply(n,arguments)})),this.s.push(this.p,t),this.p=null))},e}(),Mu=function(){function e(e){this.G=du,this.I=au,this.Z=wu,this.ondata=e}return e.prototype.push=function(e,t){_u.prototype.push.call(this,e,t)},e}(),Eu=function e(t,r,n,i){for(var o in t){var a=t[o];o=r+o,a instanceof Vs?n[o]=[a,i]:Array.isArray(a)?n[o]=[a[0],Cl(i,a[1])]:e(a,o+"/",n,i)}},Pu="undefined"!=typeof TextEncoder&&new TextEncoder,Ou="undefined"!=typeof TextDecoder&&new TextDecoder,Ru=0;try{Ou.decode(El,{stream:!0}),Ru=1}catch($s){}var ku=function(e){for(var t="",r=0;;){var n=e[r++],i=(127<n)+(223<n)+(239<n);if(r+i>e.length)return[t,ml(e,r-1)];i?3==i?(n=((15&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=1&i?String.fromCharCode((31&n)<<6|63&e[r++]):String.fromCharCode((15&n)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(n)}},Au=function(){function e(e){this.ondata=e,Ru?this.t=new TextDecoder:this.p=El}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var r=((r=new Vs(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=ku(r))[0];if(e=e[1],t){if(e.length)throw"invalid utf-8 data";this.p=null}else this.p=e;this.ondata(r,t)}},e}(),Cu=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Lu(e),this.d=t||!1)},e}();function Lu(e,t){if(t){for(var r=new Vs(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(Pu)return Pu.encode(e);var i=e.length,o=new Vs(e.length+(e.length>>1)),a=0,s=function(e){o[a++]=e};for(n=0;n<i;++n){a+5>o.length&&((l=new Vs(a+8+(i-n<<1))).set(o),o=l);var l=e.charCodeAt(n);l<128||t?s(l):(l<2048?s(192|l>>6):(55295<l&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++n))>>18),s(128|l>>12&63)):s(224|l>>12),s(128|l>>6&63)),s(128|63&l))}return ml(o,0,a)}function Du(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}if(Ou)return Ou.decode(e);var i=(t=ku(e))[0];if(t[1].length)throw"invalid utf-8 data";return i}function Iu(e){return 1==e?3:e<6?2:9==e?1:0}var ju=function(e,t){return t+30+Wl(e,t+26)+Wl(e,t+28)},Uu=function(e,t,r){var n=Wl(e,t+28),i=Du(e.subarray(t+46,t+46+n),!(2048&Wl(e,t+8))),o=(n=t+46+n,Xl(e,t+20)),a=(o=(r=r&&4294967295==o?Bu(e,n):[o,Xl(e,t+24),Xl(e,t+42)])[0],r[1]);return r=r[2],[Wl(e,t+10),o,a,i,n+Wl(e,t+30)+Wl(e,t+32),r]},Bu=function(e,t){for(;1!=Wl(e,t);t+=4+Wl(e,t+2));return[al(e,t+12),al(e,t+4),al(e,t+20)]},zu=function(e){var t=0;if(e)for(var r in e){if(65535<(r=e[r].length))throw"extra field too long";t+=r+4}return t},Nu=function(e,t,r,n,i,o,a,s){var l=n.length,u=r.extra,c=s&&s.length,h=zu(u),p=(ql(e,t,null!=a?33639248:67324752),t+=4,null!=a&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(null==o&&8),e[t++]=i&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8,i=new Date(null==r.mtime?Date.now():r.mtime)).getFullYear()-1980;if(p<0||119<p)throw"date not in range 1980-2099";if(ql(e,t,p<<25|i.getMonth()+1<<21|i.getDate()<<16|i.getHours()<<11|i.getMinutes()<<5|i.getSeconds()>>>1),t+=4,null!=o&&(ql(e,t,r.crc),ql(e,t+4,o),ql(e,t+8,r.size)),ql(e,t+12,l),ql(e,t+14,h),t+=16,null!=a&&(ql(e,t,c),ql(e,t+6,r.attrs),ql(e,t+10,a),t+=14),e.set(n,t),t+=l,h)for(var f in u){var d=u[f],m=d.length;ql(e,t,+f),ql(e,t+2,m),e.set(d,t+4),t+=4+m}return c&&(e.set(s,t),t+=c),t},Fu=function(e,t,r,n,i){ql(e,t,101010256),ql(e,t+8,r),ql(e,t+10,r),ql(e,t+12,n),ql(e,t+16,i)},Vu=function(){function e(e){this.filename=e,this.c=Rl(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Hu=function(){function e(e,t){var r=this;t=t||{},Vu.call(this,e),this.d=new tu(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=Iu(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Vu.prototype.push.call(this,e,t)},e}(),Gu=function(){function e(e,t){var r=this;t=t||{},Vu.call(this,e),this.d=new ru(t,(function(e,t,n){r.ondata(e,t,n)})),this.compression=8,this.flag=Iu(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Vu.prototype.push.call(this,e,t)},e}(),Wu=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var r=Lu(e.filename),n=r.length,i=(o=e.comment)&&Lu(o),o=n!=e.filename.length||i&&o.length!=i.length,a=n+zu(e.extra)+30;if(65535<n)throw"filename too long";function s(){for(var e=0,r=l;e<r.length;e++){var n=r[e];t.ondata(null,n,!1)}l=[]}n=new Vs(a);var l=(Nu(n,0,e,r,o),[n]),u=this.d,c=(this.d=0,this.u.length),h=Cl(e,{f:r,u:o,o:i,t:function(){e.terminate&&e.terminate()},r:function(){var e;s(),u&&((e=t.u[c+1])?e.r():t.d=1),u=1}}),p=0;e.ondata=function(r,n,i){r?(t.ondata(r,n,i),t.terminate()):(p+=n.length,l.push(n),i?(r=new Vs(16),ql(r,0,134695760),ql(r,4,e.crc),ql(r,8,p),ql(r,12,e.size),l.push(r),h.c=p,h.b=a+p+16,h.crc=e.crc,h.size=e.size,u&&h.r(),u=1):u&&s())},this.u.push(h)},e.prototype.end=function(){var e=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&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,r=0,n=0,i=this.u;n<i.length;n++)r+=46+(l=i[n]).f.length+zu(l.extra)+(l.o?l.o.length:0);for(var o=new Vs(r+22),a=0,s=this.u;a<s.length;a++){var l=s[a];Nu(o,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+zu(l.extra)+(l.o?l.o.length:0),t+=l.b}Fu(o,e,this.u.length,r,t),this.ondata(null,o,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2},e}(),Xu=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),qu=function(){function e(){var e=this;this.i=new ou((function(t,r){e.ondata(null,t,r)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(r){this.ondata(r,e,t)}},e.compression=8,e}(),Yu=function(){function e(e,t){var r=this;t<32e4?this.i=new ou((function(e,t){r.ondata(null,e,t)})):(this.i=new au((function(e,t,n){r.ondata(e,t,n)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=ml(e,0)),this.i.push(e,t)},e.compression=8,e}(),Zu=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Xu},this.p=El}return e.prototype.push=function(e,t){var r=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(0<this.c){var n=Math.min(this.c,e.length),i=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(n)).length)return this.push(e,t)}else{for(var o=0,a=0,s=void 0,l=void 0,u=(this.p.length?e.length?((l=new Vs(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e,l.length),c=this.c,h=(i=c&&this.d,this);a<u-4&&"break"!==function(){var e,t,n,i,p,f,d,m,v,y,g,b=Xl(l,a);return 67324752==b?(o=1,s=a,h.d=null,h.c=0,n=Wl(l,a+6),e=Wl(l,a+8),t=2048&n,n&=8,i=Wl(l,a+26),p=Wl(l,a+28),a+30+i+p<u&&(h.k.unshift(f=[]),o=2,d=Xl(l,a+18),m=Xl(l,a+22),v=Du(l.subarray(a+30,a+=30+i),!t),4294967295==d?(i=n?[-2]:Bu(l,a),d=i[0],m=i[1]):n&&(d=-1),a+=p,h.c=d,g={name:v,compression:e,start:function(){if(!g.ondata)throw"no callback";if(d){var t=r.o[e];if(!t)throw"unknown compression type "+e;(y=d<0?new t(v):new t(v,d,m)).ondata=function(e,t,r){g.ondata(e,t,r)};for(var n=0,i=f;n<i.length;n++)y.push(i[n],!1);r.k[0]==f&&r.c?r.d=y:y.push(El,!0)}else g.ondata(null,El,!0)},terminate:function(){y&&y.terminate&&y.terminate()}},0<=d&&(g.size=d,g.originalSize=m),h.onfile(g)),"break"):c?134695760==b?(s=a+=12+(-2==c&&8),o=3,h.c=0,"break"):33639248==b?(s=a-=4,o=3,h.c=0,"break"):void 0:void 0}();++a);if(this.p=El,c<0&&(n=o?l.subarray(0,s-12-(-2==c&&8)-(134695760==Xl(l,s-16)&&4)):l.subarray(0,a),i?i.push(n,!!o):this.k[+(2==o)].push(n)),2&o)return this.push(l.subarray(a),t);this.p=l.subarray(a)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();function Qu(e,t,r){var n=r.length-e-1;if(t>=r[n])return n-1;if(t<=r[e])return e;for(var i=e,o=n,a=Math.floor((i+o)/2);t<r[a]||t>=r[a+1];)t<r[a]?o=a:i=a,a=Math.floor((i+o)/2);return a}function Ku(e,t,r,n){for(var i=[],o=[],a=[],s=i[0]=1;s<=r;++s){o[s]=t-n[e+1-s],a[s]=n[e+s]-t;for(var l=0,u=0;u<s;++u){var c=a[u+1],h=o[s-u],p=i[u]/(c+h);i[u]=l+c*p,l=h*p}i[s]=l}return i}function Ju(e,t,r,n,i){for(var o=i<e?i:e,a=[],s=Qu(e,n,t),l=function(e,t,r,n,i){for(var o=[],a=0;a<=r;++a)o[a]=0;for(var s=[],l=0;l<=n;++l)s[l]=o.slice(0);for(var u=[],c=0;c<=r;++c)u[c]=o.slice(0);u[0][0]=1;for(var h=o.slice(0),p=o.slice(0),f=1;f<=r;++f){h[f]=t-i[e+1-f],p[f]=i[e+f]-t;for(var d=0,m=0;m<f;++m){var v=p[m+1],y=h[f-m],g=(u[f][m]=v+y,u[m][f-1]/u[f][m]);u[m][f]=d+v*g,d=y*g}u[f][f]=d}for(var b=0;b<=r;++b)s[0][b]=u[b][r];for(var x=0;x<=r;++x){for(var w=0,S=1,T=[],_=0;_<=r;++_)T[_]=o.slice(0);for(var M=T[0][0]=1;M<=n;++M){var E=0,P=x-M,O=r-M;M<=x&&(T[S][0]=T[w][0]/u[1+O][P],E=T[S][0]*u[P][O]);for(var R=x-1<=O?M-1:r-x,k=-1<=P?1:-P;k<=R;++k)T[S][k]=(T[w][k]-T[w][k-1])/u[1+O][P+k],E+=T[S][k]*u[P+k][O];x<=O&&(T[S][M]=-T[w][M-1]/u[1+O][x],E+=T[S][M]*u[x][O]),s[M][x]=E;var A=w;w=S,S=A}}for(var C=r,L=1;L<=n;++L){for(var D=0;D<=r;++D)s[L][D]*=C;C*=r-L}return s}(s,n,e,o,t),u=[],h=0;h<r.length;++h){var p=r[h].clone(),f=p.w;p.x*=f,p.y*=f,p.z*=f,u[h]=p}for(var d=0;d<=o;++d){for(var m=u[s-e].clone().multiplyScalar(l[d][0]),v=1;v<=e;++v)m.add(u[s-e+v].clone().multiplyScalar(l[d][v]));a[d]=m}for(var y=o+1;y<=i+1;++y)a[y]=new c.Vector4(0,0,0);return a}function $u(e){for(var t=e.length,r=[],n=[],i=0;i<t;++i){var o=e[i];r[i]=new c.Vector3(o.x,o.y,o.z),n[i]=o.w}for(var a=[],s=0;s<t;++s){for(var l=r[s].clone(),u=1;u<=s;++u)l.sub(a[s-u].clone().multiplyScalar(function(e,t){for(var r=1,n=2;n<=e;++n)r*=n;for(var i=1,o=2;o<=t;++o)i*=o;for(var a=2;a<=e-t;++a)i*=a;return r/i}(s,u)*n[u]));a[s]=l.divideScalar(n[0])}return a}function ec(e){return(ec="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function tc(e,t){return(tc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function rc(e){return(rc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var nc,ic,oc,ac=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tc(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=rc(e);if(r=t?(r=rc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ec(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t,i,o,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(s=r.call(this)).degree=e,s.knots=t,s.controlPoints=[],s.startKnot=o||0,s.endKnot=a||s.knots.length-1;for(var l=0;l<i.length;++l){var u=i[l];s.controlPoints[l]=new c.Vector4(u.x,u.y,u.z,u.w)}return s}return t=n,(e=[{key:"getPoint",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new c.Vector3;return e=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),e=function(e,t,r,n){for(var i=Qu(e,n,t),o=Ku(i,n,e,t),a=new c.Vector4(0,0,0,0),s=0;s<=e;++s){var l=r[i-e+s],u=o[s],h=l.w*u;a.x+=l.x*h,a.y+=l.y*h,a.z+=l.z*h,a.w+=l.w*u}return a}(this.degree,this.knots,this.controlPoints,e),1!==e.w&&e.divideScalar(e.w),t.set(e.x,e.y,e.z)}},{key:"getTangent",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new c.Vector3,r=(e=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),$u(Ju(r=this.degree,this.knots,this.controlPoints,e,1)));return t.copy(r[1]).normalize(),t}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Curve);function sc(e){return(sc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function lc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function uc(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function cc(e,t,r){t&&uc(e.prototype,t),r&&uc(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function hc(e,t){return(hc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pc(e){return(pc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var fc=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&hc(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=pc(e);if(r=t?(r=pc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===sc(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){return lc(this,n),r.call(this,e)}return cc(n,[{key:"load",value:function(e,t,r,n){var i=this,o=""===i.path?c.LoaderUtils.extractUrlBase(e):i.path,a=new c.FileLoader(this.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(r){try{t(i.parse(r,o))}catch(r){n?n(r):console.error(r),i.manager.itemError(e)}}),r,n)}},{key:"parse",value:function(e,t){if(n="Kaydara FBX Binary \0",(r=e).byteLength>=n.length&&n===kc(r,0,n.length))nc=(new gc).parse(e);else{if(!function(e){for(var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0,n=0;n<t.length;++n)if(function(t){var n=e[0];return e=e.slice(r+1),r++,n}()===t[n])return;return 1}(r=kc(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(wc(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+wc(r));nc=(new yc).parse(r)}var r,n=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new dc(n,this.manager).parse(nc)}}]),n}(c.Loader),dc=function(){function e(t,r){lc(this,e),this.textureLoader=t,this.manager=r}return cc(e,[{key:"parse",value:function(){ic=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new mc).parse(t);return this.parseScene(t,r,e),oc}},{key:"parseConnections",value:function(){var e=new Map;return"Connections"in nc&&nc.Connections.connections.forEach((function(t){var r=t[0],n=t[1],i=(t=t[2],e.has(r)||e.set(r,{parents:[],children:[]}),{ID:n,relationship:t});e.get(r).parents.push(i),e.has(n)||e.set(n,{parents:[],children:[]}),i={ID:r,relationship:t},e.get(n).children.push(i)})),e}},{key:"parseImages",value:function(){var e,t={},r={};if("Video"in nc.Objects){var n,i=nc.Objects.Video;for(n in i){var o,a,s=i[n];t[parseInt(n)]=s.RelativeFilename||s.Filename,"Content"in s&&(a=s.Content instanceof ArrayBuffer&&0<s.Content.byteLength,o="string"==typeof s.Content&&""!==s.Content,(a||o)&&(a=this.parseImage(i[n]),r[s.RelativeFilename||s.Filename]=a))}}for(e in t){var l=t[e];void 0!==r[l]?t[e]=r[l]:t[e]=t[e].split("\\").pop()}return t}},{key:"parseImage",value:function(e){var t,r=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();switch(i){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}return"string"==typeof r?"data:"+t+";base64,"+r:(e=new Uint8Array(r),window.URL.createObjectURL(new Blob([e],{type:t})))}},{key:"parseTextures",value:function(e){var t=new Map;if("Texture"in nc.Objects){var r,n=nc.Objects.Texture;for(r in n){var i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}},{key:"parseTexture",value:function(e,t){var r=((t=this.loadTexture(e,t)).ID=e.id,t.name=e.attrName,e.WrapModeU),n=e.WrapModeV;return r=void 0!==r?r.value:0,n=void 0!==n?n.value:0,t.wrapS=0===r?c.RepeatWrapping:c.ClampToEdgeWrapping,t.wrapT=0===n?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e&&(r=e.Scaling.value,t.repeat.x=r[0],t.repeat.y=r[1]),"Translation"in e&&(n=e.Translation.value,t.offset.x=n[0],t.offset.y=n[1]),t}},{key:"loadTexture",value:function(e,t){var r,n=this.textureLoader.path,i=ic.get(e.id).children;return i="tga"===(void 0!==i&&0<i.length&&void 0!==t[i[0].ID]&&(0!==(r=t[i[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0)),t=e.FileName.slice(-3).toLowerCase())?null===(i=this.manager.getHandler(".tga"))?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),new c.Texture):(i.setPath(this.textureLoader.path),i.load(r)):"psd"===t?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),new c.Texture):this.textureLoader.load(r),this.textureLoader.setPath(n),i}},{key:"parseMaterials",value:function(e){var t=new Map;if("Material"in nc.Objects){var r,n=nc.Objects.Material;for(r in n){var i=this.parseMaterial(n[r],e);null!==i&&t.set(parseInt(r),i)}}return t}},{key:"parseMaterial",value:function(e,t){var r,n=e.id,i=e.attrName,o=e.ShadingModel;if("object"===sc(o)&&(o=o.value),!ic.has(n))return null;switch(e=this.parseParameters(e,t,n),o.toLowerCase()){case"phong":r=new c.MeshPhongMaterial;break;case"lambert":r=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),r=new c.MeshPhongMaterial}return r.setValues(e),r.name=i,r}},{key:"parseParameters",value:function(e,t,r){var n={},i=(e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new c.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new c.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new c.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new c.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=(new c.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new c.Color).fromArray(e.SpecularColor.value)),this);return ic.get(r).children.forEach((function(e){var r=e.relationship;switch(r){case"Bump":n.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=i.getTexture(t,e.ID),void 0!==n.map&&(n.map.encoding=c.sRGBEncoding);break;case"DisplacementColor":n.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=i.getTexture(t,e.ID),void 0!==n.emissiveMap&&(n.emissiveMap.encoding=c.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=i.getTexture(t,e.ID),void 0!==n.envMap&&(n.envMap.mapping=c.EquirectangularReflectionMapping,n.envMap.encoding=c.sRGBEncoding);break;case"SpecularColor":n.specularMap=i.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.encoding=c.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=i.getTexture(t,e.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}})),n}},{key:"getTexture",value:function(e,t){return"LayeredTexture"in nc.Objects&&t in nc.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ic.get(t).children[0].ID),e.get(t)}},{key:"parseDeformers",value:function(){var e={},t={};if("Deformer"in nc.Objects){var r,n=nc.Objects.Deformer;for(r in n){var i,o=n[r],a=ic.get(parseInt(r));"Skin"===o.attrType?((i=this.parseSkeleton(a,n)).ID=r,1<a.parents.length&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),i.geometryID=a.parents[0].ID,e[r]=i):"BlendShape"===o.attrType&&((i={id:r}).rawTargets=this.parseMorphTargets(a,n),i.id=r,1<a.parents.length&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=i)}}return{skeletons:e,morphTargets:t}}},{key:"parseSkeleton",value:function(e,t){var r=[];return e.children.forEach((function(e){var n=t[e.ID];"Cluster"===n.attrType&&(e={ID:e.ID,indices:[],weights:[],transformLink:(new c.Matrix4).fromArray(n.TransformLink.a)},"Indexes"in n&&(e.indices=n.Indexes.a,e.weights=n.Weights.a),r.push(e))})),{rawBones:r,bones:[]}}},{key:"parseMorphTargets",value:function(e,t){for(var r=[],n=0;n<e.children.length;n++){var i=e.children[n],o=t[i.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if("BlendShapeChannel"!==o.attrType)return;a.geoID=ic.get(parseInt(i.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,r.push(a)}return r}},{key:"parseScene",value:function(e,t,r){oc=new c.Group;var n=this.parseModels(e.skeletons,t,r),i=nc.Objects.Model,o=this;n.forEach((function(e){var t=i[e.ID];o.setLookAtProperties(e,t),ic.get(e.ID).parents.forEach((function(t){void 0!==(t=n.get(t.ID))&&t.add(e)})),null===e.parent&&oc.add(e)})),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),oc.traverse((function(e){var t;e.userData.transformData&&(e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld),t=Pc(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new vc).parse(),1===oc.children.length&&oc.children[0].isGroup&&(oc.children[0].animations=r,oc=oc.children[0]),oc.animations=r}},{key:"parseModels",value:function(e,t,r){var n,i=new Map,o=nc.Objects.Model;for(n in o){var a=parseInt(n),s=o[n],l=ic.get(a),u=this.buildSkeleton(l,e,a,s.attrName);if(!u){switch(s.attrType){case"Camera":u=this.createCamera(l);break;case"Light":u=this.createLight(l);break;case"Mesh":u=this.createMesh(l,t,r);break;case"NurbsCurve":u=this.createCurve(l,t);break;case"LimbNode":case"Root":u=new c.Bone;break;default:u=new c.Group}u.name=s.attrName?c.PropertyBinding.sanitizeNodeName(s.attrName):"",u.ID=a}this.getTransformData(u,s),i.set(a,u)}return i}},{key:"buildSkeleton",value:function(e,t,r,n){var i=null;return e.parents.forEach((function(e){for(var o in t)!function(o){var a=t[o];a.rawBones.forEach((function(t,o){var s;t.ID===e.ID&&(s=i,(i=new c.Bone).matrixWorld.copy(t.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=r,a.bones[o]=i,null!==s&&i.add(s))}))}(o)})),i}},{key:"createCamera",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=nc.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new c.Object3D;else{var n=0,i=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(n=1),1),o=(void 0!==r.NearPlane&&(i=r.NearPlane.value/1e3),1e3),a=(void 0!==r.FarPlane&&(o=r.FarPlane.value/1e3),window.innerWidth),s=window.innerHeight,l=(void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(a=r.AspectWidth.value,s=r.AspectHeight.value),a/s),u=45,h=(void 0!==r.FieldOfView&&(u=r.FieldOfView.value),r.FocalLength?r.FocalLength.value:null);switch(n){case 0:t=new c.PerspectiveCamera(u,l,i,o),null!==h&&t.setFocalLength(h);break;case 1:t=new c.OrthographicCamera(-a/2,a/2,s/2,-s/2,i,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new c.Object3D}}return t}},{key:"createLight",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=nc.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new c.Object3D;else{e=void 0===r.LightType?0:r.LightType.value;var n=16777215,i=(void 0!==r.Color&&(n=(new c.Color).fromArray(r.Color.value)),void 0===r.Intensity?1:r.Intensity.value/100),o=(void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(i=0),0);switch(void 0!==r.FarAttenuationEnd&&(o=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value),e){case 0:t=new c.PointLight(n,i,o,1);break;case 1:t=new c.DirectionalLight(n,i);break;case 2:var a=Math.PI/3,s=(void 0!==r.InnerAngle&&(a=c.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(s=c.MathUtils.degToRad(r.OuterAngle.value),s=Math.max(s,1)),t=new c.SpotLight(n,i,o,a,s,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(n,i)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t}},{key:"createMesh",value:function(e,t,r){var n,i=null,o=null,a=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),r.has(e.ID)&&a.push(r.get(e.ID))})),1<a.length?o=a:0<a.length?o=a[0]:(o=new c.MeshPhongMaterial({color:13421772}),a.push(o)),"color"in i.attributes&&a.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(n=new c.SkinnedMesh(i,o)).normalizeSkinWeights():n=new c.Mesh(i,o),n}},{key:"createCurve",value:function(e,t){e=e.children.reduce((function(e,r){return t.has(r.ID)?t.get(r.ID):e}),null);var r=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(e,r)}},{key:"getTransformData",value:function(e,t){var r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?Oc(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r}},{key:"setLookAtProperties",value:function(e,t){"LookAtProperty"in t&&ic.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=nc.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),oc.add(e.target)):e.lookAt((new c.Vector3).fromArray(t)))}))}},{key:"bindSkeleton",value:function(e,t,r){var n,i=this.parsePoseNodes();for(n in e)!function(n){var o=e[n];ic.get(parseInt(o.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,ic.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new c.Skeleton(o.bones),i[e.ID])})))}))}(n)}},{key:"parsePoseNodes",value:function(){var e={};if("Pose"in nc.Objects){var t,r,n=nc.Objects.Pose;for(t in n)"BindPose"===n[t].attrType&&0<n[t].NbPoseNodes&&(r=n[t].PoseNode,Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new c.Matrix4).fromArray(t.Matrix.a)})):e[r.Node]=(new c.Matrix4).fromArray(r.Matrix.a))}return e}},{key:"createAmbientLight",value:function(){var e,t,r;"GlobalSettings"in nc&&"AmbientColor"in nc.GlobalSettings&&(r=(t=nc.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new c.Color(r,e,t),oc.add(new c.AmbientLight(r,1))))}}]),e}(),mc=function(){function e(){lc(this,e)}return cc(e,[{key:"parse",value:function(e){var t=new Map;if("Geometry"in nc.Objects){var r,n=nc.Objects.Geometry;for(r in n){var i=ic.get(parseInt(r));i=this.parseGeometry(i,n[r],e),t.set(parseInt(r),i)}}return t}},{key:"parseGeometry",value:function(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}},{key:"parseMeshGeometry",value:function(e,t,r){var n,i=r.skeletons,o=[],a=e.parents.map((function(e){return nc.Objects.Model[e.ID]}));if(0!==a.length)return n=e.children.reduce((function(e,t){return void 0!==i[t.ID]?i[t.ID]:e}),null),e.children.forEach((function(e){void 0!==r.morphTargets[e.ID]&&o.push(r.morphTargets[e.ID])})),e=a[0],a={},"RotationOrder"in e&&(a.eulerOrder=Oc(e.RotationOrder.value)),"InheritType"in e&&(a.inheritType=parseInt(e.InheritType.value)),"GeometricTranslation"in e&&(a.translation=e.GeometricTranslation.value),"GeometricRotation"in e&&(a.rotation=e.GeometricRotation.value),"GeometricScaling"in e&&(a.scale=e.GeometricScaling.value),e=Pc(a),this.genGeometry(t,n,o,e)}},{key:"genGeometry",value:function(e,t,r,n){var i,o,a=new c.BufferGeometry,s=(e.attrName&&(a.name=e.attrName),this.parseGeoNode(e,t)),l=this.genBuffers(s),u=new c.Float32BufferAttribute(l.vertex,3);return u.applyMatrix4(n),a.setAttribute("position",u),0<l.colors.length&&a.setAttribute("color",new c.Float32BufferAttribute(l.colors,3)),t&&(a.setAttribute("skinIndex",new c.Uint16BufferAttribute(l.weightsIndices,4)),a.setAttribute("skinWeight",new c.Float32BufferAttribute(l.vertexWeights,4)),a.FBX_Deformer=t),0<l.normal.length&&(u=(new c.Matrix3).getNormalMatrix(n),(t=new c.Float32BufferAttribute(l.normal,3)).applyNormalMatrix(u),a.setAttribute("normal",t)),l.uvs.forEach((function(e,t){var r="uv"+(t+1).toString();a.setAttribute(r=0===t?"uv":r,new c.Float32BufferAttribute(l.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType&&(i=l.materialIndex[0],o=0,l.materialIndex.forEach((function(e,t){e!==i&&(a.addGroup(o,t-o,i),i=e,o=t)})),0<a.groups.length&&(t=(u=a.groups[a.groups.length-1]).start+u.count)!==l.materialIndex.length&&a.addGroup(t,l.materialIndex.length-t,i),0===a.groups.length&&a.addGroup(0,l.materialIndex.length,l.materialIndex[0])),this.addMorphTargets(a,e,r,n),a}},{key:"parseGeoNode",value:function(e,t){var r={};if(r.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],r.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];for(var n=0;e.LayerElementUV[n];)e.LayerElementUV[n].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[n])),n++}return r.weightTable={},null!==t&&(r.skeleton=t).rawBones.forEach((function(e,t){e.indices.forEach((function(n,i){void 0===r.weightTable[n]&&(r.weightTable[n]=[]),r.weightTable[n].push({id:t,weight:e.weights[i]})}))})),r}},{key:"genBuffers",value:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},r=0,n=0,i=!1,o=[],a=[],s=[],l=[],u=[],c=[],h=this;return e.vertexIndices.forEach((function(p,f){var d,m,v,y,g=!1,b=(p<0&&(p^=-1,g=!0),[]),x=[];if(o.push(3*p,3*p+1,3*p+2),e.color&&(y=_c(f,r,p,e.color),s.push(y[0],y[1],y[2])),e.skeleton){for(void 0!==e.weightTable[p]&&e.weightTable[p].forEach((function(e){x.push(e.weight),b.push(e.id)})),4<x.length&&(i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0),m=[0,0,0,0],v=[0,0,0,0],x.forEach((function(e,t){var r=e,n=b[t];v.forEach((function(e,t,i){e<r&&(i[t]=r,r=e,i=m[t],m[t]=n,n=i)}))})),b=m,x=v);x.length<4;)x.push(0),b.push(0);for(var w=0;w<4;++w)u.push(x[w]),c.push(b[w])}e.normal&&(y=_c(f,r,p,e.normal),a.push(y[0],y[1],y[2])),e.material&&"AllSame"!==e.material.mappingType&&(d=_c(f,r,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=_c(f,r,p,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),n++,g&&(h.genFace(t,e,o,d,a,s,l,u,c,n),r++,n=0,o=[],a=[],s=[],l=[],u=[],c=[])})),t}},{key:"genFace",value:function(e,t,r,n,i,o,a,s,l,u){for(var c=2;c<u;c++)!function(u){e.vertex.push(t.vertexPositions[r[0]]),e.vertex.push(t.vertexPositions[r[1]]),e.vertex.push(t.vertexPositions[r[2]]),e.vertex.push(t.vertexPositions[r[3*(u-1)]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[r[3*u]]),e.vertex.push(t.vertexPositions[r[3*u+1]]),e.vertex.push(t.vertexPositions[r[3*u+2]]),t.skeleton&&(e.vertexWeights.push(s[0]),e.vertexWeights.push(s[1]),e.vertexWeights.push(s[2]),e.vertexWeights.push(s[3]),e.vertexWeights.push(s[4*(u-1)]),e.vertexWeights.push(s[4*(u-1)+1]),e.vertexWeights.push(s[4*(u-1)+2]),e.vertexWeights.push(s[4*(u-1)+3]),e.vertexWeights.push(s[4*u]),e.vertexWeights.push(s[4*u+1]),e.vertexWeights.push(s[4*u+2]),e.vertexWeights.push(s[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[3*(u-1)]),e.colors.push(o[3*(u-1)+1]),e.colors.push(o[3*(u-1)+2]),e.colors.push(o[3*u]),e.colors.push(o[3*u+1]),e.colors.push(o[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(u-1)]),e.normal.push(i[3*(u-1)+1]),e.normal.push(i[3*(u-1)+2]),e.normal.push(i[3*u]),e.normal.push(i[3*u+1]),e.normal.push(i[3*u+2])),t.uv&&t.uv.forEach((function(t,r){void 0===e.uvs[r]&&(e.uvs[r]=[]),e.uvs[r].push(a[r][0]),e.uvs[r].push(a[r][1]),e.uvs[r].push(a[r][2*(u-1)]),e.uvs[r].push(a[r][2*(u-1)+1]),e.uvs[r].push(a[r][2*u]),e.uvs[r].push(a[r][2*u+1])}))}(c)}},{key:"addMorphTargets",value:function(e,t,r,n){var i;0!==r.length&&(e.morphTargetsRelative=!0,e.morphAttributes.position=[],i=this,r.forEach((function(r){r.rawTargets.forEach((function(r){var o=nc.Objects.Geometry[r.geoID];void 0!==o&&i.genMorphGeometry(e,t,o,n,r.name)}))})))}},{key:"genMorphGeometry",value:function(e,t,r,n,i){t=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[];for(var o=void 0!==r.Vertices?r.Vertices.a:[],a=void 0!==r.Indexes?r.Indexes.a:[],s=3*e.attributes.position.count,l=new Float32Array(s),u=0;u<a.length;u++){var h=3*a[u];l[h]=o[3*u],l[1+h]=o[3*u+1],l[2+h]=o[3*u+2]}s=this.genBuffers({vertexIndices:t,vertexPositions:l}),(t=new c.Float32BufferAttribute(s.vertex,3)).name=i||r.attrName,t.applyMatrix4(n),e.morphAttributes.position.push(t)}},{key:"parseNormals",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=e.Normals.a,i=[];return"IndexToDirect"===r&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:i,mappingType:t,referenceType:r}}},{key:"parseUVs",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=[];return{dataSize:2,buffer:e.UV.a,indices:n="IndexToDirect"===r?e.UVIndex.a:n,mappingType:t,referenceType:r}}},{key:"parseVertexColors",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,n=[];return{dataSize:4,buffer:e.Colors.a,indices:n="IndexToDirect"===r?e.ColorIndex.a:n,mappingType:t,referenceType:r}}},{key:"parseMaterialIndices",value:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};for(var n=e.Materials.a,i=[],o=0;o<n.length;++o)i.push(o);return{dataSize:1,buffer:n,indices:i,mappingType:t,referenceType:r}}},{key:"parseNurbsGeometry",value:function(e){if(void 0===ac)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 c.BufferGeometry;var t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;for(var r=t-1,n=(t=e.KnotVector.a,[]),i=e.Points.a,o=0,a=i.length;o<a;o+=4)n.push((new c.Vector4).fromArray(i,o));if("Closed"===e.Form)n.push(n[0]);else if("Periodic"===e.Form)for(var s=r,l=t.length-1-s,u=0;u<r;++u)n.push(n[u]);return e=new ac(r,t,n,s,l).getPoints(12*n.length),(new c.BufferGeometry).setFromPoints(e)}}]),e}(),vc=function(){function e(){lc(this,e)}return cc(e,[{key:"parse",value:function(){var e=[],t=this.parseClips();if(void 0!==t)for(var r in t)r=t[r],r=this.addClip(r),e.push(r);return e}},{key:"parseClips",value:function(){var e;if(void 0!==nc.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}},{key:"parseAnimationCurveNodes",value:function(){var e,t=nc.Objects.AnimationCurveNode,r=new Map;for(e in t){var n=t[e];null!==n.attrName.match(/S|R|T|DeformPercent/)&&(n={id:n.id,attr:n.attrName,curves:{}},r.set(n.id,n))}return r}},{key:"parseAnimationCurves",value:function(e){var t,r=nc.Objects.AnimationCurve;for(t in r){var n,i={id:r[t].id,times:r[t].KeyTime.a.map(Sc),values:r[t].KeyValueFloat.a},o=ic.get(i.id);void 0!==o&&(n=o.parents[0].ID,(o=o.parents[0].relationship).match(/X/)?e.get(n).curves.x=i:o.match(/Y/)?e.get(n).curves.y=i:o.match(/Z/)?e.get(n).curves.z=i:o.match(/d|DeformPercent/)&&e.has(n)&&(e.get(n).curves.morph=i))}}},{key:"parseAnimationLayers",value:function(e){var t,r=nc.Objects.AnimationLayer,n=new Map;for(t in r)!function(t){var r=[],i=ic.get(parseInt(t));void 0!==i&&(i.children.forEach((function(t,n){if(e.has(t.ID)){var i=e.get(t.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===r[n]){var o=ic.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==o){var a=nc.Objects.Model[o.toString()];if(void 0===a)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",t);var s={modelName:a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",ID:a.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};oc.traverse((function(e){e.ID===a.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new c.Matrix4),"PreRotation"in a&&(s.preRotation=a.PreRotation.value),"PostRotation"in a&&(s.postRotation=a.PostRotation.value),r[n]=s}}r[n]&&(r[n][i.attr]=i)}else void 0!==i.curves.morph&&(void 0===r[n]&&(o=ic.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,t=ic.get(o).parents[0].ID,t=ic.get(t).parents[0].ID,t=ic.get(t).parents[0].ID,t={modelName:(t=nc.Objects.Model[t]).attrName?c.PropertyBinding.sanitizeNodeName(t.attrName):"",morphName:nc.Objects.Deformer[o].attrName},r[n]=t),r[n][i.attr]=i)}})),n.set(parseInt(t),r))}(t);return n}},{key:"parseAnimStacks",value:function(e){var t,r=nc.Objects.AnimationStack,n={};for(t in r){var i=(1<(i=ic.get(parseInt(t)).children).length&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers."),e.get(i[0].ID));n[t]={name:r[t].attrName,layer:i}}return n}},{key:"addClip",value:function(e){var t=[],r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new c.AnimationClip(e.name,-1,t)}},{key:"generateTracks",value:function(e){var t=[],r=new c.Vector3,n=new c.Quaternion,i=new c.Vector3;return e.transform&&e.transform.decompose(r,n,i),r=r.toArray(),n=(new c.Euler).setFromQuaternion(n,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&0<Object.keys(e.T.curves).length&&void 0!==(r=this.generateVectorTrack(e.modelName,e.T.curves,r,"position"))&&t.push(r),void 0!==e.R&&0<Object.keys(e.R.curves).length&&void 0!==(r=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder))&&t.push(r),void 0!==e.S&&0<Object.keys(e.S.curves).length&&void 0!==(n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale"))&&t.push(n),void 0!==e.DeformPercent&&void 0!==(r=this.generateMorphTrack(e))&&t.push(r),t}},{key:"generateVectorTrack",value:function(e,t,r,n){var i=this.getTimesForAllAxes(t);return t=this.getKeyframeTrackValues(i,t,r),new c.VectorKeyframeTrack(e+"."+n,i,t)}},{key:"generateRotationTrack",value:function(e,t,r,n,i,o){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));for(var a=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(a,t,r),l=(void 0!==n&&((n=n.map(c.MathUtils.degToRad)).push(o),n=(new c.Euler).fromArray(n),n=(new c.Quaternion).setFromEuler(n)),void 0!==i&&((i=i.map(c.MathUtils.degToRad)).push(o),i=(new c.Euler).fromArray(i),i=(new c.Quaternion).setFromEuler(i).invert()),new c.Quaternion),u=new c.Euler,h=[],p=0;p<s.length;p+=3)u.set(s[p],s[p+1],s[p+2],o),l.setFromEuler(u),void 0!==n&&l.premultiply(n),void 0!==i&&l.multiply(i),l.toArray(h,p/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",a,h)}},{key:"generateMorphTrack",value:function(e){var t=e.DeformPercent.curves.morph,r=t.values.map((function(e){return e/100})),n=oc.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+n+"]",t.times,r)}},{key:"getTimesForAllAxes",value:function(e){var t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),1<(t=(t=void 0!==e.z?t.concat(e.z.times):t).sort((function(e,t){return e-t}))).length){for(var r=1,n=t[0],i=1;i<t.length;i++){var o=t[i];o!==n&&(n=t[r]=o,r++)}t=t.slice(0,r)}return t}},{key:"getKeyframeTrackValues",value:function(e,t,r){var n=r,i=[],o=-1,a=-1,s=-1;return e.forEach((function(e){t.x&&(o=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),-1!==o?(e=t.x.values[o],i.push(e),n[0]=e):i.push(n[0]),-1!==a?(e=t.y.values[a],i.push(e),n[1]=e):i.push(n[1]),-1!==s?(e=t.z.values[s],i.push(e),n[2]=e):i.push(n[2])})),i}},{key:"interpolateRotations",value:function(e){for(var t=1;t<e.values.length;t++){var r=e.values[t-1],n=e.values[t]-r;if(180<=(i=Math.abs(n))){for(var i,o=n/(i/=180),a=r+o,s=(n=e.times[t-1],(e.times[t]-n)/i),l=n+s,u=[],c=[];l<e.times[t];)u.push(l),l+=s,c.push(a),a+=o;e.times=Ac(e.times,t,u),e.values=Ac(e.values,t,c)}}}}]),e}(),yc=function(){function e(){lc(this,e)}return cc(e,[{key:"getPrevNode",value:function(){return this.nodeStack[this.currentIndent-2]}},{key:"getCurrentNode",value:function(){return this.nodeStack[this.currentIndent-1]}},{key:"getCurrentProp",value:function(){return this.currentProp}},{key:"pushStack",value:function(e){this.nodeStack.push(e),this.currentIndent+=1}},{key:"popStack",value:function(){this.nodeStack.pop(),--this.currentIndent}},{key:"setCurrentProp",value:function(e,t){this.currentProp=e,this.currentPropName=t}},{key:"parse",value:function(e){this.currentIndent=0,this.allNodes=new xc,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var t=this,r=e.split(/[\r\n]+/);return r.forEach((function(e,n){var i,o=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);o||a||(o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),i=e.match("^\\t{"+(t.currentIndent-1)+"}}"),o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,r[++n]):i?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e))})),this.allNodes}},{key:"parseNodeBegin",value:function(e,t){var r=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=(t=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),{name:r}),i=(t=this.parseNodeAttr(t),this.getCurrentNode());0===this.currentIndent?this.allNodes.add(r,n):r in i?("PoseNode"===r?i.PoseNode.push(n):void 0!==i[r].id&&(i[r]={},i[r][i[r].id]=i[r]),""!==t.id&&(i[r][t.id]=n)):"number"==typeof t.id?(i[r]={},i[r][t.id]=n):"Properties70"!==r&&(i[r]="PoseNode"===r?[n]:n),"number"==typeof t.id&&(n.id=t.id),""!==t.name&&(n.attrName=t.name),""!==t.type&&(n.attrType=t.type),this.pushStack(n)}},{key:"parseNodeAttr",value:function(e){var t=e[0],r=(""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0])),""),n="";return 1<e.length&&(r=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:r,type:n}}},{key:"parseNodeProperty",value:function(e,t,r){var n=t[1].replace(/^"/,"").replace(/"$/,"").trim();if(t=t[2].replace(/^"/,"").replace(/"$/,"").trim(),"Properties70"===("Content"===n&&","===t&&(t=r.replace(/"/g,"").replace(/,$/,"").trim()),r=this.getCurrentNode()).name)this.parseNodeSpecialProperty(e,n,t);else{if("C"===n){e=t.split(",").slice(1);for(var i=parseInt(e[0]),o=(e=parseInt(e[1]),(o=t.split(",").slice(3)).map((function(e){return e.trim().replace(/^"/,"")}))),a=(n="connections",t=[i,e]),s=o,l=0,u=a.length,c=s.length;l<c;l++,u++)a[u]=s[l];void 0===r[n]&&(r[n]=[])}"Node"===n&&(r.id=t),n in r&&Array.isArray(r[n])?r[n].push(t):"a"!==n?r[n]=t:r.a=t,this.setCurrentProp(r,n),"a"===n&&","!==t.slice(-1)&&(r.a=Rc(t))}}},{key:"parseNodePropertyContinued",value:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=Rc(t.a))}},{key:"parseNodeSpecialProperty",value:function(e,t,r){r=r.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}));var n=r[0],i=r[1],o=r[2],a=r[3],s=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":s=parseFloat(s);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":s=Rc(s)}this.getPrevNode()[n]={type:i,type2:o,flag:a,value:s},this.setCurrentProp(this.getPrevNode(),n)}}]),e}(),gc=function(){function e(){lc(this,e)}return cc(e,[{key:"parse",value:function(e){var t=new bc(e),r=(t.skip(23),t.getUint32());if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);for(var n=new xc;!this.endOfContent(t);){var i=this.parseNode(t,r);null!==i&&n.add(i.name,i)}return n}},{key:"endOfContent",value:function(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}},{key:"parseNode",value:function(e,t){var r={},n=7500<=t?e.getUint64():e.getUint32(),i=7500<=t?e.getUint64():e.getUint32(),o=(7500<=t?e.getUint64():e.getUint32(),e.getUint8()),a=e.getString(o);if(0===n)return null;for(var s=[],l=0;l<i;l++)s.push(this.parseProperty(e));o=0<s.length?s[0]:"";var u=1<s.length?s[1]:"",c=2<s.length?s[2]:"";for(r.singleProperty=1===i&&e.getOffset()===n;n>e.getOffset();){var h=this.parseNode(e,t);null!==h&&this.parseSubNode(a,r,h)}return r.propertyList=s,"number"==typeof o&&(r.id=o),""!==u&&(r.attrName=u),""!==c&&(r.attrType=c),""!==a&&(r.name=a),r}},{key:"parseSubNode",value:function(e,t,r){var n,i,o,a,s;!0===r.singleProperty?(i=r.propertyList[0],Array.isArray(i)?(t[r.name]=r).a=i:t[r.name]=i):"Connections"===e&&"C"===r.name?(n=[],r.propertyList.forEach((function(e,t){0!==t&&n.push(e)})),void 0===t.connections&&(t.connections=[]),t.connections.push(n)):"Properties70"===r.name?Object.keys(r).forEach((function(e){t[e]=r[e]})):"Properties70"===e&&"P"===r.name?(i=r.propertyList[0],e=r.propertyList[1],o=r.propertyList[2],a=r.propertyList[3],0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),s="Color"===(e=0===e.indexOf("Lcl ")?e.replace("Lcl ","Lcl_"):e)||"ColorRGB"===e||"Vector"===e||"Vector3D"===e||0===e.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[i]={type:e,type2:o,flag:a,value:s}):void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)}},{key:"parseProperty",value:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var r=e.getUint32(),n=e.getUint32(),o=e.getUint32();if(0===n)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}void 0===i&&console.error("THREE.FBXLoader: External library fflate.min.js required."),n=Tu(new Uint8Array(e.getArrayBuffer(o)));var a=new bc(n.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}]),e}(),bc=function(){function e(t,r){lc(this,e),this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===r||r}return cc(e,[{key:"getOffset",value:function(){return this.offset}},{key:"size",value:function(){return this.dv.buffer.byteLength}},{key:"skip",value:function(e){this.offset+=e}},{key:"getBoolean",value:function(){return 1==(1&this.getUint8())}},{key:"getBooleanArray",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getBoolean());return t}},{key:"getUint8",value:function(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e}},{key:"getInt16",value:function(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}},{key:"getInt32",value:function(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getInt32Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getInt32());return t}},{key:"getUint32",value:function(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getInt64",value:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,-(4294967296*(t=4294967295==(e=4294967295&~e)?t+1&4294967295:t)+(e=e+1&4294967295))):4294967296*t+e}},{key:"getInt64Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getInt64());return t}},{key:"getUint64",value:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}},{key:"getFloat32",value:function(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}},{key:"getFloat32Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getFloat32());return t}},{key:"getFloat64",value:function(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}},{key:"getFloat64Array",value:function(e){for(var t=[],r=0;r<e;r++)t.push(this.getFloat64());return t}},{key:"getArrayBuffer",value:function(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}},{key:"getString",value:function(e){for(var t=[],r=0;r<e;r++)t[r]=this.getUint8();var n=t.indexOf(0);return 0<=n&&(t=t.slice(0,n)),c.LoaderUtils.decodeText(new Uint8Array(t))}}]),e}(),xc=function(){function e(){lc(this,e)}return cc(e,[{key:"add",value:function(e,t){this[e]=t}}]),e}();function wc(e){if(e=e.match(/FBXVersion: (\d+)/))return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Sc(e){return e/46186158e3}var Tc=[];function _c(e,t,r,n){var i;switch(n.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=r;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}for(var o=(i="IndexToDirect"===n.referenceType?n.indices[i]:i)*n.dataSize,a=o+n.dataSize,s=Tc,l=n.buffer,u=a,c=o,h=0;c<u;c++,h++)s[h]=l[c];return s}var Mc=new c.Euler,Ec=new c.Vector3;function Pc(e){var t=new c.Matrix4,r=new c.Matrix4,n=new c.Matrix4,i=new c.Matrix4,o=new c.Matrix4,a=new c.Matrix4,s=new c.Matrix4,l=new c.Matrix4,u=new c.Matrix4,h=new c.Matrix4,p=new c.Matrix4,f=new c.Matrix4,d=e.inheritType||0,m=(e.translation&&t.setPosition(Ec.fromArray(e.translation)),e.preRotation&&((m=e.preRotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),r.makeRotationFromEuler(Mc.fromArray(m))),e.rotation&&((m=e.rotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),n.makeRotationFromEuler(Mc.fromArray(m))),e.postRotation&&((m=e.postRotation.map(c.MathUtils.degToRad)).push(e.eulerOrder),i.makeRotationFromEuler(Mc.fromArray(m)),i.invert()),e.scale&&o.scale(Ec.fromArray(e.scale)),e.scalingOffset&&s.setPosition(Ec.fromArray(e.scalingOffset)),e.scalingPivot&&a.setPosition(Ec.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(Ec.fromArray(e.rotationOffset)),e.rotationPivot&&u.setPosition(Ec.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),h.copy(e.parentMatrixWorld)),r.clone().multiply(n).multiply(i)),v=(((e=new c.Matrix4).extractRotation(h),v=new c.Matrix4).copyPosition(h),v.clone().invert().multiply(h)),y=(v=e.clone().invert().multiply(v),o),g=new c.Matrix4;return 0===d?g.copy(e).multiply(m).multiply(v).multiply(y):1===d?g.copy(e).multiply(v).multiply(m).multiply(y):(d=(new c.Matrix4).scale((new c.Vector3).setFromMatrixScale(p)).clone().invert(),p=v.clone().multiply(d),g.copy(e).multiply(m).multiply(p).multiply(y)),v=u.clone().invert(),d=a.clone().invert(),e=t.clone().multiply(l).multiply(u).multiply(r).multiply(n).multiply(i).multiply(v).multiply(s).multiply(a).multiply(o).multiply(d),m=(new c.Matrix4).copyPosition(e),p=h.clone().multiply(m),f.copyPosition(p),(e=f.clone().multiply(g)).premultiply(h.invert()),e}function Oc(e){var t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function Rc(e){return e.split(",").map((function(e){return parseFloat(e)}))}function kc(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),c.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function Ac(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}function Cc(e){return(Cc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Lc(e,t){return(Lc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Dc(e){return(Dc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ic=/^[og]\s*(.+)?/,jc=/^mtllib /,Uc=/^usemtl /,Bc=/^usemap /,zc=new c.Vector3,Nc=new c.Vector3,Fc=new c.Vector3,Vc=new c.Vector3,Hc=new c.Vector3,Gc=new c.Color;function Wc(){var e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);return r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1),e={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&0<t.length?t[t.length-1]:"",smooth:(void 0!==r?r:this).smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){return(e={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1}).clone=this.clone.bind(e),e}},this.materials.push(e),e},currentMaterial:function(){if(0<this.materials.length)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&1<this.materials.length)for(var r=this.materials.length-1;0<=r;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone&&((e=r.clone(0)).inherited=!0,this.object.materials.push(e)),this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){return 3*(0<=(e=parseInt(e,10))?e-1:e+t/3)},parseNormalIndex:function(e,t){return 3*(0<=(e=parseInt(e,10))?e-1:e+t/3)},parseUVIndex:function(e,t){return 2*(0<=(e=parseInt(e,10))?e-1:e+t/2)},addVertex:function(e,t,r){var n=this.vertices,i=this.object.geometry.vertices;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[r+0],n[r+1],n[r+2])},addVertexPoint:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,r){var n=this.normals,i=this.object.geometry.normals;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[r+0],n[r+1],n[r+2])},addFaceNormal:function(e,t,r){var n=this.vertices,i=this.object.geometry.normals;zc.fromArray(n,e),Nc.fromArray(n,t),Fc.fromArray(n,r),Hc.subVectors(Fc,Nc),Vc.subVectors(zc,Nc),Hc.cross(Vc),Hc.normalize(),i.push(Hc.x,Hc.y,Hc.z),i.push(Hc.x,Hc.y,Hc.z),i.push(Hc.x,Hc.y,Hc.z)},addColor:function(e,t,r){var n=this.colors,i=this.object.geometry.colors;void 0!==n[e]&&i.push(n[e+0],n[e+1],n[e+2]),void 0!==n[t]&&i.push(n[t+0],n[t+1],n[t+2]),void 0!==n[r]&&i.push(n[r+0],n[r+1],n[r+2])},addUV:function(e,t,r){var n=this.uvs,i=this.object.geometry.uvs;i.push(n[e+0],n[e+1]),i.push(n[t+0],n[t+1]),i.push(n[r+0],n[r+1])},addDefaultUV:function(){var e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){var t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,r,n,i,o,a,s,l){var u=this.vertices.length;e=this.parseVertexIndex(e,u),t=this.parseVertexIndex(t,u),r=this.parseVertexIndex(r,u),this.addVertex(e,t,r),this.addColor(e,t,r),void 0!==a&&""!==a?(u=this.normals.length,e=this.parseNormalIndex(a,u),t=this.parseNormalIndex(s,u),r=this.parseNormalIndex(l,u),this.addNormal(e,t,r)):this.addFaceNormal(e,t,r),void 0!==n&&""!==n?(a=this.uvs.length,e=this.parseUVIndex(n,a),t=this.parseUVIndex(i,a),r=this.parseUVIndex(o,a),this.addUV(e,t,r),this.object.geometry.hasUVIndices=!0):this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";for(var t=this.vertices.length,r=0,n=e.length;r<n;r++){var i=this.parseVertexIndex(e[r],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,n=this.uvs.length,i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],r));for(var a=0,s=t.length;a<s;a++)this.addUVLine(this.parseUVIndex(t[a],n))}};return e.startObject("",!1),e}var Xc=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Lc(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Dc(e);if(r=t?(r=Dc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Cc(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return(e=r.call(this,e)).materials=null,e;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"load",value:function(e,t,r,n){var i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(r){try{t(i.parse(r))}catch(r){n?n(r):console.error(r),i.manager.itemError(e)}}),r,n)}},{key:"setMaterials",value:function(e){return this.materials=e,this}},{key:"parse",value:function(e){for(var t,r,n,i=new Wc,o=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n"),a="",s=[],l="function"==typeof"".trimLeft,u=0,h=o.length;u<h;u++)if(a=o[u],0!==(a=l?a.trimLeft():a.trim()).length&&"#"!==(t=a.charAt(0)))if("v"===t){var p=a.split(/\s+/);switch(p[0]){case"v":i.vertices.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),7<=p.length?(Gc.setRGB(parseFloat(p[4]),parseFloat(p[5]),parseFloat(p[6])).convertSRGBToLinear(),i.colors.push(Gc.r,Gc.g,Gc.b)):i.colors.push(void 0,void 0,void 0);break;case"vn":i.normals.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));break;case"vt":i.uvs.push(parseFloat(p[1]),parseFloat(p[2]))}}else if("f"===t){for(var f=a.slice(1).trim().split(/\s+/),d=[],m=0,v=f.length;m<v;m++){var y=f[m];0<y.length&&(y=y.split("/"),d.push(y))}for(var g=d[0],b=1,x=d.length-1;b<x;b++){var w=d[b],S=d[b+1];i.addFace(g[0],w[0],S[0],g[1],w[1],S[1],g[2],w[2],S[2])}}else if("l"===t){var T=a.substring(1).trim().split(" "),_=[],M=[];if(-1===a.indexOf("/"))_=T;else for(var E=0,P=T.length;E<P;E++){var O=T[E].split("/");""!==O[0]&&_.push(O[0]),""!==O[1]&&M.push(O[1])}i.addLineGeometry(_,M)}else"p"===t?(r=a.slice(1).trim().split(" "),i.addPointGeometry(r)):null!==(s=Ic.exec(a))?(r=(" "+s[0].slice(1).trim()).slice(1),i.startObject(r)):Uc.test(a)?i.object.startMaterial(a.substring(7).trim(),i.materialLibraries):jc.test(a)?i.materialLibraries.push(a.substring(7).trim()):Bc.test(a)?console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.'):"s"===t?(1<(s=a.split(" ")).length?(n=s[1].trim().toLowerCase(),i.object.smooth="0"!==n&&"off"!==n):i.object.smooth=!0,(n=i.object.currentMaterial())&&(n.smooth=i.object.smooth)):"\0"!==a&&console.warn('THREE.OBJLoader: Unexpected line: "'+a+'"');i.finalize();var R,k=new c.Group;if(1==(k.materialLibraries=[].concat(i.materialLibraries),e=!(1===i.objects.length&&0===i.objects[0].geometry.vertices.length)))for(var A=0,C=i.objects.length;A<C;A++){var L=i.objects[A],D=L.geometry,I=L.materials,j="Line"===D.type,U="Points"===D.type,B=!1;if(0!==D.vertices.length){for(var z=new c.BufferGeometry,N=(z.setAttribute("position",new c.Float32BufferAttribute(D.vertices,3)),0<D.normals.length&&z.setAttribute("normal",new c.Float32BufferAttribute(D.normals,3)),0<D.colors.length&&(B=!0,z.setAttribute("color",new c.Float32BufferAttribute(D.colors,3))),!0===D.hasUVIndices&&z.setAttribute("uv",new c.Float32BufferAttribute(D.uvs,2)),[]),F=0,V=I.length;F<V;F++){var H,G=I[F],W=G.name+"_"+G.smooth+"_"+B,X=i.materials[W];null!==this.materials&&(X=this.materials.create(G.name),!j||!X||X instanceof c.LineBasicMaterial?!U||!X||X instanceof c.PointsMaterial||(H=new c.PointsMaterial({size:10,sizeAttenuation:!1}),c.Material.prototype.copy.call(H,X),H.color.copy(X.color),H.map=X.map,X=H):(H=new c.LineBasicMaterial,c.Material.prototype.copy.call(H,X),H.color.copy(X.color),X=H)),void 0===X&&((X=j?new c.LineBasicMaterial:U?new c.PointsMaterial({size:1,sizeAttenuation:!1}):new c.MeshPhongMaterial).name=G.name,X.flatShading=!G.smooth,X.vertexColors=B,i.materials[W]=X),N.push(X)}if(D=void 0,1<N.length){for(var q=0,Y=I.length;q<Y;q++){var Z=I[q];z.addGroup(Z.groupStart,Z.groupCount,q)}D=new(j?c.LineSegments:U?c.Points:c.Mesh)(z,N)}else D=new(j?c.LineSegments:U?c.Points:c.Mesh)(z,N[0]);D.name=L.name,k.add(D)}}else 0<i.vertices.length&&(e=new c.PointsMaterial({size:1,sizeAttenuation:!1}),(R=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute(i.vertices,3)),0<i.colors.length&&void 0!==i.colors[0]&&(R.setAttribute("color",new c.Float32BufferAttribute(i.colors,3)),e.vertexColors=!0),R=new c.Points(R,e),k.add(R));return k}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Loader),qc=function(e,t,r,n){return new(r=r||Promise)((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};class Yc{constructor(e){this.parses={fbx:new fc,obj:new Xc,object:new c.ObjectLoader},this.runScene=e}getBack(e){return e.name.substring(e.name.lastIndexOf(".")+1).toLowerCase()}parse(e){if(e instanceof Array)return e.map((e=>this.parse(e)));if(-1!==e.type.indexOf("image"))return this.img(e);let t;switch(this.getBack(e).toLowerCase()){case"gltf":case"glb":t=this.glb(e);break;case"fbx":t=this.fbx(e);break;case"obj":t=this.obj(e);break;case"json":t=this.json(e)}return t}img(e){console.log(e,"file")}glb(e){return qc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"arrayBuffer");return this.runScene.loaderer.gltf.parse(t)}))}fbx(e){return qc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"arrayBuffer");const r=this.parses.fbx.parse(t,"");r.traverse((e=>{e.material&&(e.material=this.runScene.materialEx.create())})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}obj(e){return qc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"text");const r=this.parses.obj.parse(t);r.traverse((e=>{e.material&&(e.material=this.runScene.materialEx.create())})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}json(e){return qc(this,void 0,void 0,(function*(){var t=yield(0,Ye.toResult)(e,"text");const r=yield this.parses.object.parseAsync(JSON.parse(t));r.traverse((e=>{this.runScene.uniqueEx.material.add(e.material)})),this.runScene.modelEx.add(this.runScene.sceneEx.cleanUnlessLevel(r))}))}}function Zc(e){return(Zc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Qc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Kc(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Jc(e,t,r){t&&Kc(e.prototype,t),r&&Kc(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function $c(){return($c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ih(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function eh(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&th(e,t)}function th(e,t){return(th=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function rh(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ih(e);if(r=t?(r=ih(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Zc(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return nh(n)}}function nh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ih(e){return(ih=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var oh=new c.Raycaster,ah=new c.Vector3,sh=new c.Vector3,lh=new c.Quaternion,uh={X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)},ch={type:"change"},hh={type:"mouseDown"},ph={type:"mouseUp",mode:null},fh={type:"objectChange"};function dh(e,t,r){for(var n=t.intersectObject(e,!0),i=0;i<n.length;i++)if(n[i].object.visible||r)return n[i];return!1}xs=function(){eh(t,c.Object3D);var e=rh(t);function t(r,n){Qc(this,t),i=e.call(this),void 0===n&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),n=document),i.visible=!1,i.domElement=n,i.domElement.style.touchAction="none";var i,o=new Rh,a=(i._gizmo=o,i.add(o),new kh),s=(i._plane=a,i.add(a),nh(i));function l(e,t){var r=t;Object.defineProperty(s,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,a[e]=t,o[e]=t,s.dispatchEvent({type:e+"-changed",value:t}),s.dispatchEvent(ch))}}),s[e]=t,a[e]=t,o[e]=t}l("camera",r),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),n=new c.Vector3,r=new c.Vector3;var u=new c.Quaternion,h=new c.Quaternion,p=new c.Vector3,f=new c.Quaternion,d=new c.Vector3,m=new c.Vector3,v=new c.Vector3,y=new c.Vector3;return l("worldPosition",n),l("worldPositionStart",r),l("worldQuaternion",u),l("worldQuaternionStart",h),l("cameraPosition",p),l("cameraQuaternion",f),l("pointStart",d),l("pointEnd",m),l("rotationAxis",v),l("rotationAngle",0),l("eye",y),i._offset=new c.Vector3,i._startNorm=new c.Vector3,i._endNorm=new c.Vector3,i._cameraScale=new c.Vector3,i._parentPosition=new c.Vector3,i._parentQuaternion=new c.Quaternion,i._parentQuaternionInv=new c.Quaternion,i._parentScale=new c.Vector3,i._worldScaleStart=new c.Vector3,i._worldQuaternionInv=new c.Quaternion,i._worldScale=new c.Vector3,i._positionStart=new c.Vector3,i._quaternionStart=new c.Quaternion,i._scaleStart=new c.Vector3,i._getPointer=function(e){var t;return this.domElement.ownerDocument.pointerLockElement?{x:0,y:0,button:e.button}:(t=this.domElement.getBoundingClientRect(),{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button})}.bind(nh(i)),i._onPointerDown=function(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}.bind(nh(i)),i._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(nh(i)),i._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(nh(i)),i._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(nh(i)),i.domElement.addEventListener("pointerdown",i._onPointerDown),i.domElement.addEventListener("pointermove",i._onPointerHover),i.domElement.addEventListener("pointerup",i._onPointerUp),i}return Jc(t,[{key:"updateMatrixWorld",value:function(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),$c(ih(t.prototype),"updateMatrixWorld",this).call(this,this)}},{key:"pointerHover",value:function(e){void 0!==this.object&&!0!==this.dragging&&(oh.setFromCamera(e,this.camera),e=dh(this._gizmo.picker[this.mode],oh),this.axis=e?e.object.name:null)}},{key:"pointerDown",value:function(e){void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis&&(oh.setFromCamera(e,this.camera),(e=dh(this._plane,oh,!0))&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,hh.mode=this.mode,this.dispatchEvent(hh))}},{key:"pointerMove",value:function(e){var t=this.axis,r=this.mode,n=this.object,i=this.space;"scale"===r?i="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(i="world"),void 0!==n&&null!==t&&!1!==this.dragging&&-1===e.button&&(oh.setFromCamera(e,this.camera),(e=dh(this._plane,oh,!0))&&(this.pointEnd.copy(e.point).sub(this.worldPositionStart),"translate"===r?(this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===i&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),("local"===i&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart):this._offset.applyQuaternion(this._parentQuaternionInv)).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===i&&(n.position.applyQuaternion(lh.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===i&&(n.parent&&n.position.add(ah.setFromMatrixPosition(n.parent.matrixWorld)),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(ah.setFromMatrixPosition(n.parent.matrixWorld))))):"scale"===r?(-1!==t.search("XYZ")?(e=this.pointEnd.length()/this.pointStart.length(),this.pointEnd.dot(this.pointStart)<0&&(e*=-1),sh.set(e,e,e)):(ah.copy(this.pointStart),sh.copy(this.pointEnd),ah.applyQuaternion(this._worldQuaternionInv),sh.applyQuaternion(this._worldQuaternionInv),sh.divide(ah),-1===t.search("X")&&(sh.x=1),-1===t.search("Y")&&(sh.y=1),-1===t.search("Z")&&(sh.z=1)),n.scale.copy(this._scaleStart).multiply(sh),this.scaleSnap&&(-1!==t.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))):"rotate"===r&&(this._offset.copy(this.pointEnd).sub(this.pointStart),e=20/this.worldPosition.distanceTo(ah.setFromMatrixPosition(this.camera.matrixWorld)),"E"===t?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ah.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(uh[t]),ah.copy(uh[t]),"local"===i&&ah.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(ah.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===i&&"E"!==t&&"XYZE"!==t?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(lh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(lh.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())),this.dispatchEvent(ch),this.dispatchEvent(fh)))}},{key:"pointerUp",value:function(e){0===e.button&&(this.dragging&&null!==this.axis&&(ph.mode=this.mode,this.dispatchEvent(ph)),this.dragging=!1,this.axis=null)}},{key:"dispose",value:function(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}},{key:"attach",value:function(e){return this.object=e,this.visible=!0,this}},{key:"detach",value:function(){return this.object=void 0,this.visible=!1,this.axis=null,this}},{key:"reset",value:function(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ch),this.dispatchEvent(fh),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return oh}},{key:"getMode",value:function(){return this.mode}},{key:"setMode",value:function(e){this.mode=e}},{key:"setTranslationSnap",value:function(e){this.translationSnap=e}},{key:"setRotationSnap",value:function(e){this.rotationSnap=e}},{key:"setScaleSnap",value:function(e){this.scaleSnap=e}},{key:"setSize",value:function(e){this.size=e}},{key:"setSpace",value:function(e){this.space=e}},{key:"update",value:function(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}]),t}(),xs.prototype.isTransformControls=!0;var mh=new c.Euler,vh=new c.Vector3(0,1,0),yh=new c.Vector3(0,0,0),gh=new c.Matrix4,bh=new c.Quaternion,xh=new c.Quaternion,wh=new c.Vector3,Sh=new c.Matrix4,Th=new c.Vector3(1,0,0),_h=new c.Vector3(0,1,0),Mh=new c.Vector3(0,0,1),Eh=new c.Vector3,Ph=new c.Vector3,Oh=new c.Vector3,Rh=function(){eh(t,c.Object3D);var e=rh(t);function t(){Qc(this,t),(r=e.call(this)).type="TransformControlsGizmo";var r,n=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=n.clone(),a=((((o.opacity=.15,i=i.clone()).opacity=.5,x=n.clone()).color.setHex(16711680),w=n.clone()).color.setHex(65280),n.clone()),s=(a.color.setHex(255),n.clone()),l=(s.color.setHex(16711680),s.opacity=.5,n.clone()),u=(l.color.setHex(65280),l.opacity=.5,n.clone()),h=(u.color.setHex(255),u.opacity=.5,n.clone());(h.opacity=.25,g=n.clone()).color.setHex(16776960),g.opacity=.25,n.clone().color.setHex(16776960);var p=(((n=n.clone()).color.setHex(7895160),m=new c.CylinderGeometry(0,.04,.1,12)).translate(0,.05,0),new c.BoxGeometry(.08,.08,.08)),f=(p.translate(0,.04,0),new c.BufferGeometry);function d(e,t){return(e=new c.TorusGeometry(e,.0075,3,64,t*Math.PI*2)).rotateY(Math.PI/2),e.rotateX(Math.PI/2),e}(f.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3)),S=new c.CylinderGeometry(.0075,.0075,.5,3)).translate(0,.25,0);var m={X:[[new c.Mesh(m,x),[.5,0,0],[0,0,-Math.PI/2]],[new c.Mesh(m,x),[-.5,0,0],[0,0,Math.PI/2]],[new c.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(m,w),[0,.5,0]],[new c.Mesh(m,w),[0,-.5,0],[Math.PI,0,0]],[new c.Mesh(S,w)]],Z:[[new c.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new c.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new c.Mesh(S,a),null,[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),h.clone()),[0,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),s.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),o)]],XY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]]},y={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new c.Line(((y=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),y),i),null,null,null,"helper"]],X:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},g=(n={XYZE:[[new c.Mesh(d(.5,1),n),null,[0,Math.PI/2,0]]],X:[[new c.Mesh(d(.5,.5),x)]],Y:[[new c.Mesh(d(.5,.5),w),null,[0,0,-Math.PI/2]]],Z:[[new c.Mesh(d(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new c.Mesh(d(.75,1),g),null,[0,Math.PI/2,0]]]},{AXIS:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]}),b={XYZE:[[new c.Mesh(new c.SphereGeometry(.25,10,8),o)]],X:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(.75,.1,2,24),o)]]},x={X:[[new c.Mesh(p,x),[.5,0,0],[0,0,-Math.PI/2]],[new c.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]],[new c.Mesh(p,x),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(p,w),[0,.5,0]],[new c.Mesh(S,w)],[new c.Mesh(p,w),[0,-.5,0],[0,0,Math.PI]]],Z:[[new c.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new c.Mesh(S,a),[0,0,0],[Math.PI/2,0,0]],[new c.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.BoxGeometry(.1,.1,.1),h.clone())]]},w={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new c.Mesh(new c.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),o),[0,0,0]]]},S={X:[[new c.Line(f,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(f,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(f,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(e){var t,r=new c.Object3D;for(t in e)for(var n=e[t].length;n--;){var i=e[t][n][0].clone(),o=e[t][n][1],a=e[t][n][2],s=e[t][n][3],l=e[t][n][4];(i.name=t,i.tag=l,o&&i.position.set(o[0],o[1],o[2]),a&&i.rotation.set(a[0],a[1],a[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix(),l=i.geometry.clone()).applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),r.add(i)}return r}return r.gizmo={},r.picker={},r.helper={},r.add(r.gizmo.translate=T(m)),r.add(r.gizmo.rotate=T(n)),r.add(r.gizmo.scale=T(x)),r.add(r.picker.translate=T(v)),r.add(r.picker.rotate=T(b)),r.add(r.picker.scale=T(w)),r.add(r.helper.translate=T(y)),r.add(r.helper.rotate=T(g)),r.add(r.helper.scale=T(S)),r.picker.translate.visible=!1,r.picker.rotate.visible=!1,r.picker.scale.visible=!1,r}return Jc(t,[{key:"updateMatrixWorld",value:function(e){var r=this,n="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:xh,i=(this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode,[]);i=(i=(i=i.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(var o=0;o<i.length;o++)!function(e){var t=i[e];if(t.visible=!0,t.rotation.set(0,0,0),e=void t.position.copy(r.worldPosition),e=r.camera.isOrthographicCamera?(r.camera.top-r.camera.bottom)/r.camera.zoom:r.worldPosition.distanceTo(r.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*r.camera.fov/360)/r.camera.zoom,7),t.scale.set(1,1,1).multiplyScalar(e*r.size/4),"helper"===t.tag)return t.visible=!1,"AXIS"===t.name?(t.position.copy(r.worldPositionStart),t.visible=!!r.axis,"X"===r.axis&&(lh.setFromEuler(mh.set(0,0,0)),t.quaternion.copy(n).multiply(lh),.9<Math.abs(vh.copy(Th).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Y"===r.axis&&(lh.setFromEuler(mh.set(0,0,Math.PI/2)),t.quaternion.copy(n).multiply(lh),.9<Math.abs(vh.copy(_h).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Z"===r.axis&&(lh.setFromEuler(mh.set(0,Math.PI/2,0)),t.quaternion.copy(n).multiply(lh),.9<Math.abs(vh.copy(Mh).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"XYZE"===r.axis&&(lh.setFromEuler(mh.set(0,Math.PI/2,0)),vh.copy(r.rotationAxis),t.quaternion.setFromRotationMatrix(gh.lookAt(yh,vh,_h)),t.quaternion.multiply(lh),t.visible=r.dragging),"E"===r.axis&&(t.visible=!1)):"START"===t.name?(t.position.copy(r.worldPositionStart),t.visible=r.dragging):"END"===t.name?(t.position.copy(r.worldPosition),t.visible=r.dragging):"DELTA"===t.name?(t.position.copy(r.worldPositionStart),t.quaternion.copy(r.worldQuaternionStart),ah.set(1e-10,1e-10,1e-10).add(r.worldPositionStart).sub(r.worldPosition).multiplyScalar(-1),ah.applyQuaternion(r.worldQuaternionStart.clone().invert()),t.scale.copy(ah),t.visible=r.dragging):(t.quaternion.copy(n),r.dragging?t.position.copy(r.worldPositionStart):t.position.copy(r.worldPosition),r.axis&&(t.visible=-1!==r.axis.search(t.name)));t.quaternion.copy(n),"translate"===r.mode||"scale"===r.mode?("X"===t.name&&.99<Math.abs(vh.copy(Th).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Y"===t.name&&.99<Math.abs(vh.copy(_h).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Z"===t.name&&.99<Math.abs(vh.copy(Mh).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XY"===t.name&&Math.abs(vh.copy(Mh).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"YZ"===t.name&&Math.abs(vh.copy(Th).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XZ"===t.name&&Math.abs(vh.copy(_h).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1)):"rotate"===r.mode&&(bh.copy(n),vh.copy(r.eye).applyQuaternion(lh.copy(n).invert()),-1!==t.name.search("E")&&t.quaternion.setFromRotationMatrix(gh.lookAt(r.eye,yh,_h)),"X"===t.name&&(lh.setFromAxisAngle(Th,Math.atan2(-vh.y,vh.z)),lh.multiplyQuaternions(bh,lh),t.quaternion.copy(lh)),"Y"===t.name&&(lh.setFromAxisAngle(_h,Math.atan2(vh.x,vh.z)),lh.multiplyQuaternions(bh,lh),t.quaternion.copy(lh)),"Z"===t.name&&(lh.setFromAxisAngle(Mh,Math.atan2(vh.y,vh.x)),lh.multiplyQuaternions(bh,lh),t.quaternion.copy(lh))),t.visible=t.visible&&(-1===t.name.indexOf("X")||r.showX),t.visible=t.visible&&(-1===t.name.indexOf("Y")||r.showY),t.visible=t.visible&&(-1===t.name.indexOf("Z")||r.showZ),t.visible=t.visible&&(-1===t.name.indexOf("E")||r.showX&&r.showY&&r.showZ),t.material._color=t.material._color||t.material.color.clone(),t.material._opacity=t.material._opacity||t.material.opacity,t.material.color.copy(t.material._color),t.material.opacity=t.material._opacity,r.enabled&&r.axis&&(t.name===r.axis||r.axis.split("").some((function(e){return t.name===e})))&&(t.material.color.setHex(16776960),t.material.opacity=1)}(o);$c(ih(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}(),kh=(Rh.prototype.isTransformControlsGizmo=!0,function(){eh(t,c.Mesh);var e=rh(t);function t(){var r;return Qc(this,t),(r=e.call(this,new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1}))).type="TransformControlsPlane",r}return Jc(t,[{key:"updateMatrixWorld",value:function(e){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),Eh.copy(Th).applyQuaternion("local"===r?this.worldQuaternion:xh),Ph.copy(_h).applyQuaternion("local"===r?this.worldQuaternion:xh),Oh.copy(Mh).applyQuaternion("local"===r?this.worldQuaternion:xh),vh.copy(Ph),this.mode){case"translate":case"scale":switch(this.axis){case"X":vh.copy(this.eye).cross(Eh),wh.copy(Eh).cross(vh);break;case"Y":vh.copy(this.eye).cross(Ph),wh.copy(Ph).cross(vh);break;case"Z":vh.copy(this.eye).cross(Oh),wh.copy(Oh).cross(vh);break;case"XY":wh.copy(Oh);break;case"YZ":wh.copy(Eh);break;case"XZ":vh.copy(Oh),wh.copy(Ph);break;case"XYZ":case"E":wh.set(0,0,0)}break;default:wh.set(0,0,0)}0===wh.length()?this.quaternion.copy(this.cameraQuaternion):(Sh.lookAt(ah.set(0,0,0),wh,vh),this.quaternion.setFromRotationMatrix(Sh)),$c(ih(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}());kh.prototype.isTransformControlsPlane=!0;class Ah extends xs{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new c.Vector3,this.beginScale=new c.Vector3,this.posStart=new c.Vector2,this.posEnd=new c.Vector2,this.deleteRedundantParts()}deleteRedundantParts(){this.transGizmo.gizmo.translate.children.splice(1,1),this.transGizmo.gizmo.translate.children.splice(3,1),this.transGizmo.gizmo.translate.children.splice(5,1),this.transGizmo.gizmo.scale.children.splice(0,1),this.transGizmo.gizmo.scale.children.splice(2,1),this.transGizmo.gizmo.scale.children.splice(4,1)}pointerDown(e){void 0===this.object||null===this.axis||this.dragging||0!==e.button||(this.posStart.set(e.x,e.y),this.beginScale.set(this.object.scale.x,this.object.scale.y,this.object.scale.z),super.pointerDown(e))}pointerMove(e){if(super.pointerMove(e),void 0!==this.object&&null!==this.axis&&this.dragging&&-1===e.button&&"scale"===this.mode&&-1!==this.axis.search("XYZ")){this.posEnd.set(e.x,e.y),e=(Math.abs(this.beginScale.x)+Math.abs(this.beginScale.y)+Math.abs(this.beginScale.z))/3;let t=12*this.pointStart.distanceTo(this.pointEnd)/e;this.posEnd.x>this.posStart.x&&(t*=-1),(t=-1.1<t&&t<1.1?1:t)<0&&(t=-1.1/t),this.scaleCoefficient.set(t,t,t),this.object.scale.copy(this._scaleStart).multiply(this.scaleCoefficient)}}}class Ch{constructor(e){this.grid=null,this.transContro=null,this.boxHelper=null,this.deepIsHelper=e=>"Scene"===e.type||!this.isHelper(e)&&!!e.parent&&this.deepIsHelper(e.parent),this.getBoxHelper=e=>(e=new c.BoxHelper(e),this.setHelper(e),this.runScene.assetsEx.get().scene.add(e),e),this.runScene=e,"running"!==this.runScene.optionsEx.options.mode&&(this.transContro=new class{constructor(e){this.tansControls=null,this.controlsMode="position",this.isDraggingChange=!1,this.modelNewVal=new vi.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new vi.Vector3,this.draggingChanged=e=>{const t=this.runScene.assetsEx.get().controls;var r=this.controlsMode;let n=this.runScene.modelEx.select;if(e.value){if(!this.runScene.multipSelector.isEmpty()){t.enabled=!1;const e=this.runScene.multipSelector.getLast();this.multipSelectLast=e,this.worldOldVal=Mo(e,this.runScene.sceneEx.get())}}else if(!t.enabled&&!this.runScene.multipSelector.isEmpty()&&this.multipSelectLast){const e=this.multipSelectLast;this.multipObj=e,this.runScene.events.mouse.enableUp=!1,this.runScene.helperEx.boxHelper.setFromObject(this.runScene.assetsEx.get().scene);var i=Mo(e,this.runScene.sceneEx.get());this.runScene.multipSelector.setInfo(e,r,this.modelNewVal,e[r],i,this.worldOldVal),this.runScene.modelEx.selectNull(),this.multipSelectLast=void 0}if(this.runScene.multipSelector.isEmpty()?this.runScene.events.mouse.enableUp=!0:this.runScene.events.mouse.enableUp=!1,!n){if(this.runScene.multipSelector.isEmpty())return;n=this.runScene.multipSelector.getLast()}t.enabled?(this.modelNewVal=this.runScene.modelEx.cloneV3(n[r]),this.isDraggingChange=!0,this.worldOldVal=Mo(n,this.runScene.sceneEx.get())):(this.runScene.multipSelector.isEmpty()?this.runScene.modelEx.setV3({model:n,info:r,newV3:this.runScene.modelEx.cloneV3(n[r]),oldV3:this.modelNewVal},!0,!1):(this.multipObj=n,this.runScene.events.mouse.enableUp=!1,this.runScene.helperEx.boxHelper.setFromObject(this.runScene.assetsEx.get().scene),i=Mo(n,this.runScene.sceneEx.get()),this.runScene.multipSelector.setInfo(n,r,this.modelNewVal,n[r],i,this.worldOldVal)),this.isDraggingChange=!1),this.runScene.assetsEx.get().controls.enabled=!e.value},this.runScene=e}init(){const{camera:e,renderer:t,scene:r}=this.runScene.assetsEx;this.tansControls=new Ah(e,t.domElement),this.tansControls.addEventListener("dragging-changed",this.draggingChanged),this.tansControls.addEventListener("change",this.transChangeFn.bind(this)),this.tansControls.name="helper",r.add(this.tansControls),this.tansControls.traverse((e=>e.isHelper=!0))}changeMode(e){this.controlsMode=e,this.tansControls.setMode(this.transControlsStatusMap[e])}transControSize(e){this.tansControls.setSize(e?this.tansControls.size+.1:Math.max(this.tansControls.size-.1,.1))}changeState(e){this.tansControls.enabled=e}addObject(e){this.removeFocus(),this.tansControls.attach(e)}removeFocus(){this.tansControls.detach()}changeSpaceState(){this.tansControls.setSpace("local"===this.tansControls.space?"world":"local"),this.tansControls.detach()}transChangeFn(e){var t=this.runScene.modelEx.select;t&&(this.runScene.lightEx.update(t),this.runScene.helperEx.boxHelper.setFromObject(t))}close(){this.tansControls.enabled=!1}open(){this.tansControls.enabled=!0}reset(){this.dispose(),this.init()}dispose(){this.tansControls&&(this.tansControls.removeEventListener("dragging-changed",this.draggingChanged),this.tansControls.removeEventListener("change",this.transChangeFn),this.tansControls.dispose(),this.runScene.assetsEx.get().scene.remove(this.tansControls))}}(e),this.grid=this.createGrid(),this.init())}init(){this.transContro.init(),this.runScene.assetsEx.get().scene.add(this.grid)}createGrid(){const e=new vi.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof c.Material&&(e.material.opacity=.75,e.material.transparent=!0),e}dispose(){}reset(){"running"!==this.runScene.optionsEx.options.mode&&this.transContro.reset()}isHelper(e){return"GridHelper"===e.type||"CubeCamera"===e.type||e.isTransformControls||e.userData.isHelper}setHelper(e,t=!1,r){return e.userData.isHelper=!0,t&&e.traverse((e=>{e.userData.isHelper=!0,r&&r(e)})),e}focus(e){"running"!==this.runScene.optionsEx.options.mode&&(this.boxHelper||(this.boxHelper=this.getBoxHelper(e)),this.transContro.addObject(e),this.boxHelper.setFromObject(e),this.focusModelId=this.runScene.uniqueEx.getId(e))}unfocus(){var e;"running"!==this.runScene.optionsEx.options.mode&&(this.transContro.removeFocus(),null!=(e=this.boxHelper)&&e.setFromObject(this.runScene.assetsEx.get().scene),this.focusModelId=void 0)}}function Lh(e){return(Lh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dh(e,t){return(Dh=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ih(e){return(Ih=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var jh=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Dh(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Ih(e);if(r=t?(r=Ih(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Lh(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e,t){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");var i=new c.BufferGeometry,o=(i.setAttribute("position",new c.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),new c.LineBasicMaterial({fog:!1}));return((i=r.call(this,i,o)).light=e,i.color=t,i.type="RectAreaLightHelper",o=new c.BufferGeometry).setAttribute("position",new c.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),i.add(new c.Mesh(o,new c.MeshBasicMaterial({side:c.BackSide,fog:!1}))),i}return t=n,(e=[{key:"updateMatrixWorld",value:function(){var e,t;this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color?(this.material.color.set(this.color),this.children[0].material.color.set(this.color)):(this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),e=this.material.color,1<(t=Math.max(e.r,e.g,e.b))&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)),this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Line);class Uh{constructor(e){this.runScene=e}}class Bh extends Uh{get(){}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o}=e;return{type:t,intensity:r,name:n,visible:i,color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("AmbientLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o}=e;return t.intensity=r,t.type=e,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t}}class zh extends Uh{get(){throw new Error("Method not implemented.")}toJSON(e){const{intensity:t,name:r,type:n,position:i,visible:o,color:a,castShadow:s,shadow:l,rotation:u,target:c}=e;var{mapSize:e,camera:h}=l,{scale:h,near:p,far:f}=h;return{type:n,intensity:t,name:r,visible:o,color:a.getHexString(),castShadow:s,shadow:{mapSize:e.x,camera:{near:p,far:f,scale:h.x}},position:{x:i.x,y:i.y,z:i.z},rotation:{x:u.x,y:u.y,z:u.z},targetPosition:{x:c.position.x,y:c.position.y,z:c.position.z}}}parseJSON(e){const t=this.runScene.lightEx.get("DirectionalLight",{addUndo:!1});var{targetPosition:e,intensity:r,name:n,position:i,visible:o,color:a,castShadow:s,shadow:l,rotation:u,type:c}=e,{mapSize:l,camera:h}=l,{scale:h,near:p,far:f}=h;return t.intensity=r,t.type=c,t.name=n,t.visible=o,t.castShadow=s,t.color=new vi.Color("#"+a),t.position.set(i.x,i.y,i.z),t.rotation.set(u.x,u.y,u.z),t.target.position.set(e.x,e.y,e.z),t.shadow.mapSize.x=l,t.shadow.mapSize.y=l,t.shadow.camera.scale.x=h,t.shadow.camera.scale.y=h,t.shadow.camera.scale.z=h,t.shadow.camera.near=p,t.shadow.camera.far=f,t.shadow.camera.updateProjectionMatrix(),null!=(r=t.cameraHelper)&&r.update(),t}}class Nh extends Uh{get(){throw new Error("Method not implemented.")}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o,groundColor:a,position:s}=e;return{name:n,type:t,intensity:r,visible:i,position:{x:s.x,y:s.y,z:s.z},groundColor:a.getHexString(),color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("HemisphereLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o,groundColor:a,position:s}=e;return t.type=e,t.intensity=r,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t.groundColor=new vi.Color("#"+a),t.position.set(s.x,s.y,s.z),t}}class Fh extends Uh{get(){throw new Error("Method not implemented.")}toJSON(e){const{name:t,type:r,intensity:n,distance:i,decay:o,renderOrder:a,color:s,visible:l,castShadow:u,shadow:c,position:h}=e;var{mapSize:e,camera:p,bias:f,radius:d}=c,{scale:p,near:m,far:v}=p;return{name:t,type:r,intensity:n,visible:l,color:s.getHexString(),castShadow:u,distance:i,decay:o,renderOrder:a,shadow:{mapSize:e.x,camera:{near:m,far:v,scale:p.x},radius:d,bias:f},position:{x:h.x,y:h.y,z:h.z}}}parseJSON(e){const t=this.runScene.lightEx.get("PointLight",{addUndo:!1});var{name:e,type:r,intensity:n,distance:i,decay:o,renderOrder:a,color:s,visible:l,castShadow:u,shadow:c,position:h}=e,{mapSize:c,camera:p,bias:f,radius:d}=c,{scale:p,near:m,far:v}=p;return t.intensity=n,t.type=r,t.name=e,t.visible=l,t.castShadow=u,t.distance=i,t.renderOrder=a,t.color=new vi.Color("#"+s),t.position.set(h.x,h.y,h.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=f,t.decay=o,t.shadow.radius=d,t.shadow.camera.scale.x=p,t.shadow.camera.scale.y=p,t.shadow.camera.scale.z=p,t.shadow.camera.near=m,t.shadow.camera.far=v,t.shadow.camera.updateProjectionMatrix(),t}}class Vh{constructor(e){this.runScene=e}toJSON(e){const{type:t,intensity:r,name:n,visible:i,color:o,position:a}=e;return{name:n,type:t,intensity:r,visible:i,position:{x:a.x,y:a.y,z:a.z},color:o.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("RectAreaLight",{addUndo:!1});var{type:e,intensity:r,name:n,visible:i,color:o,position:a}=e;return t.type=e,t.intensity=r,t.name=n,t.visible=i,t.color=new vi.Color("#"+o),t.position.set(a.x,a.y,a.z),t}}class Hh{constructor(e){this.runScene=e}toJSON(e){const{name:t,type:r,color:n,distance:i,decay:o,intensity:a,angle:s,penumbra:l,visible:u,castShadow:c,shadow:h,renderOrder:p,position:f,target:d}=e;var{bias:e,camera:m,normalBias:v,mapSize:y,radius:g}=h,m=m.near;return{type:r,intensity:a,name:t,visible:u,distance:i,angle:s,decay:o,penumbra:l,renderOrder:p,color:n.getHexString(),castShadow:c,shadow:{bias:e,normalBias:v,mapSize:y.x,camera:{near:m},radius:g},position:{x:f.x,y:f.y,z:f.z},targetPosition:{x:d.position.x,y:d.position.y,z:d.position.z}}}parseJSON(e){const t=this.runScene.lightEx.get("SpotLight",{addUndo:!1});var{name:e,type:r,color:n,distance:i,decay:o,intensity:a,angle:s,penumbra:l,visible:u,castShadow:c,shadow:h,renderOrder:p,position:f,targetPosition:d}=e,{bias:h,camera:m,normalBias:v,mapSize:y,radius:g}=h,m=m.near;return t.intensity=a,t.type=r,t.name=e,t.visible=u,t.distance=i,t.decay=o,t.angle=s,t.penumbra=l,t.renderOrder=p,t.castShadow=c,t.color=new vi.Color("#"+n),t.position.set(f.x,f.y,f.z),t.shadow.mapSize.x=y,t.shadow.mapSize.y=y,t.shadow.camera.near=m,t.target.position.set(d.x,d.y,d.z),t.shadow.bias=h,t.shadow.normalBias=v,t.shadow.radius=g,t.shadow.camera.updateProjectionMatrix(),t}}class Gh{constructor(e){this.shadowList=["DirectionalLight","PointLight","SpotLight"],this.helperList=["DirectionalLight","PointLight","SpotLight","RectAreaLight","HemisphereLight"],this.lightDom=void 0,this.helperUpdateList=["DirectionalLight","PointLight","SpotLight","HemisphereLight"],this.runScene=e,this.lightExMap={DirectionalLight:new zh(e),PointLight:new Fh(e),SpotLight:new Hh(e),RectAreaLight:new Vh(e),HemisphereLight:new Nh(e),AmbientLight:new Bh(e)}}getLightsByScene(e=this.runScene.sceneEx.get()){return e.children.filter((e=>e.isLight))}get(e,t){var{isClone:t,id:r,addUndo:n,addToScene:i}=$o({isClone:!1,id:(0,l.getId)(),addUndo:!0,addToScene:!0},t);let o=new vi[e];if(o.position.y=10,o.name=e,o.userData.id=r,this.shadowList.includes(e)&&(o.castShadow=!0),this.setLight(o),!i)return o;if(this.helperList.includes(o.type)){const t=this.setLightHelper(o);t.push({model:o,parent:this.runScene.sceneEx.get(),addTree:!0}),r=t.map((e=>new Ka(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute())),n&&this.runScene.undoEx.addUndo(r),null!=(e=null==o?void 0:o.lightHelper)&&e.update()}else this.runScene.modelEx.add(o,void 0,{addUndo:n});return this.runScene.modelEx.setSelectByModel(o,{isClone:t}),o}setNull(e){e.userData.light&&this.setNull(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper&&(e.cameraHelper.visible=!1):"SpotLight"===e.type&&(e.cameraHelper&&(e.cameraHelper.visible=!1),e.helper&&(e.helper.visible=!0)))}setSelect(e){e.userData.light&&this.setSelect(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper&&(e.cameraHelper.visible=!0):"SpotLight"===e.type&&(e.cameraHelper&&(e.cameraHelper.visible=!0),e.helper&&(e.helper.visible=!0)))}update(e){var t;e.userData.isLightTarget&&e.userData.light&&(e=e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type||"SpotLight"===e.type?(e.helper.update(),null!=(t=e.cameraHelper)&&t.update()):null!=(e=null==(t=e.helper)?void 0:t.update)&&e.call(t))}remove(e,t=!0){let r;return this.runScene.helperEx.unfocus(),r="DirectionalLight"===e.type||"SpotLight"===e.type?[e,e.cameraHelper,e.helper].map((t=>{if(t)return new $a({addTree:t===e,runScene:this.runScene,model:t,parent:t.parent||this.runScene.sceneEx.get()}).execute()})).filter((e=>e)):[e,e.helper].map((t=>{if(t)return new $a({addTree:t===e,runScene:this.runScene,model:t,parent:t.parent||this.runScene.sceneEx.get()}).execute()})).filter((e=>e)),t&&r&&this.runScene.undoEx.addUndo(r),r}getLightHelper(e,t){this.runScene.uniqueEx.model.add(t);const r=this.runScene.uniqueEx.getId(t);let n,i=[];switch(e){case"RectAreaLight":n=new jh(t,16773120);break;case"DirectionalLight":if(n=new vi.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new vi.Object3D;(t.target=e).name="helperModel",e.position.y=-10,t.shadow.autoUpdate=!0,e.userData.isLightTarget=!0,(e.userData.light=t).add(e)}t.shadow.camera.layers.set(1),t.shadow.camera.far=1e5,t.shadowCameraLeft=-5,t.shadowCameraRight=5,t.shadowCameraTop=5,t.shadowCameraBottom=-5,t.shadow.camera.updateProjectionMatrix();const e=new vi.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,this.runScene.helperEx.setHelper(e,!0,(e=>{e.userData.id=r,e.userData.unClick=!0})),e.userData.id=r,e.userData.unClick=!0,t.cameraHelper=e,i.push({model:e,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"PointLight":n=new vi.PointLightHelper(t,1,16711935);break;case"SpotLight":n=new vi.SpotLightHelper(t);let o=new vi.Object3D;(t.target=o).name="helperModel",o.userData.isLightTarget=!0,o.userData.light=t,o.position.y=-10,t.shadow.autoUpdate=!0,t.add(o);const a=new vi.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,this.runScene.helperEx.setHelper(a,!0,(e=>{e.userData.id=r})),a.userData.id=r,t.cameraHelper=a,i.push({model:a,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"HemisphereLight":n=new vi.HemisphereLightHelper(t,1,16773135)}return n.name="helperModel",this.runScene.helperEx.setHelper(n,!0,(e=>{e.userData.id=r})),n.userData.id=r,(n.light=t).helper=n,i.push({model:n,parent:this.runScene.sceneEx.get(),addTree:!1}),i}setLightHelper(e){return"editor"!==this.runScene.optionsEx.options.mode?[]:this.getLightHelper(e.type,e)}isUpdateHelper(e){return this.helperUpdateList.includes(e)}initLight(e){console.log("初始化灯光helper:",e),e.forEach((e=>this.setLightHelper(e)))}setNormal(e,t=0){var{model:e,info:r,val:n,cb:i}=e;return new Na({target:e,runScene:this.runScene,info:r,oldVal:e[r],newVal:n,cb:i}).execute()}setMultip(e,t,r=!0,n=!0){if(e instanceof Array)return i=e.map((e=>{var{model:e,typeList:n,newVal:i}=e;const o=new Ra({target:e,typeList:n,newVal:i,cb:t});return r?o.execute():o})),n&&this.runScene.undoEx.addUndo(i),i;{var{model:i,typeList:e,newVal:o}=e;const a=new Ra({target:i,typeList:e,newVal:o,cb:t});return n&&this.runScene.undoEx.addUndo(a),r?a.execute():a}}isLight(e){return null==(e=e.userData)?void 0:e.isLight}setLight(e){e.userData.isLight=!0}isHelperTarget(e){return e.userData.isLightTarget}clone(e){return this.runScene.modelEx.selectNull(),this.get(e.type,{isClone:!0,id:(0,l.getId)()})}}function Wh(e){return(Wh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Xh(e,t){return(Xh=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function qh(e){return(qh=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Yh=new WeakMap,Zh=function(e){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Xh(t,e);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=qh(e);if(r=t?(r=qh(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Wh(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return(e=r.call(this,e)).decoderPath="",e.decoderConfig={},e.decoderBinary=null,e.decoderPending=null,e.workerLimit=4,e.workerPool=[],e.workerNextTaskID=1,e.workerSourceURL="",e.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},e.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"},e;throw new TypeError("Cannot call a class as a function")}return t=n,(e=[{key:"setDecoderPath",value:function(e){return this.decoderPath=e,this}},{key:"setDecoderConfig",value:function(e){return this.decoderConfig=e,this}},{key:"setWorkerLimit",value:function(e){return this.workerLimit=e,this}},{key:"load",value:function(e,t,r,n){var i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(e){var r={attributeIDs:i.defaultAttributeIDs,attributeTypes:i.defaultAttributeTypes,useUniqueIDs:!1};i.decodeGeometry(e,r).then(t).catch(n)}),r,n)}},{key:"decodeDracoFile",value:function(e,t,r,n){n={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r},this.decodeGeometry(e,n).then(t)}},{key:"decodeGeometry",value:function(e,t){var r,n=this;for(r in t.attributeTypes){var i=t.attributeTypes[r];void 0!==i.BYTES_PER_ELEMENT&&(t.attributeTypes[r]=i.name)}var o,a=JSON.stringify(t);if(Yh.has(e)){if((l=Yh.get(e)).key===a)return l.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var s=this.workerNextTaskID++,l=e.byteLength;return l=this._getWorker(s,l).then((function(r){return o=r,new Promise((function(r,n){o._callbacks[s]={resolve:r,reject:n},o.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))})).then((function(e){return n._createGeometry(e.geometry)})),l.catch((function(){return!0})).then((function(){o&&s&&n._releaseTask(o,s)})),Yh.set(e,{key:a,promise:l}),l}},{key:"_createGeometry",value:function(e){var t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(var r=0;r<e.attributes.length;r++){var n=(o=e.attributes[r]).name,i=o.array,o=o.itemSize;t.setAttribute(n,new c.BufferAttribute(i,o))}return t}},{key:"_loadLibrary",value:function(e,t){var r=new c.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((function(t,n){r.load(e,t,void 0,n)}))}},{key:"preload",value:function(){return this._initDecoder(),this}},{key:"_initDecoder",value:function(){var e=this;if(this.decoderPending)return this.decoderPending;var t="object"!==("undefined"==typeof WebAssembly?"undefined":Wh(WebAssembly))||"js"===this.decoderConfig.type,r=[];return t?r.push(this._loadLibrary("draco_decoder.js","text")):(r.push(this._loadLibrary("draco_wasm_wrapper.js","text")),r.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(r).then((function(r){var n=r[0];t||(e.decoderConfig.wasmBinary=r[1]),r=function(){var e,t;onmessage=function(r){var n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":var i=n.buffer,o=n.taskConfig;t.then((function(e){var t=new(e=e.draco).Decoder,r=new e.DecoderBuffer;r.Init(new Int8Array(i),i.byteLength);try{var a=function(e,t,r,n){var i,o=n.attributeIDs,a=n.attributeTypes,s=t.GetEncodedGeometryType(r);if(s===e.TRIANGULAR_MESH)i=new e.Mesh,y=t.DecodeBufferToMesh(r,i);else{if(s!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");i=new e.PointCloud,y=t.DecodeBufferToPointCloud(r,i)}if(!y.ok()||0===i.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());var l,u,c,h,p,f,d,m,v,y,g,b,x,w={index:null,attributes:[]};for(l in o){var S=self[a[l]],T=void 0,_=void 0;if(n.useUniqueIDs)_=o[l],T=t.GetAttributeByUniqueId(i,_);else{if(-1===(_=t.GetAttributeId(i,e[o[l]])))continue;T=t.GetAttribute(i,_)}w.attributes.push((_=e,u=t,c=i,h=l,p=T.num_components(),d=(f=c.num_points()*p)*S.BYTES_PER_ELEMENT,m=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(_,S),v=_._malloc(d),u.GetAttributeDataArrayForAllPoints(c,T,m,d,v),u=new S(_.HEAPF32.buffer,v,f).slice(),_._free(v),{name:h,array:u,itemSize:p}))}return s===e.TRIANGULAR_MESH&&(w.index=(r=e,y=t,b=4*(g=3*(s=i).num_faces()),x=r._malloc(b),y.GetTrianglesUInt32Array(s,b,x),y=new Uint32Array(r.HEAPF32.buffer,x,g).slice(),r._free(x),{array:y,itemSize:1})),e.destroy(i),w}(e,t,r,o),s=a.attributes.map((function(e){return e.array.buffer}));a.index&&s.push(a.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:a},s)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{e.destroy(r),e.destroy(t)}}))}}}.toString(),n=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n"),e.workerSourceURL=URL.createObjectURL(new Blob([n]))})),this.decoderPending}},{key:"_getWorker",value:function(e,t){var r=this;return this._initDecoder().then((function(){r.workerPool.length<r.workerLimit?((n=new Worker(r.workerSourceURL))._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:r.decoderConfig}),n.onmessage=function(e){var t=e.data;switch(t.type){case"decode":n._callbacks[t.id].resolve(t);break;case"error":n._callbacks[t.id].reject(t);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+t.type+'"')}},r.workerPool.push(n)):r.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n,i=r.workerPool[r.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}},{key:"_releaseTask",value:function(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}},{key:"debug",value:function(){console.log("Task load: ",this.workerPool.map((function(e){return e._taskLoad})))}},{key:"dispose",value:function(){for(var e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(c.Loader),Qh={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};var Kh=new(function(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(t,r,n){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var i=this,o=!1,a=0,s=0,l=void 0,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=r,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==i.onStart&&i.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,s),a===s&&(o=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return l?l(e):e},this.setURLModifier=function(e){return l=e,this},this.addHandler=function(e,t){return u.push(e,t),this},this.removeHandler=function(e){return-1!==(e=u.indexOf(e))&&u.splice(e,2),this},this.getHandler=function(e){for(var t=0,r=u.length;t<r;t+=2){var n=u[t],i=u[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}})));var Jh=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.manager=void 0!==t?t:Kh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}var t,r;return t=e,(r=[{key:"load",value:function(){}},{key:"loadAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.load(e,n,t,i)}))}},{key:"parse",value:function(){}},{key:"setCrossOrigin",value:function(e){return this.crossOrigin=e,this}},{key:"setWithCredentials",value:function(e){return this.withCredentials=e,this}},{key:"setPath",value:function(e){return this.path=e,this}},{key:"setResourcePath",value:function(e){return this.resourcePath=e,this}},{key:"setRequestHeader",value:function(e){return this.requestHeader=e,this}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function $h(e){return($h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ep(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function tp(e,t){return(tp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function rp(e){return(rp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var np=function(){var e=n,t=Jh;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&tp(e,t);var r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=rp(e);if(r=t?(r=rp(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===$h(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==n)return n;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}(n);function n(e){if(this instanceof n)return e=r.call(this,e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),e.options={premultiplyAlpha:"none"},e;throw new TypeError("Cannot call a class as a function")}return e=n,(t=[{key:"setOptions",value:function(e){return this.options=e,this}},{key:"load",value:function(e,t,r,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var i=this,o=Qh.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;var a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return Promise.all([createImageBitmap(e,Object.assign(i.options,{imageOrientation:"flipY"})),Promise.resolve(e)])})).then((function(r){r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),2!==o.length);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e)||function(e,t){if(e){if("string"==typeof e)return ep(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ep(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r);var n=r[0];r=r[1],Qh.add(e,n),t&&t(n,r),i.manager.itemEnd(e)})).catch((function(t){n&&n(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),n}();function ip(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||ap(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function op(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=ap(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),r=0,{s:t=function(){},n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function ap(e,t){if(e){if("string"==typeof e)return sp(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sp(e,t):void 0}}function sp(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function lp(e){return(lp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function up(){return(up="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=yp(e)););return e}(e,t);if(n)return(n=Object.getOwnPropertyDescriptor(n,t)).get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function cp(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hp(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function pp(e,t,r){return t&&hp(e.prototype,t),r&&hp(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function fp(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&dp(e,t)}function dp(e,t){return(dp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function mp(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=yp(e);if(r=t?(r=yp(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===lp(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return vp(n)}}function vp(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yp(e){return(yp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}np.prototype.isImageBitmapLoader=!0;var gp=function(){fp(t,c.Loader);var e=mp(t);function t(r){return cp(this,t),(r=e.call(this,r)).dracoLoader=null,r.ktx2Loader=null,r.meshoptDecoder=null,r.pluginCallbacks=[],r.register((function(e){return new Tp(e)})),r.register((function(e){return new Rp(e)})),r.register((function(e){return new kp(e)})),r.register((function(e){return new _p(e)})),r.register((function(e){return new Mp(e)})),r.register((function(e){return new Ep(e)})),r.register((function(e){return new Pp(e)})),r.register((function(e){return new Op(e)})),r.register((function(e){return new wp(e)})),r.register((function(e){return new Ap(e)})),r}return pp(t,[{key:"load",value:function(e,t,r,n){function i(t){n?n(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)}var o=this,a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:c.LoaderUtils.extractUrlBase(e),s=(this.manager.itemStart(e),new c.FileLoader(this.manager));s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(r){try{o.parse(r,a,(function(r){t(r),o.manager.itemEnd(e)}),i)}catch(r){i(r)}}),r,i)}},{key:"setDRACOLoader",value:function(e){return this.dracoLoader=e,this}},{key:"setDDSLoader",value:function(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}},{key:"setKTX2Loader",value:function(e){return this.ktx2Loader=e,this}},{key:"setMeshoptDecoder",value:function(e){return this.meshoptDecoder=e,this}},{key:"register",value:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}},{key:"unregister",value:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}},{key:"parse",value:function(e,t,r,n,i){var o,a={},s={};if("string"==typeof e)o=e;else if(c.LoaderUtils.decodeText(new Uint8Array(e,0,4))===Cp){try{a[xp.KHR_BINARY_GLTF]=new Lp(e)}catch(e){return void(n&&n(e))}o=a[xp.KHR_BINARY_GLTF].content}else o=c.LoaderUtils.decodeText(new Uint8Array(e));var l=JSON.parse(o);if(void 0===l.asset||l.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{i.helper.beforeLoader(l);var u=new $p(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:i});u.fileLoader.setRequestHeader(this.requestHeader);for(var h=0;h<this.pluginCallbacks.length;h++){var p=this.pluginCallbacks[h](u);a[(s[p.name]=p).name]=!0}if(l.extensionsUsed)for(var f=0;f<l.extensionsUsed.length;++f){var d=l.extensionsUsed[f],m=l.extensionsRequired||[];switch(d){case xp.KHR_MATERIALS_UNLIT:a[d]=new Sp;break;case xp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:a[d]=new Up;break;case xp.KHR_DRACO_MESH_COMPRESSION:a[d]=new Dp(l,this.dracoLoader);break;case xp.KHR_TEXTURE_TRANSFORM:a[d]=new Ip;break;case xp.KHR_MESH_QUANTIZATION:a[d]=new Bp;break;default:0<=m.indexOf(d)&&void 0===s[d]&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}u.setExtensions(a),u.setPlugins(s),u.parse(r,n)}}},{key:"parseAsync",value:function(e,t){var r=this;return new Promise((function(n,i){r.parse(e,t,n,i)}))}}]),t}();function bp(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var xp={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"},wp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}return pp(e,[{key:"_markDefs",value:function(){for(var e=this.parser,t=this.parser.json.nodes||[],r=0,n=t.length;r<n;r++){var i=t[r];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}},{key:"_loadLight",value:function(e){var t=this.parser,r="light:"+e,n=t.cache.get(r);if(n)return n;var i,o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e],s=new c.Color(16777215),l=(void 0!==a.color&&s.fromArray(a.color),void 0!==a.range?a.range:0);switch(a.type){case"directional":(i=new c.DirectionalLight(s)).target.position.set(0,0,-1),i.add(i.target);break;case"point":(i=new c.PointLight(s)).distance=l;break;case"spot":(i=new c.SpotLight(s)).distance=l,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,i.angle=a.spot.outerConeAngle,i.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return i.position.set(0,0,0),i.decay=2,void 0!==a.intensity&&(i.intensity=a.intensity),i.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(i),t.cache.add(r,n),n}},{key:"createNodeAttachment",value:function(e){var t=this,r=this.parser,n=((e=r.json.nodes[e]).extensions&&e.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return r._getNodeRef(t.cache,n,e)}))}}]),e}(),Sp=function(){function e(){cp(this,e),this.name=xp.KHR_MATERIALS_UNLIT}return pp(e,[{key:"getMaterialType",value:function(){return c.MeshBasicMaterial}},{key:"extendParams",value:function(e,t,r){var n,i=[];return e.color=new c.Color(1,1,1),e.opacity=1,(t=t.pbrMetallicRoughness)&&(Array.isArray(t.baseColorFactor)&&(n=t.baseColorFactor,e.color.fromArray(n),e.opacity=n[3]),void 0!==t.baseColorTexture&&i.push(r.assignTexture(e,"map",t.baseColorTexture))),Promise.all(i)}}]),e}(),Tp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_CLEARCOAT}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(e=e.extensions[this.name]).clearcoatFactor&&(t.clearcoat=e.clearcoatFactor),void 0!==e.clearcoatTexture&&n.push(r.assignTexture(t,"clearcoatMap",e.clearcoatTexture)),void 0!==e.clearcoatRoughnessFactor&&(t.clearcoatRoughness=e.clearcoatRoughnessFactor),void 0!==e.clearcoatRoughnessTexture&&n.push(r.assignTexture(t,"clearcoatRoughnessMap",e.clearcoatRoughnessTexture)),void 0!==e.clearcoatNormalTexture&&(n.push(r.assignTexture(t,"clearcoatNormalMap",e.clearcoatNormalTexture)),void 0!==e.clearcoatNormalTexture.scale&&(r=e.clearcoatNormalTexture.scale,t.clearcoatNormalScale=new c.Vector2(r,r))),Promise.all(n)}}]),e}(),_p=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_SHEEN}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,e=e.extensions[this.name]).sheenColorFactor&&t.sheenColor.fromArray(e.sheenColorFactor),void 0!==e.sheenRoughnessFactor&&(t.sheenRoughness=e.sheenRoughnessFactor),void 0!==e.sheenColorTexture&&n.push(r.assignTexture(t,"sheenColorMap",e.sheenColorTexture)),void 0!==e.sheenRoughnessTexture&&n.push(r.assignTexture(t,"sheenRoughnessMap",e.sheenRoughnessTexture)),Promise.all(n)}}]),e}(),Mp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_TRANSMISSION}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[];return void 0!==(e=e.extensions[this.name]).transmissionFactor&&(t.transmission=e.transmissionFactor),void 0!==e.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",e.transmissionTexture)),Promise.all(n)}}]),e}(),Ep=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_VOLUME}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){if(!(e=(n=this.parser).json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var r=[],n=(e=e.extensions[this.name],t.thickness=void 0!==e.thicknessFactor?e.thicknessFactor:0,void 0!==e.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",e.thicknessTexture)),t.attenuationDistance=e.attenuationDistance||0,e.attenuationColor||[1,1,1]);return t.attenuationColor=new c.Color(n[0],n[1],n[2]),Promise.all(r)}}]),e}(),Pp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_IOR}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?(e=e.extensions[this.name],t.ior=void 0!==e.ior?e.ior:1.5,Promise.resolve()):Promise.resolve()}}]),e}(),Op=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_MATERIALS_SPECULAR}return pp(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?c.MeshPhysicalMaterial:null}},{key:"extendMaterialParams",value:function(e,t){var r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();var n=[],i=(e=e.extensions[this.name],t.specularIntensity=void 0!==e.specularFactor?e.specularFactor:1,void 0!==e.specularTexture&&n.push(r.assignTexture(t,"specularIntensityMap",e.specularTexture)),e.specularColorFactor||[1,1,1]);return t.specularColor=new c.Color(i[0],i[1],i[2]),void 0!==e.specularColorTexture&&n.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=c.sRGBEncoding}))),Promise.all(n)}}]),e}(),Rp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.KHR_TEXTURE_BASISU}return pp(e,[{key:"loadTexture",value:function(e){var t=this.parser,r=t.json;if(!(n=r.textures[e]).extensions||!n.extensions[this.name])return null;var n=n.extensions[this.name],i=t.options.ktx2Loader;if(i)return t.loadTextureImage(e,n.source,i);if(r.extensionsRequired&&0<=r.extensionsRequired.indexOf(this.name))throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}}]),e}(),kp=function(){function e(t){cp(this,e),this.parser=t,this.name=xp.EXT_TEXTURE_WEBP,this.isSupported=null}return pp(e,[{key:"loadTexture",value:function(e){var t=this.name,r=this.parser,n=r.json;if(!(i=n.textures[e]).extensions||!i.extensions[t])return null;var i=i.extensions[t],o=n.images[i.source],a=r.textureLoader;return o.uri&&null!==(i=r.options.manager.getHandler(o.uri))&&(a=i),this.detectSupport().then((function(i){if(i)return r.loadTextureImage(e,o,a);if(n.extensionsRequired&&0<=n.extensionsRequired.indexOf(t))throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))}},{key:"detectSupport",value:function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}]),e}(),Ap=function(){function e(t){cp(this,e),this.name=xp.EXT_MESHOPT_COMPRESSION,this.parser=t}return pp(e,[{key:"loadBufferView",value:function(e){var t=this.parser.json;if((e=t.bufferViews[e]).extensions&&e.extensions[this.name]){var r=e.extensions[this.name],n=(e=this.parser.getDependency("buffer",r.buffer),this.parser.options.meshoptDecoder);if(n&&n.supported)return Promise.all([e,n.ready]).then((function(e){var t=r.byteOffset||0,i=r.byteLength||0,o=r.count,a=r.byteStride,s=new ArrayBuffer(o*a);return e=new Uint8Array(e[0],t,i),n.decodeGltfBuffer(new Uint8Array(s),o,a,e,r.mode,r.filter),s}));if(t.extensionsRequired&&0<=t.extensionsRequired.indexOf(this.name))throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return null}}]),e}(),Cp="glTF",Lp=pp((function e(t){cp(this,e),this.name=xp.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(t,0,12);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==Cp)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var n=this.header.length-12,i=new DataView(t,12),o=0;o<n;){var a,s=i.getUint32(o,!0),l=(o+=4,i.getUint32(o,!0));o+=4,1313821514===l?(a=new Uint8Array(t,12+o,s),this.content=c.LoaderUtils.decodeText(a)):5130562===l&&(this.body=t.slice(a=12+o,a+s)),o+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),Dp=function(){function e(t,r){if(cp(this,e),!r)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=xp.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=r,this.dracoLoader.preload()}return pp(e,[{key:"decodePrimitive",value:function(e,t){var r,n,i=this.json,o=this.dracoLoader,a=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,l={},u={},c={};for(r in s){var h=Xp[r]||r.toLowerCase();l[h]=s[r]}for(n in e.attributes){var p,f,d=Xp[n]||n.toLowerCase();void 0!==s[n]&&(p=i.accessors[e.attributes[n]],f=Vp[p.componentType],c[d]=f,u[d]=!0===p.normalized)}return t.getDependency("bufferView",a).then((function(e){return new Promise((function(t){o.decodeDracoFile(e,(function(e){for(var r in e.attributes){var n=e.attributes[r];void 0!==(r=u[r])&&(n.normalized=r)}t(e)}),l,c)}))}))}}]),e}(),Ip=function(){function e(){cp(this,e),this.name=xp.KHR_TEXTURE_TRANSFORM}return pp(e,[{key:"extendTexture",value:function(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}]),e}(),jp=function(){fp(t,c.MeshStandardMaterial);var e=mp(t);function t(r){cp(this,t),(n=e.call(this)).isGLTFSpecularGlossinessMaterial=!0;var n,i=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),o=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),a=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),s=["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"),l=["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"),u={specular:{value:(new c.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};return n._extraUniforms=u,n.onBeforeCompile=function(e){for(var t in u)e.uniforms[t]=u[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",i).replace("#include <metalnessmap_pars_fragment>",o).replace("#include <roughnessmap_fragment>",a).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",l)},Object.defineProperties(vp(n),{specular:{get:function(){return u.specular.value},set:function(e){u.specular.value=e}},specularMap:{get:function(){return u.specularMap.value},set:function(e){(u.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return u.glossiness.value},set:function(e){u.glossiness.value=e}},glossinessMap:{get:function(){return u.glossinessMap.value},set:function(e){(u.glossinessMap.value=e)?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete n.metalness,delete n.roughness,delete n.metalnessMap,delete n.roughnessMap,n.setValues(r),n}return pp(t,[{key:"copy",value:function(e){return up(yp(t.prototype),"copy",this).call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}]),t}(),Up=function(){function e(){cp(this,e),this.name=xp.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"]}return pp(e,[{key:"getMaterialType",value:function(){return jp}},{key:"extendParams",value:function(e,t,r){t=t.extensions[this.name];var n,i=(e.color=new c.Color(1,1,1),e.opacity=1,[]);return Array.isArray(t.diffuseFactor)&&(n=t.diffuseFactor,e.color.fromArray(n),e.opacity=n[3]),void 0!==t.diffuseTexture&&i.push(r.assignTexture(e,"map",t.diffuseTexture)),e.emissive=new c.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new c.Color(1,1,1),Array.isArray(t.specularFactor)&&e.specular.fromArray(t.specularFactor),void 0!==t.specularGlossinessTexture&&(n=t.specularGlossinessTexture,i.push(r.assignTexture(e,"glossinessMap",n)),i.push(r.assignTexture(e,"specularMap",n))),Promise.all(i)}},{key:"createMaterial",value:function(e){var t=new jp(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=c.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}]),e}(),Bp=pp((function e(){cp(this,e),this.name=xp.KHR_MESH_QUANTIZATION})),zp=function(){fp(t,c.Interpolant);var e=mp(t);function t(r,n,i,o){return cp(this,t),e.call(this,r,n,i,o)}return pp(t,[{key:"copySampleValue_",value:function(e){for(var t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=e*n*3+n,o=0;o!==n;o++)t[o]=r[i+o];return t}}]),t}(),Np=(zp.prototype.beforeStart_=zp.prototype.copySampleValue_,zp.prototype.afterEnd_=zp.prototype.copySampleValue_,zp.prototype.interpolate_=function(e,t,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,u=n-t,c=e*l,h=c-l,p=-2*(t=(r=(n=(r-t)/u)*n)*n)+3*r,f=t-r,d=1-p,m=f-r+n,v=0;v!==a;v++){var y=o[h+v+a],g=o[h+v+s]*u,b=o[c+v+a],x=o[c+v]*u;i[v]=d*y+m*g+p*b+f*x}return i},new c.Quaternion),Fp=function(){fp(t,zp);var e=mp(t);function t(){return cp(this,t),e.apply(this,arguments)}return pp(t,[{key:"interpolate_",value:function(e,r,n,i){return e=up(yp(t.prototype),"interpolate_",this).call(this,e,r,n,i),Np.fromArray(e).normalize().toArray(e),e}}]),t}(),Vp={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Hp={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},Gp={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},Wp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Xp={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},qp={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yp={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete};function Zp(e,t,r){for(var n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function Qp(e,t){void 0!==t.extras&&("object"===lp(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Kp(e){for(var t="",r=Object.keys(e).sort(),n=0,i=r.length;n<i;n++)t+=r[n]+":"+e[r[n]]+";";return t}function Jp(e){switch(e){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.")}}var $p=function(){function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};cp(this,e),this.json=t,this.extensions={},this.plugins={},this.options=r,this.cache=new bp,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox|^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new np(this.options.manager):this.textureLoader=new c.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}return pp(e,[{key:"setExtensions",value:function(e){this.extensions=e}},{key:"setPlugins",value:function(e){this.plugins=e}},{key:"parse",value:function(e,t){var r=this,n=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.options.myOptions.helper.processInput(n,this)].concat(function(e){return function(e){if(Array.isArray(e))return sp(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ap(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))))).then((function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])})).then((function(t){var o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:r,userData:{}};Zp(i,o,n),Qp(o,n),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){e(o)}))})).catch(t)}},{key:"_markDefs",value:function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],n=0,i=t.length;n<i;n++)for(var o=t[n].joints,a=0,s=o.length;a<s;a++)e[o[a]].isBone=!0;for(var l=0,u=e.length;l<u;l++){var c=e[l];void 0!==c.mesh&&(this._addNodeRef(this.meshCache,c.mesh),void 0!==c.skin&&(r[c.mesh].isSkinnedMesh=!0)),void 0!==c.camera&&this._addNodeRef(this.cameraCache,c.camera)}}},{key:"_addNodeRef",value:function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}},{key:"_getNodeRef",value:function(e,t,r){var n=this;if(e.refs[t]<=1)return r;var i=r.clone();return function e(t,r){var i,o=n.associations.get(t),a=(null!=o&&n.associations.set(r,o),op(t.children.entries()));try{for(a.s();!(i=a.n()).done;){var s=ip(i.value,2),l=s[0];e(s[1],r.children[l])}}catch(e){a.e(e)}finally{a.f()}}(r,i),i.name+="_instance_"+e.uses[t]++,i}},{key:"_invokeOne",value:function(e){var t=Object.values(this.plugins);t.push(this);for(var r=0;r<t.length;r++){var n=e(t[r]);if(n)return n}return null}},{key:"_invokeAll",value:function(e){for(var t=Object.values(this.plugins),r=(t.unshift(this),[]),n=0;n<t.length;n++){var i=e(t[n]);i&&r.push(i)}return r}},{key:"getDependency",value:function(e,t){var r=e+":"+t,n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this.loadNode(t);break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this.loadAnimation(t);break;case"camera":n=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,n)}return n}},{key:"getDependencies",value:function(e){var t,r,n=this.cache.get(e);return n||(r=(t=this).json[e+("mesh"===e?"es":"s")]||[],n=Promise.all(r.map((function(r,n){return t.getDependency(e,n)}))),this.cache.add(e,n)),n}},{key:"loadBuffer",value:function(e){var t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[xp.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(e,i){r.load(c.LoaderUtils.resolveURL(t.uri,n.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}},{key:"loadBufferView",value:function(e){var t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+r)}))}},{key:"loadAccessor",value:function(e){var t=this,r=this.json,n=this.json.accessors[e];return void 0===n.bufferView&&void 0===n.sparse?Promise.resolve(null):(e=[],void 0!==n.bufferView?e.push(this.getDependency("bufferView",n.bufferView)):e.push(null),void 0!==n.sparse&&(e.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),e.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(e).then((function(e){var i,o=e[0],a=Wp[n.type],s=Vp[n.componentType],l=s.BYTES_PER_ELEMENT,u=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized,f=h&&h!==l*a?(d=Math.floor(u/h),m="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+d+":"+n.count,(v=t.cache.get(m))||(i=new s(o,d*h,n.count*h/l),v=new c.InterleavedBuffer(i,h/l),t.cache.add(m,v)),new c.InterleavedBufferAttribute(v,a,u%h/l,p)):(i=null===o?new s(n.count*a):new s(o,u,n.count*a),new c.BufferAttribute(i,a,p));if(void 0!==n.sparse){var d=Vp[n.sparse.indices.componentType],m=n.sparse.indices.byteOffset||0,v=n.sparse.values.byteOffset||0,y=new d(e[1],m,n.sparse.count*Wp.SCALAR),g=new s(e[2],v,n.sparse.count*a);null!==o&&(f=new c.BufferAttribute(f.array.slice(),f.itemSize,f.normalized));for(var b=0,x=y.length;b<x;b++){var w=y[b];if(f.setX(w,g[b*a]),2<=a&&f.setY(w,g[b*a+1]),3<=a&&f.setZ(w,g[b*a+2]),4<=a&&f.setW(w,g[b*a+3]),5<=a)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})))}},{key:"loadTexture",value:function(e){var t=this.json,r=this.options,n=t.textures[e].source,i=(t=t.images[n],this.textureLoader);return t.uri&&null!==(r=r.manager.getHandler(t.uri))&&(i=r),this.loadTextureImage(e,n,i)}},{key:"loadTextureImage",value:function(e,t,r){var n=this,i=this.json,o=i.textures[e],a=((a=i.images[t]).uri||a.bufferView)+":"+o.sampler;return this.textureCache[a]?this.textureCache[a]:(t=this.loadImageSource(t,r).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);var r=(i.samplers||{})[o.sampler]||{};return t.magFilter=Hp[r.magFilter]||c.LinearFilter,t.minFilter=Hp[r.minFilter]||c.LinearMipmapLinearFilter,t.wrapS=Gp[r.wrapS]||c.RepeatWrapping,t.wrapT=Gp[r.wrapT]||c.RepeatWrapping,n.associations.set(t,{textures:e}),n.options.myOptions.helper.material.processTexture({texture:t,textureDef:o}),t})).catch((function(){return null})),this.textureCache[a]=t)}},{key:"loadImageSource",value:function(e,t){var r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((function(e){return e.clone()})).catch((function(e){throw e}));var i=r.images[e],o=self.URL||self.webkitURL,a=i.uri||"";if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){return e=new Blob([e],{type:i.mimeType}),a=o.createObjectURL(e)}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return r=Promise.resolve(a).then((function(e){return new Promise((function(r,i){var o=r;!0===t.isImageBitmapLoader&&(o=function(e,t){(e=new c.Texture(e)).needsUpdate=!0,r({texture:e,blob:t})}),t.load(c.LoaderUtils.resolveURL(e,n.path),o,void 0,i)}))})).then((function(e){var t=e.texture;return e=e.blob,t.userData.url=a,t.userData.blob=e,t.url=a,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e})),this.sourceCache[e]=r}},{key:"assignTexture",value:function(e,t,r){var n=this;return this.getDependency("texture",r.index).then((function(i){var o,a;return void 0===r.texCoord||0==r.texCoord||"aoMap"===t&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+t+" not yet supported."),n.extensions[xp.KHR_TEXTURE_TRANSFORM]&&(o=void 0!==r.extensions?r.extensions[xp.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=n.associations.get(i),i=n.extensions[xp.KHR_TEXTURE_TRANSFORM].extendTexture(i,o),n.associations.set(i,a)),e[t]=i}))}},{key:"assignFinalMaterial",value:function(e){var t,r,n=e.geometry,i=e.material,o=void 0===n.attributes.tangent,a=void 0!==n.attributes.color,s=void 0===n.attributes.normal;e.isPoints?(t="PointsMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new c.PointsMaterial,c.Material.prototype.copy.call(r,i),r.color.copy(i.color),r.map=i.map,r.sizeAttenuation=!1,this.cache.add(t,r)),i=r):e.isLine&&(t="LineBasicMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new c.LineBasicMaterial,c.Material.prototype.copy.call(r,i),r.color.copy(i.color),this.cache.add(t,r)),i=r),(o||a||s)&&(t="ClonedMaterial:"+i.uuid+":",i.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),o&&(t+="derivative-tangents:"),a&&(t+="vertex-colors:"),s&&(t+="flat-shading:"),(r=this.cache.get(t))||(r=i.clone(),a&&(r.vertexColors=!0),s&&(r.flatShading=!0),o&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(t,r),this.associations.set(r,this.associations.get(i))),i=r),i.aoMap&&void 0===n.attributes.uv2&&void 0!==n.attributes.uv&&n.setAttribute("uv2",n.attributes.uv),this.options.myOptions.helper.material.process({material:i,materialDef:i.userData,model:e}),e.material=i}},{key:"getMaterialType",value:function(){return c.MeshStandardMaterial}},{key:"loadMaterial",value:function(e){var t,r=this,n=this.json,i=this.extensions,o=n.materials[e],a={},s=[],l=((n=o.extensions||{})[xp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]?(l=i[xp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS],t=l.getMaterialType(),s.push(l.extendParams(a,o,r))):n[xp.KHR_MATERIALS_UNLIT]?(l=i[xp.KHR_MATERIALS_UNLIT],t=l.getMaterialType(),s.push(l.extendParams(a,o,r))):(n=o.pbrMetallicRoughness||{},a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)&&(l=n.baseColorFactor,a.color.fromArray(l),a.opacity=l[3]),void 0!==n.baseColorTexture&&s.push(r.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&&(s.push(r.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),s.push(r.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),s.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))),!0===o.doubleSided&&(a.side=c.DoubleSide),o.alphaMode||"OPAQUE");return"BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==c.MeshBasicMaterial&&(s.push(r.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new c.Vector2(1,1),void 0!==o.normalTexture.scale&&(n=o.normalTexture.scale,a.normalScale.set(n,n))),void 0!==o.occlusionTexture&&t!==c.MeshBasicMaterial&&(s.push(r.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==c.MeshBasicMaterial&&(a.emissive=(new c.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&t!==c.MeshBasicMaterial&&s.push(r.assignTexture(a,"emissiveMap",o.emissiveTexture)),Promise.all(s).then((function(){var n=t===jp?i[xp.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new t(a);return o.name&&(n.name=o.name),n.map&&(n.map.encoding=c.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=c.sRGBEncoding),Qp(n,o),r.associations.set(n,{materials:e}),o.extensions&&Zp(i,n,o),n}))}},{key:"createUniqueName",value:function(e){for(var t=c.PropertyBinding.sanitizeNodeName(e||""),r=t,n=1;this.nodeNamesUsed[r];++n)r=t+"_"+n;return this.nodeNamesUsed[r]=!0,r}},{key:"loadGeometries",value:function(e){for(var t=this,r=this.extensions,n=this.primitiveCache,i=[],o=0,a=e.length;o<a;o++){var s=e[o],l=(u=void 0,u=(u=(l=s).extensions&&l.extensions[xp.KHR_DRACO_MESH_COMPRESSION])?"draco:"+u.bufferView+":"+u.indices+":"+Kp(u.attributes):l.indices+":"+Kp(l.attributes)+":"+l.mode),u=n[l];u?i.push(u.promise):(u=void 0,u=s.extensions&&s.extensions[xp.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[xp.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return ef(r,e,t)}))}(s):ef(new c.BufferGeometry,s,t),n[l]={primitive:s,promise:u},i.push(u))}return Promise.all(i)}},{key:"loadMesh",value:function(e){for(var t=this,r=this.json,n=this.extensions,i=r.meshes[e],o=i.primitives,a=[],s=0,l=o.length;s<l;s++){var u=void 0===o[s].material?(void 0===(u=this.cache).DefaultMaterial&&(u.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),u.DefaultMaterial):this.getDependency("material",o[s].material);u.then((function(e){})),a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then((function(r){for(var a=r.slice(0,r.length-1),s=r[r.length-1],l=[],u=0,h=s.length;u<h;u++){var p=s[u],f=o[u],d=void 0,m=a[u];if(4===f.mode||5===f.mode||6===f.mode||void 0===f.mode)!0!==(d=new(!0===i.isSkinnedMesh?c.SkinnedMesh:c.Mesh)(p,m)).isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),5===f.mode?d.geometry=tf(d.geometry,c.TriangleStripDrawMode):6===f.mode&&(d.geometry=tf(d.geometry,c.TriangleFanDrawMode));else if(1===f.mode)d=new c.LineSegments(p,m);else if(3===f.mode)d=new c.Line(p,m);else if(2===f.mode)d=new c.LineLoop(p,m);else{if(0!==f.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);d=new c.Points(p,m)}if(0<Object.keys(d.geometry.morphAttributes).length){S=w=x=b=g=v=void 0;var v=d,y=i;if(v.updateMorphTargets(),void 0!==y.weights)for(var g=0,b=y.weights.length;g<b;g++)v.morphTargetInfluences[g]=y.weights[g];if(y.extras&&Array.isArray(y.extras.targetNames)){var x=y.extras.targetNames;if(v.morphTargetInfluences.length===x.length){v.morphTargetDictionary={};for(var w=0,S=x.length;w<S;w++)v.morphTargetDictionary[x[w]]=w}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}d.name=t.createUniqueName(i.name||"mesh_"+e),Qp(d,i),f.extensions&&Zp(n,d,f),t.assignFinalMaterial(d),l.push(d)}for(var T=0,_=l.length;T<_;T++)t.associations.set(l[T],{meshes:e,primitives:T});if(1===l.length)return l[0];var M=new c.Group;t.associations.set(M,{meshes:e});for(var E=0,P=l.length;E<P;E++)M.add(l[E]);return M}))}},{key:"loadCamera",value:function(e){var t,r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new c.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),Qp(t,e),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}},{key:"loadSkin",value:function(e){var t={joints:(e=this.json.skins[e]).joints};return void 0===e.inverseBindMatrices?Promise.resolve(t):this.getDependency("accessor",e.inverseBindMatrices).then((function(e){return t.inverseBindMatrices=e,t}))}},{key:"loadAnimation",value:function(e){for(var t=this.json.animations[e],r=[],n=[],i=[],o=[],a=[],s=0,l=t.channels.length;s<l;s++){var u=t.channels[s],h=t.samplers[u.sampler],p=void 0!==(u=u.target).node?u.node:u.id,f=void 0!==t.parameters?t.parameters[h.input]:h.input,d=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",p)),n.push(this.getDependency("accessor",f)),i.push(this.getDependency("accessor",d)),o.push(h),a.push(u)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(r){for(var n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=[],u=0,h=n.length;u<h;u++)!function(e){var t=n[e],r=i[e],u=o[e],h=a[e],p=s[e];if(void 0!==t){t.updateMatrix(),t.matrixAutoUpdate=!0;var f=void 0;switch(qp[p.path]){case qp.weights:f=c.NumberKeyframeTrack;break;case qp.rotation:f=c.QuaternionKeyframeTrack;break;default:f=c.VectorKeyframeTrack}e=t.name||t.uuid;var d=void 0!==h.interpolation?Yp[h.interpolation]:c.InterpolateLinear,m=[],v=(qp[p.path]===qp.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name||e.uuid)})):m.push(e),u.array);if(u.normalized){for(var y=Jp(v.constructor),g=new Float32Array(v.length),b=0,x=v.length;b<x;b++)g[b]=v[b]*y;v=g}for(var w=0,S=m.length;w<S;w++){var T=new f(m[w]+"."+qp[p.path],r.array,v,d);"CUBICSPLINE"===h.interpolation&&(T.createInterpolant=function(e){return new(this instanceof c.QuaternionKeyframeTrack?Fp:zp)(this.times,this.values,this.getValueSize()/3,e)},T.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(T)}}}(u);return r=t.name||"animation_"+e,new c.AnimationClip(r,void 0,l)}))}},{key:"createNodeMesh",value:function(e){var t=this.json,r=this,n=t.nodes[e];return void 0===n.mesh?null:r.getDependency("mesh",n.mesh).then((function(e){return e=r._getNodeRef(r.meshCache,n.mesh,e),void 0!==n.weights&&e.traverse((function(e){if(e.isMesh)for(var t=0,r=n.weights.length;t<r;t++)e.morphTargetInfluences[t]=n.weights[t]})),e}))}},{key:"loadNode",value:function(e){var t,r=this.json,n=this.extensions,i=this,o=r.nodes[e],a=o.name?i.createUniqueName(o.name):"";return t=[],(r=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)})))&&t.push(r),void 0!==o.camera&&t.push(i.getDependency("camera",o.camera).then((function(e){return i._getNodeRef(i.cameraCache,o.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t).then((function(t){var r,s=!0===o.isBone?new c.Bone:1<t.length?new c.Group:1===t.length?t[0]:new c.Object3D;if(s!==t[0])for(var l=0,u=t.length;l<u;l++)s.add(t[l]);return o.name&&(s.userData.name=o.name,s.name=a),Qp(s,o),o.extensions&&Zp(n,s,o),void 0!==o.matrix?((r=new c.Matrix4).fromArray(o.matrix),s.applyMatrix4(r)):(void 0!==o.translation&&s.position.fromArray(o.translation),void 0!==o.rotation&&s.quaternion.fromArray(o.rotation),void 0!==o.scale&&s.scale.fromArray(o.scale)),i.associations.has(s)||i.associations.set(s,{}),i.associations.get(s).nodes=e,i.options.myOptions.helper.processNode({node:s,nodeDef:o})||s}))}},{key:"loadScene",value:function(e){for(var t=this.json,r=this.extensions,n=(e=this.json.scenes[e],this),i=new c.Group,o=(e.name&&(i.name=n.createUniqueName(e.name)),Qp(i,e),e.extensions&&Zp(r,i,e),e.nodes||[]),a=[],s=0,l=o.length;s<l;s++)a.push(function e(t,r,n,i){var o=n.nodes[t];return i.getDependency("node",t).then((function(e){return void 0===o.skin?e:i.getDependency("skin",o.skin).then((function(e){for(var r=[],n=0,o=(t=e).joints.length;n<o;n++)r.push(i.getDependency("node",t.joints[n]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){for(var n=[],i=[],o=0,a=r.length;o<a;o++){var s=r[o];s?(n.push(s),s=new c.Matrix4,void 0!==t.inverseBindMatrices&&s.fromArray(t.inverseBindMatrices.array,16*o),i.push(s)):console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[o])}e.bind(new c.Skeleton(n,i),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var a=[];if(o.children)for(var s=o.children,l=0,u=s.length;l<u;l++){var c=s[l];a.push(e(c,t,n,i))}return Promise.all(a)}))}(o[s],i,t,n));return Promise.all(a).then((function(){var e;return null!=(e=n.options.myOptions)&&e.models.push(i),n.associations=function(e){console.log(e,e.children,"node,node.children");var t,r=new Map,i=op(n.associations);try{for(i.s();!(t=i.n()).done;){var o=ip(t.value,2),a=o[0],s=o[1];(a instanceof c.Material||a instanceof c.Texture)&&r.set(a,s)}}catch(e){i.e(e)}finally{i.f()}return e.traverse((function(e){var t=n.associations.get(e);null!=t&&r.set(e,t)})),r}(i),i}))}}]),e}();function ef(e,t,r){var n,i=t.attributes,o=[];for(n in i){var a=Xp[n]||n.toLowerCase();a in e.attributes||o.push(function(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}(i[n],a))}void 0===t.indices||e.index||(s=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),o.push(s)),Qp(e,t);var s=e,l=t,u=r,h=l.attributes,p=new c.Box3;if(void 0!==h.POSITION){var f=(h=u.json.accessors[h.POSITION]).min,d=h.max;if(void 0===f||void 0===d)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{p.set(new c.Vector3(f[0],f[1],f[2]),new c.Vector3(d[0],d[1],d[2])),h.normalized&&(f=Jp(Vp[h.componentType]),p.min.multiplyScalar(f),p.max.multiplyScalar(f));var m=l.targets;if(void 0!==m){for(var v=new c.Vector3,y=new c.Vector3,g=0,b=m.length;g<b;g++){var x,w,S=m[g];void 0!==S.POSITION&&(w=(S=u.json.accessors[S.POSITION]).min,x=S.max,void 0!==w&&void 0!==x?(y.setX(Math.max(Math.abs(w[0]),Math.abs(x[0]))),y.setY(Math.max(Math.abs(w[1]),Math.abs(x[1]))),y.setZ(Math.max(Math.abs(w[2]),Math.abs(x[2]))),S.normalized&&(w=Jp(Vp[S.componentType]),y.multiplyScalar(w)),v.max(y)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}p.expandByVector(v)}s.boundingBox=p,d=new c.Sphere,p.getCenter(d.center),d.radius=p.min.distanceTo(p.max)/2,s.boundingSphere=d}}return Promise.all(o).then((function(){if(void 0===t.targets)return e;for(var n=e,i=t.targets,o=r,a=!1,s=!1,l=!1,u=0,c=i.length;u<c;u++){var h=i[u];if(void 0!==h.POSITION&&(a=!0),void 0!==h.NORMAL&&(s=!0),void 0!==h.COLOR_0&&(l=!0),a&&s&&l)break}if(!a&&!s&&!l)return Promise.resolve(n);for(var p=[],f=[],d=[],m=0,v=i.length;m<v;m++){var y,g=i[m];a&&(y=void 0!==g.POSITION?o.getDependency("accessor",g.POSITION):n.attributes.position,p.push(y)),s&&(y=void 0!==g.NORMAL?o.getDependency("accessor",g.NORMAL):n.attributes.normal,f.push(y)),l&&(g=void 0!==g.COLOR_0?o.getDependency("accessor",g.COLOR_0):n.attributes.color,d.push(g))}return Promise.all([Promise.all(p),Promise.all(f),Promise.all(d)]).then((function(e){var t=e[0],r=e[1];return e=e[2],a&&(n.morphAttributes.position=t),s&&(n.morphAttributes.normal=r),l&&(n.morphAttributes.color=e),n.morphTargetsRelative=!0,n}))}))}function tf(e,t){var r=e.getIndex();if(null===r){var n=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var o=0;o<i.count;o++)n.push(o);e.setIndex(n),r=e.getIndex()}var a=r.count-2,s=[];if(t===c.TriangleFanDrawMode)for(var l=1;l<=a;l++)s.push(r.getX(0)),s.push(r.getX(l)),s.push(r.getX(l+1));else for(var u=0;u<a;u++)u%2==0?(s.push(r.getX(u)),s.push(r.getX(u+1)),s.push(r.getX(u+2))):(s.push(r.getX(u+2)),s.push(r.getX(u+1)),s.push(r.getX(u)));return s.length/3!=a&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),(t=e.clone()).setIndex(s),t}class rf{constructor(e){this.materialMap={},this.textureMap={},this.materialIns={},this.textureIns={},this.pending=[],this.parser=null,this.processTextureMap=(()=>{const e=e=>{const{target:t,data:r}=e;var n;r&&(({x:e,y:n}="object"==typeof r?r:{x:r,y:r}),t.x=e,t.y=n)};return t=>{(0,Xe.js)(t,((t,r)=>{var{format:r,center:n,rotation:i,offset:o,repeat:a}=r;const s=this.textureIns[t];s&&(s.format=r,e({target:s.repeat,data:a}),e({target:s.center,data:n}),e({target:s.offset,data:o}),i&&(s.rotation=i),this.runScene.textureEx.initTextureAndAddtoAll(s))}))}})(),this.processMaterialMap=(()=>{const e=e=>{const{textures:t,normal:r,models:n,material:i}=e;this.runScene.optionsEx.options.texture.load&&this.processBaseMaterialTextures({material:i,textures:t}),this.runScene.materialEx.parseNromals(r,i),n.map((e=>e.material=i))},t=e=>{const{textures:t,normal:r,models:n,material:i}=e;e=(0,Xe.js)(t,((e,t)=>({type:e,texture:this.textureIns[t]})));const o=this.runScene.materialEx.getDataByType(r.type,{normal:r,textures:e,models:n,material:i});this.runScene.materialEx.parseNromals(r,o),o&&n.map((e=>e.material=o))};return r=>{(0,Xe.js)(r,((r,n)=>{const{material:i,models:o}=this.materialIns[r];i&&(({normal:r,textures:n}=n),(r.type?t:e)({textures:n,models:o,material:i,normal:r}),i.needsUpdate=!0)}))}})(),this.baseMaterialTextures=[],this.processBaseMaterialTextures=e=>{const{textures:t,material:r}=e;(0,Xe.js)(t,((e,t)=>{var n;(t=this.textureIns[t])&&(this.runScene.optionsEx.options.texture.lazyLoad.open&&"scene"===(null==(n=this.parser)?void 0:n.json.asset.ex.type)&&(null==(n=this.parser)?void 0:n.json.asset.ex.sceneEx.materialId)!==r.userData.id?this.baseMaterialTextures.push({material:r,type:e,texture:t}):(this.runScene.uniqueEx.texture.addMaterial(t,{material:r,type:e}),r[e]=t))}))},this.lazyLoad=(()=>{const e=()=>{this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),this.runScene.optionsEx.log("贴图懒加载完毕","base","success")},t=(r,n)=>{var i=this.baseMaterialTextures[r];if(!i)return n(),e();const{texture:o,type:a,material:s}=i;this.runScene.uniqueEx.texture.addMaterial(o,{material:s,type:a}),s[a]=o,s.needsUpdate=!0,setTimeout((()=>t(++r,n)),this.runScene.optionsEx.options.texture.lazyLoad.intervalTime)};return()=>new Promise((r=>{if(!this.runScene.optionsEx.options.texture.lazyLoad.open)return r(0),e();t(0,r)}))})(),this.runScene=e}processInput(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.parser=t}))}processTexture(e){const{textureDef:t,texture:r}=e;var{md5:e,format:n,size:i}=t;r.userData.md5=e,n&&(r.format=n,r.userData.format=n),r.userData.size=i,this.textureIns[t.id]=this.runScene.textureEx.getSameTexture(e,r)||r}process(e){var{materialDef:e,material:t,model:r}=e;this.materialIns[e.id]||(this.materialIns[e.id]={material:t,models:[]}),this.materialIns[e.id].models.push(r)}done(e){var{materialMap:e,textureMap:t}=e.asset.ex||{};return this.processTextureMap(t||{}),this.processMaterialMap(e||{}),this.pending.push(this.lazyLoad()),Promise.all(this.pending)}}class nf{constructor(e){this.runScene=e}done(e){var t,r,n,i;e.asset.ex&&(({camera:e,lights:t,sceneEx:r,options:n,controls:i}=e.asset.ex),this.camera(e),this.controls(i),this.lights(t),this.ex(r),this.options(n))}controls(e){var t,r;e&&(({x:e,y:t,z:r}=e),this.runScene.assetsEx.controls.target.set(e,t,r),this.runScene.assetsEx.controls.update())}camera(e){var{position:e,far:t,near:r,fov:n,name:i,userData:o}=this.runScene.loaderer.object.parse(e);const a=this.runScene.assetsEx.get().camera;a.position.copy(e),a.far=t,a.near=r,a.fov=n,a.name=i,a.updateProjectionMatrix(),a.userData.id=o.id,this.runScene.uniqueEx.model.add(a),this.runScene.assetsEx.get().controls.update()}lights(e){e.map((e=>{var t=e.type;(t=this.runScene.lightEx.lightExMap[t].parseJSON(e)).target&&this.runScene.modelEx.setSelectByModel(t.target),this.runScene.lightEx.setNull(t)}))}ex(e){var t,r;e=e.fog;const n=this.runScene.sceneEx.get();e&&(({color:e,near:t,far:r}=e),n.fog=new c.Fog(e,t,r),this.runScene.optionsEx.cb.setScene.cb({scene:n,type:"fog"}))}options(e){e.map((e=>{var{type:e,data:t}=e;const r=this.runScene.exporter.gltf.options.getParse(e);null!=r&&r.parse(t)}))}}class of{constructor(e){this.runScene=e}setTextureLoader(e){this.textureLoader=e,this.initTextureLoader(e)}initTextureLoader(e){e instanceof np&&e.setOptions({textureQuality:this.runScene.optionsEx.options.texture.quality})}}class af{constructor(e){this.parser=null,this.helperModels=[],this.pending=[],this.nodeType={MySpriteMaterial:Za},this.cloneMap={},this.runScene=e,this.material=new rf(e),this.scene=new nf(e),this.options=new of(e)}processInput(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.material.processInput(e,t)}))}beforeLoader(e){this.runScene.loaderer.gltf.beforeParse(null==(e=null==(e=e.asset)?void 0:e.ex)?void 0:e.type)}processNode(e){var t;let{node:r,nodeDef:n}=e;if((0,Xe.js)(this.runScene.modelEx.defNodeMap,((e,t)=>{var i=n[e];null!=i&&(r[e]=i)})),n.extras){const{layers:o,normal:a,local:s,cloneId:l,id:u}=n.extras;if(l&&(this.cloneMap[l]||(this.cloneMap[l]=new Set),u&&this.cloneMap[l].add(u)),s&&([e,t,i]=s.split(","),r.position.set(e,t,i)),o&&(r.layers.enable(1),this.runScene.optionsEx.cb.model.setLayers.cb({model:r,val:1})),n.extras.isHelper&&this.helperModels.push(r),a){const n=this.nodeType[null==a?void 0:a.type].modelTools.parseData(r,a);var i=null==(t=null==(e=null==r?void 0:r.material)?void 0:e.userData)?void 0:t.id;if(i){const e=this.material.materialIns[i];if(e){const t=[];e.models.map((e=>{e===r?t.push(n):t.push(e)})),e.models=t}}r=n}}return n.wireframe&&(r.material.wireframe=!0),r}done(e){var t;return this.pending.push(this.material.done(e)),"scene"===(null==(t=e.asset.ex)?void 0:t.type)&&(this.scene.done(e),this.sceneEx(e)),this.removeHelperModel(),Promise.all(this.pending)}mergeGeometry(){}mergeClone(){this.runScene.optionsEx.options.instanceClone&&(0,Xe.js)(this.cloneMap,((e,t)=>{const r=this.runScene.uniqueEx.model.get(e);(e=[...t].map((e=>{if((null==(e=this.runScene.uniqueEx.model.get(e))?void 0:e.material)===r.material)return this.runScene.modelEx.remove(e,!1),e})).filter((e=>e))).length&&(t=is(r,e),this.runScene.modelEx.add(t,r.parent),this.runScene.modelEx.remove(r,!1))}))}sceneEx(e){const t=this.runScene.sceneEx.get();var r=this.material.materialIns,{materialId:e,backgroundMapping:n,backgroundColor:i,fog:o}=e.asset.ex.sceneEx;if(e&&(e=null==(r=r[e])?void 0:r.material)){const{map:r,envMap:i}=e;r&&(r.mapping=n||300,r.needsUpdate=!0,this.runScene.sceneEx.setBackground(r,!1),r.userData.isBackgroud=!0),i&&(t.environment=Li(i))}i&&(t.background=new c.Color("#"+i)),o&&(({color:r,far:e,near:n}=o),t.fog=new c.Fog("#"+r,n,e),t.fog.open="true"),this.runScene.optionsEx.cb.setScene.cb({scene:t,type:"any"})}removeHelperModel(){this.helperModels.map((e=>{var t;return null==(t=e.parent)?void 0:t.remove(e)}))}}class sf{constructor(e){this.dracoPath="./draco/",this._gltf=new gp,this.runScene=e;const t=new Zh;t.setDecoderPath(this.runScene.optionsEx.options.decodePath),this._gltf.setDRACOLoader(t)}load(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){var r=yield Jo(e);return r?this.parse(r,t):Promise.resolve()}))}parse(e,t){return new Promise((r=>{try{e instanceof ArrayBuffer&&this._gltf.parse(e,"",(e=>{e=this.afterParse(e.parser.options.myOptions,e,t),r(e)}),(e=>{}),{rootModel:this.runScene.assetsEx.get().scene,models:[],helper:new af(this.runScene),runScene:this.runScene})}catch(e){this.runScene.optionsEx.log("加载场景出错:"+e)}}))}beforeParse(e){"scene"===e&&this.runScene.optionsEx.sceneOptions.loaded&&this.runScene.sceneEx.clean()}afterParse(e,t,r){const n=e.helper.done(t);var{addToScene:r,cleanJSON:i}=$o({addToScene:!0,cleanJSON:!0},{config:r}),o=e.models;console.log(o,"models");let a=[];return"material"===t.asset.ex.type?this.parseMaterial(o):("model"===t.asset.ex.type&&(a=this.parseModel(o[0],r)),"scene"===t.asset.ex.type&&(a=this.parseScene({model:o[0],json:t,addToScene:r})),this.runScene.modelEx.selectNull(),e.helper.mergeClone(),this.runScene.optionsEx.log(t,"detail"),n.then((()=>{this.runScene.optionsEx.cb.load.complete.cb("")}))),!1!==i&&this.disposeJSON(t),this.runScene.optionsEx.sceneOptions.loaded=!0,a}parseMaterial(e){var t,[e]=e;(e=this.runScene.sceneEx.cleanUnlessLevel(e).material)&&(this.runScene.materialEx.add(e),(t=this.runScene.modelEx.select)&&this.runScene.materialEx.resetMaterial(t,e))}parseModel(e,t){return e.children.map((e=>e.userData.id=(0,l.getId)())),!1!==t&&this.runScene.modelEx.add(e,void 0,{addUndo:!1,select:!1}),[e]}parseScene(e){const{model:t,json:r,addToScene:n}=e;return e=t.children.filter((e=>this.runScene.modelEx.isUnless(e)?void 0:e)),!1!==n&&this.runScene.modelEx.add(e,void 0,{addUndo:!1,select:!1}),this.runScene.timeLineEx.parseSavedGroupMap(r.asset.ex.timeLine||{}),this.runScene.optionsEx.cb.load.loaded.cb(""),e}disposeJSON(e){(0,Xe.js)(e,(t=>delete e[t])),e=null}}class lf{constructor(e){this.imgBitMap=new c.ImageBitmapLoader,this.object=new c.ObjectLoader,this.runScene=e,this.gltf=new sf(e)}}var uf=a(185);class cf{constructor(e){this.selectors={},this.boxHelperMap={},(this.runScene=e).events.mouse.bindEvent({type:"up",local:"local",name:"MultipSelector",fn:t=>{e.events.key.ctrl||this.setEmpty()}})}add(e,t=!1){if("array"===(0,uf.getType)(e))return e.map((e=>this.add(e)));var r=this.runScene.modelEx.select;if(r&&(this.runScene.modelEx.selectNull(),delete this.selectors[e.uuid],this.add(r)),"BoxHelper"!==e.type){if(this.selectors[e.uuid]){if(this.remove(e),this.removeBoxHelper(e),!t)return;this.add(e)}this.addBoxHelper(e),this.selectors[e.uuid]=e,this.runScene.optionsEx.cb.model.focus.cb({model:e,status:!0,domActive:!0}),this.runScene.helperEx.focus(e)}}setInfo(e,t,r,n,i,o){"position"!==t&&(i=n,o=r);const a=this.getSelectedList("value");var{x:i,y:s,z:l}=i;const u=i-o.x,c=s-o.y,h=l-o.z,p=[new es({target:e,info:t,oldV3:this.runScene.modelEx.cloneV3(r),newV3:n,runScene:this.runScene}).execute()];a.map((r=>{if(r!==e){var{x:n,y:i,z:o}=r[t],n=n+=u,i=i+=c,o=o+=h;let e=r[t].clone();e.x=n,e.y=i,e.z=o,n=new es({target:r,info:t,oldV3:this.runScene.modelEx.cloneV3(r[t]),newV3:e,runScene:this.runScene}).execute(),p.push(n),this.boxHelperMap[r.uuid].setFromObject(r)}})),this.runScene.undoEx.addUndo(p)}getLast(){var e=this.getSelectedList("value");return e[e.length-1]}addBoxHelper(e){var t=this.runScene.helperEx.getBoxHelper(e);this.boxHelperMap[e.uuid]=t}removeBoxHelper(e){this.runScene.assetsEx.get().scene.remove(this.boxHelperMap[e.uuid]),this.boxHelperMap[e.uuid]=null,delete this.selectors[e.uuid]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));this.runScene.optionsEx.cb.model.unFocus.cb(e),this.selectors[e.uuid]=null,delete this.selectors[e.uuid]}isEmpty(){return 0===this.getSelectedList("key").length}getSelectedList(e){return"key"===e?Object.keys(this.selectors):Object.values(this.selectors)}getSelect(){var e=Object.values(this.selectors);return 0!==e.length?e:void 0}selectedLoop(e){return Object.keys(this.selectors).map((t=>e(t,this.selectors[t])))}delete(){this.setBoxHelperEmpty(),this.setEmpty(),this.runScene.helperEx.unfocus()}setBoxHelperEmpty(){var e=Object.values(this.boxHelperMap);this.runScene.assetsEx.get().scene.remove(...e),this.boxHelperMap={}}setEmpty(){this.getSelectedList("value").map((e=>{this.runScene.optionsEx.cb.model.unFocus.cb(e)})),this.setBoxHelperEmpty(),this.selectors={}}createGroup(){this.runScene.helperEx.unfocus(),this.runScene.modelEx.selectNull();var e=new c.Group;const t=new c.Group;this.runScene.modelEx.add(e,void 0,{addUndo:!1}),this.runScene.modelEx.add(t);var r=[...this.getSelectedList("value")],n=(this.runScene.optionsEx.cb.model.multipDrop.cb(this.getSelectedList("value"),e),Ta().group.getCenter(e));t.position.copy(n),this.runScene.optionsEx.cb.model.multipDrop.cb(r,t),this.runScene.modelEx.remove(e,!1),this.runScene.modelEx.select=t}getSelectorGroup(){const e=this.getSelectedList("value"),t=new c.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}}class hf{constructor(){this.cbs=[]}cb(e,t){return Promise.all(this.cbs.map((r=>{var n;return null==(n=r.fn)?void 0:n.call(r,e,t)})))}add(e,t){return this.cbs.push({fn:t,name:e})}get(e){var t=this.cbs.findIndex((t=>t.name===e));if(-1!==t)return{data:this.cbs[t],index:t}}reset(e,t){return!!(e=this.get(e))&&(e.data.fn=t,!0)}remove(e){this.reset(e,null)}}class pf{constructor(){this.resize=new hf,this.setSelectMaterial=new hf,this.setScene=new hf,this.reset=new hf,this.render=new hf,this.baseLog=new hf,this.inited=new hf,this.texture={add:new hf,remove:new hf},this.model={setSelect:new hf,add:new hf,remove:new hf,multipDrop:new hf,focus:new hf,unFocus:new hf,changeName:new hf,setOpen:new hf,setMainStatue:new hf,setVisible:new hf,setParent:new hf,setLayers:new hf,clone:new hf,dispose:new hf},this.material={add:new hf,dispose:new hf,setName:new hf},this.unique={material:{add:new hf}},this.undo={addUndos:new hf,removeUndos:new hf,undoByIndex:new hf,reset:new hf},this.scene={save:new hf,saveNet:new hf},this.timeLine={setProgress:new hf,playGroup:new hf,setGroupMap:new hf,reset:new hf,closeGroup:new hf},this.events={key:{g:new hf},mouse:{move:new hf,down:new hf,up:new hf},pointer:{down:new hf,up:new hf}},this.bloom={glow:{setData:new hf,setStatus:new hf}},this.load={lazyLoadedTexture:new hf,loaded:new hf,models:new hf,progress:new hf,getArrayBuffer:new hf,complete:new hf}}}function ff(){var e=0,t=document.createElement("div");function r(e){return t.appendChild(e.dom),e}function n(r){for(var n=0;n<t.children.length;n++)t.children[n].style.display=n===r?"block":"none";e=r}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(r){r.preventDefault(),n(++e%t.children.length)}),!1);var i,o=(performance||Date).now(),a=o,s=0,l=r(new ff.Panel("FPS","#0ff","#002")),u=r(new ff.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=r(new ff.Panel("MB","#f08","#201"))),n(0),{REVISION:16,dom:t,addPanel:r,showPanel:n,begin:function(){o=(performance||Date).now()},end:function(){s++;var e,t=(performance||Date).now();return u.update(t-o,200),a+1e3<=t&&(l.update(1e3*s/(t-a),100),a=t,s=0,i&&(e=performance.memory,i.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){o=this.end()},domElement:t,setMode:n}}ff.Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),s=80*a,l=48*a,u=3*a,c=2*a,h=3*a,p=15*a,f=74*a,d=30*a,m=document.createElement("canvas"),v=(m.width=s,m.height=l,m.style.cssText="width:80px;height:48px",m.getContext("2d"));return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,s,l),v.fillStyle=t,v.fillText(e,u,c),v.fillRect(h,p,f,d),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h,p,f,d),{dom:m,update:function(l,y){n=Math.min(n,l),i=Math.max(i,l),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,s,p),v.fillStyle=t,v.fillText(o(l)+" "+e+" ("+o(n)+"-"+o(i)+")",u,c),v.drawImage(m,h+a,p,f-a,d,h,p,f-a,d),v.fillRect(h+f-a,p,a,d),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h+f-a,p,a,o((1-l/y)*d))}}};const df=ff;class mf{constructor(e){this.options={msg:{show:!1,level:"base"},run:!0,decodePath:"./draco/",showFps:!1,loadInterval:2e3,mode:"running",hideLocal:!1,instanceClone:!1,render2:!1,render3:!1,texture:{load:!0,lazyLoad:{open:!1,intervalTime:16.6},quality:1}},this.exporterOptions={compressTexture:!1,notMaterial:!1},this.sceneOptions={loaded:!1},this.setLoadInterval=(()=>{let e=null;return t=>{const{inputInterval:r,cb:n}=t;e&&clearTimeout(e),e=setTimeout((()=>{n(),e=null,clearTimeout(e)}),r)}})(),this.cb=new pf,this.runScene=e}init(e){this.options=ba(this.options,e||{}),this.options.showFps&&(this.addFps(),this.cb.render.add("optionx-ex-render",this.render.bind(this)))}addFps(){this.stats=df(),this.stats.showPanel(0),this.runScene.assetsEx.engineDom.appendChild(this.stats.dom)}render(){var e;null!=(e=this.stats)&&e.update()}log(e,t="detail",r="success"){var n;null!=(n=null==(n=this.options)?void 0:n.msg)&&n.show&&("base"===this.options.msg.level&&"base"===t&&this.cb.baseLog.cb(e,r),console.log(e))}}class vf{constructor(e){this.setSize=(e,t)=>{var{w:r,h:n}=this.getDomSize();this.runScene.setSize(e||r,t||n)},this.runScene=e}create(e){let t=new c.WebGLRenderer({antialias:!0,alpha:!0,powerPreference:"high-performance"});return t.domElement.style.position="absolute",t.setPixelRatio(window.devicePixelRatio),t.shadowMap.enabled=!0,t.shadowMap.type=c.PCFSoftShadowMap,t.physicallyCorrectLights=!0,t.localClippingEnabled=!0,e.appendChild(t.domElement),t}getDomSize(){var{clientWidth:e,clientHeight:t}=this.runScene.assetsEx.get().engineDom;return{w:e,h:t}}}const yf=(e,t)=>{t=(t||{}).removeDom,!(e.render=()=>{})!==t&&e.domElement.remove(),e.setAnimationLoop(null),e.dispose(),e.renderLists&&e.renderLists.dispose()};class gf{constructor(e){this.oldFog=null,this.removeMap={light:{valid:e=>this.runScene.lightEx.isLight(e),remove:e=>this.runScene.lightEx.remove(e)}},this.runScene=e}each(e){return this.runScene.assetsEx.get().scene.traverseAncestors(e)}get(){return new Proxy(this.runScene.assetsEx.get().scene,{set:(e,t,r)=>(e[t]=r,!0)})}getNromal(){return this.get().children.filter((e=>!this.runScene.helperEx.isHelper(e)))}remove(e){var t;if(e){if(e instanceof Array){const t=[];return e.map((e=>{for(const r in this.removeMap){const{valid:n,remove:i}=this.removeMap[r];if(n(e))return t.push(...(0,_a.multiArrToArr)(i(e)))}t.push(new $a({model:e,runScene:this.runScene,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(t),t}for(const t in this.removeMap){const{valid:r,remove:n}=this.removeMap[t];if(r(e))return n(e)}this.runScene.modelEx.remove(e),null!=(t=this.runScene.helperEx.boxHelper)&&t.setFromObject(this.get())}}cleanUnlessLevel(e){return this.runScene.modelEx.isUnlessLevel(e)&&!this.runScene.helperEx.isHelper(e)&&0!==e.children.length&&1===e.children.length?this.cleanUnlessLevel(e.children[0]):e}getClearModels(){return this.get().children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e)))}getClear(){const e=this.get(),t=new c.Group;return e.children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e))).map((e=>{t.add(e.clone())})),this.runScene.helperEx.setHelper(t),this.cleanUnlessLevel(t)}cleanNormal(){this.getNromal().map((e=>this.remove(e)))}cleanSceneInfo(e){e.background=null,e.environment=null,e.fog=null}setBackground(e,t=!0){e instanceof c.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),n=new Na({target:r,info:"background",newVal:e,oldVal:r.background,runScene:this.runScene,cb:e=>{this.runScene.bloom.glow.setBackground(e.background)}}).execute();return t&&this.runScene.undoEx.addUndo(n),this.runScene.optionsEx.cb.setScene.cb({scene:r,type:"background"}),this.runScene.bloom.glow.setBackground(e),e}isBackground(e){return e.userData.isBackgroud}clean(){this.runScene.helperEx.unfocus();const e=this.getClearModels();let t=[];e.map((e=>{e.traverse((e=>t.push(e)))})),t.map((e=>{ns(e,{remove:!1}),this.runScene.optionsEx.cb.model.dispose.cb(e)})),yf(this.runScene.assetsEx.get().renderer),this.runScene.assetsEx.get().controls.dispose(),this.runScene.assetsEx.reset(),this.runScene.modelEx.selectNull(),this.cleanSceneInfo(this.get()),this.runScene.cameraEx.reset(this.runScene.assetsEx.get().camera),this.cleanNormal(),this.runScene.assetsEx.get().renderer.resetState(),this.runScene.assetsEx.get().controls.update(),this.runScene.uniqueEx.dispose(),this.runScene.materialEx.dispose(),this.runScene.undoEx.reset(),this.runScene.timeLineEx.reset(),this.runScene.bloom.glow.dispose(),this.runScene.bloom.glow.init(this.runScene.assetsEx.get()),this.runScene.helperEx.reset(),this.runScene.optionsEx.cb.reset.cb(this.get())}dispose(){const{renderer:e,controls:t}=this.runScene.assetsEx.get();this.clean(),yf(e),t.dispose(),this.runScene.bloom.glow.dispose(),c.Cache.clear()}render(){}create(){return new c.Scene}setEnv(e,t){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){let r;return t instanceof File&&(r=Li(yield this.runScene.textureEx.parse(t))),null!=t&&t.isTexture&&(r=Li(this.runScene.textureEx.clone(t))),this.setNormal({model:e,info:"environment",val:r}),this.runScene.optionsEx.cb.setScene.cb({scene:e,type:"environment"}),r}))}setNormal(e,t=!0){var{model:e,info:r,val:n}=e;e=new Na({target:e,info:r,oldVal:e[r],newVal:n,runScene:this.runScene}).execute(),t&&this.runScene.undoEx.addUndo(e)}setFogShow(e){var{show:e,color:t,scene:r}=e;e?this.setNormal({model:r,info:"fog",val:this.oldFog||new c.Fog(t)}):(this.oldFog=r.fog,this.setNormal({model:r,info:"fog",val:null})),this.runScene.optionsEx.cb.setScene.cb({scene:r,type:"fog"})}setFog(e){var{scene:e,type:t,val:r}=e;e=new Ra({target:e,typeList:["fog",t],newVal:r}).execute(),this.runScene.undoEx.addUndo(e)}getFogJson(e){const{color:t,far:r,near:n}=e;return{color:t.getHexString(),far:r,near:n}}sreenShotDefFile(){this.runScene.helperEx.unfocus();var{w:e,h:t}=this.runScene.renderEx.getDomSize();const r=this.runScene.assetsEx.get().renderer.domElement,{renderer:n,scene:i,camera:o}=(r.width=1920,r.height=1080,this.runScene.renderEx.setSize(1920,1080),this.runScene.assetsEx.get());n.render(i,o);var a=r.toDataURL("image/webp",1);return a=(0,Ye.base64ToFile)(a,"screenShot.jpg"),r.width=e,r.height=t,this.runScene.renderEx.setSize(),n.render(i,o),a}}class bf{constructor(e,t){this.showTransform=!1,this.data=new Proxy({},{set:(e,t,r)=>(e[t]=r,!0)}),this.uuid="",this.getAnimaByModelData=(()=>{const e=(e,t,r,n)=>{const i={},o={};if(e=bf.isNotNow(e)?this.getAllData():e,(0,Xe.js)(n,((r,n)=>{void 0!==e[r]&&("number"===(n=n.type)?(i[r]=t[r],o[r]=e[r]):"color"===n&&(0,Xe.js)(e[r],((e,n)=>{var a=r+e;i[a]=t[r][e],o[a]=n})))})),!(0,Xe.CV)(i))return{begin:i,end:o}};return(t,r,n,i=!1,o)=>{let a=i?n.time:0;const s=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var l=(0,_a.lastArrayEle)(s),u=i?"0.00":String(n.time);return l!==u&&(t[u]=Object.assign({},l),s.push(u)),s.map((s=>{var l=t[String(s)],u=.001*((u=i?a-s:s-a)<=0?.001:u)*n.speed;a=s;{var c=r,h=l,p=u,f=o;const t={color(e){const{animaData:t,defType:r}=e,n={};(0,Xe.js)(t,(e=>{var i;-1!==e.indexOf(r)&&(i=e.substring(r.length),["r","g","b"].includes(i)&&(n[i]=t[e]))}));var{r:e,g:i,b:o}=n;if((0,uf.isTrue)(e)&&(0,uf.isTrue)(i)&&(0,uf.isTrue)(o))return n}};return()=>{let r;return{promise:new Promise((n=>{var i;if(!(i=e(h,c,0,f)))return n(0);var{begin:i,end:o}=i;return r=_o(i,o,p,(e=>{(0,Xe.js)(f,((r,n)=>{n=n.type;var i,o=e[r];"number"===n?c[r]=o:"color"===n&&(o=t.color({animaData:e,defType:r}))&&(({r:n,g:o,b:i}=o),c[r].setRGB(n,o,i))}))}),n)})),anima:r}}}}))}})(),this.runScene=t,this.target=e,this.target.userData.isTimeLineUsed=!0,this.uuid=this.getId(e)}toJSON(){var{data:e,type:t}=this;return{data:e,type:t}}addData(e,t,r=!1){return 1e3<Number(e)&&(e="1000.00"),r?this.data[e]=this.getAllData():(this.data[e]||(this.data[e]={}),this.data[e][t]=this.getData(t)),this.data[e]}addTriggerNowData(e){return this.data[e]=this.getAllData(!0)}removeData(e){delete this.data[e]}static isNotNow(e){return"notNow"===Object.values(e)[0]}static getAllDefValByType(e,t,r=!1){const n={};return(0,Xe.js)(e,(i=>{n[i]=r?"notNow":bf.getValByType(t,i,e)})),n}static getValByType(e,t,r){var n,i;return r=r[t].type,e=e[t],"number"===r?e:"color"===r?(({r:t,g:n,b:i}=e),{r:t,g:n,b:i}):"V3"===r?Ta().model.v3ToMap(e):""}static SetTargetByData(e){const{baseType:t,data:r,defType:n,target:i}=e;var o,a;"number"===t?i[n]=r:"color"===t&&(({r:e,g:o,b:a}=r),i[n].setRGB(e,o,a))}getAllData(e=!1){return bf.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return bf.getValByType(this.target,e,this.defOptions)}static getTarget(e,t){}getAnima(e,t){return this.getAnimaByModelData(this.data,this.target,e,t,this.defOptions)}setTargetByBetween(e,t,r){bf.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const n=new(0,wf[r])(e);return n.data=t,n}reset(){(0,Xe.js)(this.defOptions,((e,t)=>{bf.SetTargetByData({baseType:t.type,data:bf.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}remove(){delete this.target.userData.isTimeLineUsed}}bf.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,n,i,o)=>{(0,Xe.js)(i,((i,a)=>{var s,l,u,c,h,p;a=a.type,void 0!==t[i]&&void 0!==r[i]&&bf.SetTargetByData({baseType:a,data:(s=t[i],l=r[i],u=n,"number"===a?e(s,l,u):"color"===a?(({r:a,g:s,b:c}=s),({r:l,g:h,b:p}=l),{r:e(a,l,u),g:e(s,h,u),b:e(c,p,u)}):void 0),defType:i,target:o})}))}})();const xf=bf,wf={model:class extends xf{constructor(e,t){super(e,t),this.type="model",this.defOptions={position:{type:"V3"},scale:{type:"V3"},rotation:{type:"V3"}},this.setTargetByBetween=(()=>{const e=(e,t,r)=>{var{x:e,y:n,z:i}=e,{x:t,y:o,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:n!==o?(o-n)*r+n:n,z:i!==a?(a-i)*r+i:i}};return(t,r,n)=>{var i,{position:t,scale:o,rotation:a}=t,{position:r,scale:s,rotation:l}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,n)),this.target.position.set(t,r,i)),o&&s&&(({x:t,y:r,z:i}=e(o,s,n)),this.target.scale.set(t,r,i)),a&&l&&(({x:o,y:s,z:t}=e(a,l,n)),this.target.rotation.set(o,s,t))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:n,rotation:i}=t,{position:e,scale:o,rotation:a}=xf.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},o?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:i.x,ry:i.y,rz:i.z}:{}),end:Object.assign({},r.curve?{ease:"none"}:{},e?{px:e.x,py:e.y,pz:e.z}:{},o?{sx:o.x,sy:o.y,sz:o.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{})}};return(t,r,n,i=!1)=>{let o=i?n.time:0;const a=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var s=(0,_a.lastArrayEle)(a),l=i?"0.00":String(n.time)+".00";return s!==l&&(t[l]={position:"notNow",rotation:"notNow",scale:"notNow"},a.push(l)),a.map((a=>{var s,l,u,c,h=t[String(a)],p=.001*((p=i?o-a:a-o)<=0?.001:p)*n.speed;return o=a,s=r,l=h,u=p,c=n,()=>{let t;return{promise:new Promise((r=>{var{begin:n,end:i}=e(l,s,c);return t=_o(n,i,u,(e=>{var{px:e,py:t,pz:r,sx:n,sy:i,sz:o,rx:a,ry:u,rz:c}=e;l.position&&s.position.set(e,t,r),l.scale&&s.scale.set(n,i,o),l.rotation&&s.rotation.set(a,u,c)}),r)})),anima:t}}}))}})(),this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.model.get(e)}isRemoved(){return!(this.target&&this.target.parent)}getAnima(e,t=!1){return this.getAnimaByModelData(this.data,this.target,e,t)}getId(){return this.runScene.uniqueEx.getId(this.target)}reset(){var{position:e,scale:t,rotation:r}=this.beginData;this.target.position.set(e.x,e.y,e.z),this.target.scale.set(t.x,t.y,t.z),this.target.rotation.set(r.x,r.y,r.z)}},camera:class extends xf{constructor(e,t){super(e,t),this.type="camera",this.defOptions={position:{type:"V3"},scale:{type:"V3"},rotation:{type:"V3"},target:{type:"V3"}},this.setTargetByBetween=(()=>{const e=(e,t,r)=>{var{x:e,y:n,z:i}=e,{x:t,y:o,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:n!==o?(o-n)*r+n:n,z:i!==a?(a-i)*r+i:i}};return(t,r,n)=>{var i,{position:t,scale:o,rotation:a,target:s}=t,{position:r,scale:l,rotation:u,target:c}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,n)),this.target.position.set(t,r,i)),o&&l&&(({x:t,y:r,z:i}=e(o,l,n)),this.target.scale.set(t,r,i)),a&&u&&(({x:o,y:l,z:t}=e(a,u,n)),this.target.rotation.set(o,l,t)),s&&c&&(({x:r,y:i,z:a}=e(s,c,n)),this.controls.target.set(r,i,a))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:n,rotation:i}=t,{position:e,scale:o,rotation:a,target:s}=xf.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},o?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:i.x,ry:i.y,rz:i.z}:{},s?{tx:this.controls.target.x,ty:this.controls.target.y,tz:this.controls.target.z}:{}),end:Object.assign({},r.curve?{ease:"none"}:{},e?{px:e.x,py:e.y,pz:e.z}:{},o?{sx:o.x,sy:o.y,sz:o.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{},s?{tx:s.x,ty:s.y,tz:s.z}:{})}},t=(t,r,n,i)=>()=>{let o;return{promise:new Promise((a=>{var{begin:s,end:l}=e(r,t,i);return o=_o(s,l,n,(e=>{var{px:e,py:n,pz:i,sx:o,sy:a,sz:s,rx:l,ry:u,rz:c,tx:h,ty:p,tz:f}=e;r.position&&t.position.set(e,n,i),r.scale&&t.scale.set(o,a,s),r.rotation&&t.rotation.set(l,u,c),r.target&&this.controls.target.set(h,p,f)}),a)})),anima:_o}};return(e,r,n,i=!1)=>{let o=i?n.time:0;const a=Object.keys(e).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var s=(0,_a.lastArrayEle)(a),l=i?"0.00":String(n.time);return s!==l&&(e[l]=Object.assign({},s),a.push(l)),a.map((a=>{var s=e[String(a)],l=.001*((l=i?o-a:a-o)<=0?.001:l)*n.speed;return o=a,t(r,s,l,n)}))}})(),this.controls=this.runScene.assetsEx.get().controls,this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.model.get(e)}getBeginData(e){return this.getAllData()}isRemoved(){return!this.target}getAllData(e=!1){var{position:t,scale:r,rotation:n}=this.target;return{position:e?"notNow":Ta().model.v3ToMap(t),scale:e?"notNow":Ta().model.v3ToMap(r),rotation:e?"notNow":Ta().model.v3ToMap(n),target:e?"notNow":Ta().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:n}=this.target;let i;if("position"===e)i=Ta().model.v3ToMap(t);else if("scale"===e)i=Ta().model.v3ToMap(r);else if("rotation"===e)i=Ta().model.v3ToMap(n);else{if("target"!==e)throw TypeError("输入值不存在");i=Ta().model.v3ToMap(this.controls.target)}return i}getAnima(e,t=!1){return this.getAnimaByModelData(this.data,this.target,e,t)}getId(){return this.runScene.uniqueEx.getId(this.target)}reset(){var{position:e,scale:t,rotation:r,target:n}=this.beginData;this.target.position.set(e.x,e.y,e.z),this.target.scale.set(t.x,t.y,t.z),this.target.rotation.set(r.x,r.y,r.z),this.controls.target.set(n.x,n.y,n.z)}},material:class extends xf{constructor(e,t){super(e,t),this.type="material",this.defOptions={roughness:{type:"number"},metalness:{type:"number"},opacity:{type:"number"},emissive:{type:"color"},color:{type:"color"}},this.beginData=this.getAllData()}static getTarget(e,t){return t.uniqueEx.material.get(e)}isRemoved(){return!0}getId(){return this.runScene.uniqueEx.getId(this.target)}}};class Sf{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){if(e&&e.userData){let n=e.userData.id;n||(n=(0,l.getId)(),e.userData.id=n),this.map[n]||(this.map[n]={material:e,models:new Set},this.unique.runScene.optionsEx.cb.unique.material.add.cb(e),t&&this.addModel(t,e,r))}}addModel(e,t,r){t&&t.userData&&(t=t.userData.id,null!=(t=this.map[t])&&t.models.add(e)),r&&null!=(t=this.map[r.userData.id])&&t.models.delete(e)}get(e){return null==(e=this.map[e])?void 0:e.material}remove(e){delete this.map[e]}addRemoved(e){this.map[e.uuid]&&this.removes.push(e.uuid)}dispose(){(0,Xe.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var Tf=a(1);class _f extends class{constructor(e){this.map={},this.unique=e}add(e){if(e instanceof Array)return e.map((e=>this.add(e)));let t=e.userData.id;return t||(t=(0,l.getId)(),e.userData.id=t),this.map[t]?void 0:(this.map[t]=e,t)}get(e){return this.map[e]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));delete this.map[e.userData.id]}}{constructor(){super(...arguments),this.nameMap={},this.parseName=(()=>{const e=e=>{var t=e.lastIndexOf("_");return-1===t?-1:(e=e.slice(t+1),Tf.type.isNumber(e)?Number.parseInt(e):-1)},t=(r,n)=>{var i=(t=>{if(-1===e(t))return t;var r=t.lastIndexOf("_");return-1===r?t:t.slice(0,r)})(r)+"_"+n++;return this.nameMap[i]?t(r,n):i},r=e=>Object.keys(this.nameMap).find((t=>this.nameMap[t]===e)),n=["PerspectiveCamera"];return i=>{if(n.includes(i.type))return i.name=i.type;let o=i.name;if(Tf.valid.isTrue(o)||(o=i.type),!this.nameMap[o])return a=this.unique.getId(i),(s=r(a))&&delete this.nameMap[s],void(this.nameMap[o]=a);var a,s=this.nameMap[o];return this.unique.model.get(s)!==i?(a=e(o),a=t(o,s=-1===a?0:a),this.nameMap[a]=this.unique.getId(i),i.name=a):void 0}})()}add(e,t){var{reset:r,hasReset:n}=t||{};if(e instanceof Array)return e.map((e=>this.add(e,t)));if(e){let i=e.userData.id;if(i&&!r||(i=(0,l.getId)(),e.userData.id=i),this.map[i]){if(!n)return;i=(0,l.getId)(),e.userData.id=i}return this.map[i]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):i}}get(e){return this.map[e]}getByName(e){return this.nameMap[e]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));e.traverse((e=>{delete this.nameMap[e.name]})),delete this.map[e.userData.id]}dispose(){this.map={},this.nameMap={}}}class Mf{constructor(e){this.map={},this.unique=e}add(e){if(e instanceof Array)return e.map((e=>this.add(e)));let t=e.userData.id;return t||(t=(0,l.getId)(),e.userData.id=t),this.map[t]?void 0:(this.map[t]={texture:e,materialMap:{}},t)}getLength(){return Object.keys(this.map).length}addMaterial(e,t,r){var n=e.userData.id;this.map[n]||this.add(e),t&&(({material:e,type:t}=t),this.map[n].materialMap[e.userData.id]||(this.map[n].materialMap[e.userData.id]=new Set),this.map[n].materialMap[e.userData.id].add(t)),r&&(({material:e,type:t}=r),this.map[n].materialMap[e.userData.id]&&this.map[n].materialMap[e.userData.id].delete(t))}get(e){return null==(e=this.map[e])?void 0:e.texture}getMaterials(e){return null==(e=this.map[e])?void 0:e.materialMap}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));delete this.map[e.userData.id]}dispose(){(0,Xe.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}class Ef{constructor(e){this.runScene=e,this.model=new _f(this),this.material=new Sf(this),this.texture=new Mf(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}}const Pf={RunScene:class{constructor(e){this.uniqueEx=new Ef(this),this.fileEx=new Yc(this),this.optionsEx=new mf(this),this.undoEx=new Pa(this),this.textureEx=new Si(this),this.controlsEx=new Ge,this.assetsEx=new V(this),this.renderEx=new vf(this),this.events=new class{constructor(e){this.key=new wa(this),this.mouse=new Sa(this),this.drag=new We(this),this.mouseEventMap={move:{timeLineMove:e=>{}},down:{},up:{timeLineUp:e=>{}}},this.mouseDown=e=>{},this.mouseUp=e=>{this.runScene.optionsEx.cb.events.mouse.up.cb(e),Object.values(this.mouseEventMap.up).map((t=>t(e)))},this.mouseMove=e=>{this.runScene.optionsEx.cb.events.mouse.move.cb(e),Object.values(this.mouseEventMap.move).map((t=>t(e)))},this.runScene=e}init(e){this.key.init(e),this.mouse.init(e),window.addEventListener("resize",(()=>{this.runScene.renderEx.setSize(),this.runScene.optionsEx.cb.resize.cb("")})),window.addEventListener("mousemove",this.mouseMove),window.addEventListener("mousedown",this.mouseDown),window.addEventListener("mouseup",this.mouseUp)}}(this),this.multipSelector=new cf(this),this.helperEx=null,this.materialEx=new Ha(this),this.cameraEx=new De(this),this.sceneEx=new gf(this),this.modelEx=new ts(this),this.loaderer=new lf(this),this.exporter=new Bs(this),this.lightEx=new Gh(this),this.timeLineEx=new class{constructor(e){this.timerMap={},this.animaMap={},this.groupMap={},this.setModelLocal=(e,t)=>{Object.values(e.data).map((e=>{var r,n,i=((e,t)=>{let r=-1,n=1e3;const i=Object.keys(e).sort(((e,t)=>Number(e)-Number(t)));if(1!==i.length&&(i.map(((e,i)=>{e=Number(e),0<(e=t-e)&&e<n&&(n=e,r=i)})),-1!==r)){var o=i[r],a=i[r+1],s=e[o];if(e=e[a],s&&e){var l=Object.values(s)[0],u=Object.values(e)[0];if("notNow"!==l&&"notNow"!==u)return{left:s,right:e,progress:(t-Number(o))/(Number(a)-Number(o))}}}})(e.data,t);i&&(({left:i,right:r,progress:n}=i),e.setTargetByBetween(i,r,n))}))},this.runScene=e}reset(){this.timerMap={},this.animaMap={},this.groupMap={},this.runScene.optionsEx.cb.timeLine.reset.cb("")}closeGroup(e){var t,r;this.timerMap[e]&&(({setProgressTime:t,awaitRuned:r}=this.timerMap[e]),t&&clearInterval(t),r&&clearInterval(r)),this.groupMap[e].run=!1,this.runScene.optionsEx.cb.timeLine.closeGroup.cb(e);const n=this.animaMap[e];n&&n.length&&n.map((e=>{e.controls.clean=!0}))}resetGroup(e){var t=this.groupMap[e];t&&(this.closeGroup(e),this.runScene.optionsEx.cb.timeLine.setProgress.cb(0),Object.values(t.data).map((e=>e.reset())))}getSavedData(){return(0,Xe.js)(this.groupMap,((e,t)=>{t.run=!1})),this.groupMap}parseSavedGroupMap(e){Object.keys(e).map((t=>{const r=e[t],n={};(0,Xe.js)(r.data,((e,t)=>{var{type:t,data:r}=t;const i=wf[t];if(t=i.getTarget(e,this.runScene)){const o=new i(t,this.runScene);o.data=r,n[e]=o}})),r.data=n,this.groupMap[t]=r,this.runScene.optionsEx.cb.timeLine.setGroupMap.cb({group:r,groupName:t})}))}playGroup(e){this.runScene.helperEx.unfocus();const t=this.groupMap[e];if(t&&!t.run){t.run=!0;const n=Object.keys(t.data).map((e=>{const r=t.data[e],n=(r.data=new Proxy(r.data,{set:(e,t,r)=>(e[t]=r,!0)}),r.getAnima(t));return t.reverse&&(e=r.getAnima(t,!0),n.push(...e)),n})),i=(this.animaMap[e]||(this.animaMap[e]=[]),this.animaMap[e]=n.map((e=>(0,_a.eachTriggerArrGetControls)(e))),t.time*t.speed*(t.reverse?2:1)),o=(new Date).valueOf(),a=i;var r=setInterval((()=>{var t=((new Date).valueOf()-o)/a;this.runScene.optionsEx.cb.timeLine.playGroup.cb({groupName:e,progress:t})}),16.6);let s;const l=new Promise((e=>s=setTimeout(e,i)));return this.timerMap[e]={setProgressTime:r,awaitRuned:s},l.then((()=>{if(clearInterval(this.timerMap[e].setProgressTime),t.run)return t.run=!1,t.loop?this.playGroup(e):void 0}))}}}(this),this.bloom={glow:new Le(this)};var{rootDom:t,options:r}=e;if(!t)throw TypeError("根节点或路径不可为空");this.optionsEx.init(r),(t=(r||{}).loadInterval)?this.optionsEx.setLoadInterval({inputInterval:t,cb:this.load.bind(this,e)}):this.load(e)}load(e){var{path:e,rootDom:t}=e;this.events.init(t),this.assetsEx.init(t),this.helperEx=new Ch(this);const{camera:r,controls:n}=this.assetsEx.get();this.uniqueEx.model.add(r),this.renderEx.setSize(),n.update(),this.bloom.glow.init(this.assetsEx.get()),this.optionsEx.cb.inited.cb(0),this.cameraEx.reset(r),this.loadScene(e)}loadScene(e){return function(e,t,r,n){return new(r=r||Promise)((function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?t(e.value):((n=e.value)instanceof r?n:new r((function(e){e(n)}))).then(o,a)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function*(){if(e instanceof ArrayBuffer)return this.optionsEx.log("正在解析二进制文件","base","info"),this.loaderer.gltf.parse(e);this.optionsEx.log("正在拉取场景","base","info");var t=yield s().get(e,{responseType:"arraybuffer",onUploadProgress:e=>{var{total:e,loaded:t}=e;let r=t/e;1<(r=r<0?0:r)&&(r=1),t=100*Number(r.toFixed(2)),this.optionsEx.log("下载场景进度:"+t,"detail"),this.optionsEx.cb.load.progress.cb(t)}}).then((e=>e.data)).catch((e=>{this.optionsEx.log("下载场景失败:",e)}));return t?(this.optionsEx.cb.load.getArrayBuffer.cb(t),this.optionsEx.log("拉取场景成功、正在解析","base","success"),this.loaderer.gltf.parse(t)):void 0}))}render(){var e;if(null!=(e=this.optionsEx.options)&&e.run){const{render2:e,render3:t,scene:r,camera:n}=this.assetsEx;this.optionsEx.cb.render.cb(""),this.bloom.glow.update(),null!=t&&t.render(r,n),null!=e&&e.render(r,n)}}dispose(){this.assetsEx.dispose(),this.sceneEx.clean()}on(e,t){return null!=(e=this.optionsEx.cb.load[e])&&e.add("load-callback"+(0,l.getId)(),t),this}setSize(e,t){const{camera:r,render3:n,render2:i,renderer:o}=this.assetsEx;r.aspect=e/t,r.updateProjectionMatrix(),null!=n&&n.setSize(e,t),null!=i&&i.setSize(e,t),o.setSize(e,t),this.bloom.glow.setSize(e,t)}},Utils:t,ModelEx:n,MaterialEx:r,TextureEx:e}})(),u.default;function a(e){var t=l[e];return void 0!==t||(t=l[e]={exports:{}},s[e].call(t.exports,t,t.exports,a)),t.exports}var s,l,u}));