run-scene-v2 0.0.9 → 0.0.12

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 d(){}function f(){}var m,v,g=(l(m={},o,(function(){return this})),(v=(v=Object.getPrototypeOf)&&v(v(T([]))))&&v!==t&&r.call(v,o)&&(m=v),f.prototype=p.prototype=Object.create(m));function y(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:M}}function M(){return{value:void 0,done:!0}}return l(g,"constructor",d.prototype=f),l(f,"constructor",d),d.displayName=l(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(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()}))},y(g),l(g,s,"Generator"),l(g,o,(function(){return this})),l(g,"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:()=>Yh});var e={},t=(a.r(e),a.d(e,{anima:()=>bi,arrayBufferToBase64:()=>Ri,arrayBufferToBlobUr:()=>Pi,base64ToArrayBuffer:()=>_i,base64ToBlob:()=>Ci,bitMapToCanvas:()=>Bi,blobToFile:()=>Di,canvasToBlob:()=>Wi,compressImgToUrl:()=>Ni,fileAndBlobToCanvas:()=>Ui,fileToBlob:()=>Li,getFilesByDataTransfer:()=>Gi,getImgPixels:()=>Hi,getImgPixels1:()=>Vi,getMd5:()=>ji,getRes:()=>qi,getTruthBase64:()=>Ei,getTypeByBase64:()=>Ai,getWorldLocal:()=>xi,hslToRgb:()=>zi,imgArrayBufferToBlobUrl:()=>ki,imgBitMapToBase64:()=>wi,imgBitMapToBlob:()=>Si,imgBitMapToBlobAndBase64:()=>Mi,reverseImg:()=>Ti,rgbToHsl:()=>Fi,transByte:()=>Ii,urlToBlob:()=>Oi,vector:()=>Xi}),{}),r=(a.r(t),a.d(t,{AsyncCompress:()=>As,AsyncDecompress:()=>Zs,AsyncDeflate:()=>Es,AsyncGunzip:()=>Bs,AsyncGzip:()=>As,AsyncInflate:()=>Os,AsyncUnzipInflate:()=>yl,AsyncUnzlib:()=>Ws,AsyncZipDeflate:()=>fl,AsyncZlib:()=>Vs,Compress:()=>Ds,DecodeUTF8:()=>tl,Decompress:()=>Ys,Deflate:()=>_s,EncodeUTF8:()=>rl,Gunzip:()=>Us,Gzip:()=>Ds,Inflate:()=>Rs,Unzip:()=>bl,UnzipInflate:()=>gl,UnzipPassThrough:()=>vl,Unzlib:()=>Gs,Zip:()=>ml,ZipDeflate:()=>dl,ZipPassThrough:()=>pl,Zlib:()=>zs,compress:()=>Is,compressSync:()=>js,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]?Ns:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Cs:Xs)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?Fs:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Ls:qs)(e,t)},deflate:()=>Ps,deflateSync:()=>ks,gunzip:()=>Ns,gunzipSync:()=>Fs,gzip:()=>Is,gzipSync:()=>js,inflate:()=>Cs,inflateSync:()=>Ls,strFromU8:()=>il,strToU8:()=>nl,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!=vs(e,o);--o)if(!o||65558<e.length-o)return void t("invalid zip file",null);var a=ms(e,o+8);a||t(null,{});var s=a,l=vs(e,o+16),u=4294967295==l;if(u){if(o=vs(e,o-12),101075792!=vs(e,o))return void t("invalid zip file",null);s=a=vs(e,o+32),l=vs(e,o+48)}for(var c=function(o){function s(e,r){e?(n(),t(e,null)):(i[d]=r,--a||t(null,i))}var c=(m=sl(e,l,u))[0],h=m[1],p=m[2],d=m[3],f=m[4],m=m[5];if(m=al(e,m),l=f,c)if(8==c)if(f=e.subarray(m,m+h),h<32e4)try{s(null,Ls(f,new pa(p)))}catch(o){s(o,null)}else r.push(Cs(f,{size:p},s));else s("unknown compression type "+c,null);else s(null,Na(e,m,m+h))},h=0;h<s;++h)c();return n},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=vs(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var n=ms(e,r+8);if(!n)return{};var i=vs(e,r+16),o=4294967295==i;if(o){if(r=vs(e,r-12),101075792!=vs(e,r))throw"invalid zip file";n=vs(e,r+32),i=vs(e,r+48)}for(var a=0;a<n;++a){var s=(p=sl(e,i,o))[0],l=p[1],u=p[2],c=p[3],h=p[4],p=p[5];if(p=al(e,p),i=h,s){if(8!=s)throw"unknown compression type "+s;t[c]=Ls(e.subarray(p,p+l),new pa(u))}else t[c]=Na(e,p,p+l)}return t},unzlib:()=>Xs,unzlibSync:()=>qs,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 pa(u+22),t=l,n=u-l,i=u=0;i<c;++i){var o=h[i];try{var a=o.c.length,s=(cl(e,u,o,o.f,o.u,a),30+o.f.length+ul(o.extra)),p=u+s;e.set(o.c,p),cl(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)}}hl(e,l,h.length,n,t),r(null,e)}var o={},a=(Qs(e,"",o,t),Object.keys(o)),s=a.length,l=0,u=0,c=s,h=new Array(s),p=[];s||i();for(var d=function(e){function t(t,o){t?(n(),r(t,null)):(t=o.length,h[e]=rs(m,{size:g,crc:v.d(),c:o,f:y,m:w,u:b!=c.length||w&&x.length!=S,compression:M}),l+=30+b+T+t,u+=76+2*(b+T)+(S||0)+t,--s||i())}var c=a[e],d=o[c],f=d[0],m=d[1],v=$a(),g=f.length,y=(v.p(f),nl(c)),b=y.length,x=m.comment,w=x&&nl(x),S=w&&w.length,T=ul(m.extra),M=0==m.level?0:8;if(65535<b&&t("filename too long",null),M)if(g<16e4)try{t(null,ks(f,m))}catch(d){t(d,null)}else p.push(Ps(f,m,t));else t(null,f)},f=0;f<c;++f)d(f);return n},zipSync:()=>function(e,t){var r,n={},i=[],o=(Qs(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=nl(r)).length,h=s.comment,p=h&&nl(h),d=p&&p.length,f=ul(s.extra);if(65535<c)throw"filename too long";var m=u?ks(l,s):l,v=m.length,g=$a();g.p(l),i.push(rs(s,{size:l.length,crc:g.d(),c:m,f:x,m:p,u:c!=r.length||p&&h.length!=d,o,compression:u})),o+=30+c+f+v,a+=76+2*(c+f)+(d||0)+v}for(var y=new pa(a+22),b=(e=o,t=a-o,0);b<i.length;++b){var x=i[b],w=(cl(y,x.o,x,x.f,x.u,x.c.length),30+x.f.length+ul(x.extra));y.set(x.c,x.o+w),cl(y,o,x,x.f,x.u,x.c.length,x.o,x.m),o+=16+w+(x.m?x.m.length:0)}return hl(y,o,i.length,t,e),y},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[ss,cs,function(){return[Hs]}],(function(e){return ps(Hs(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>Hs}),a(300)),n=a.n(r),i=a(251),o=a(881);function s(e){return(s="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 l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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 h(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(){return(p="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=v(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 d(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&&f(e,t)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(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=v(e);if(r=t?(r=v(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===s(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 v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var g=new o.Vector3,y=new o.Quaternion,b=new o.Vector3,x=function(){d(t,o.Object3D);var e=m(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return l(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 h(t,[{key:"copy",value:function(e,r){return p(v(t.prototype),"copy",this).call(this,e,r),this.element=e.element.cloneNode(!0),this}}]),t}();x.prototype.isCSS3DObject=!0,function(){d(t,x);var e=m(t);function t(r){return l(this,t),(r=e.call(this,r)).rotation2D=0,r}return h(t,[{key:"copy",value:function(e,r){return p(v(t.prototype),"copy",this).call(this,e,r),this.rotation2D=e.rotation2D,this}}]),t}().prototype.isCSS3DSprite=!0;var w=new o.Matrix4,S=new o.Matrix4,T=h((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(l(this,e),this),s={camera:{fov:0,style:""},objects:new WeakMap},u=void 0!==o.element?o.element:document.createElement("div"),c=(u.style.overflow="hidden",this.domElement=u,document.createElement("div"));function h(e){return Math.abs(e)<1e-10?0:e}function p(e){return"matrix3d("+h((e=e.elements)[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(e){return"translate(-50%,-50%)matrix3d("+h((e=e.elements)[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}c.style.transformStyle="preserve-3d",c.style.pointerEvents="none",u.appendChild(c),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&&(u.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,l=(t.top+t.bottom)/2),t.isOrthographicCamera?"scale("+r+")translate("+h(o)+"px,"+h(l)+"px)"+p(t.matrixWorldInverse):"translateZ("+r+"px)"+p(t.matrixWorldInverse)),l=o+"translate("+n+"px,"+i+"px)";s.camera.style!==l&&(c.style.transform=l,s.camera.style=l),function e(t,r,n,i){var o,l,u;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?(w.copy(n.matrixWorldInverse),w.transpose(),0!==t.rotation2D&&w.multiply(S.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(g,y,b),w.setPosition(g),w.scale(b),w.elements[3]=0,w.elements[7]=0,w.elements[11]=0,w.elements[15]=1,d(w)):d(t.matrixWorld),l=t.element,void 0!==(u=s.objects.get(t))&&u.style===o||(u={style:l.style.transform=o},s.objects.set(t,u)),l.parentNode!==c&&c.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,u.style.width=e+"px",u.style.height=o+"px",c.style.width=e+"px",c.style.height=o+"px"}}));function M(e){return(M="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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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 P(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function k(){return(k="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=O(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 R(e,t){return(R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}(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&&R(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=O(e);if(r=t?(r=O(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===M(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 _(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 P(n,[{key:"copy",value:function(e,t){return k(O(n.prototype),"copy",this).call(this,e,t),this.element=e.element.cloneNode(!0),this}}]),n})(o.Object3D).prototype.isCSS2DObject=!0;var C=new o.Vector3,L=new o.Matrix4,D=new o.Matrix4,A=new o.Vector3,I=new o.Vector3,j=P((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(_(this,e),this),s={objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div");function u(e,t){return A.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(t.matrixWorld),A.distanceToSquared(I)}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(),L.copy(t.matrixWorldInverse),D.multiplyMatrices(t.projectionMatrix,L),function e(t,r,o){var c;t.isCSS2DObject&&(C.setFromMatrixPosition(t.matrixWorld),C.applyMatrix4(D),c=!0===t.visible&&-1<=C.z&&C.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(C.x*n+n)+"px,"+Math.round(-C.y*i+i)+"px)":c.style.transform="translate(-50%,-50%) translate("+(C.x*n+n)+"px,"+(-C.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 U{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 T;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 j;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,n.domElement),{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 B={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 N(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 z(e,t,r){t&&F(e.prototype,t),r&&F(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var V=function(){function e(){N(this,e),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}return z(e,[{key:"setSize",value:function(){}},{key:"render",value:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}]),e}(),H=new o.OrthographicCamera(-1,1,1,-1,0,1),G=new o.BufferGeometry,W=(G.setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),G.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2)),function(){function e(t){N(this,e),this._mesh=new o.Mesh(G,t)}return z(e,[{key:"dispose",value:function(){this._mesh.geometry.dispose()}},{key:"render",value:function(e){e.render(this._mesh,H)}},{key:"material",get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}]),e}());function X(e){return(X="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 q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Z=function(){var e=n,t=V;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&&q(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=Y(e);if(r=t?(r=Y(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===X(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 o.ShaderMaterial?(i.uniforms=e.uniforms,i.material=e):e&&(i.uniforms=o.UniformsUtils.clone(e.uniforms),i.material=new o.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:i.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),i.fsQuad=new W(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}(),Q={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new o.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 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=V;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,i,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(s=r.call(this)).strength=void 0!==t?t:1,s.radius=i,s.threshold=a,s.resolution=void 0!==e?new o.Vector2(e.x,e.y):new o.Vector2(256,256),s.clearColor=new o.Color(0,0,0),s.renderTargetsHorizontal=[],s.renderTargetsVertical=[],s.nMips=5;var l=Math.round(s.resolution.x/2),u=Math.round(s.resolution.y/2);s.renderTargetBright=new o.WebGLRenderTarget(l,u),s.renderTargetBright.texture.name="UnrealBloomPass.bright",s.renderTargetBright.texture.generateMipmaps=!1;for(var c=0;c<s.nMips;c++){var h;((h=new o.WebGLRenderTarget(l,u)).texture.name="UnrealBloomPass.h"+c,h.texture.generateMipmaps=!1,s.renderTargetsHorizontal.push(h),h=new o.WebGLRenderTarget(l,u)).texture.name="UnrealBloomPass.v"+c,h.texture.generateMipmaps=!1,s.renderTargetsVertical.push(h),l=Math.round(l/2),u=Math.round(u/2)}i=Q;for(var p=(s.highPassUniforms=o.UniformsUtils.clone(i.uniforms),s.highPassUniforms.luminosityThreshold.value=a,s.highPassUniforms.smoothWidth.value=.01,s.materialHighPassFilter=new o.ShaderMaterial({uniforms:s.highPassUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,defines:{}}),s.separableBlurMaterials=[],[3,5,7,9,11]),d=(l=Math.round(s.resolution.x/2),u=Math.round(s.resolution.y/2),0);d<s.nMips;d++)s.separableBlurMaterials.push(s.getSeperableBlurMaterial(p[d])),s.separableBlurMaterials[d].uniforms.texSize.value=new o.Vector2(l,u),l=Math.round(l/2),u=Math.round(u/2);return s.compositeMaterial=s.getCompositeMaterial(s.nMips),s.compositeMaterial.uniforms.blurTexture1.value=s.renderTargetsVertical[0].texture,s.compositeMaterial.uniforms.blurTexture2.value=s.renderTargetsVertical[1].texture,s.compositeMaterial.uniforms.blurTexture3.value=s.renderTargetsVertical[2].texture,s.compositeMaterial.uniforms.blurTexture4.value=s.renderTargetsVertical[3].texture,s.compositeMaterial.uniforms.blurTexture5.value=s.renderTargetsVertical[4].texture,s.compositeMaterial.uniforms.bloomStrength.value=t,s.compositeMaterial.uniforms.bloomRadius.value=.1,s.compositeMaterial.needsUpdate=!0,s.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],s.bloomTintColors=[new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1)],s.compositeMaterial.uniforms.bloomTintColors.value=s.bloomTintColors,e=B,s.copyUniforms=o.UniformsUtils.clone(e.uniforms),s.copyUniforms.opacity.value=1,s.materialCopy=new o.ShaderMaterial({uniforms:s.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:o.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),s.enabled=!0,s.needsSwap=!1,s._oldClearColor=new o.Color,s.oldClearAlpha=1,s.basic=new o.MeshBasicMaterial,s.fsQuad=new W(null),s}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 o.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 o.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new o.Vector2(.5,.5)},direction:{value:new o.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 o.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 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 re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ne(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 ie(e,t,r){t&&ne(e.prototype,t),r&&ne(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function oe(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&&ae(e,t)}function ae(e,t){return(ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function se(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=le(e);if(r=t?(r=le(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")}}function le(e){return(le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}ee.BlurDirectionX=new o.Vector2(1,0),ee.BlurDirectionY=new o.Vector2(0,1);var ue=function(){oe(t,V);var e=se(t);function t(r,n){var i;return re(this,t),(i=e.call(this)).scene=r,i.camera=n,i.clear=!0,i.needsSwap=!1,i.inverse=!1,i}return ie(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}(),ce=function(){oe(t,V);var e=se(t);function t(){var r;return re(this,t),(r=e.call(this)).needsSwap=!1,r}return ie(t,[{key:"render",value:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}]),t}();function he(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 pe=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 o.Vector2),this._pixelRatio=t.getPixelRatio(),this._width=n.width,this._height=n.height,(r=new o.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===Z&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Z(B),this.clock=new o.Clock}return function(e,t,r){t&&he(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!==ue&&(s instanceof ue?r=!0:s instanceof ce&&(r=!1)))}this.renderer.setRenderTarget(t)}},{key:"reset",value:function(e){var t;void 0===e&&(t=this.renderer.getSize(new o.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 de(e){return(de="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 fe(e,t){return(fe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function me(e){return(me=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}new o.OrthographicCamera(-1,1,1,-1,0,1),(r=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),r.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2));var ve=function(){var e=n,t=V;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&&fe(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=me(e);if(r=t?(r=me(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===de(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,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(s=r.call(this)).scene=e,s.camera=t,s.sampleLevel=4,s.unbiased=!0,s.clearColor=void 0!==i?i:0,s.clearAlpha=void 0!==a?a:0,s._oldClearColor=new o.Color,e=B,s.copyUniforms=o.UniformsUtils.clone(e.uniforms),s.copyMaterial=new o.ShaderMaterial({uniforms:s.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:o.AdditiveBlending,depthTest:!1,depthWrite:!1}),s.fsQuad=new W(s.copyMaterial),s}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 o.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var n=ge[Math.max(0,Math.min(this.sampleLevel,5))],i=e.autoClear,a=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),s=1/n.length,l=(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(l,r);for(var u=0;u<n.length;u++){var c=n[u];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*c[0],l.offsetY+.0625*c[1],l.width,l.height),c=s,this.unbiased&&(c+=1/32*((u+.5)/n.length-.5)),this.copyUniforms.opacity.value=c,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===u&&(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,a)}}])&&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}(),ge=[[[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 ye(e){return(ye="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(){return(be="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=we(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 xe(e,t){return(xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function we(e){return(we=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Se=function(){var e=n,t=ve;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&&xe(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=we(e);if(r=t?(r=we(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ye(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 be(we(n.prototype),"render",this).call(this,e,t,r,i),void(this.accumulateIndex=-1);var a=Te[5],s=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new o.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new o.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(be(we(n.prototype),"render",this).call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0),i=e.autoClear,e.autoClear=!1,1/a.length);if(0<=this.accumulateIndex&&this.accumulateIndex<a.length){this.copyUniforms.opacity.value=s,this.copyUniforms.tDiffuse.value=t.texture;for(var l=Math.pow(2,this.sampleLevel),u=0;u<l;u++){var c=a[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*c[0],.0625*c[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>=a.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(s=this.accumulateIndex*s)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),s<1&&(this.copyUniforms.opacity.value=1-s,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==s&&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}(),Te=[[[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 Me extends V{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof o.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=o.UniformsUtils.clone(e.uniforms),this.material=new o.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new W(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 _e extends V{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 o.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 Ee={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 Pe{constructor(e){this.bloomParams={isBloom:!1,bloomStrength:2,bloomThreshold:0,bloomRadius:0},this.runScene=e,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 Pe.instance||(Pe.instance=new Pe(e)),Pe.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?o.ACESFilmicToneMapping:o.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 o.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 o.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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=o.FloatType,this.effectRT.texture.format=o.RGBAFormat,this.effectRT.texture.encoding=o.sRGBEncoding,this.effectRT.texture.minFilter=o.LinearFilter,this.effectRT.texture.magFilter=o.LinearFilter),this.effectRT.depthTexture=new o.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=o.DepthFormat,this.effectRT.depthTexture.type=o.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new Se(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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=o.FloatType,this.sampleRT.texture.format=o.RGBAFormat,this.sampleRT.texture.encoding=o.sRGBEncoding,this.sampleRT.texture.minFilter=o.LinearFilter,this.sampleRT.texture.magFilter=o.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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=o.FloatType,this.holdRT.texture.format=o.RGBAFormat,this.holdRT.texture.encoding=o.sRGBEncoding,this.holdRT.texture.minFilter=o.LinearFilter,this.holdRT.texture.magFilter=o.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 _e(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 ee(new o.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 Me(Ee,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new Z(B),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 pe(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 ke{constructor(e){this.runScene=e}create(){return new o.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 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 Oe(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&&Ce(e,t)}function Ce(e,t){return(Ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Le(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ae={type:"change"},Ie={type:"start"},je={type:"end"},Ue=function(){Oe(t,o.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=De(e);if(r=t?(r=De(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");return Le(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 o.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:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},i.touches={ONE:o.TOUCH.ROTATE,TWO:o.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(Ae),p.update(),f=d.NONE},i.update=(a=new o.Vector3,s=(new o.Quaternion).setFromUnitVectors(r.up,new o.Vector3(0,1,0)),l=s.clone().invert(),u=new o.Vector3,c=new o.Quaternion,h=2*Math.PI,function(){var e=p.object.position,t=(a.copy(e).sub(p.target),a.applyQuaternion(s),v.setFromVector3(a),p.autoRotate&&f===d.NONE&&D(2*Math.PI/60/60*p.autoRotateSpeed),p.enableDamping?(v.theta+=g.theta*p.dampingFactor,v.phi+=g.phi*p.dampingFactor):(v.theta+=g.theta,v.phi+=g.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*=y,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),a.setFromSpherical(v),a.applyQuaternion(l),e.copy(p.target).add(a),p.object.lookAt(p.target),!0===p.enableDamping?(g.theta*=1-p.dampingFactor,g.phi*=1-p.dampingFactor,b.multiplyScalar(1-p.dampingFactor)):(g.set(0,0,0),b.set(0,0,0)),y=1,!(!(x||u.distanceToSquared(p.object.position)>m||8*(1-c.dot(p.object.quaternion))>m)||(p.dispatchEvent(Ae),u.copy(p.object.position),c.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,a,s,l,u,c,h,p=Le(i),d={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},f=d.NONE,m=1e-6,v=new o.Spherical,g=new o.Spherical,y=1,b=new o.Vector3,x=!1,w=new o.Vector2,S=new o.Vector2,T=new o.Vector2,M=new o.Vector2,_=new o.Vector2,E=new o.Vector2,P=new o.Vector2,k=new o.Vector2,R=new o.Vector2,O=[],C={};function L(){return Math.pow(.95,p.zoomSpeed)}function D(e){g.theta-=e}function A(e){g.phi-=e}I=new o.Vector3;var I,j,U,B=function(e,t){I.setFromMatrixColumn(t,0),I.multiplyScalar(-e),b.add(I)},N=(j=new o.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)}),F=(U=new o.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),N(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),N(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 z(e){p.object.isPerspectiveCamera?y/=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?y*=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){M.set(e.clientX,e.clientY)}function W(){var e,t;1===O.length?w.set(O[0].pageX,O[0].pageY):(e=.5*(O[0].pageX+O[1].pageX),t=.5*(O[0].pageY+O[1].pageY),w.set(e,t))}function X(){var e,t;1===O.length?M.set(O[0].pageX,O[0].pageY):(e=.5*(O[0].pageX+O[1].pageX),t=.5*(O[0].pageY+O[1].pageY),M.set(e,t))}function q(){var e=O[0].pageX-O[1].pageX,t=O[0].pageY-O[1].pageY;e=Math.sqrt(e*e+t*t),P.set(0,e)}function Y(e){1==O.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;D(2*Math.PI*T.x/r.clientHeight),A(2*Math.PI*T.y/r.clientHeight),w.copy(S)}function Z(e){var t,r;1===O.length?_.set(e.pageX,e.pageY):(t=ae(e),r=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),_.set(r,e)),E.subVectors(_,M).multiplyScalar(p.panSpeed),F(E.x,E.y),M.copy(_)}function Q(e){var t=ae(e),r=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(r*r+e*e),k.set(0,t),R.set(0,Math.pow(k.y/P.y,p.zoomSpeed)),z(R.y),P.copy(k)}function K(e){if(!1!==p.enabled)if(0===O.length&&(p.domElement.setPointerCapture(e.pointerId),p.domElement.addEventListener("pointermove",J),p.domElement.addEventListener("pointerup",$)),O.push(e),"touch"===e.pointerType){switch(oe(e),O.length){case 1:switch(p.touches.ONE){case o.TOUCH.ROTATE:if(!1===p.enableRotate)return;W(),f=d.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(!1===p.enablePan)return;X(),f=d.TOUCH_PAN;break;default:f=d.NONE}break;case 2:switch(p.touches.TWO){case o.TOUCH.DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;p.enableZoom&&q(),p.enablePan&&X(),f=d.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;p.enableZoom&&q(),p.enableRotate&&W(),f=d.TOUCH_DOLLY_ROTATE;break;default:f=d.NONE}break;default:f=d.NONE}f!==d.NONE&&p.dispatchEvent(Ie)}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 o.MOUSE.DOLLY:if(!1===p.enableZoom)return;!function(e){P.set(e.clientX,e.clientY)}(r),f=d.DOLLY;break;case o.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enablePan)return;G(r),f=d.PAN}else{if(!1===p.enableRotate)return;H(r),f=d.ROTATE}break;case o.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enableRotate)return;H(r),f=d.ROTATE}else{if(!1===p.enablePan)return;G(r),f=d.PAN}break;default:f=d.NONE}f!==d.NONE&&p.dispatchEvent(Ie)}}function J(e){if(!1!==p.enabled)if("touch"===e.pointerType){var t=e;switch(oe(t),f){case d.TOUCH_ROTATE:if(!1===p.enableRotate)return;Y(t),p.update();break;case d.TOUCH_PAN:if(!1===p.enablePan)return;Z(t),p.update();break;case d.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 d.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:f=d.NONE}}else{var r=e;if(!1!==p.enabled)switch(f){case d.ROTATE:if(!1===p.enableRotate)return;!function(e){S.set(e.clientX,e.clientY),T.subVectors(S,w).multiplyScalar(p.rotateSpeed),e=p.domElement,D(2*Math.PI*T.x/e.clientHeight),A(2*Math.PI*T.y/e.clientHeight),w.copy(S),p.update()}(r);break;case d.DOLLY:if(!1===p.enableZoom)return;!function(e){k.set(e.clientX,e.clientY),R.subVectors(k,P),0<R.y?z(L()):R.y<0&&V(L()),P.copy(k),p.update()}(r);break;case d.PAN:if(!1===p.enablePan)return;!function(e){_.set(e.clientX,e.clientY),E.subVectors(_,M).multiplyScalar(p.panSpeed),F(E.x,E.y),M.copy(_),p.update()}(r)}}}function $(e){ie(e),0===O.length&&(p.domElement.releasePointerCapture(e.pointerId),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$)),p.dispatchEvent(je),f=d.NONE}function ee(e){ie(e)}function te(e){!1!==p.enabled&&!1!==p.enableZoom&&f===d.NONE&&(e.preventDefault(),p.dispatchEvent(Ie),e.deltaY<0?V(L()):0<e.deltaY&&z(L()),p.update(),p.dispatchEvent(je))}function re(e){if(!1!==p.enabled&&!1!==p.enablePan){var t=!1;switch(e.code){case p.keys.UP:F(0,p.keyPanSpeed),t=!0;break;case p.keys.BOTTOM:F(0,-p.keyPanSpeed),t=!0;break;case p.keys.LEFT:F(p.keyPanSpeed,0),t=!0;break;case p.keys.RIGHT:F(-p.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),p.update())}}function ne(e){!1!==p.enabled&&e.preventDefault()}function ie(e){delete C[e.pointerId];for(var t=0;t<O.length;t++)if(O[t].pointerId==e.pointerId)return void O.splice(t,1)}function oe(e){var t=C[e.pointerId];void 0===t&&(t=new o.Vector2,C[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ae(e){return e=e.pointerId===O[0].pointerId?O[1]:O[0],C[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 Be{create(e,t){return new Ue(e,t)}}class Ne{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 Fe=a(594),ze=a(129),Ve=a(685);function He(){return(He="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=Ye(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 Ge(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&&We(e,t)}function We(e,t){return(We=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Xe(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=Ye(e);if(r=t?(r=Ye(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===et(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return qe(n)}}function qe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ye(e){return(Ye=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ze(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 Qe(e,t,r){return t&&Ze(e.prototype,t),r&&Ze(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Je(e){return function(e){if(Array.isArray(e))return $e(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 $e(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)?$e(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 $e(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 et(e){return(et="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 tt(e){return void 0===e}function rt(){return"undefined"!=typeof window}function nt(e){return Rr(e)||kr(e)}function it(e){return(Hr=dt(e,Vr))&&ui}function ot(e,t){return!t&&console.warn(e)}function at(e,t){return e&&(Vr[e]=t)&&Hr&&(Hr[e]=t)||Vr}function st(){return 0}function lt(e,t,r){return(r=e[t])&&Rr(r)?e[t]():tt(r)&&e.getAttribute&&e.getAttribute(t)||r}function ut(e,t){(e=e.split(",")).forEach(t)}function ct(e,t,r,n){Xr.length&&rn(),e.render(t,r,n),Xr.length&&rn()}function ht(e){var t=parseFloat(e);return(t||0===t)&&(e+"").match(Fr).length<2?t:kr(e)?e.trim():e}function pt(e){return e}function dt(e,t){for(var r in t)e[r]=t[r];return e}function ft(e,t){for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=Cr(t[r])?ft(e[r]||(e[r]={}),t[r]):t[r]);return e}function mt(e){var t,r=e.parent||Yt,n=e.keyframes?(t=Ar(e.keyframes),function(e,r){for(var n in r)n in e||"duration"===n&&t||"ease"===n||(e[n]=r[n])}):nn;if(Lr(e.inherit))for(;r;)n(e,r.vars.defaults),r=r.parent||r._dp;return e}function vt(e){return!e||e._ts&&vt(e.parent)}function gt(e){return e._repeat?yt(e._tTime,e=e.duration()+e._rDelay)*e:0}function yt(e,t){return t=Math.floor(e/=t),e&&t===e?t-1:t}function bt(e,t){return(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur)}function xt(e,t){var r;if((t._time||t._initted&&!t._dur)&&(r=bt(e.rawTime(),t),(!t._dur||Ot(0,t.totalDuration(),r)-t._tTime>wr)&&t.render(r,!0)),ln(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=-wr}}function wt(e,t,r,n){return t.parent&&sn(t),t._start=tn((Or(r)?r:r||e!==Yt?kt(e,r,t):e._time)+t._delay),t._end=tn(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),_t(t)||(e._recent=t),n||xt(e,t),e}function St(e,t){(Vr.ScrollTrigger||Gr("scrollTrigger",t))&&Vr.ScrollTrigger.create(t,e)}function Tt(e,t,r,n){return An(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&$t!==_n.frame?(Xr.push(e),e._lazy=[t,n]):void 0:1}function Mt(e){return(e=e.parent)&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||Mt(e))}function _t(e){return"isFromStart"===(e=e.data)||"isStart"===e}function Et(e,t,r,n){var i=e._repeat,o=tn(t)||0;return(t=e._tTime/e._tDur)&&!n&&(e._time*=o/e._dur),e._dur=o,e._tDur=i?i<0?1e10:tn(o*(i+1)+e._rDelay*i):o,0<t&&!n?cn(e,e._tTime=e._tDur*t):e.parent&&un(e),r||ln(e.parent,e),e}function Pt(e){return e instanceof Xn?ln(e):Et(e,e._dur)}function kt(e,t,r){var n,i,o,a=e.labels,s=e._recent||hn,l=e.duration()>=xr?s.endTime(!1):e._dur;return kr(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*(Ar(r)?r[0]:r).totalDuration()),1<n?kt(e,t.substr(0,n-1),r)+i:l+i)):null==t?l:+t}function Rt(e,t,r){var n,i,o=Or(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=Lr(i.vars.inherit)&&i.parent;s.immediateRender=Lr(n.immediateRender),e<2?s.runBackwards=1:s.startAt=t[a-1]}return new Jn(t[0],s,t[1+a])}function Ot(e,t,r){return r<e?e:t<r?t:r}function Ct(e){if(Rr(e))return e;var t=Cr(e)?e:{each:e},r=Cn(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 kr(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,d,f,m,v,g,y,b,x=(h||t).length,w=o[x];if(!w){if(!(b="auto"===t.grid?0:(t.grid||[1,xr])[1])){for(g=-xr;g<(g=h[b++].getBoundingClientRect().left)&&b<x;);b--}for(w=o[x]=[],p=a?Math.min(b,x)*l-.5:n%b,d=b===xr?0:a?x*u/b-.5:n/b|0,y=xr,v=g=0;v<x;v++)m=v%b-p,f=d-(v/b|0),w[v]=m=s?Math.abs("y"===s?f:m):_r(m*m+f*f),g<m&&(g=m),m<y&&(y=m);"random"===n&&gn(w),w.max=g-y,w.min=y,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=dn(t.amount||t.each)||0,r=r&&x<0?On(r):r}return x=(w[e]-w.min)/w.max||0,tn(w.b+(r?r(x):x)*w.v)+w.u}}function Lt(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+(Or(r)?0:dn(r))}}function Dt(e,t){var r,n,i=Ar(e);return!i&&Cr(e)&&(r=i=e.radius||xr,e.values?(e=vn(e.values),(n=!Or(e[0]))&&(r*=r)):e=Lt(e.increment)),pn(t,i?Rr(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=xr,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||Or(t)?u:u+dn(t)}:Lt(e))}function At(e,t,r,n){return pn(Ar(e)?!t:!0===r?!!(r=0):!n,(function(){return Ar(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 It(e,t,r){return pn(r,(function(r){return e[~~t(r)]}))}function jt(e,t,r,n,i){var o=t-e,a=n-r;return pn(i,(function(t){return r+((t-e)/o*a||0)}))}function Ut(e,t,r){var n,i,o,a=e.labels,s=xr;for(n in a)(i=a[n]-t)<0==!!r&&i&&s>(i=Math.abs(i))&&(o=n,s=i);return o}function Bt(e,t,r){var n=e.vars,i=n[t];i&&(t=n[t+"Params"],n=n.callbackScope||e,r&&Xr.length&&rn(),t?i.apply(n,t):i.call(n))}function Nt(e){return sn(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&Bt(e,"onInterrupt"),e}function Ft(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)*bn+.5|0}function zt(e,t,r){var n,i,o,a,s="",l=(e+s).match(Tn),u=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((function(e){return(e=wn(e,t,1))&&u+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")"})),r&&(o=Sn(e),(n=r.c).join(s)!==o.c.join(s)))for(a=(i=e.replace(Tn,"1").split(Ur)).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(Tn)).length-1;c<a;c++)s+=i[c]+l[c];return s+i[a]}function Vt(e,t){for(var r,n=e._first;n;)n instanceof Xn?Vt(n,t):!n.vars.yoyoEase||n._yoyo&&n._repeat||n._yoyo===t||(n.timeline?Vt(n.timeline,t):(r=n._ease,n._ease=n._yEase,n._yEase=r,n._yoyo=t)),n=n._next}function Ht(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}};ut(e,(function(e){for(var t in Pn[e]=Vr[e]=i,Pn[r=e.toLowerCase()]=n,i)Pn[r+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Pn[e+"."+t]=i[t]}))}function Gt(e){return function(t){return t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2}}function Wt(e,t,r){function n(e){return 1===e?1:i*Math.pow(2,-10*e)*Pr((e-o)*a)+1}var i=1<=t?t:1,o=(a=(r||(e?.3:.45))/(t<1?t:1))/Sr*(Math.asin(1/i)||0),a=(r="out"===e?n:"in"===e?function(e){return 1-n(1-e)}:Gt(n),Sr/a);return r.config=function(t,r){return Wt(e,t,r)},r}function Xt(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)}:Gt(t);return n.config=function(t){return Xt(e,t)},n}var qt,Yt,Zt,Qt,Kt,Jt,$t,er,tr,rr,nr,ir,or,ar,sr,lr,ur,cr,hr,pr,dr,fr,mr,vr,gr,yr={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},br={duration:.5,overwrite:!1,delay:0},xr=1e8,wr=1/xr,Sr=2*Math.PI,Tr=Sr/4,Mr=0,_r=Math.sqrt,Er=Math.cos,Pr=Math.sin,kr=function(e){return"string"==typeof e},Rr=function(e){return"function"==typeof e},Or=function(e){return"number"==typeof e},Cr=function(e){return"object"==et(e)},Lr=function(e){return!1!==e},Dr="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},Ar=Array.isArray,Ir=/(?:-?\.?\d|\.)+/gi,jr=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Ur=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,Br=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,Nr=/[+-]=-?[.\d]+/,Fr=/[^,'"\[\]\s]+/gi,zr=/[\d.+\-=]+(?:e[-+]\d*)*/i,Vr={},Hr={},Gr=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Wr={},Xr=[],qr={},Yr={},Zr={},Qr=30,Kr=[],Jr="",$r=function(e){var t,r,n=e[0];if(Cr(n)||Rr(n)||(e=[e]),!(t=(n._gsap||{}).harness)){for(r=Kr.length;r--&&!Kr[r].targetTest(n););t=Kr[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new Gn(e[r],t)))||e.splice(r,1);return e},en=function(e){return e._gsap||$r(vn(e))[0]._gsap},tn=function(e){return Math.round(1e7*e)/1e7||0},rn=function(){var e,t,r=Xr.length,n=Xr.slice(0);for(qr={},e=Xr.length=0;e<r;e++)(t=n[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},nn=function(e,t){for(var r in t)r in e||(e[r]=t[r]);return e},on=function(e,t){var r,n={};for(r in e)r in t||(n[r]=e[r]);return n},an=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},sn=function(e,t){!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},ln=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},un=function(e){return e._end=tn(e._start+(e._tDur/Math.abs(e._ts||e._rts||wr)||0))},cn=function(e,t){var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=tn(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),un(e),r._dirty||ln(r,e)),e},hn={_start:0,endTime:st,totalDuration:st},pn=function(e,t){return e||0===e?t(e):t},dn=function(e,t){return kr(e)&&(t=zr.exec(e))?e.substr(t.index+t[0].length):""},fn=[].slice,mn=function(e,t){return e&&Cr(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Cr(e[0]))&&!e.nodeType&&e!==Zt},vn=function(e,t,r){return!kr(e)||r||!Qt&&En()?Ar(e)?function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return e.forEach((function(e){return kr(e)&&!t||mn(e,1)?r.push.apply(r,Je(vn(e))):r.push(e)}))||r}(e,r):mn(e)?fn.call(e,0):e?[e]:[]:fn.call((t||Kt).querySelectorAll(e),0)},gn=function(e){return e.sort((function(){return.5-Math.random()}))},yn=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?Fr:Ir),a+=e.substr(o,t-o)+At(i?r:+r[0],i?0:+r[1],+r[2]||1e-5),o=n+1;return a+e.substr(o,e.length-o)},bn=255,xn={aqua:[0,bn,bn],lime:[0,bn,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,bn],navy:[0,0,128],white:[bn,bn,bn],olive:[128,128,0],yellow:[bn,bn,0],orange:[bn,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[bn,0,0],pink:[bn,192,203],cyan:[0,bn,bn],transparent:[bn,bn,bn,0]},wn=function(e,t,r){var n,i,o,a,s,l,u,c=e?Or(e)?[e>>16,e>>8&bn,e&bn]:0:xn.black;if(!c){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),xn[e])c=xn[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&bn,c&bn,parseInt(e.substr(7),16)/255];c=[(e=parseInt(e.substr(1),16))>>16,e>>8&bn,e&bn]}else if("hsl"===e.substr(0,3))if(c=u=e.match(Ir),t){if(~e.indexOf("="))return c=e.match(jr),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]=Ft(a+1/3,n,i),c[1]=Ft(a,n,i),c[2]=Ft(a-1/3,n,i);else c=e.match(Ir)||xn.transparent;c=c.map(Number)}return t&&!u&&(n=c[0]/bn,i=c[1]/bn,o=c[2]/bn,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},Sn=function(e){var t=[],r=[],n=-1;return e.split(Tn).forEach((function(e){e=e.match(Ur)||[],t.push.apply(t,Je(e)),r.push(n+=e.length+1)})),t.c=r,t},Tn=function(){var e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in xn)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),Mn=/hsl[a]?\(/,_n=(sr=Date.now,lr=500,ur=33,cr=sr(),hr=cr,dr=pr=1e3/240,mr={time:0,frame:0,tick:function(){Ln(!0)},deltaRatio:function(e){return or/(1e3/(e||60))},wake:function(){Jt&&(!Qt&&rt()&&(Zt=Qt=window,Kt=Zt.document||{},Vr.gsap=ui,(Zt.gsapVersions||(Zt.gsapVersions=[])).push(ui.version),it(Hr||Zt.GreenSockGlobals||!Zt.gsap&&Zt||{}),ir=Zt.requestAnimationFrame),rr&&mr.sleep(),nr=ir||function(e){return setTimeout(e,dr-1e3*mr.time+1|0)},tr=1,Ln(2))},sleep:function(){(ir?Zt.cancelAnimationFrame:clearTimeout)(rr),tr=0,nr=st},lagSmoothing:function(e,t){lr=e||1/wr,ur=Math.min(t,lr,0)},fps:function(e){pr=1e3/(e||240),dr=1e3*mr.time+pr},add:function(e){fr.indexOf(e)<0&&fr.push(e),En()},remove:function(e,t){~(t=fr.indexOf(e))&&fr.splice(t,1)&&t<=ar&&ar--},_listeners:fr=[]}),En=function(){return!tr&&_n.wake()},Pn={},kn=/^[\d.\-M][\d.\-,\s]/,Rn=/["']/g,On=function(e){return function(t){return 1-e(1-t)}},Cn=function(e,t){return e&&(Rr(e)?e:Pn[e]||function(e){var t,r,n,i=(e+"").split("("),o=Pn[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(Rn,"").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(ht))):Pn._CE&&kn.test(e)?Pn._CE("",e):o}(e))||t};function Ln(e){var t,r,n,i=sr()-hr,o=!0===e;if(lr<i&&(cr+=i-ur),(0<(i=(r=(hr+=i)-cr)-dr)||o)&&(n=++mr.frame,or=r-1e3*mr.time,mr.time=r/=1e3,dr+=i+(pr<=i?4:pr-i),t=1),o||(rr=nr(Ln)),t)for(ar=0;ar<fr.length;ar++)fr[ar](r,or,n,e)}function Dn(e){return e<gr?vr*e*e:e<.7272727272727273?vr*Math.pow(e-1.5/2.75,2)+.75:e<.9090909090909092?vr*(e-=2.25/2.75)*e+.9375:vr*Math.pow(e-2.625/2.75,2)+.984375}function An(e,t){var r,n,i,o,a,s,l,u,c,h,p,d,f,m=e.vars,v=m.ease,g=m.startAt,y=m.immediateRender,b=m.lazy,x=m.onUpdate,w=m.onUpdateParams,S=m.callbackScope,T=m.runBackwards,M=m.yoyoEase,_=m.keyframes,E=m.autoRevert,P=e._dur,k=e._startAt,R=e._targets,O=e.parent,C=O&&"nested"===O.data?O.parent._targets:R,L="auto"===e._overwrite&&!qt,D=e.timeline;if(e._ease=Cn(v=!D||_&&v?v:"none",br.ease),e._yEase=M?On(Cn(!0===M?v:M,br.ease)):0,M&&e._yoyo&&!e._repeat&&(M=e._yEase,e._yEase=e._ease,e._ease=M),e._from=!D&&!!m.runBackwards,!D||_&&!m.stagger){if(d=(u=R[0]?en(R[0]).harness:0)&&m[u.prop],r=on(m,Wr),k&&sn(k.render(-1,!0)),g)if(sn(e._startAt=Jn.set(R,nn({data:"isStart",overwrite:!1,parent:O,immediateRender:!0,lazy:Lr(b),startAt:null,delay:0,onUpdate:x,onUpdateParams:w,callbackScope:S,stagger:0},g))),t<0&&!y&&!E&&e._startAt.render(-1,!0),y){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(k)E||(e._startAt=0);else if(i=nn({overwrite:!1,data:"isFromStart",lazy:(y=!t&&y)&&Lr(b),immediateRender:y,stagger:0,parent:O},r),d&&(i[u.prop]=d),sn(e._startAt=Jn.set(R,i)),t<0&&e._startAt.render(-1,!0),e._zTime=t,y){if(!t)return}else An(e._startAt,wr);for(e._pt=0,b=P&&Lr(b)||b&&!P,n=0;n<R.length;n++){if(l=(a=R[n])._gsap||$r(R)[n]._gsap,e._ptLookup[n]=h={},qr[l.id]&&Xr.length&&rn(),p=C===R?n:C.indexOf(a),u&&!1!==(c=new u).init(a,d||r,e,p,C)&&(e._pt=o=new ai(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||d)for(i in r)Yr[i]&&(c=Zn(i,r,e,p,a,C))?c.priority&&(s=1):h[i]=o=Yn.call(e,a,i,"get",r[i],p,C,0,m.stringFilter);e._op&&e._op[n]&&e.kill(a,e._op[n]),L&&e._pt&&(Hn=e,Yt.killTweensOf(a,h,e.globalTime(t)),f=!e.parent,Hn=0),e._pt&&b&&(qr[l.id]=1)}s&&oi(e),e._onInit&&e._onInit(e)}e._onUpdate=x,e._initted=(!e._op||e._pt)&&!f,_&&t<=0&&D.render(xr,!0,!0)}function In(e,t,r,n,i){return Rr(e)?e.call(t,r,n,i):kr(e)&&~e.indexOf("random(")?yn(e):e}function jn(e,t,r){return e.setAttribute(t,r)}function Un(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 Bn(e,t){for(var r=t._pt;r;)r.r(e,r.d),r=r._next}function Nn(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 Fn(e){for(var t,r,n=this._pt;n;)r=n._next,n.p===e&&!n.op||n.op===e?an(this,n,"_pt"):n.dep||(t=1),n=r;return!t}function zn(e,t,r,n){n.mSet(e,t,n.m.call(n.tween,r,n.mt),n)}function Vn(e,t){return{name:e,rawVars:1,init:function(e,r,n){n._onInit=function(e){var n,i;if(kr(r)&&(n={},ut(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?li(s,o):s)&&s.modifier&&s.modifier(u[o],l,c[a],o)}}}}ut("Linear,Quad,Cubic,Quart,Quint,Strong",(function(e,t){var r=t<5?t+1:t;Ht(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}))})),Pn.Linear.easeNone=Pn.none=Pn.Linear.easeIn,Ht("Elastic",Wt("in"),Wt("out"),Wt()),vr=7.5625,gr=1/2.75,Ht("Bounce",(function(e){return 1-Dn(1-e)}),Dn),Ht("Expo",(function(e){return e?Math.pow(2,10*(e-1)):0})),Ht("Circ",(function(e){return-(_r(1-e*e)-1)})),Ht("Sine",(function(e){return 1===e?1:1-Er(e*Tr)})),Ht("Back",Xt("in"),Xt("out"),Xt()),Pn.SteppedEase=Pn.steps=Vr.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-wr;return function(e){return((n*Ot(0,o,e)|0)+i)*r}}},br.ease=Pn["quad.out"],ut("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(function(e){return Jr+=e+","+e+"Params,"}));var Hn,Gn=Qe((function e(t,r){Ke(this,e),this.id=Mr++,(t._gsap=this).target=t,this.harness=r,this.get=r?r.get:lt,this.set=r?r.getSetter:ri})),Wn=function(){function e(t){Ke(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,Et(this,+t.duration,1,1),this.data=t.data,tr||_n.wake()}return Qe(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,Et(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}},{key:"totalTime",value:function(e,t){if(En(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(cn(this,e),r._dp&&!r.parent&&xt(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)&&wt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===wr||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),ct(this,e,t)),this}},{key:"time",value:function(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+gt(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)+gt(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?yt(this._tTime,r)+1:1}},{key:"timeScale",value:function(e){if(!arguments.length)return this._rts===-wr?0:this._rts;if(this._rts===e)return this;for(var t=this.parent&&this._ts?bt(this.parent._time,this):this._tTime,r=(this._rts=+e||0,this._ts=this._ps||e===-wr?0:this._rts,e=this.totalTime(Ot(-this._delay,this._tDur,t),!0)).parent;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent;return un(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):(En(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==wr&&(this._tTime-=wr)))),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||wt(t,this,e-this._delay),this):this._start}},{key:"endTime",value:function(e){return this._start+(Lr(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?bt(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,Pt(this)):-2===this._repeat?1/0:this._repeat}},{key:"repeatDelay",value:function(e){var t;return arguments.length?(t=this._time,this._rDelay=e,Pt(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(kt(this,e),Lr(t))}},{key:"restart",value:function(e,t){return this.play().totalTime(e?-this._delay:0,Lr(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?-wr:0)),this):this._rts<0}},{key:"invalidate",value:function(){return this._initted=this._act=0,this._zTime=-wr,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)-wr))}},{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,Rr(i)&&(i=i(t))&&(i.then||i===t)&&(t.then=e),r(i),t.then=e}var i=Rr(e)?e:pt;t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?n():t._prom=n}))}},{key:"kill",value:function(){Nt(this)}}]),e}(),Xn=(nn(Wn.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:-wr,_prom:0,_ps:!1,_rts:1}),function(){Ge(t,Wn);var e=Xe(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=1<arguments.length?arguments[1]:void 0;return Ke(this,t),(r=e.call(this,n)).labels={},r.smoothChildTiming=!!n.smoothChildTiming,r.autoRemoveChildren=!!n.autoRemoveChildren,r._sort=Lr(n.sortChildren),Yt&&wt(n.parent||Yt,qe(r),i),n.reversed&&r.reverse(),n.paused&&r.paused(!0),n.scrollTrigger&&St(qe(r),n.scrollTrigger),r}return Qe(t,[{key:"to",value:function(e,t,r){return Rt(0,arguments,this),this}},{key:"from",value:function(e,t,r){return Rt(1,arguments,this),this}},{key:"fromTo",value:function(e,t,r,n){return Rt(2,arguments,this),this}},{key:"set",value:function(e,t,r){return t.duration=0,t.parent=this,mt(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new Jn(e,t,kt(this,r),1),this}},{key:"call",value:function(e,t,r){return wt(this,Jn.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 Jn(e,r,kt(this,i)),this}},{key:"staggerFrom",value:function(e,t,r,n,i,o,a){return r.runBackwards=1,mt(r).immediateRender=Lr(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,mt(n).immediateRender=Lr(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,d=this._time,f=this._dirty?this.totalDuration():this._tDur,m=this._dur,v=e<=0?0:tn(e),g=this._zTime<0!=e<0&&(this._initted||!m);if((v=this!==Yt&&f<v&&0<=e?f:v)!==this._tTime||r||g){if(d!==this._time&&m&&(v+=this._time-d,e+=this._time-d),n=v,c=this._start,s=!(u=this._ts),g&&(m||(d=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(g=this._yoyo,a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(n=tn(v%a),v===f?(o=this._repeat,n=m):((o=~~(v/a))&&o===v/a&&(n=m,o--),m<n&&(n=m)),h=yt(this._tTime,a),g&&1&o&&(n=m-n,p=1),o!==(h=!d&&this._tTime&&h!==o?o:h)&&!this._lock){var y=g&&1&h;if(g=y===(g&&1&o),d=(y=o<h?!y:y)?0:m,this._lock=1,this.render(d||(p?0:tn(o*a)),t,!m)._lock=0,this._tTime=v,!t&&this.parent&&Bt(this,"onRepeat"),this.vars.repeatRefresh&&!p&&(this.invalidate()._lock=1),d&&d!==this._time||s!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(m=this._dur,f=this._tDur,g&&(this._lock=2,this.render(d=y?m:-1e-4,!0),this.vars.repeatRefresh&&!p&&this.invalidate()),this._lock=0,!this._ts&&!s)return this;Vt(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,tn(d),tn(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,d=0),!d&&n&&!t&&(Bt(this,"onStart"),this._tTime!==v))return this;if(d<=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=-wr);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?-wr:wr);break}}b=i}if(l&&!t&&(this.pause(),l.render(d<=n?0:-wr)._zTime=d<=n?1:-1,this._ts))return this._start=c,un(this),this.render(e,t,r);this._onUpdate&&!t&&Bt(this,"onUpdate",!0),!(v===f&&f>=this.totalDuration()||!v&&d)||c!==this._start&&Math.abs(u)===Math.abs(this._ts)||this._lock||(!e&&m||!(v===f&&0<this._ts||!v&&this._ts<0)||sn(this,1),t||e<0&&!d||!v&&!d&&f||(Bt(this,v===f&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||v<f&&0<this.timeScale()||this._prom()))}return this}},{key:"add",value:function(e,t){var r=this;if(Or(t)||(t=kt(this,t,e)),!(e instanceof Wn)){if(Ar(e))return e.forEach((function(e){return r.add(e,t)})),this;if(kr(e))return this.addLabel(e,t);if(!Rr(e))return this;e=Jn.delayedCall(0,e)}return this!==e?wt(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]:-xr,i=[],o=this._first;o;)o._start>=n&&(o instanceof Jn?t&&i.push(o):(r&&i.push(o),e&&i.push.apply(i,Je(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 kr(e)?this.removeLabel(e):Rr(e)?this.killTweensOf(e):(an(this,e),e===this._recent&&(this._recent=this._last),ln(this))}},{key:"totalTime",value:function(e,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=tn(_n.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),He(Ye(t.prototype),"totalTime",this).call(this,e,r),this._forcing=0,this):this._tTime}},{key:"addLabel",value:function(e,t){return this.labels[e]=kt(this,t),this}},{key:"removeLabel",value:function(e){return delete this.labels[e],this}},{key:"addPause",value:function(e,t,r){return(t=Jn.delayedCall(0,t||st,r)).data="isPause",this._hasPause=1,wt(this,t,kt(this,e))}},{key:"removePause",value:function(e){var t=this._first;for(e=kt(this,e);t;)t._start===e&&"isPause"===t.data&&sn(t),t=t._next}},{key:"killTweensOf",value:function(e,t,r){for(var n=this.getTweensOf(e,r),i=n.length;i--;)Hn!==n[i]&&n[i].kill(e,t);return this}},{key:"getTweensOf",value:function(e,t){for(var r,n=[],i=vn(e),o=this._first,a=Or(t);o;)o instanceof Jn?function(e,t){for(var r=t.length,n=0;e.indexOf(t[n])<0&&++n<r;);return n<r}(o._targets,i)&&(a?(!Hn||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,Je(r)),o=o._next;return n}},{key:"tweenTo",value:function(e,t){t=t||{};var r,n=this,i=kt(n,e),o=(e=t).startAt,a=e.onStart,s=e.onStartParams,l=(e=e.immediateRender,Jn.to(n,nn({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())||wr,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&&Et(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,nn({startAt:{time:kt(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 Ut(this,kt(this,e))}},{key:"previousLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ut(this,kt(this,e),1)}},{key:"currentLabel",value:function(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+wr)}},{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 ln(this)}},{key:"invalidate",value:function(){var e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return He(Ye(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={}),ln(this)}},{key:"totalDuration",value:function(e){var t,r,n,i=0,o=this,a=o._last,s=xr;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,wt(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;Et(o,o===Yt&&o._time>i?o._time:i,1,1),o._dirty=0}return o._tDur}}],[{key:"updateRoot",value:function(e){if(Yt._ts&&(ct(Yt,bt(e,Yt)),$t=_n.frame),_n.frame>=Qr){Qr+=yr.autoSleep||120;var t=Yt._first;if((!t||!t._ts)&&yr.autoSleep&&_n._listeners.length<2){for(;t&&!t._ts;)t=t._next;t||_n.sleep()}}}}]),t}()),qn=(nn(Xn.prototype,{_lock:0,_hasPause:0,_forcing:0}),function(e,t,r,n,i,o,a){var s,l,u,c,h,p=new ai(this._pt,e,t,0,1,Un,null,i),d=0,f=0;for(p.b=r,p.e=n,r+="",(i=~(n+="").indexOf("random("))&&(n=yn(n)),o&&(o(o=[r,n],e,t),r=o[0],n=o[1]),s=r.match(Br)||[];c=Br.exec(n);)u=c[0],c=n.substring(d,c.index),l?l=(l+1)%5:"rgba("===c.substr(-5)&&(l=1),u!==s[f++]&&(h=parseFloat(s[f-1])||0,p._pt={_next:p._pt,p:c||1===f?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},d=Br.lastIndex);return p.c=d<n.length?n.substring(d,n.length):"",p.fp=a,(Nr.test(n)||i)&&(p.e=0),this._pt=p}),Yn=function(e,t,r,n,i,o,a,s,l){var u;if(Rr(n)&&(n=n(i||0,e,o)),i=e[t],o="get"!==r?r:Rr(i)?l?e[t.indexOf("set")||!Rr(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():i,r=Rr(i)?l?ti:ei:$n,kr(n)&&"="===(n=~n.indexOf("random(")?yn(n):n).charAt(1)&&(!(u=parseFloat(o)+parseFloat(n.substr(2))*("-"===n.charAt(0)?-1:1)+(dn(o)||0))&&0!==u||(n=u)),o!==n)return isNaN(o*n)||""===n?(i||t in e||Gr(t,n),qn.call(this,e,t,o,n,r,s||yr.stringFilter,l)):(u=new ai(this._pt,e,t,+o||0,n-(o||0),"boolean"==typeof i?ii:ni,0,r),l&&(u.fp=l),a&&u.modifier(a,this,e),this._pt=u)},Zn=function(e,t,r,n,i,o){var a,s,l,u;if(Yr[e]&&!1!==(a=new Yr[e]).init(i,a.rawVars?t[e]:function(e,t,r,n,i){if(Rr(e)&&(e=In(e,i,t,r,n)),!Cr(e)||e.style&&e.nodeType||Ar(e)||Dr(e))return kr(e)?In(e,i,t,r,n):e;var o,a={};for(o in e)a[o]=In(e[o],i,t,r,n);return a}(t[e],n,i,o,r),r,n,o)&&(r._pt=s=new ai(r._pt,i,e,0,1,a.render,a,0,a.priority),r!==er))for(l=r._ptLookup[r._targets.indexOf(i)],u=a._props.length;u--;)l[a._props[u]]=s;return a},Qn=Jr+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",Kn={},Jn=(ut(Qn+",id,stagger,delay,duration,paused,scrollTrigger",(function(e){return Kn[e]=1})),function(){Ge(t,Wn);var e=Xe(t);function t(r,n,i,o){Ke(this,t),"number"==typeof n&&(i.duration=n,n=i,i=null);var a,s,l,u,c,h,p,d,f,m=(o=(a=e.call(this,o?n:mt(n))).vars).duration,v=o.delay,g=o.immediateRender,y=o.stagger,b=o.overwrite,x=o.keyframes,w=o.defaults,S=o.scrollTrigger,T=o.yoyoEase,M=(o=n.parent||Yt,(Ar(r)||Dr(r)?Or(r[0]):"length"in n)?[r]:vn(r));if(a._targets=M.length?$r(M):ot("GSAP target "+r+" not found. https://greensock.com",!yr.nullTargetWarn)||[],a._ptLookup=[],a._overwrite=b,x||y||nt(m)||nt(v)){if(n=a.vars,(s=a.timeline=new Xn({data:"nested",defaults:w||{}})).kill(),s.parent=s._dp=qe(a),s._start=0,y||nt(m)||nt(v)){if(c=M.length,d=y&&Ct(y),Cr(y))for(h in y)~Qn.indexOf(h)&&((f=f||{})[h]=y[h]);for(l=0;l<c;l++)(u=on(n,Kn)).stagger=0,T&&(u.yoyoEase=T),f&&dt(u,f),p=M[l],u.duration=+In(m,qe(a),l,p,M),u.delay=(+In(v,qe(a),l,p,M)||0)-a._delay,!y&&1===c&&u.delay&&(a._delay=v=u.delay,a._start+=v,u.delay=0),s.to(p,u,d?d(l,p,M):0),s._ease=Pn.none;s.duration()?m=v=0:a.timeline=0}else if(x){mt(nn(s.vars.defaults,{ease:"none"})),s._ease=Cn(x.ease||n.ease||"none");var _,E,P,k=0;if(Ar(x))x.forEach((function(e){return s.to(M,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(Ar(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(_=u[h].sort((function(e,t){return e.t-t.t})),l=k=0;l<_.length;l++)(P={ease:(E=_[l]).e,duration:(E.t-(l?_[l-1].t:0))/100*m})[h]=E.v,s.to(M,P,k),k+=P.duration;s.duration()<m&&s.to({},{duration:m-s.duration()})}}m||a.duration(m=s.duration())}else a.timeline=0;return!0!==b||qt||(Hn=qe(a),Yt.killTweensOf(M),Hn=0),wt(o,qe(a),i),n.reversed&&a.reverse(),n.paused&&a.paused(!0),(g||!m&&!x&&a._start===tn(o._time)&&Lr(g)&&vt(qe(a))&&"nested"!==o.data)&&(a._tTime=-wr,a.render(Math.max(0,-v))),S&&St(qe(a),S),a}return Qe(t,[{key:"render",value:function(e,t,r){var n,i,o=this._time,a=this._tDur,s=this._dur,l=a-wr<e&&0<=e?a:e<wr?0:e;if(s){if(l!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(m=l,f=this.timeline,this._repeat){if(h=s+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*h+e,t,r);if(m=tn(l%h),l===a?(g=this._repeat,m=s):((g=~~(l/h))&&g===l/h&&(m=s,g--),s<m&&(m=s)),(d=this._yoyo&&1&g)&&(p=this._yEase,m=s-m),y=yt(this._tTime,h),m===o&&!r&&this._initted)return this;g!==y&&(f&&this._yEase&&Vt(f,d),!this.vars.repeatRefresh||d||this._lock||(this._lock=r=1,this.render(tn(h*g),!0).invalidate()._lock=0))}if(!this._initted){if(Tt(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&&(Bt(this,"onStart"),this._tTime!==l))return this;for(n=this._pt;n;)n.r(i,n.d),n=n._next;f&&f.render(e<0?e:!m&&d?-wr:f._dur*f._ease(m/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),Bt(this,"onUpdate")),this._repeat&&g!==y&&this.vars.onRepeat&&!t&&this.parent&&Bt(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)||sn(this,1),t||e<0&&!o||!l&&!o||(Bt(this,l===a?"onComplete":"onReverseComplete",!0),!this._prom||l<a&&0<this.timeScale()||this._prom()))}}else{var u,c,h=this,p=e,d=t,f=r,m=h.ratio,v=p<0||!p&&(!h._start&&Mt(h)&&(h._initted||!_t(h))||(h._ts<0||h._dp._ts<0)&&!_t(h))?0:1,g=h._rDelay,y=0;if(g&&h._repeat&&(c=yt(y=Ot(0,h._tDur,p),g),h._yoyo&&1&c&&(v=1-v),c!==yt(h._tTime,g)&&(m=1-v,h.vars.repeatRefresh&&h._initted&&h.invalidate())),v!==m||f||h._zTime===wr||!p&&h._zTime){if(h._initted||!Tt(h,p,f,d)){for(c=h._zTime,h._zTime=p||(d?wr:0),d=d||p&&!c,h.ratio=v,h._from&&(v=1-v),h._time=0,h._tTime=y,u=h._pt;u;)u.r(v,u.d),u=u._next;h._startAt&&p<0&&h._startAt.render(p,!0,!0),h._onUpdate&&!d&&Bt(h,"onUpdate"),y&&h._repeat&&!d&&h.parent&&Bt(h,"onRepeat"),(p>=h._tDur||p<0)&&h.ratio===v&&(v&&sn(h,1),d||(Bt(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(),He(Ye(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?Nt(this):this;if(this.timeline)return p=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,Hn&&!0!==Hn.vars.overwrite)._first||Nt(this),this.parent&&p!==this.timeline.totalDuration()&&Et(this,this._dur*this.timeline._tDur/p,0,1),this;var r,n,i,o,a,s,l,u=this._targets,c=e?vn(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),Nt(this);for(r=this._op=this._op||[],"all"!==t&&(kr(t)&&(a={},ut(t,(function(e){return a[e]=1})),t=a),t=function(e,t){var r,n,i,o,a=(e=e[0]?en(e[0]).harness:0)&&e.aliases;if(!a)return t;for(n in r=dt({},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)||an(this,s,"_pt"),delete n[a]),"all"!==i&&(i[a]=1);return this._initted&&!this._pt&&p&&Nt(this),this}}],[{key:"to",value:function(e,r){return new t(e,r,arguments[2])}},{key:"from",value:function(e,t){return Rt(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 Rt(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 Yt.killTweensOf(e,t,r)}}]),t}()),$n=(nn(Jn.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),ut("staggerTo,staggerFrom,staggerFromTo",(function(e){Jn[e]=function(){var t=new Xn,r=fn.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}),ei=function(e,t,r){return e[t](r)},ti=function(e,t,r,n){return e[t](n.fp,r)},ri=function(e,t){return Rr(e[t])?ei:tt(e[t])&&e.setAttribute?jn:$n},ni=function(e,t){return t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t)},ii=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},oi=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},ai=function(){function e(t,r,n,i,o,a,s,l,u){Ke(this,e),this.t=r,this.s=i,this.c=o,this.p=n,this.r=a||ni,this.d=s||this,this.set=l||$n,this.pr=u||0,(this._next=t)&&(t._prev=this)}return Qe(e,[{key:"modifier",value:function(e,t,r){this.mSet=this.mSet||this.set,this.set=zn,this.m=e,this.mt=r,this.tween=t}}]),e}(),si=(ut(Jr+"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 Wr[e]=1})),Vr.TweenMax=Vr.TweenLite=Jn,Vr.TimelineLite=Vr.TimelineMax=Xn,Yt=new Xn({sortChildren:!1,defaults:br,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),yr.stringFilter=function(e){var t=e.join(" ");if(Tn.lastIndex=0,Tn.test(t))return t=Mn.test(t),e[1]=zt(e[1],t),e[0]=zt(e[0],t,Sn(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=Rr(e),n=(r=t&&!r&&e.init?function(){this._props=[]}:e,{init:st,render:Bn,add:Yn,kill:Fn,modifier:Nn,rawVars:0}),i={targetTest:0,get:0,getSetter:ri,aliases:{},register:0};if(En(),e!==r){if(Yr[t])return;nn(r,nn(on(e,n),i)),dt(r.prototype,dt(n,on(e,i))),Yr[r.prop=t]=r,e.targetTest&&(Kr.push(r),Wr[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}at(t,r),e.register&&e.register(ui,r,ai)}))},timeline:function(e){return new Xn(e)},getTweensOf:function(e,t){return Yt.getTweensOf(e,t)},getProperty:function(e,t,r,n){kr(e)&&(e=vn(e)[0]);var i=en(e||{}).get,o=r?pt:ht;return"native"===r&&(r=""),e&&(t?o((Yr[t]&&Yr[t].get||i)(e,t,r,n)):function(t,r,n){return o((Yr[t]&&Yr[t].get||i)(e,t,r,n))})},quickSetter:function(e,t,r){var n,i;if(1<(e=vn(e)).length)return n=e.map((function(e){return ui.quickSetter(e,t,r)})),i=n.length,function(e){for(var t=i;t--;)n[t](e)};e=e[0]||{};var o=Yr[t],a=en(e),s=a.harness&&(a.harness.aliases||{})[t]||t,l=o?function(t){var n=new o;er._pt=0,n.init(e,r?t+r:t,er,0,[e]),n.render(1,n),er._pt&&Bn(1,er)}:a.set(e,s);return o?l:function(t){return l(e,s,r?t+r:t,a,1)}},isTweening:function(e){return 0<Yt.getTweensOf(e,!0).length},defaults:function(e){return e&&e.ease&&(e.ease=Cn(e.ease,br.ease)),ft(br,e||{})},config:function(e){return ft(yr,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&&!Yr[e]&&!Vr[e]&&ot(t+" effect requires "+e+" plugin.")})),Zr[t]=function(e,t,n){return r(vn(e),nn(t||{},i),n)},e&&(Xn.prototype[t]=function(e,r,n){return this.add(Zr[t](e,Cr(r)?r:(n=r)&&{},this),n)})},registerEase:function(e,t){Pn[e]=Cn(t)},parseEase:function(e,t){return arguments.length?Cn(e,t):Pn},getById:function(e){return Yt.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 Xn(r);for(i.smoothChildTiming=Lr(r.smoothChildTiming),Yt.remove(i),i._dp=0,i._time=i._tTime=Yt._time,e=Yt._first;e;)t=e._next,!n&&!e._dur&&e instanceof Jn&&e.vars.onComplete===e._targets[0]||wt(i,e,e._start-e._delay),e=t;return wt(Yt,i,0),i},utils:{wrap:function e(t,r,n){var i=r-t;return Ar(t)?It(t,e(0,t.length),r):pn(n,(function(e){return(i+(e-t)%i)%i+t}))},wrapYoyo:function e(t,r,n){var i=r-t,o=2*i;return Ar(t)?It(t,e(0,t.length-1),r):pn(n,(function(e){return t+(i<(e=(o+(e-t)%o)%o||0)?o-e:e)}))},distribute:Ct,random:At,snap:Dt,normalize:function(e,t,r){return jt(e,t,0,1,r)},getUnit:dn,clamp:function(e,t,r){return pn(r,(function(r){return Ot(e,t,r)}))},splitColor:wn,toArray:vn,selector:function(e){return e=vn(e)[0]||ot("Invalid scope")||{},function(t){var r=e.current||e.nativeElement||e;return vn(t,r.querySelectorAll?r:r===e?ot("Invalid scope")||Kt.createElement("div"):e)}},mapRange:jt,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||dn(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=kr(t),p={};if(!0===n&&(i=1)&&(n=null),h)t={p:t},r={p:r};else if(Ar(t)&&!Ar(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=dt(Ar(t)?[]:{},t));if(!l){for(a in r)Yn.call(p,t,a,"get",r[a]);o=function(e){return Bn(e,p),h?t.p:t}}}return pn(n,o)},shuffle:gn},install:it,effects:Zr,ticker:_n,updateRoot:Xn.updateRoot,plugins:Yr,globalTimeline:Yt,core:{PropTween:ai,globals:at,Tween:Jn,Timeline:Xn,Animation:Wn,getCache:en,_removeLinkedListItem:an,suppressOverwrites:function(e){return qt=e}}}),li=(ut("to,from,fromTo,delayedCall,set,killTweensOf",(function(e){return si[e]=Jn[e]})),_n.add(Xn.updateRoot),er=si.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}),ui=si.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])}},Vn("roundProps",Lt),Vn("modifiers"),Vn("snap",Dt))||si;Jn.version=Xn.version=ui.version="3.9.1",Jt=1,rt()&&En(),Pn.Power0,Pn.Power1,Pn.Power2,Pn.Power3,Pn.Power4,Pn.Linear,Pn.Quad,Pn.Cubic,Pn.Quart,Pn.Quint,Pn.Strong,Pn.Elastic,Pn.Back,Pn.SteppedEase,Pn.Bounce,Pn.Sine,Pn.Expo,Pn.Circ;const ci=o,hi=["map","normalMap","aoMap"],pi=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"];class di{}const fi=class extends di{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){console.log(this,e,"this,data"),this.target[this.info]=e,this.target.needsUpdate=!0,pi.includes(this.info)&&(console.log(this.info,"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 mi=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 vi{constructor(e){this.allTextures=new Set,this.runScene=e}loadImagBit(e){return createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"})}load(e){return mi(this,void 0,void 0,(function*(){var t=yield this.loadImagBit(yield Oi(e));return t=new o.Texture(t),this.afterLoad(e,t)}))}clone(e){const t=new o.Texture(e.image);return t.userData=Object.assign({},e.userData),this._afterLoad(t)}getDef(e){return e=new o.Texture(e),this._afterLoad(e)}toThree(e){return e.mapping=ci.EquirectangularReflectionMapping,e.needsUpdate=!0,e}toTwo(e){return e.mapping=300,e.needsUpdate=!0,e}_afterLoad(e){const{md5:t,blob:r}=e.userData;var n=this.getSameTexture(t,e);return n?(e.dispose(),n):(e.userData.url=URL.createObjectURL(r),e.userData.md5=t,e.userData.gm=gi(e),e.format=-1!==r.type.indexOf("png")?1023:1022,e.needsUpdate=!0,e.flipY=!1,e.minFilter=ci.LinearMipmapLinearFilter,this.addToAllTextures(e),e)}afterLoad(e,t){return mi(this,void 0,void 0,(function*(){const r=yield Oi(e);t.userData.blob=r;var n=ji(yield r.arrayBuffer());return t.userData.url=URL.createObjectURL(r),t.userData.md5=n,this._afterLoad(t)}))}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}}bindData(e){return mi(this,void 0,void 0,(function*(){if(this.setTexture(e),this.addToAllTextures(e),e.userData.gm=gi(e),!e.userData.blob){const t=yield this.getBlob(e);return e.userData.md5=ji(yield t.arrayBuffer()),e.userData.blob=t,e.userData.url=URL.createObjectURL(t),e}}))}setTexture(e){return e.magFilter=1003,e.wrapS=ci.RepeatWrapping,e.wrapT=ci.RepeatWrapping,e.encoding=3e3,e.needsUpdate=!0,e.version=3,e.minFilter=ci.LinearMipmapLinearFilter,e}addToAllTextures(e){var t=this.runScene.uniqueEx.texture.getLength();this.runScene.uniqueEx.texture.add(e),this.runScene.uniqueEx.texture.getLength()!==t&&(this.setTexture(e),this.runScene.optionsEx.cb.texture.add.cb(e))}parse(e){return mi(this,void 0,void 0,(function*(){var t=yield Li(e);return this.afterLoad(URL.createObjectURL(t),new o.Texture(yield this.loadImagBit(t)))}))}getBlob(e){return e.userData.blob||Si(e.image)}getUrl(e){return console.log(e,"texture"),e.userData.url}getBlobAndBase64(e){return e.userData.blob?e.userData:Mi(e)}dispose(e){e.dispose()}reverseY(e){return createImageBitmap(e,{imageOrientation:"flipY"})}coverByImage(e,t){return mi(this,void 0,void 0,(function*(){let r;r=t instanceof o.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,Fe.js)(n,((n,i)=>{const o=this.runScene.uniqueEx.material.get(n);o&&i.forEach((n=>{t.push(new fi({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 gi=e=>{var{width:e,height:t}=e.image;return e*t*4*1.33};var yi=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 bi=(e,t,r,n,i)=>{let o=Object.assign({},e),a=new Jn(o,r,t).eventCallback("onUpdate",(e=>n&&n(o))).eventCallback("onComplete",(e=>{i&&i(),Jn.killTweensOf(a)}));return a},xi=(e,t)=>(t.updateMatrixWorld(!0),t=new ci.Vector3,e.getWorldPosition(t),t),wi=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()},Si=e=>yi(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)}))}))})),Ti=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)},Mi=e=>yi(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=1023===e.format?"image/png":"image/jpeg";return n.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(i)})}),i)}))})),_i=e=>yi(void 0,void 0,void 0,(function*(){-1!==e.indexOf(",")&&(e=Ei(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})),Ei=e=>e.substring(e.indexOf(",")+1),Pi=e=>URL.createObjectURL(new Blob([e])),ki=(e,t)=>URL.createObjectURL(new Blob([e],t)),Ri=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)},Oi=e=>yi(void 0,void 0,void 0,(function*(){return(yield n().get(e,{responseType:"blob"})).data})),Ci=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})},Li=e=>yi(void 0,void 0,void 0,(function*(){return Ci(yield(0,Ve.toResult)(e,"base64"))})),Di=(e,t)=>new File([e],t),Ai=e=>e.substring(e.indexOf(":")+1,e.indexOf(";")),Ii=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},ji=e=>(0,ze.md5)(e),Ui=(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})}}))},Bi=e=>{const t=document.createElement("canvas"),r=t.getContext("2d");return r.drawImage(e,0,0,e.width,e.height),{ctx:r,canvas:t}},Ni=(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)}))},Fi=(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]},zi=(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]},Vi=e=>yi(void 0,void 0,void 0,(function*(){var{bitmap:t,texture:r}=e;const{ctx:n,canvas:i}=yield Ui(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=Fi(o.data[a],o.data[a+1],o.data[a+2]))[0]/100,u=c[1]/100,c=c[2]/100;l=zi(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 ci.Texture(i)})),Hi=e=>{for(var t=(e=e.bitmap).width,r=e.height,n=Bi(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)))},Gi=e=>new Array(e.files.length).fill(0).map(((t,r)=>e.files.item(r))).filter((e=>null!==e)),Wi=e=>new Promise((t=>{e.toBlob((e=>{t(e)}))})),Xi={parse(e){var{x:e,y:t,z:r}=e;return void 0===r?new o.Vector2(e,t):new o.Vector3(e,t,r)},toJSON(e){var{x:t,y:r}=e;return e instanceof o.Vector2?{x:t,y:r}:{x:t,y:r,z:e.z}}},qi=(e,t)=>n().get(e,{responseType:t||"arraybuffer"}).then((e=>e.data)).catch((e=>{console.log(e,"加载出错")}));class Yi{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:a}=this.events.runScene.assetsEx.get(),s=new o.Vector3,l=new o.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 a=new o.Vector3;t=e.geometry.attributes.position.array,a.set(Math.abs(t[0]-t[3]),Math.abs(t[1]-t[7]),Math.abs(t[2]-t[14])),l.x=.5*(t[0]+t[3]),l.y=.5*(t[1]+t[7]),l.z=.5*(t[2]+t[14]);let u=new o.Vector3;u.subVectors(n.position,l),u.projectOnPlane(new o.Vector3(0,1,0)),u.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*n.fov*Math.PI/180),t=a.length()/r/t,s.addVectors(l,u.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new o.Vector3,e.getWorldPosition(t),l.set(t.x,t.y,t.z);let i=new o.Vector3;i.subVectors(n.position,l),i.projectOnPlane(new o.Vector3(0,1,0)),i.normalize(),s.addVectors(l,i.multiplyScalar(3))}bi({positionX:n.position.x,positionY:n.position.y,positionZ:n.position.z,targetX:a.target.x,targetY:a.target.y,targetZ:a.target.z},{positionX:s.x,positionY:s.y,positionZ:s.z,targetX:l.x,targetY:l.y,targetZ:l.z},.5,(e=>{n.position.set(e.positionX,e.positionY,e.positionZ),n.lookAt(e.targetX,e.targetY,e.targetZ),a.target.set(e.targetX,e.targetY,e.targetZ),a.update(),n.updateProjectionMatrix()}))}},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,Fe.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,!0,!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,Fe.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 Zi{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.down=e=>{(0,Fe.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,Fe.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 o.Raycaster,r=new o.Vector2,{engineDom:n,camera:i,scene:a}=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=a.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)}}r=a(356);var Qi=a.n(r),Ki=a(298);const Ji=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"];class $i{static create(){return new o.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],n=e[t];if(r instanceof o.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 pi)if(e[t])return!1;return!0}}$i.defVal={color:new o.Color(16777215),emissive:new o.Color(0),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new o.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class eo{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];console.log(e,"last"),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){if(e>this.dataMap.index){const t=this.undos.slice(this.dataMap.index+1,e+1);t.map((e=>{e instanceof Array?e.map((e=>e.redo())):e.redo()})),console.log(t,"0")}else if(e<this.dataMap.index){const t=this.undos.slice(e+1,this.dataMap.index+1);t.reverse().map((e=>{e instanceof Array?e.map((e=>e.undo())):e.undo()})),console.log(t,this.undos,"ls1")}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];console.log(e,"last"),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(""),console.log(this,"this")}}function to(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=to(e[t]),n[t]=r);return n}}const ro=class extends di{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,Fe.qR)(e.target,this.typeList)[(0,Ki.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,Fe.qR)(this.target,this.typeList);t[(0,Ki.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 no{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 o.ShaderMaterial({uniforms:to(io.uniforms),vertexShader:io.vertexShader,fragmentShader:io.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=>!no.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];n.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new o.Vector4(t.x,t.y,t.z,t.w):t})),n.userData.tools=this.tools,n},toNormal:e=>{const t=yo(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),{}),n=e.uniforms,i=io.uniforms;return Object.keys(n).filter((e=>!no.TextureNames.includes(e))).map((e=>{var t,a,s,l,u,c,h=n[e].value,p=i[e].value;h instanceof o.Vector4?(({x:t,y:a,z:s}=h),({x:l,y:u,z:c}=p),t===l&&a===u&&s===c||(r[e]=h)):(console.log(h,p,"val,defVal"),h!==p&&(r[e]=h))})),console.log(r,"uniforms"),t.userData.normal.uniforms=r,console.log(t,"newMaterial"),t},clone:function(e,t){return e}},this.runScene=e}create(){const e=new o.ShaderMaterial({uniforms:to(io.uniforms),vertexShader:io.vertexShader,fragmentShader:io.fragmentShader});return e.userData.tools=this.tools,e}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new ro({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}no.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"];const io={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new o.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 o.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new o.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 "},oo={uniforms:{tDiffuse:new o.Uniform(null),h:new o.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}"},ao={uniforms:{tDiffuse:new o.Uniform(null),v:new o.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 o.Uniform(null),new o.Uniform(null),new o.Uniform(0),new o.Uniform(0),new o.Uniform(0),new o.Uniform(new o.Vector2),new o.Uniform(.1),new o.Uniform(1e3);class so{constructor(e){this.materials={},this.render=()=>{(0,Fe.js)(this.materials,((e,t)=>{const{model:r,material:n}=t;n.update(r)}))},this.tools={type:"Reflector",getTextures:e=>xo(e),parseData:e=>{const{textures:t,normal:r,models:n,material:i}=e,o=bo(i,new lo(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=>!so.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=bo(e,yo()),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=uo.uniforms;return Object.keys(n).filter((e=>!so.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,i.getId)();t.userData.id=r,this.materials[r]=e}create(e){const t=new lo(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 ro({target:e,typeList:[...t],newVal:r}).execute())}dispose(){this.materials={}}}so.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"];class lo extends o.MeshStandardMaterial{constructor(e,t,r){e?super(e):(super(),this.opacity=uo.uniforms.opacity.value,this.transparent=uo.uniforms.transparent.value,this.roughness=uo.uniforms.roughness.value,this.metalness=uo.uniforms.metalness.value),this.runScene=r,t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new o.Uniform(t.mirror),this.mixBlur=new o.Uniform(t.mixBlur),this.mixStrength=new o.Uniform(t.mixStrength),this.mixContrast=new o.Uniform(t.mixContrast)):(this.resolution=uo.uniforms.resolution.value,this.blurSize=uo.uniforms.blurSize.value,this.mirror=new o.Uniform(uo.uniforms.mirror.value),this.mixBlur=new o.Uniform(uo.uniforms.mixBlur.value),this.mixStrength=new o.Uniform(uo.uniforms.mixStrength.value),this.mixContrast=new o.Uniform(uo.uniforms.mixContrast.value)),this.textureMatrix=new o.Uniform(new o.Matrix4),this.reflectorWorldPosition=new o.Vector3,this.cameraWorldPosition=new o.Vector3,this.rotationMatrix=new o.Matrix4,this.normal=new o.Vector3,this.view=new o.Vector3,this.lookAtPosition=new o.Vector3,this.target=new o.Vector3,this.tempQuaternion=new o.Vector4,this.virtualCamera=new o.PerspectiveCamera,this.reflectorPlane=new o.Plane,this.clipPlane=new o.Vector4,e={minFilter:o.LinearFilter,magFilter:o.LinearFilter,type:o.HalfFloatType,encoding:this.runScene.assetsEx.get().renderer.outputEncoding},this.glRT1=new o.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new o.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new o.Uniform(this.glRT1.texture),this.tDiffuseBlur=new o.Uniform(this.glRT2.texture),this.hBlurPass=new Z(oo),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 Z(ao),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=uo.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",uo.vertexShader),e.fragmentShader=uo.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",uo.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 uo={uniforms:{opacity:new o.Uniform(1),transparent:new o.Uniform(!1),roughness:new o.Uniform(1),metalness:new o.Uniform(.6),resolution:new o.Uniform(1024),blurSize:new o.Uniform(1024),mirror:new o.Uniform(0),mixBlur:new o.Uniform(10),mixStrength:new o.Uniform(2),mixContrast:new o.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 co{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=bo(n,new ho(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=>!co.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.insertFresnelShader(),i.userData.tools=this.tools,i},toNormal:e=>{const t=bo(e,yo()),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=po.uniforms;return Object.keys(n).filter((e=>!co.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){console.log("Fresnel Create");const t=new ho(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 ro({target:e,typeList:[...t],newVal:r}).execute())}}co.TextureNames=["envMap"];class ho extends o.MeshPhysicalMaterial{constructor(e,t,r){if(e?super(e):(super(),this.emissive=new o.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 o.Uniform(t.fresnelBias),this.fresnelScale=new o.Uniform(t.fresnelScale),this.fresnelPower=new o.Uniform(t.fresnelPower)):(this.fresnelBias=new o.Uniform(po.uniforms.fresnelBias.value),this.fresnelScale=new o.Uniform(po.uniforms.fresnelScale.value),this.fresnelPower=new o.Uniform(po.uniforms.fresnelPower.value)),!this.cubeCamera){const e=new o.WebGLCubeRenderTarget(2048);e.texture.mapping=o.CubeRefractionMapping,this.cubeCamera=new o.CubeCamera(.1,1e5,e),this.runScene.assetsEx.scene.add(this.cubeCamera),console.log("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,po.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,po.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,po.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,po.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 po={uniforms:{fresnelBias:new o.Uniform(0),fresnelScale:new o.Uniform(1),fresnelPower:new o.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 "},fo=class extends di{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),this.runScene.optionsEx.cb.model.changeName.cb({model:this.target,name:e=t||e})):"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)}},mo={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},vo=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];class go{constructor(e){this.defMaterialMap={BaseMaterial:$i,SpriteMaterial:wo,FakeInterior:no,Reflector:so,Fresnel:co},this.defMaterial=yo(),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:$i,SpriteMaterial:wo,FakeInterior:new no(e),Reflector:new so(e),Fresnel:new co(e)}}add(e,t,r){this.runScene.uniqueEx.material.add(e,t,r)}create(){var e=new o.MeshStandardMaterial;return this.add(e),e}clone(e){const t=e.clone();return t.userData.id=(0,i.getId)(),t}setNormal(e,t=!0){return e=new fi(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&&this.runScene.textureEx.toThree(e.newVal),new fi(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 fo({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,Fe.js)(mo,((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,Fe.js)(e,((e,r)=>{var n,i,o,a,s;void 0!==mo[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&&$i.isDefval(e)}}const yo=()=>{const e=new o.MeshStandardMaterial;return e.userData.id=(0,i.getId)(),e},bo=(e,t)=>(vo.map((r=>{const n=e[r];"object"==typeof n&&(t[r]=n.clone()),t[r]=n})),t),xo=e=>{var t=e.userData.textures||pi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t};class wo{static create(){const e=new o.SpriteMaterial;return e.userData.tools=this.tools,e}}wo.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=ko("Box");return t.userData.normal={type:"MySpriteMaterial"},wo.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=ko("Sprite");return wo.modelTools.merge(e,r),r.material=e.material,r}},wo.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=bo(r,wo.create());return t.map((e=>{var{type:e,texture:t}=e;n[e]=t})),n},toNormal:e=>{const t=bo(e,yo());return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:wo.tools.type},textures:wo.tools.getTextures(e)}),t},clone:function(e,t){return e}};class So{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 To extends So{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 Mo=class extends di{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 _o extends So{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 Eo=class extends di{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){console.log(e,"data"),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(){console.log(1,"1"),this._execute(this.newV3)}};class Po{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=!0,n=!1,i=!0){if(e instanceof Array)return e.map((e=>this.add(e,t,r,n,i)));n&&(this.runScene.uniqueEx.model.add(e,{hasReset:!0}),this.runScene.optionsEx.cb.model.clone.cb(e));var o=new To({model:e,parent:t||this.runScene.sceneEx.get(),isClone:n,runScene:this.runScene}).execute();!0===r&&this.runScene.undoEx.addUndo(o),i&&this.setSelectByModel(e,{isDomTreeActive:!1,isClone:n})}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 _o({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 Qi().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 Mo({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 Eo({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 fo({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 fo({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(ko(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new o.MeshBasicMaterial,t=new o.SphereGeometry(.7,150,150);return new o.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 ro({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const n=t||new o.Group,i=[];i.push(new To({model:n,runScene:this.runScene,parent:r||this.runScene.assetsEx.get().scene}).execute()),e instanceof Array?i.push(...e.map((e=>new Mo({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()))):i.push(new Mo({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,Ki.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 Mo({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 _o({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===Qi().model.deepFindParentByUuid(n,t)&&n.uuid!==e.uuid&&i.push(n):n.uuid!==e.uuid&&i.push(n)}))}));var o=i.map((e=>new fo({target:e,info:"visible",newVal:!1,runScene:this.runScene,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(o),Qi().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 fo({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 _o({runScene:this.runScene,model:e,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(r)}}const ko=e=>{if(Ji.includes(e)){const t=Qi().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=wo.tools),t}throw TypeError("")};class Ro{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 Oo{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;r.md5=t.userData.md5,r.id=t.userData.id}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 Co{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 o.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 Lo{constructor(e,t){this.helperModels=[],this.runScene=t,this.type=e,this.material=new Oo(t),this.scene=new Co(t)}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,Fe.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}),console.log(e,"json"),"scene"===this.type&&(yield this.scene.done(e)),yield this.material.done(e)}))}}var Do=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 Ao{constructor(e,t){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.modelType={Sprite:wo},this.type=e,this.runScene=t}parse(e){return Do(this,void 0,void 0,(function*(){const t=new o.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 o.Texture||t.environment instanceof o.Texture){this.runScene.bloom.glow.setUpdate(!1),t.userData.ex={};var{background:r,environment:n}=t;this.runScene.bloom.glow.setUpdate(!0);const a=this.runScene.modelEx.create(),s=yo();a.material=s,e.add(a),e=(0,i.getId)(),t.userData.ex.materialId=e,s.userData.id=e,this.materialMap[e]={material:s},r instanceof o.Texture&&303===(s.map=r).mapping&&(t.userData.ex.backgroundMapping=303),n instanceof o.Texture&&(s.envMap=n)}}_processMaterial(e){if(e.material){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))):(console.log(e.material.userData.id,"material.userData.id"),r=t||this.runScene.optionsEx.exporterOptions.notMaterial?this.runScene.materialEx.defMaterial:this.runScene.materialEx.toNromal(e.material),e.material=r,console.log(r.userData.id,"material.userData.id"),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,Fe.js)(this.materialMap,((e,t)=>Do(this,void 0,void 0,(function*(){var e=t.material,r=xo(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 Do(this,void 0,void 0,(function*(){return e.map((e=>{const{type:r,texture:n}=e;this.runScene.uniqueEx.texture.add(n),t[r]=null;var{isSame:e,texture:i}=this.mergeSame(n);if(e)this.runScene.textureEx.dispose(n);else if(!this.json.textureMap[n.userData.id]){var o,{format:a,repeat:s,center:l,rotation:u,offset:c}=n;const e={format:a};this.runScene.modelEx.isNavieV2(s,1)||(({x:a,y:o}=s),e.repeat=a===o?a:s),this.runScene.modelEx.isNavieV2(l,0)||(({x:o,y:a}=l),e.center=o===a?o:l),this.runScene.modelEx.isNavieV2(c,0)||(({x:s,y:a}=c),e.offset=s===a?s:c),0!==u&&(e.rotation=u),this.json.textureMap[n.userData.id]=e}"normalMap"!==r||n.userData.isNormalMap||(n.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[r]=i.userData.id}))}))}setMultipMaterial(e,t){const r=this.runScene.modelEx.create(),n=yo();r.material=n,e.add(r);for(const e of hi){if(!t.length)return;var i=t.pop();if(!i)return;n[e]=this.textureMap[i].texture}t.length&&this.setMultipMaterial(e,t)}}function Io(){Io=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=(d="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",i=d.asyncIterator||"@@asyncIterator",o=d.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 d,f,m=(a(d={},n,(function(){return this})),(f=(f=Object.getPrototypeOf)&&f(f(w([]))))&&f!==t&&r.call(f,n)&&(d=f),p.prototype=c.prototype=Object.create(d));function v(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function g(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"==Uo(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 y(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(y,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(g.prototype),a(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(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 jo(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 Uo(e){return(Uo="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 Bo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function No(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 Fo(e,t,r){t&&No(e.prototype,t),r&&No(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var zo=function(){function e(){Bo(this,e),this.pluginCallbacks=[],this.register((function(e){return new ea(e)})),this.register((function(e){return new ta(e)})),this.register((function(e){return new ra(e)})),this.register((function(e){return new ia(e)})),this.register((function(e){return new oa(e)})),this.register((function(e){return new na(e)}))}return Fo(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"===Uo(r)&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),n=r);for(var i=new $o,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}(),Vo=5121,Ho=5123,Go=(r=9728,9729),Wo=9984,Xo=9986,qo={},Yo=(qo[o.NearestFilter]=r,qo[o.NearestMipmapNearestFilter]=Wo,qo[o.NearestMipmapLinearFilter]=Xo,qo[o.LinearFilter]=Go,qo[o.LinearMipmapNearestFilter]=9985,qo[o.LinearMipmapLinearFilter]=9987,qo[o.ClampToEdgeWrapping]=33071,qo[o.RepeatWrapping]=10497,qo[o.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function Zo(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Qo(e){return 4*Math.ceil(e/4)}function Ko(e,t){var r=1<arguments.length&&void 0!==t?t:0,n=Qo(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 Jo=null,$o=function(){function e(){Bo(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 Fo(e,[{key:"setPlugins",value:function(e){this.plugins=e}},{key:"write",value:(t=Io().mark((function e(t,r,n){var i,o,a,s,l,u,c;return Io().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=Ko(u.result),t=new DataView(new ArrayBuffer(8)),n=(t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0),Ko(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){jo(o,n,i,a,s,"next",e)}function s(e){jo(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 o.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 o.Vector3,i=0,a=r.count;i<a;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),a=document.createElement("canvas"),s=(a.width=e,a.height=i,a.getContext("2d")),l=(s.fillStyle="#ffffff",s.fillRect(0,0,e,i),s.getImageData(0,0,e,i));if(t){s.drawImage(t,0,0,e,i);for(var u=s.getImageData(0,0,e,i).data,c=0;c<u.length;c+=4)l.data[c]=u[c]}if(r){s.drawImage(r,0,0,e,i);for(var h=s.getImageData(0,0,e,i).data,p=1;p<h.length;p+=4)l.data[p]=h[p]}if(n){s.drawImage(n,0,0,e,i);for(var d=s.getImageData(0,0,e,i).data,f=2;f<d.length;f+=4)l.data[f]=d[f]}return s.putImageData(l,0,0),new o.Texture(a)}}},{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===Vo?1:t===Ho?2:4,Qo(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===Ho?l.setUint16(u,p,!0):t===Vo&&l.setUint8(u,p),u+=o}var d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};return void 0!==i&&(d.target=i),34962===i&&(d.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(d),{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=Ko(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=Ho;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");i=Vo}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,a=this,s=a.cache,l=a.json,u=a.options,c=a.pending,h=(s.images.has(e)||s.images.set(e,{}),s=s.images.get(e),null==(h=n.userData)?void 0:h.blob),p=n.userData.isNormalMap,d=(i=a.options.myOptions.optionsEx.exporterOptions.compressTexture)?"image/webp":"image/png";if(void 0!==s[(i&&(h=!!p),i=d+":flipY/"+r.toString())])return s[i];l.images||(l.images=[]);var f={mimeType:d};if(!0===u.binary&&h)c.push(new Promise((function(e){a.processBufferViewImage(n.userData.blob).then((function(t){f.bufferView=t,e()}))})));else if(u.embedImages){var m=Jo=Jo||document.createElement("canvas");if((m.width=Math.min(e.width,u.maxTextureSize),m.height=Math.min(e.height,u.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!==o.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);for(var v=new Uint8ClampedArray(e.height*e.width*4),g=0;g<v.length;g+=4)v[g+0]=e.data[g+0],v[g+1]=e.data[g+1],v[g+2]=e.data[g+2],v[g+3]=e.data[g+3];p.putImageData(new ImageData(v,e.width,e.height),0,0)}!0===u.binary?c.push(new Promise((function(e){m.toBlob((function(t){a.processBufferViewImage(t).then((function(t){f.bufferView=t,e()}))}),d)}))):f.uri=m.toDataURL(d)}else f.uri=e.src;return r=l.images.push(f)-1,s[i]=r}},{key:"processSampler",value:function(e){var t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:qo[e.magFilter],minFilter:qo[e.minFilter],wrapS:qo[e.wrapS],wrapT:qo[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:{}},a=(Zo((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."),a=e.color.toArray().concat([e.opacity])),[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=a),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(a={index:this.processTexture(null)},this.applyTextureTransform(a,e.metalnessMap||e.roughnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=a),e.map&&(a={index:this.processTexture(e.map)},this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a),e.emissive&&(a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),1<(n=Math.max(a.r,a.g,a.b))&&(a.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<n&&(i.emissiveFactor=a.toArray()),e.emissiveMap&&(n={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(n,e.emissiveMap),i.emissiveTexture=n)),e.normalMap&&(a={index:this.processTexture(e.normalMap)},e.normalScale&&1!==e.normalScale.x&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a),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===o.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,a),a}},{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,a=e.material.length;i<a;i++)n.push(e.material[i].uuid);else n.push(e.material.uuid);var s=n.join(":");if(t.meshes.has(s))return t.meshes.get(s);var l=e.geometry,u=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4;if(!0!==l.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");var c,h,p,d={},f={},m=[],v=[],g={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},y=l.getAttribute("normal"),b=(void 0===y||this.isNormalizedNormalAttribute(y)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),l.setAttribute("normal",this.createNormalizedNormalAttribute(y))),null);for(h in l.attributes)"morph"!==h.slice(0,5)&&(c=l.attributes[h],h=g[h]||h.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(h)||(h="_"+h),t.attributes.has(this.getUID(c))?f[h]=t.attributes.get(this.getUID(c)):(b=null,p=c.array,"JOINTS_0"!==h||p instanceof Uint16Array||p instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=new o.BufferAttribute(new Uint16Array(p),c.itemSize,c.normalized)),null!==(p=this.processAccessor(b||c,l))&&(f[h]=p,t.attributes.set(this.getUID(c),p))));if(void 0!==y&&l.setAttribute("normal",y),0===Object.keys(f).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 M=0;M<e.morphTargetInfluences.length;++M){var _,E={},P=!1;for(_ in l.morphAttributes)if("position"!==_&&"normal"!==_)P||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),P=!0);else{var k=l.morphAttributes[_][M],R=_.toUpperCase(),O=l.attributes[_];if(t.attributes.has(this.getUID(k)))E[R]=t.attributes.get(this.getUID(k));else{var C=k.clone();if(!l.morphTargetsRelative)for(var L=0,D=k.count;L<D;L++)C.setXYZ(L,k.getX(L)-O.getX(L),k.getY(L)-O.getY(L),k.getZ(L)-O.getZ(L));E[R]=this.processAccessor(C,l),t.attributes.set(this.getUID(O),E[R])}}v.push(E),x.push(e.morphTargetInfluences[M]),void 0!==e.morphTargetDictionary&&w.push(S[M])}d.weights=x,0<w.length&&(d.extras={},d.extras.targetNames=w)}if((y=Array.isArray(e.material))&&0===l.groups.length)return null;for(var A=y?e.material:[e.material],I=y?l.groups:[{materialIndex:0,start:void 0,count:void 0}],j=0,U=I.length;j<U;j++){var B={mode:u,attributes:f},N=(this.serializeUserData(l,B),0<v.length&&(B.targets=v),null!==l.index&&(N=this.getUID(l.index),void 0===I[j].start&&void 0===I[j].count||(N+=":"+I[j].start+":"+I[j].count),t.attributes.has(N)?B.indices=t.attributes.get(N):(B.indices=this.processAccessor(l.index,l,I[j].start,I[j].count),t.attributes.set(N,B.indices)),null===B.indices&&delete B.indices),this.processMaterial(A[I[j].materialIndex]));null!==N&&(B.material=N),m.push(B)}return d.primitives=m,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,d)})),y=r.meshes.push(d)-1,t.meshes.set(s,y),y}},{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:o.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=zo.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks),a=[],s=[],l=0;l<i.length;++l){var u=i[l],c=o.PropertyBinding.parseTrackName(u.name),h=o.PropertyBinding.findNode(t,c.nodeName),p=Yo[c.propertyName];if(!(h="bones"===c.objectName?!0===h.isSkinnedMesh?h.skeleton.getBoneByName(c.objectIndex):void 0:h)||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;c=u.values.length/u.times.length;var d=void(p===Yo.morphTargetInfluences&&(c/=h.morphTargetInfluences.length));!0===u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",c/=3):d=u.getInterpolation()===o.InterpolateDiscrete?"STEP":"LINEAR",s.push({input:this.processAccessor(new o.BufferAttribute(u.times,1)),output:this.processAccessor(new o.BufferAttribute(u.values,c)),interpolation:d}),a.push({sampler:s.length-1,target:{node:n.get(h),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:s,channels:a}),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 a=e.skeleton.bones[0];if(void 0===a)return null;for(var s=[],l=new Float32Array(16*i.bones.length),u=new o.Matrix4,c=0;c<i.bones.length;++c)s.push(r.get(i.bones[c])),u.copy(i.boneInverses[c]),u.multiply(e.bindMatrix).toArray(l,16*c);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new o.BufferAttribute(l,16)),joints:s,skeleton:r.get(a)}),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(),Zo(r,[0,0,0,1])||(a.rotation=r),Zo(h,[0,0,0])||(a.translation=h),Zo(t,[1,1,1])||(a.scale=t)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===Zo(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 o.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)})),[]),a=0;a<e.length;a++)e[a]instanceof o.Scene?this.processScene(e[a]):i.push(e[a]);1===i.length?(t=i[0],["Group","Object3D"].includes(t.type)||((r=new o.Group).name="glb_model",r.add(t),t=r),this.processScene(t)):1<i.length&&this.processObjects(i);for(var s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(var l=0;l<n.animations.length;++l)this.processAnimation(n.animations[l],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}(),ea=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_lights_punctual"}return Fo(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}(),ta=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_materials_unlit"}return Fo(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}(),ra=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_materials_pbrSpecularGlossiness"}return Fo(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}(),na=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_materials_clearcoat"}return Fo(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}(),ia=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_materials_transmission"}return Fo(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}(),oa=function(){function e(t){Bo(this,e),this.writer=t,this.name="KHR_materials_volume"}return Fo(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}(),aa=(zo.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,a=0;a<i.length;++a){var s=i[a],l=o.PropertyBinding.parseTrackName(s.name),u=o.PropertyBinding.findNode(t,l.nodeName);if("morphTargetInfluences"!==l.propertyName||void 0===l.propertyIndex)r.push(s);else{if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.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."),(s=s.clone()).setInterpolation(o.InterpolateLinear)}var c=u.morphTargetInfluences.length,h=u.morphTargetDictionary[l.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);var p=void 0;if(void 0===n[u.uuid]){for(var d=new((p=s.clone()).ValueBufferType)(c*p.times.length),f=0;f<p.times.length;f++)d[f*c+h]=p.values[f];p.name=(l.nodeName||"")+".morphTargetInfluences",p.values=d,n[u.uuid]=p,r.push(p)}else{var m=s.createInterpolant(new s.ValueBufferType(1));p=n[u.uuid];for(var v=0;v<p.times.length;v++)p.values[v*c+h]=m.evaluate(p.times[v]);for(var g=0;g<s.times.length;g++){var y=this.insertKeyframe(p,s.times[g]);p.values[y*c+h]=s.values[g]}}}}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 sa{constructor(e){this._gltf=new zo,this.options=new Ro,this.runScene=e}getArrayBuffer(e=this.runScene.sceneEx.getClear(),t="scene"){return aa(this,void 0,void 0,(function*(){const r=new Lo(t,this.runScene),n=new Ao(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 aa(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,Ve.downloadFile)(new Blob([t]),"scene.glb")}))}model(){return aa(this,void 0,void 0,(function*(){const e=this.runScene.modelEx.select;var t;e&&(t=yield this.getArrayBuffer(e.clone(),"model"),(0,Ve.downloadFile)(new Blob([t]),"scene.glb"))}))}material(){var e;return aa(this,void 0,void 0,(function*(){var t=null==(e=this.runScene.modelEx.select)?void 0:e.material;if(t){const e=ko("Box");e.material=t,t=yield this.getArrayBuffer(e,"material"),(0,Ve.downloadFile)(new Blob([t]),"material.glb")}}))}scene(){return aa(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,Ve.downloadFile)(new Blob([e]),"scene.glb")}))}}class la{constructor(e){this.runScene=e,this.gltf=new sa(e)}}var ua={},ca=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},ha=function(e){return new Worker(e)};try{URL.revokeObjectURL(ca(""))}catch(Ta){ca=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},ha=function(e){return new Worker(e,{type:"module"})}}for(var pa=Uint8Array,da=Uint16Array,fa=Uint32Array,ma=new pa([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]),va=new pa([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]),ga=new pa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ya=(r=function(e,t){for(var r=new da(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new fa(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]},(Wo=r(ma,2))[0]),ba=Wo[1],xa=(ya[28]=258,ba[258]=28,Xo=r(va,0))[0],wa=Xo[1],Sa=new da(32768),Ta=0;Ta<32768;++Ta){var Ma=(43690&Ta)>>>1|(21845&Ta)<<1;Sa[Ta]=((65280&(Ma=(61680&(Ma=(52428&Ma)>>>2|(13107&Ma)<<2))>>>4|(3855&Ma)<<4))>>>8|(255&Ma)<<8)>>>1}var _a=function(e,t,r){for(var n=e.length,i=0,o=new da(t);i<n;++i)++o[e[i]-1];var a=new da(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(r){var s=new da(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[Sa[h]>>>l]=u}else for(s=new da(n),i=0;i<n;++i)e[i]&&(s[i]=Sa[a[e[i]-1]++]>>>15-e[i]);return s},Ea=new pa(288);for(Ta=0;Ta<144;++Ta)Ea[Ta]=8;for(Ta=144;Ta<256;++Ta)Ea[Ta]=9;for(Ta=256;Ta<280;++Ta)Ea[Ta]=7;for(Ta=280;Ta<288;++Ta)Ea[Ta]=8;var Pa=new pa(32);for(Ta=0;Ta<32;++Ta)Pa[Ta]=5;function ka(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 Ra(e,t,r,n,i){var o,a=os(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 Oa(e,t){return vs(e,t)+4294967296*vs(e,t+4)}var Ca=_a(Ea,9,0),La=_a(Ea,9,1),Da=_a(Pa,5,0),Aa=_a(Pa,5,1),Ia=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},ja=function(e,t,r){var n=t/8|0;return(e[n]|e[1+n]<<8)>>(7&t)&r},Ua=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},Ba=function(e){return(e/8|0)+(7&e&&1)},Na=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof da?da:e instanceof fa?fa:pa)(r-(t=null==t||t<0?0:t));return n.set(e.subarray(t,r)),n},Fa=function(e,t,r){var n=e.length;if(!n||r&&!r.l&&n<5)return t||new pa(0);function i(e){var r=t.length;r<e&&((r=new pa(Math.max(2*r,e))).set(t),t=r)}var o=!t||r,a=!r||r.i,s=(r=r||{},t=t||new pa(3*n),r.f||0),l=r.p||0,u=r.b||0,c=r.l,h=r.d,p=r.m,d=r.n,f=8*n;do{if(!c){r.f=s=ja(e,l,1);var m=ja(e,l+1,3);if(l+=3,!m){var v=e[(_=Ba(l)+4)-4]|e[_-3]<<8;if(n<(S=_+v)){if(a)throw"unexpected EOF";break}o&&i(u+v),t.set(e.subarray(_,S),u),r.b=u+=v,r.p=l=8*S;continue}if(1==m)c=La,h=Aa,p=9,d=5;else{if(2!=m)throw"invalid block type";v=ja(e,l,31)+257;for(var g=ja(e,l+10,15)+4,y=v+ja(e,l+5,31)+1,b=(l+=14,new pa(y)),x=new pa(19),w=0;w<g;++w)x[ga[w]]=ja(e,l+3*w,7);l+=3*g;var S,T=(1<<(S=Ia(x)))-1,M=_a(x,S,1);for(w=0;w<y;){var _,E=M[ja(e,l,T)];if(l+=15&E,(_=E>>>4)<16)b[w++]=_;else{var P=0,k=0;for(16==_?(k=3+ja(e,l,3),l+=2,P=b[w-1]):17==_?(k=3+ja(e,l,7),l+=3):18==_&&(k=11+ja(e,l,127),l+=7);k--;)b[w++]=P}}m=b.subarray(0,v);var R=b.subarray(v);p=Ia(m),d=Ia(R),c=_a(m,p,1),h=_a(R,d,1)}if(f<l){if(a)throw"unexpected EOF";break}}o&&i(u+131072);for(var O=(1<<p)-1,C=(1<<d)-1,L=l;;L=l){var D=(P=c[Ua(e,l)&O])>>>4;if(f<(l+=15&P)){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(D<256)t[u++]=D;else{if(256==D){L=l,c=null;break}var A,I=D-254,j=(264<D&&(A=ma[w=D-257],I=ja(e,l,(1<<A)-1)+ya[w],l+=A),(D=h[Ua(e,l)&C])>>>4);if(!D)throw"invalid distance";if(l+=15&D,R=xa[j],3<j&&(A=va[j],R+=Ua(e,l)&(1<<A)-1,l+=A),f<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=L,r.b=u,c&&(s=1,r.m=p,r.d=h,r.n=d)}while(!s);return u==t.length?t:Na(t,0,u)},za=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8},Va=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8,e[2+n]|=r>>>16},Ha=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[Qa,0];if(1==i)return(m=new pa(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 da(h+1),d=Ga(r[u-1],p,0);if(t<d){n=0;var f=0,m=d-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 g=o[n].s;if(!(p[g]>t))break;f+=v-(1<<d-p[g]),p[g]=t}for(f>>>=m;0<f;){var y=o[n].s;p[y]<t?f-=1<<t-p[y]++-1:++n}for(;0<=n&&f;--n){var b=o[n].s;p[b]==t&&(--p[b],++f)}d=t}return[new pa(p),d]},Ga=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},Wa=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new da(++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]},Xa=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},qa=function(e,t,r){var n=r.length,i=Ba(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)},Ya=function(e,t,r,n,i,o,a,s,l,u,c){za(t,c++,r),++i[256];for(var h=(r=Ha(i,15))[0],p=(r=r[1],(d=Ha(o,15))[0]),d=d[1],f=(m=Wa(h))[0],m=m[1],v=(g=Wa(p))[0],g=g[1],y=new da(19),b=0;b<f.length;++b)y[31&f[b]]++;for(b=0;b<v.length;++b)y[31&v[b]]++;for(var x=(w=Ha(y,7))[0],w=w[1],S=19;4<S&&!x[ga[S-1]];--S);var T,M=u+5<<3,_=Xa(i,Ea)+Xa(o,Pa)+a;if(i=Xa(i,h)+Xa(o,p)+a+14+3*S+Xa(y,x)+(2*y[16]+3*y[17]+7*y[18]),M<=_&&M<=i)return qa(t,c,e.subarray(l,l+u));if(za(t,c,1+(i<_)),c+=2,i<_){var E=_a(h,r,0),P=h,k=_a(p,d,0),R=p,O=_a(x,w,0);for(za(t,c,m-257),za(t,c+5,g-1),za(t,c+10,S-4),c+=14,b=0;b<S;++b)za(t,c+3*b,x[ga[b]]);c+=3*S;for(var C=[f,v],L=0;L<2;++L){var D=C[L];for(b=0;b<D.length;++b){var A=31&D[b];za(t,c,O[A]),c+=x[A],15<A&&(za(t,c,D[b]>>>5&127),c+=D[b]>>>12)}}}else E=Ca,P=Ea,k=Da,R=Pa;for(b=0;b<s;++b)255<n[b]?(A=n[b]>>>18&31,Va(t,c,E[A+257]),c+=P[A+257],7<A&&(za(t,c,n[b]>>>23&31),c+=ma[A]),T=31&n[b],Va(t,c,k[T]),c+=R[T],3<T&&(Va(t,c,n[b]>>>5&8191),c+=va[T])):(Va(t,c,E[n[b]]),c+=P[n[b]]);return Va(t,c,E[256]),c+P[256]},Za=new fa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qa=new pa(0),Ka=function(e,t,r,n,i,o){var a=e.length,s=new pa(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?qa(l,u,e.subarray(c,h)):(l[c]=o,qa(l,u,e.subarray(c,a)))}else{for(var p=(t=Za[t-1])>>>13,d=8191&t,f=(1<<r)-1,m=new da(32768),v=new da(1+f),g=Math.ceil(r/3),y=2*g,b=function(t){return(e[t]^e[t+1]<<g^e[t+2]<<y)&f},x=new fa(25e3),w=new da(288),S=new da(32),T=0,M=0,_=(c=0,0),E=0,P=0;c<a;++c){var k=b(c),R=32767&c,O=v[k];if(m[R]=O,v[k]=R,E<=c){var C=a-c;if((7e3<T||24576<_)&&423<C){u=Ya(e,l,0,x,w,S,M,_,P,c-P,u),_=T=M=0,P=c;for(var L=0;L<286;++L)w[L]=0;for(L=0;L<30;++L)S[L]=0}var D=2,A=0,I=d,j=R-O&32767;if(2<C&&k==b(c-j))for(var U=Math.min(p,C)-1,B=Math.min(32767,c),N=Math.min(258,C);j<=B&&--I&&R!=O;){if(e[c+D]==e[c+D-j]){for(var F=0;F<N&&e[c+F]==e[c+F-j];++F);if(D<F){if(A=j,U<(D=F))break;var z=Math.min(j,F-2),V=0;for(L=0;L<z;++L){var H=c-j+L+32768&32767,G=H-m[H]+32768&32767;V<G&&(V=G,O=H)}}}j+=(R=O)-(O=m[R])+32768&32767}A?(x[_++]=268435456|ba[D]<<18|wa[A],k=31&ba[D],C=31&wa[A],M+=ma[k]+va[C],++w[257+k],++S[C],E=c+D,++T):(x[_++]=e[c],++w[e[c]])}}u=Ya(e,l,o,x,w,S,M,_,P,c-P,u),!o&&7&u&&(u=qa(l,u+1,Qa))}return Na(s,0,n+Ba(u)+i)},Ja=function(){for(var e=new fa(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),$a=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=Ja[255&r^t[n]]^r>>>8;e=r},d:function(){return~e}}},es=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}}},ts=function(e,t,r,n,i){return Ka(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)},rs=function(e,t){var r,n={};for(r in e)n[r]=e[r];for(r in t)n[r]=t[r];return n},ns=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]},is=[],os=function(e,t,r,n){var i;if(!is[r]){for(var o="",a={},s=e.length-1,l=0;l<s;++l)o=(i=ns(e[l],o,a))[0],a=i[1];is[r]=ns(e[s],o,a)}var u=rs({},is[r][1]);return function(e,t,r,n,i){return(t=ha(ua[t]||(ua[t]=ca(e)))).onerror=function(e){return i(e.error,null)},t.onmessage=function(e){return i(null,e.data)},t.postMessage(r,n),t}(is[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 pa||e[t]instanceof da||e[t]instanceof fa)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(u),n)},as=function(){return[pa,da,fa,ma,va,ga,ya,xa,La,Aa,Sa,_a,Ia,ja,Ua,Ba,Na,Fa,Ls,ps,ds]},ss=function(){return[pa,da,fa,ma,va,ga,ba,wa,Ca,Ea,Da,Pa,Sa,Za,Qa,_a,za,Va,Ha,Ga,Wa,Xa,qa,Ya,Ba,Na,Ka,ts,ks,ps]},ls=function(){return[ys,ws,gs,$a,Ja]},us=function(){return[bs,xs]},cs=function(){return[Ss,gs,es]},hs=function(){return[Ts]},ps=function(e){return postMessage(e,[e.buffer])},ds=function(e){return e&&e.size&&new pa(e.size)},fs=function(e,t,r,n,i,o){var a=os(r,n,i,(function(e,t){a.terminate(),o(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},ms=function(e,t){return e[t]|e[t+1]<<8},vs=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},gs=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},ys=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&&gs(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)}},bs=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)},xs=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},ws=function(e){return 10+(e.filename&&e.filename.length+1||0)},Ss=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)},Ts=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 Ms(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var _s=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(ts(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}(),Es=function(e,t){Ra([ss,function(){return[ka,_s]}],this,Ms.call(this,e,t),(function(e){e=new _s(e.data),onmessage=ka(e)}),6)};function Ps(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[ss],(function(e){return ps(ks(e.data[0],e.data[1]))}),0,r)}function ks(e,t){return ts(e,t||{},0,0)}var Rs=function(){function e(e){this.s={},this.p=new pa(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 pa(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=Fa(this.p,this.o,this.s);this.ondata(Na(t,e,this.s.b),this.d),this.o=Na(t,this.s.b-32768),this.s.b=this.o.length,this.p=Na(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),Os=function(e){this.ondata=e,Ra([as,function(){return[ka,Rs]}],this,0,(function(){var e=new Rs;onmessage=ka(e)}),7)};function Cs(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[as],(function(e){return ps(Ls(e.data[0],ds(e.data[1])))}),1,r)}function Ls(e,t){return Fa(e,t)}var Ds=function(){function e(e,t){this.c=$a(),this.l=0,this.v=1,_s.call(this,e,t)}return e.prototype.push=function(e,t){_s.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=ts(e,this.o,this.v&&ws(this.o),t&&8,!t),this.v&&(ys(e,this.o),this.v=0),t&&(gs(e,e.length-8,this.c.d()),gs(e,e.length-4,this.l)),this.ondata(e,t)},e}(),As=function(e,t){Ra([ss,ls,function(){return[ka,_s,Ds]}],this,Ms.call(this,e,t),(function(e){e=new Ds(e.data),onmessage=ka(e)}),8)};function Is(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[ss,ls,function(){return[js]}],(function(e){return ps(js(e.data[0],e.data[1]))}),2,r)}function js(e,t){t=t||{};var r=$a(),n=e.length,i=(r.p(e),e=ts(e,t,ws(t),8)).length;return ys(e,t),gs(e,i-8,r.d()),gs(e,i-4,n),e}var Us=function(){function e(e){this.v=1,Rs.call(this,e)}return e.prototype.push=function(e,t){if(Rs.prototype.e.call(this,e),this.v){if((e=3<this.p.length?bs(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)}Rs.prototype.c.call(this,t)},e}(),Bs=function(e){this.ondata=e,Ra([as,us,function(){return[ka,Rs,Us]}],this,0,(function(){var e=new Us;onmessage=ka(e)}),9)};function Ns(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[as,us,function(){return[Fs]}],(function(e){return ps(Fs(e.data[0]))}),3,r)}function Fs(e,t){return Fa(e.subarray(bs(e),-8),t||new pa(xs(e)))}var zs=function(){function e(e,t){this.c=es(),this.v=1,_s.call(this,e,t)}return e.prototype.push=function(e,t){_s.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=ts(e,this.o,this.v&&2,t&&4,!t),this.v&&(Ss(e,this.o),this.v=0),t&&gs(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),Vs=function(e,t){Ra([ss,cs,function(){return[ka,_s,zs]}],this,Ms.call(this,e,t),(function(e){e=new zs(e.data),onmessage=ka(e)}),10)};function Hs(e,t){t=t||{};var r=es();return r.p(e),e=ts(e,t,2,4),Ss(e,t),gs(e,e.length-4,r.d()),e}var Gs=function(){function e(e){this.v=1,Rs.call(this,e)}return e.prototype.push=function(e,t){if(Rs.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)}Rs.prototype.c.call(this,t)},e}(),Ws=function(e){this.ondata=e,Ra([as,hs,function(){return[ka,Rs,Gs]}],this,0,(function(){var e=new Gs;onmessage=ka(e)}),11)};function Xs(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return fs(e,t,[as,hs,function(){return[qs]}],(function(e){return ps(qs(e.data[0],ds(e.data[1])))}),5,r)}function qs(e,t){return Fa((Ts(e),e.subarray(2,-4)),t)}var Ys=function(){function e(e){this.G=Us,this.I=Rs,this.Z=Gs,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 pa(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}(),Zs=function(){function e(e){this.G=Bs,this.I=Os,this.Z=Ws,this.ondata=e}return e.prototype.push=function(e,t){Ys.prototype.push.call(this,e,t)},e}(),Qs=function e(t,r,n,i){for(var o in t){var a=t[o];o=r+o,a instanceof pa?n[o]=[a,i]:Array.isArray(a)?n[o]=[a[0],rs(i,a[1])]:e(a,o+"/",n,i)}},Ks="undefined"!=typeof TextEncoder&&new TextEncoder,Js="undefined"!=typeof TextDecoder&&new TextDecoder,$s=0;try{Js.decode(Qa,{stream:!0}),$s=1}catch(Ta){}var el=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,Na(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)}},tl=function(){function e(e){this.ondata=e,$s?this.t=new TextDecoder:this.p=Qa}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 pa(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=el(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}(),rl=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(nl(e),this.d=t||!1)},e}();function nl(e,t){if(t){for(var r=new pa(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(Ks)return Ks.encode(e);var i=e.length,o=new pa(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 pa(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 Na(o,0,a)}function il(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(Js)return Js.decode(e);var i=(t=el(e))[0];if(t[1].length)throw"invalid utf-8 data";return i}function ol(e){return 1==e?3:e<6?2:9==e?1:0}var al=function(e,t){return t+30+ms(e,t+26)+ms(e,t+28)},sl=function(e,t,r){var n=ms(e,t+28),i=il(e.subarray(t+46,t+46+n),!(2048&ms(e,t+8))),o=(n=t+46+n,vs(e,t+20)),a=(o=(r=r&&4294967295==o?ll(e,n):[o,vs(e,t+24),vs(e,t+42)])[0],r[1]);return r=r[2],[ms(e,t+10),o,a,i,n+ms(e,t+30)+ms(e,t+32),r]},ll=function(e,t){for(;1!=ms(e,t);t+=4+ms(e,t+2));return[Oa(e,t+12),Oa(e,t+4),Oa(e,t+20)]},ul=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},cl=function(e,t,r,n,i,o,a,s){var l=n.length,u=r.extra,c=s&&s.length,h=ul(u),p=(gs(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(gs(e,t,p<<25|i.getMonth()+1<<21|i.getDate()<<16|i.getHours()<<11|i.getMinutes()<<5|i.getSeconds()>>>1),t+=4,null!=o&&(gs(e,t,r.crc),gs(e,t+4,o),gs(e,t+8,r.size)),gs(e,t+12,l),gs(e,t+14,h),t+=16,null!=a&&(gs(e,t,c),gs(e,t+6,r.attrs),gs(e,t+10,a),t+=14),e.set(n,t),t+=l,h)for(var d in u){var f=u[d],m=f.length;gs(e,t,+d),gs(e,t+2,m),e.set(f,t+4),t+=4+m}return c&&(e.set(s,t),t+=c),t},hl=function(e,t,r,n,i){gs(e,t,101010256),gs(e,t+8,r),gs(e,t+10,r),gs(e,t+12,n),gs(e,t+16,i)},pl=function(){function e(e){this.filename=e,this.c=$a(),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}(),dl=function(){function e(e,t){var r=this;t=t||{},pl.call(this,e),this.d=new _s(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=ol(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){pl.prototype.push.call(this,e,t)},e}(),fl=function(){function e(e,t){var r=this;t=t||{},pl.call(this,e),this.d=new Es(t,(function(e,t,n){r.ondata(e,t,n)})),this.compression=8,this.flag=ol(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){pl.prototype.push.call(this,e,t)},e}(),ml=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=nl(e.filename),n=r.length,i=(o=e.comment)&&nl(o),o=n!=e.filename.length||i&&o.length!=i.length,a=n+ul(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 pa(a);var l=(cl(n,0,e,r,o),[n]),u=this.d,c=(this.d=0,this.u.length),h=rs(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 pa(16),gs(r,0,134695760),gs(r,4,e.crc),gs(r,8,p),gs(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+ul(l.extra)+(l.o?l.o.length:0);for(var o=new pa(r+22),a=0,s=this.u;a<s.length;a++){var l=s[a];cl(o,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+ul(l.extra)+(l.o?l.o.length:0),t+=l.b}hl(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}(),vl=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),gl=function(){function e(){var e=this;this.i=new Rs((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}(),yl=function(){function e(e,t){var r=this;t<32e4?this.i=new Rs((function(e,t){r.ondata(null,e,t)})):(this.i=new Os((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=Na(e,0)),this.i.push(e,t)},e.compression=8,e}(),bl=function(){function e(e){this.onfile=e,this.k=[],this.o={0:vl},this.p=Qa}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 pa(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,d,f,m,v,g,y,b=vs(l,a);return 67324752==b?(o=1,s=a,h.d=null,h.c=0,n=ms(l,a+6),e=ms(l,a+8),t=2048&n,n&=8,i=ms(l,a+26),p=ms(l,a+28),a+30+i+p<u&&(h.k.unshift(d=[]),o=2,f=vs(l,a+18),m=vs(l,a+22),v=il(l.subarray(a+30,a+=30+i),!t),4294967295==f?(i=n?[-2]:ll(l,a),f=i[0],m=i[1]):n&&(f=-1),a+=p,h.c=f,y={name:v,compression:e,start:function(){if(!y.ondata)throw"no callback";if(f){var t=r.o[e];if(!t)throw"unknown compression type "+e;(g=f<0?new t(v):new t(v,f,m)).ondata=function(e,t,r){y.ondata(e,t,r)};for(var n=0,i=d;n<i.length;n++)g.push(i[n],!1);r.k[0]==d&&r.c?r.d=g:g.push(Qa,!0)}else y.ondata(null,Qa,!0)},terminate:function(){g&&g.terminate&&g.terminate()}},0<=f&&(y.size=f,y.originalSize=m),h.onfile(y)),"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=Qa,c<0&&(n=o?l.subarray(0,s-12-(-2==c&&8)-(134695760==vs(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 xl(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 wl(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 Sl(e,t,r,n,i){for(var a=i<e?i:e,s=[],l=xl(e,n,t),u=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),d=1;d<=r;++d){h[d]=t-i[e+1-d],p[d]=i[e+d]-t;for(var f=0,m=0;m<d;++m){var v=p[m+1],g=h[d-m],y=(u[d][m]=v+g,u[m][d-1]/u[d][m]);u[m][d]=f+v*y,f=g*y}u[d][d]=f}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=[],M=0;M<=r;++M)T[M]=o.slice(0);for(var _=T[0][0]=1;_<=n;++_){var E=0,P=x-_,k=r-_;_<=x&&(T[S][0]=T[w][0]/u[1+k][P],E=T[S][0]*u[P][k]);for(var R=x-1<=k?_-1:r-x,O=-1<=P?1:-P;O<=R;++O)T[S][O]=(T[w][O]-T[w][O-1])/u[1+k][P+O],E+=T[S][O]*u[P+O][k];x<=k&&(T[S][_]=-T[w][_-1]/u[1+k][x],E+=T[S][_]*u[x][k]),s[_][x]=E;var C=w;w=S,S=C}}for(var L=r,D=1;D<=n;++D){for(var A=0;A<=r;++A)s[D][A]*=L;L*=r-D}return s}(l,n,e,a,t),c=[],h=0;h<r.length;++h){var p=r[h].clone(),d=p.w;p.x*=d,p.y*=d,p.z*=d,c[h]=p}for(var f=0;f<=a;++f){for(var m=c[l-e].clone().multiplyScalar(u[f][0]),v=1;v<=e;++v)m.add(c[l-e+v].clone().multiplyScalar(u[f][v]));s[f]=m}for(var g=a+1;g<=i+1;++g)s[g]=new o.Vector4(0,0,0);return s}function Tl(e){for(var t=e.length,r=[],n=[],i=0;i<t;++i){var a=e[i];r[i]=new o.Vector3(a.x,a.y,a.z),n[i]=a.w}for(var s=[],l=0;l<t;++l){for(var u=r[l].clone(),c=1;c<=l;++c)u.sub(s[l-c].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}(l,c)*n[c]));s[l]=u.divideScalar(n[0])}return s}function Ml(e){return(Ml="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 _l(e,t){return(_l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function El(e){return(El=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Pl,kl,Rl,Ol=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=El(e);if(r=t?(r=El(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ml(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,a,s){var l;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(l=r.call(this)).degree=e,l.knots=t,l.controlPoints=[],l.startKnot=a||0,l.endKnot=s||l.knots.length-1;for(var u=0;u<i.length;++u){var c=i[u];l.controlPoints[u]=new o.Vector4(c.x,c.y,c.z,c.w)}return l}return t=n,(e=[{key:"getPoint",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new o.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=xl(e,n,t),a=wl(i,n,e,t),s=new o.Vector4(0,0,0,0),l=0;l<=e;++l){var u=r[i-e+l],c=a[l],h=u.w*c;s.x+=u.x*h,s.y+=u.y*h,s.z+=u.z*h,s.w+=u.w*c}return s}(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 o.Vector3,r=(e=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),Tl(Sl(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}(o.Curve);function Cl(e){return(Cl="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 Ll(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Dl(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 Al(e,t,r){t&&Dl(e.prototype,t),r&&Dl(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function Il(e,t){return(Il=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function jl(e){return(jl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ul=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&&Il(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=jl(e);if(r=t?(r=jl(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Cl(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 Ll(this,n),r.call(this,e)}return Al(n,[{key:"load",value:function(e,t,r,n){var i=this,a=""===i.path?o.LoaderUtils.extractUrlBase(e):i.path,s=new o.FileLoader(this.manager);s.setPath(i.path),s.setResponseType("arraybuffer"),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(r){try{t(i.parse(r,a))}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===eu(r,0,n.length))Pl=(new Vl).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=eu(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(Wl(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Wl(r));Pl=(new zl).parse(r)}var r,n=new o.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Bl(n,this.manager).parse(Pl)}}]),n}(o.Loader),Bl=function(){function e(t,r){Ll(this,e),this.textureLoader=t,this.manager=r}return Al(e,[{key:"parse",value:function(){kl=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new Nl).parse(t);return this.parseScene(t,r,e),Rl}},{key:"parseConnections",value:function(){var e=new Map;return"Connections"in Pl&&Pl.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 Pl.Objects){var n,i=Pl.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 Pl.Objects){var r,n=Pl.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?o.RepeatWrapping:o.ClampToEdgeWrapping,t.wrapT=0===n?o.RepeatWrapping:o.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=kl.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 o.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 o.Texture):this.textureLoader.load(r),this.textureLoader.setPath(n),i}},{key:"parseMaterials",value:function(e){var t=new Map;if("Material"in Pl.Objects){var r,n=Pl.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,a=e.ShadingModel;if("object"===Cl(a)&&(a=a.value),!kl.has(n))return null;switch(e=this.parseParameters(e,t,n),a.toLowerCase()){case"phong":r=new o.MeshPhongMaterial;break;case"lambert":r=new o.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),r=new o.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 o.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new o.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new o.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new o.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 o.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new o.Color).fromArray(e.SpecularColor.value)),this);return kl.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=o.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=o.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=o.EquirectangularReflectionMapping,n.envMap.encoding=o.sRGBEncoding);break;case"SpecularColor":n.specularMap=i.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.encoding=o.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 Pl.Objects&&t in Pl.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=kl.get(t).children[0].ID),e.get(t)}},{key:"parseDeformers",value:function(){var e={},t={};if("Deformer"in Pl.Objects){var r,n=Pl.Objects.Deformer;for(r in n){var i,o=n[r],a=kl.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 o.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=kl.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){Rl=new o.Group;var n=this.parseModels(e.skeletons,t,r),i=Pl.Objects.Model,a=this;n.forEach((function(e){var t=i[e.ID];a.setLookAtProperties(e,t),kl.get(e.ID).parents.forEach((function(t){void 0!==(t=n.get(t.ID))&&t.add(e)})),null===e.parent&&Rl.add(e)})),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),Rl.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=Kl(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new Fl).parse(),1===Rl.children.length&&Rl.children[0].isGroup&&(Rl.children[0].animations=r,Rl=Rl.children[0]),Rl.animations=r}},{key:"parseModels",value:function(e,t,r){var n,i=new Map,a=Pl.Objects.Model;for(n in a){var s=parseInt(n),l=a[n],u=kl.get(s),c=this.buildSkeleton(u,e,s,l.attrName);if(!c){switch(l.attrType){case"Camera":c=this.createCamera(u);break;case"Light":c=this.createLight(u);break;case"Mesh":c=this.createMesh(u,t,r);break;case"NurbsCurve":c=this.createCurve(u,t);break;case"LimbNode":case"Root":c=new o.Bone;break;default:c=new o.Group}c.name=l.attrName?o.PropertyBinding.sanitizeNodeName(l.attrName):"",c.ID=s}this.getTransformData(c,l),i.set(s,c)}return i}},{key:"buildSkeleton",value:function(e,t,r,n){var i=null;return e.parents.forEach((function(e){for(var a in t)!function(a){var s=t[a];s.rawBones.forEach((function(t,a){var l;t.ID===e.ID&&(l=i,(i=new o.Bone).matrixWorld.copy(t.transformLink),i.name=n?o.PropertyBinding.sanitizeNodeName(n):"",i.ID=r,s.bones[a]=i,null!==l&&i.add(l))}))}(a)})),i}},{key:"createCamera",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=Pl.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new o.Object3D;else{var n=0,i=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(n=1),1),a=(void 0!==r.NearPlane&&(i=r.NearPlane.value/1e3),1e3),s=(void 0!==r.FarPlane&&(a=r.FarPlane.value/1e3),window.innerWidth),l=window.innerHeight,u=(void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(s=r.AspectWidth.value,l=r.AspectHeight.value),s/l),c=45,h=(void 0!==r.FieldOfView&&(c=r.FieldOfView.value),r.FocalLength?r.FocalLength.value:null);switch(n){case 0:t=new o.PerspectiveCamera(c,u,i,a),null!==h&&t.setFocalLength(h);break;case 1:t=new o.OrthographicCamera(-s/2,s/2,l/2,-l/2,i,a);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new o.Object3D}}return t}},{key:"createLight",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=Pl.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new o.Object3D;else{e=void 0===r.LightType?0:r.LightType.value;var n=16777215,i=(void 0!==r.Color&&(n=(new o.Color).fromArray(r.Color.value)),void 0===r.Intensity?1:r.Intensity.value/100),a=(void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(i=0),0);switch(void 0!==r.FarAttenuationEnd&&(a=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value),e){case 0:t=new o.PointLight(n,i,a,1);break;case 1:t=new o.DirectionalLight(n,i);break;case 2:var s=Math.PI/3,l=(void 0!==r.InnerAngle&&(s=o.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(l=o.MathUtils.degToRad(r.OuterAngle.value),l=Math.max(l,1)),t=new o.SpotLight(n,i,a,s,l,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new o.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,a=null,s=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),r.has(e.ID)&&s.push(r.get(e.ID))})),1<s.length?a=s:0<s.length?a=s[0]:(a=new o.MeshPhongMaterial({color:13421772}),s.push(a)),"color"in i.attributes&&s.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(n=new o.SkinnedMesh(i,a)).normalizeSkinWeights():n=new o.Mesh(i,a),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 o.LineBasicMaterial({color:3342591,linewidth:1});return new o.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?Jl(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&&kl.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=Pl.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),Rl.add(e.target)):e.lookAt((new o.Vector3).fromArray(t)))}))}},{key:"bindSkeleton",value:function(e,t,r){var n,i=this.parsePoseNodes();for(n in e)!function(n){var a=e[n];kl.get(parseInt(a.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,kl.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new o.Skeleton(a.bones),i[e.ID])})))}))}(n)}},{key:"parsePoseNodes",value:function(){var e={};if("Pose"in Pl.Objects){var t,r,n=Pl.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 o.Matrix4).fromArray(t.Matrix.a)})):e[r.Node]=(new o.Matrix4).fromArray(r.Matrix.a))}return e}},{key:"createAmbientLight",value:function(){var e,t,r;"GlobalSettings"in Pl&&"AmbientColor"in Pl.GlobalSettings&&(r=(t=Pl.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new o.Color(r,e,t),Rl.add(new o.AmbientLight(r,1))))}}]),e}(),Nl=function(){function e(){Ll(this,e)}return Al(e,[{key:"parse",value:function(e){var t=new Map;if("Geometry"in Pl.Objects){var r,n=Pl.Objects.Geometry;for(r in n){var i=kl.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 Pl.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=Jl(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=Kl(a),this.genGeometry(t,n,o,e)}},{key:"genGeometry",value:function(e,t,r,n){var i,a,s=new o.BufferGeometry,l=(e.attrName&&(s.name=e.attrName),this.parseGeoNode(e,t)),u=this.genBuffers(l),c=new o.Float32BufferAttribute(u.vertex,3);return c.applyMatrix4(n),s.setAttribute("position",c),0<u.colors.length&&s.setAttribute("color",new o.Float32BufferAttribute(u.colors,3)),t&&(s.setAttribute("skinIndex",new o.Uint16BufferAttribute(u.weightsIndices,4)),s.setAttribute("skinWeight",new o.Float32BufferAttribute(u.vertexWeights,4)),s.FBX_Deformer=t),0<u.normal.length&&(c=(new o.Matrix3).getNormalMatrix(n),(t=new o.Float32BufferAttribute(u.normal,3)).applyNormalMatrix(c),s.setAttribute("normal",t)),u.uvs.forEach((function(e,t){var r="uv"+(t+1).toString();s.setAttribute(r=0===t?"uv":r,new o.Float32BufferAttribute(u.uvs[t],2))})),l.material&&"AllSame"!==l.material.mappingType&&(i=u.materialIndex[0],a=0,u.materialIndex.forEach((function(e,t){e!==i&&(s.addGroup(a,t-a,i),i=e,a=t)})),0<s.groups.length&&(t=(c=s.groups[s.groups.length-1]).start+c.count)!==u.materialIndex.length&&s.addGroup(t,u.materialIndex.length-t,i),0===s.groups.length&&s.addGroup(0,u.materialIndex.length,u.materialIndex[0])),this.addMorphTargets(s,e,r,n),s}},{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,d){var f,m,v,g,y=!1,b=(p<0&&(p^=-1,y=!0),[]),x=[];if(o.push(3*p,3*p+1,3*p+2),e.color&&(g=Yl(d,r,p,e.color),s.push(g[0],g[1],g[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&&(g=Yl(d,r,p,e.normal),a.push(g[0],g[1],g[2])),e.material&&"AllSame"!==e.material.mappingType&&(f=Yl(d,r,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=Yl(d,r,p,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),n++,y&&(h.genFace(t,e,o,f,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=Pl.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 a=void 0!==r.Vertices?r.Vertices.a:[],s=void 0!==r.Indexes?r.Indexes.a:[],l=3*e.attributes.position.count,u=new Float32Array(l),c=0;c<s.length;c++){var h=3*s[c];u[h]=a[3*c],u[1+h]=a[3*c+1],u[2+h]=a[3*c+2]}l=this.genBuffers({vertexIndices:t,vertexPositions:u}),(t=new o.Float32BufferAttribute(l.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===Ol)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 o.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 o.BufferGeometry;for(var r=t-1,n=(t=e.KnotVector.a,[]),i=e.Points.a,a=0,s=i.length;a<s;a+=4)n.push((new o.Vector4).fromArray(i,a));if("Closed"===e.Form)n.push(n[0]);else if("Periodic"===e.Form)for(var l=r,u=t.length-1-l,c=0;c<r;++c)n.push(n[c]);return e=new Ol(r,t,n,l,u).getPoints(12*n.length),(new o.BufferGeometry).setFromPoints(e)}}]),e}(),Fl=function(){function e(){Ll(this,e)}return Al(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!==Pl.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}},{key:"parseAnimationCurveNodes",value:function(){var e,t=Pl.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=Pl.Objects.AnimationCurve;for(t in r){var n,i={id:r[t].id,times:r[t].KeyTime.a.map(Xl),values:r[t].KeyValueFloat.a},o=kl.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=Pl.Objects.AnimationLayer,n=new Map;for(t in r)!function(t){var r=[],i=kl.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 a=kl.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==a){var s=Pl.Objects.Model[a.toString()];if(void 0===s)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",t);var l={modelName:s.attrName?o.PropertyBinding.sanitizeNodeName(s.attrName):"",ID:s.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Rl.traverse((function(e){e.ID===s.id&&(l.transform=e.matrix,e.userData.transformData&&(l.eulerOrder=e.userData.transformData.eulerOrder))})),l.transform||(l.transform=new o.Matrix4),"PreRotation"in s&&(l.preRotation=s.PreRotation.value),"PostRotation"in s&&(l.postRotation=s.PostRotation.value),r[n]=l}}r[n]&&(r[n][i.attr]=i)}else void 0!==i.curves.morph&&(void 0===r[n]&&(a=kl.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,t=kl.get(a).parents[0].ID,t=kl.get(t).parents[0].ID,t=kl.get(t).parents[0].ID,t={modelName:(t=Pl.Objects.Model[t]).attrName?o.PropertyBinding.sanitizeNodeName(t.attrName):"",morphName:Pl.Objects.Deformer[a].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=Pl.Objects.AnimationStack,n={};for(t in r){var i=(1<(i=kl.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 o.AnimationClip(e.name,-1,t)}},{key:"generateTracks",value:function(e){var t=[],r=new o.Vector3,n=new o.Quaternion,i=new o.Vector3;return e.transform&&e.transform.decompose(r,n,i),r=r.toArray(),n=(new o.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 o.VectorKeyframeTrack(e+"."+n,i,t)}},{key:"generateRotationTrack",value:function(e,t,r,n,i,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(o.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(o.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(o.MathUtils.degToRad));for(var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,r),u=(void 0!==n&&((n=n.map(o.MathUtils.degToRad)).push(a),n=(new o.Euler).fromArray(n),n=(new o.Quaternion).setFromEuler(n)),void 0!==i&&((i=i.map(o.MathUtils.degToRad)).push(a),i=(new o.Euler).fromArray(i),i=(new o.Quaternion).setFromEuler(i).invert()),new o.Quaternion),c=new o.Euler,h=[],p=0;p<l.length;p+=3)c.set(l[p],l[p+1],l[p+2],a),u.setFromEuler(c),void 0!==n&&u.premultiply(n),void 0!==i&&u.multiply(i),u.toArray(h,p/3*4);return new o.QuaternionKeyframeTrack(e+".quaternion",s,h)}},{key:"generateMorphTrack",value:function(e){var t=e.DeformPercent.curves.morph,r=t.values.map((function(e){return e/100})),n=Rl.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new o.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=tu(e.times,t,u),e.values=tu(e.values,t,c)}}}}]),e}(),zl=function(){function e(){Ll(this,e)}return Al(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 Gl,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=$l(t))}}},{key:"parseNodePropertyContinued",value:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=$l(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=$l(s)}this.getPrevNode()[n]={type:i,type2:o,flag:a,value:s},this.setCurrentProp(this.getPrevNode(),n)}}]),e}(),Vl=function(){function e(){Ll(this,e)}return Al(e,[{key:"parse",value:function(e){var t=new Hl(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 Gl;!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 r=e.getString(1);switch(r){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 i=e.getUint32(),e.getArrayBuffer(i);case"S":return i=e.getUint32(),e.getString(i);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var n=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(0===i)switch(r){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}void 0===t&&console.error("THREE.FBXLoader: External library fflate.min.js required."),i=qs(new Uint8Array(e.getArrayBuffer(o)));var a=new Hl(i.buffer);switch(r){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+r)}}}]),e}(),Hl=function(){function e(t,r){Ll(this,e),this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===r||r}return Al(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)),o.LoaderUtils.decodeText(new Uint8Array(t))}}]),e}(),Gl=function(){function e(){Ll(this,e)}return Al(e,[{key:"add",value:function(e,t){this[e]=t}}]),e}();function Wl(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 Xl(e){return e/46186158e3}var ql=[];function Yl(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=ql,l=n.buffer,u=a,c=o,h=0;c<u;c++,h++)s[h]=l[c];return s}var Zl=new o.Euler,Ql=new o.Vector3;function Kl(e){var t=new o.Matrix4,r=new o.Matrix4,n=new o.Matrix4,i=new o.Matrix4,a=new o.Matrix4,s=new o.Matrix4,l=new o.Matrix4,u=new o.Matrix4,c=new o.Matrix4,h=new o.Matrix4,p=new o.Matrix4,d=new o.Matrix4,f=e.inheritType||0,m=(e.translation&&t.setPosition(Ql.fromArray(e.translation)),e.preRotation&&((m=e.preRotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),r.makeRotationFromEuler(Zl.fromArray(m))),e.rotation&&((m=e.rotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),n.makeRotationFromEuler(Zl.fromArray(m))),e.postRotation&&((m=e.postRotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),i.makeRotationFromEuler(Zl.fromArray(m)),i.invert()),e.scale&&a.scale(Ql.fromArray(e.scale)),e.scalingOffset&&l.setPosition(Ql.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(Ql.fromArray(e.scalingPivot)),e.rotationOffset&&u.setPosition(Ql.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(Ql.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),h.copy(e.parentMatrixWorld)),r.clone().multiply(n).multiply(i)),v=(((e=new o.Matrix4).extractRotation(h),v=new o.Matrix4).copyPosition(h),v.clone().invert().multiply(h)),g=(v=e.clone().invert().multiply(v),a),y=new o.Matrix4;return 0===f?y.copy(e).multiply(m).multiply(v).multiply(g):1===f?y.copy(e).multiply(v).multiply(m).multiply(g):(f=(new o.Matrix4).scale((new o.Vector3).setFromMatrixScale(p)).clone().invert(),p=v.clone().multiply(f),y.copy(e).multiply(m).multiply(p).multiply(g)),v=c.clone().invert(),f=s.clone().invert(),e=t.clone().multiply(u).multiply(c).multiply(r).multiply(n).multiply(i).multiply(v).multiply(l).multiply(s).multiply(a).multiply(f),m=(new o.Matrix4).copyPosition(e),p=h.clone().multiply(m),d.copyPosition(p),(e=d.clone().multiply(y)).premultiply(h.invert()),e}function Jl(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 $l(e){return e.split(",").map((function(e){return parseFloat(e)}))}function eu(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),o.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function tu(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}function ru(e){return(ru="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 nu(e,t){return(nu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function iu(e){return(iu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ou=/^[og]\s*(.+)?/,au=/^mtllib /,su=/^usemtl /,lu=/^usemap /,uu=new o.Vector3,cu=new o.Vector3,hu=new o.Vector3,pu=new o.Vector3,du=new o.Vector3,fu=new o.Color;function mu(){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;uu.fromArray(n,e),cu.fromArray(n,t),hu.fromArray(n,r),du.subVectors(hu,cu),pu.subVectors(uu,cu),du.cross(pu),du.normalize(),i.push(du.x,du.y,du.z),i.push(du.x,du.y,du.z),i.push(du.x,du.y,du.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 vu=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&&nu(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=iu(e);if(r=t?(r=iu(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ru(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,a=new o.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.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 mu,a=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n"),s="",l=[],u="function"==typeof"".trimLeft,c=0,h=a.length;c<h;c++)if(s=a[c],0!==(s=u?s.trimLeft():s.trim()).length&&"#"!==(t=s.charAt(0)))if("v"===t){var p=s.split(/\s+/);switch(p[0]){case"v":i.vertices.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),7<=p.length?(fu.setRGB(parseFloat(p[4]),parseFloat(p[5]),parseFloat(p[6])).convertSRGBToLinear(),i.colors.push(fu.r,fu.g,fu.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 d=s.slice(1).trim().split(/\s+/),f=[],m=0,v=d.length;m<v;m++){var g=d[m];0<g.length&&(g=g.split("/"),f.push(g))}for(var y=f[0],b=1,x=f.length-1;b<x;b++){var w=f[b],S=f[b+1];i.addFace(y[0],w[0],S[0],y[1],w[1],S[1],y[2],w[2],S[2])}}else if("l"===t){var T=s.substring(1).trim().split(" "),M=[],_=[];if(-1===s.indexOf("/"))M=T;else for(var E=0,P=T.length;E<P;E++){var k=T[E].split("/");""!==k[0]&&M.push(k[0]),""!==k[1]&&_.push(k[1])}i.addLineGeometry(M,_)}else"p"===t?(r=s.slice(1).trim().split(" "),i.addPointGeometry(r)):null!==(l=ou.exec(s))?(r=(" "+l[0].slice(1).trim()).slice(1),i.startObject(r)):su.test(s)?i.object.startMaterial(s.substring(7).trim(),i.materialLibraries):au.test(s)?i.materialLibraries.push(s.substring(7).trim()):lu.test(s)?console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.'):"s"===t?(1<(l=s.split(" ")).length?(n=l[1].trim().toLowerCase(),i.object.smooth="0"!==n&&"off"!==n):i.object.smooth=!0,(n=i.object.currentMaterial())&&(n.smooth=i.object.smooth)):"\0"!==s&&console.warn('THREE.OBJLoader: Unexpected line: "'+s+'"');i.finalize();var R,O=new o.Group;if(1==(O.materialLibraries=[].concat(i.materialLibraries),e=!(1===i.objects.length&&0===i.objects[0].geometry.vertices.length)))for(var C=0,L=i.objects.length;C<L;C++){var D=i.objects[C],A=D.geometry,I=D.materials,j="Line"===A.type,U="Points"===A.type,B=!1;if(0!==A.vertices.length){for(var N=new o.BufferGeometry,F=(N.setAttribute("position",new o.Float32BufferAttribute(A.vertices,3)),0<A.normals.length&&N.setAttribute("normal",new o.Float32BufferAttribute(A.normals,3)),0<A.colors.length&&(B=!0,N.setAttribute("color",new o.Float32BufferAttribute(A.colors,3))),!0===A.hasUVIndices&&N.setAttribute("uv",new o.Float32BufferAttribute(A.uvs,2)),[]),z=0,V=I.length;z<V;z++){var H,G=I[z],W=G.name+"_"+G.smooth+"_"+B,X=i.materials[W];null!==this.materials&&(X=this.materials.create(G.name),!j||!X||X instanceof o.LineBasicMaterial?!U||!X||X instanceof o.PointsMaterial||(H=new o.PointsMaterial({size:10,sizeAttenuation:!1}),o.Material.prototype.copy.call(H,X),H.color.copy(X.color),H.map=X.map,X=H):(H=new o.LineBasicMaterial,o.Material.prototype.copy.call(H,X),H.color.copy(X.color),X=H)),void 0===X&&((X=j?new o.LineBasicMaterial:U?new o.PointsMaterial({size:1,sizeAttenuation:!1}):new o.MeshPhongMaterial).name=G.name,X.flatShading=!G.smooth,X.vertexColors=B,i.materials[W]=X),F.push(X)}if(A=void 0,1<F.length){for(var q=0,Y=I.length;q<Y;q++){var Z=I[q];N.addGroup(Z.groupStart,Z.groupCount,q)}A=new(j?o.LineSegments:U?o.Points:o.Mesh)(N,F)}else A=new(j?o.LineSegments:U?o.Points:o.Mesh)(N,F[0]);A.name=D.name,O.add(A)}}else 0<i.vertices.length&&(e=new o.PointsMaterial({size:1,sizeAttenuation:!1}),(R=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute(i.vertices,3)),0<i.colors.length&&void 0!==i.colors[0]&&(R.setAttribute("color",new o.Float32BufferAttribute(i.colors,3)),e.vertexColors=!0),R=new o.Points(R,e),O.add(R));return 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)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(o.Loader),gu=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 yu{constructor(e){this.parses={fbx:new Ul,obj:new vu},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)}return t}img(e){console.log(e,"file")}glb(e){return gu(this,void 0,void 0,(function*(){var t=yield(0,Ve.toResult)(e,"arrayBuffer");return this.runScene.loaderer.gltf.parse(t)}))}fbx(e){return gu(this,void 0,void 0,(function*(){var t=yield(0,Ve.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 gu(this,void 0,void 0,(function*(){var t=yield(0,Ve.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))}))}}function bu(e){return(bu="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 xu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wu(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 Su(e,t,r){t&&wu(e.prototype,t),r&&wu(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function Tu(){return(Tu="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=ku(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 Mu(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&&_u(e,t)}function _u(e,t){return(_u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Eu(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=ku(e);if(r=t?(r=ku(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===bu(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return Pu(n)}}function Pu(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ku(e){return(ku=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ru=new o.Raycaster,Ou=new o.Vector3,Cu=new o.Vector3,Lu=new o.Quaternion,Du={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},Au={type:"change"},Iu={type:"mouseDown"},ju={type:"mouseUp",mode:null},Uu={type:"objectChange"};function Bu(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}Go=function(){Mu(t,o.Object3D);var e=Eu(t);function t(r,n){xu(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,a=new $u,s=(i._gizmo=a,i.add(a),new ec),l=(i._plane=s,i.add(s),Pu(i));function u(e,t){var r=t;Object.defineProperty(l,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,s[e]=t,a[e]=t,l.dispatchEvent({type:e+"-changed",value:t}),l.dispatchEvent(Au))}}),l[e]=t,s[e]=t,a[e]=t}u("camera",r),u("object",void 0),u("enabled",!0),u("axis",null),u("mode","translate"),u("translationSnap",null),u("rotationSnap",null),u("scaleSnap",null),u("space","world"),u("size",1),u("dragging",!1),u("showX",!0),u("showY",!0),u("showZ",!0),n=new o.Vector3,r=new o.Vector3;var c=new o.Quaternion,h=new o.Quaternion,p=new o.Vector3,d=new o.Quaternion,f=new o.Vector3,m=new o.Vector3,v=new o.Vector3,g=new o.Vector3;return u("worldPosition",n),u("worldPositionStart",r),u("worldQuaternion",c),u("worldQuaternionStart",h),u("cameraPosition",p),u("cameraQuaternion",d),u("pointStart",f),u("pointEnd",m),u("rotationAxis",v),u("rotationAngle",0),u("eye",g),i._offset=new o.Vector3,i._startNorm=new o.Vector3,i._endNorm=new o.Vector3,i._cameraScale=new o.Vector3,i._parentPosition=new o.Vector3,i._parentQuaternion=new o.Quaternion,i._parentQuaternionInv=new o.Quaternion,i._parentScale=new o.Vector3,i._worldScaleStart=new o.Vector3,i._worldQuaternionInv=new o.Quaternion,i._worldScale=new o.Vector3,i._positionStart=new o.Vector3,i._quaternionStart=new o.Quaternion,i._scaleStart=new o.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(Pu(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(Pu(i)),i._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(Pu(i)),i._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(Pu(i)),i._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(Pu(i)),i.domElement.addEventListener("pointerdown",i._onPointerDown),i.domElement.addEventListener("pointermove",i._onPointerHover),i.domElement.addEventListener("pointerup",i._onPointerUp),i}return Su(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(),Tu(ku(t.prototype),"updateMatrixWorld",this).call(this,this)}},{key:"pointerHover",value:function(e){void 0!==this.object&&!0!==this.dragging&&(Ru.setFromCamera(e,this.camera),e=Bu(this._gizmo.picker[this.mode],Ru),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&&(Ru.setFromCamera(e,this.camera),(e=Bu(this._plane,Ru,!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,Iu.mode=this.mode,this.dispatchEvent(Iu))}},{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&&(Ru.setFromCamera(e,this.camera),(e=Bu(this._plane,Ru,!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(Lu.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(Ou.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(Ou.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),Cu.set(e,e,e)):(Ou.copy(this.pointStart),Cu.copy(this.pointEnd),Ou.applyQuaternion(this._worldQuaternionInv),Cu.applyQuaternion(this._worldQuaternionInv),Cu.divide(Ou),-1===t.search("X")&&(Cu.x=1),-1===t.search("Y")&&(Cu.y=1),-1===t.search("Z")&&(Cu.z=1)),n.scale.copy(this._scaleStart).multiply(Cu),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(Ou.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(Ou.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Du[t]),Ou.copy(Du[t]),"local"===i&&Ou.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(Ou.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(Lu.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Lu.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())),this.dispatchEvent(Au),this.dispatchEvent(Uu)))}},{key:"pointerUp",value:function(e){0===e.button&&(this.dragging&&null!==this.axis&&(ju.mode=this.mode,this.dispatchEvent(ju)),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(Au),this.dispatchEvent(Uu),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return Ru}},{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}(),Go.prototype.isTransformControls=!0;var Nu=new o.Euler,Fu=new o.Vector3(0,1,0),zu=new o.Vector3(0,0,0),Vu=new o.Matrix4,Hu=new o.Quaternion,Gu=new o.Quaternion,Wu=new o.Vector3,Xu=new o.Matrix4,qu=new o.Vector3(1,0,0),Yu=new o.Vector3(0,1,0),Zu=new o.Vector3(0,0,1),Qu=new o.Vector3,Ku=new o.Vector3,Ju=new o.Vector3,$u=function(){Mu(t,o.Object3D);var e=Eu(t);function t(){xu(this,t),(r=e.call(this)).type="TransformControlsGizmo";var r,n=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),a=n.clone(),s=((((a.opacity=.15,i=i.clone()).opacity=.5,x=n.clone()).color.setHex(16711680),w=n.clone()).color.setHex(65280),n.clone()),l=(s.color.setHex(255),n.clone()),u=(l.color.setHex(16711680),l.opacity=.5,n.clone()),c=(u.color.setHex(65280),u.opacity=.5,n.clone()),h=(c.color.setHex(255),c.opacity=.5,n.clone());(h.opacity=.25,y=n.clone()).color.setHex(16776960),y.opacity=.25,n.clone().color.setHex(16776960);var p=(((n=n.clone()).color.setHex(7895160),m=new o.CylinderGeometry(0,.04,.1,12)).translate(0,.05,0),new o.BoxGeometry(.08,.08,.08)),d=(p.translate(0,.04,0),new o.BufferGeometry);function f(e,t){return(e=new o.TorusGeometry(e,.0075,3,64,t*Math.PI*2)).rotateY(Math.PI/2),e.rotateX(Math.PI/2),e}(d.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3)),S=new o.CylinderGeometry(.0075,.0075,.5,3)).translate(0,.25,0);var m={X:[[new o.Mesh(m,x),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(m,x),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(m,w),[0,.5,0]],[new o.Mesh(m,w),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(S,w)]],Z:[[new o.Mesh(m,s),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(m,s),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(S,s),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),h.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),a)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]]},g={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new o.Line(((g=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),g),i),null,null,null,"helper"]],X:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(d,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(d,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},y=(n={XYZE:[[new o.Mesh(f(.5,1),n),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(f(.5,.5),x)]],Y:[[new o.Mesh(f(.5,.5),w),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(f(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(f(.75,1),y),null,[0,Math.PI/2,0]]]},{AXIS:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]}),b={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),a)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),a)]]},x={X:[[new o.Mesh(p,x),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(p,x),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(p,w),[0,.5,0]],[new o.Mesh(S,w)],[new o.Mesh(p,w),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(p,s),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(S,s),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(p,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),h.clone())]]},w={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),a),[0,0,0]]]},S={X:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(d,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(d,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(e){var t,r=new o.Object3D;for(t in e)for(var n=e[t].length;n--;){var i=e[t][n][0].clone(),a=e[t][n][1],s=e[t][n][2],l=e[t][n][3],u=e[t][n][4];(i.name=t,i.tag=u,a&&i.position.set(a[0],a[1],a[2]),s&&i.rotation.set(s[0],s[1],s[2]),l&&i.scale.set(l[0],l[1],l[2]),i.updateMatrix(),u=i.geometry.clone()).applyMatrix4(i.matrix),i.geometry=u,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(g)),r.add(r.helper.rotate=T(y)),r.add(r.helper.scale=T(S)),r.picker.translate.visible=!1,r.picker.rotate.visible=!1,r.picker.scale.visible=!1,r}return Su(t,[{key:"updateMatrixWorld",value:function(e){var r=this,n="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Gu,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&&(Lu.setFromEuler(Nu.set(0,0,0)),t.quaternion.copy(n).multiply(Lu),.9<Math.abs(Fu.copy(qu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Y"===r.axis&&(Lu.setFromEuler(Nu.set(0,0,Math.PI/2)),t.quaternion.copy(n).multiply(Lu),.9<Math.abs(Fu.copy(Yu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Z"===r.axis&&(Lu.setFromEuler(Nu.set(0,Math.PI/2,0)),t.quaternion.copy(n).multiply(Lu),.9<Math.abs(Fu.copy(Zu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"XYZE"===r.axis&&(Lu.setFromEuler(Nu.set(0,Math.PI/2,0)),Fu.copy(r.rotationAxis),t.quaternion.setFromRotationMatrix(Vu.lookAt(zu,Fu,Yu)),t.quaternion.multiply(Lu),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),Ou.set(1e-10,1e-10,1e-10).add(r.worldPositionStart).sub(r.worldPosition).multiplyScalar(-1),Ou.applyQuaternion(r.worldQuaternionStart.clone().invert()),t.scale.copy(Ou),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(Fu.copy(qu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Y"===t.name&&.99<Math.abs(Fu.copy(Yu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Z"===t.name&&.99<Math.abs(Fu.copy(Zu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XY"===t.name&&Math.abs(Fu.copy(Zu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"YZ"===t.name&&Math.abs(Fu.copy(qu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XZ"===t.name&&Math.abs(Fu.copy(Yu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1)):"rotate"===r.mode&&(Hu.copy(n),Fu.copy(r.eye).applyQuaternion(Lu.copy(n).invert()),-1!==t.name.search("E")&&t.quaternion.setFromRotationMatrix(Vu.lookAt(r.eye,zu,Yu)),"X"===t.name&&(Lu.setFromAxisAngle(qu,Math.atan2(-Fu.y,Fu.z)),Lu.multiplyQuaternions(Hu,Lu),t.quaternion.copy(Lu)),"Y"===t.name&&(Lu.setFromAxisAngle(Yu,Math.atan2(Fu.x,Fu.z)),Lu.multiplyQuaternions(Hu,Lu),t.quaternion.copy(Lu)),"Z"===t.name&&(Lu.setFromAxisAngle(Zu,Math.atan2(Fu.y,Fu.x)),Lu.multiplyQuaternions(Hu,Lu),t.quaternion.copy(Lu))),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);Tu(ku(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}(),ec=($u.prototype.isTransformControlsGizmo=!0,function(){Mu(t,o.Mesh);var e=Eu(t);function t(){var r;return xu(this,t),(r=e.call(this,new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1}))).type="TransformControlsPlane",r}return Su(t,[{key:"updateMatrixWorld",value:function(e){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),Qu.copy(qu).applyQuaternion("local"===r?this.worldQuaternion:Gu),Ku.copy(Yu).applyQuaternion("local"===r?this.worldQuaternion:Gu),Ju.copy(Zu).applyQuaternion("local"===r?this.worldQuaternion:Gu),Fu.copy(Ku),this.mode){case"translate":case"scale":switch(this.axis){case"X":Fu.copy(this.eye).cross(Qu),Wu.copy(Qu).cross(Fu);break;case"Y":Fu.copy(this.eye).cross(Ku),Wu.copy(Ku).cross(Fu);break;case"Z":Fu.copy(this.eye).cross(Ju),Wu.copy(Ju).cross(Fu);break;case"XY":Wu.copy(Ju);break;case"YZ":Wu.copy(Qu);break;case"XZ":Fu.copy(Ju),Wu.copy(Ku);break;case"XYZ":case"E":Wu.set(0,0,0)}break;default:Wu.set(0,0,0)}0===Wu.length()?this.quaternion.copy(this.cameraQuaternion):(Xu.lookAt(Ou.set(0,0,0),Wu,Fu),this.quaternion.setFromRotationMatrix(Xu)),Tu(ku(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}());ec.prototype.isTransformControlsPlane=!0;class tc extends Go{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new o.Vector3,this.beginScale=new o.Vector3,this.posStart=new o.Vector2,this.posEnd=new o.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 rc{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 o.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 ci.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new ci.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=xi(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=xi(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=xi(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=xi(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 tc(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(),console.log(this.transContro,"this.transContro "))}init(){"running"!==this.runScene.optionsEx.options.mode&&(this.transContro.init(),this.runScene.assetsEx.get().scene.add(this.grid))}createGrid(){const e=new ci.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof o.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 nc(e){return(nc="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 ic(e,t){return(ic=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function oc(e){return(oc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var 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&&ic(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=oc(e);if(r=t?(r=oc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===nc(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 o.BufferGeometry,a=(i.setAttribute("position",new o.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),new o.LineBasicMaterial({fog:!1}));return((i=r.call(this,i,a)).light=e,i.color=t,i.type="RectAreaLightHelper",a=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),i.add(new o.Mesh(a,new o.MeshBasicMaterial({side:o.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}(o.Line);class sc{constructor(e){this.runScene=e}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 ci.Color("#"+o),t}}class lc{constructor(e){this.runScene=e}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:d}=h;return{type:n,intensity:t,name:r,visible:o,color:a.getHexString(),castShadow:s,shadow:{mapSize:e.x,camera:{near:p,far:d,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:d}=h;return t.intensity=r,t.type=c,t.name=n,t.visible=o,t.castShadow=s,t.color=new ci.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=d,t.shadow.camera.updateProjectionMatrix(),t.cameraHelper.update(),t}}class uc{constructor(e){this.runScene=e}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 ci.Color("#"+o),t.groundColor=new ci.Color("#"+a),t.position.set(s.x,s.y,s.z),t}}class cc{constructor(e){this.runScene=e}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:d,radius:f}=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:f,bias:d},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:d,radius:f}=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 ci.Color("#"+s),t.position.set(h.x,h.y,h.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=d,t.decay=o,t.shadow.radius=f,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 hc{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 ci.Color("#"+o),t.position.set(a.x,a.y,a.z),t}}class pc{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:d,target:f}=e;var{bias:e,camera:m,normalBias:v,mapSize:g,radius:y}=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:g.x,camera:{near:m},radius:y},position:{x:d.x,y:d.y,z:d.z},targetPosition:{x:f.position.x,y:f.position.y,z:f.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:d,targetPosition:f}=e,{bias:h,camera:m,normalBias:v,mapSize:g,radius:y}=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 ci.Color("#"+n),t.position.set(d.x,d.y,d.z),t.shadow.mapSize.x=g,t.shadow.mapSize.y=g,t.shadow.camera.near=m,t.target.position.set(f.x,f.y,f.z),t.shadow.bias=h,t.shadow.normalBias=v,t.shadow.radius=y,t.shadow.camera.updateProjectionMatrix(),t}}class dc{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 lc(e),PointLight:new cc(e),SpotLight:new pc(e),RectAreaLight:new hc(e),HemisphereLight:new uc(e),AmbientLight:new sc(e)}}getLightsByScene(e=this.runScene.sceneEx.get()){return e.children.filter((e=>e.isLight))}get(e,t){var{isClone:t,id:r,addUndo:n}=t||{};let i=new ci[e];if(i.position.y=10,i.name=e,i.userData.id=r,this.shadowList.includes(e)&&(i.castShadow=!0),this.setLight(i),this.helperList.includes(i.type)){const t=this.setLightHelper(i);t.push({model:i,parent:this.runScene.sceneEx.get(),addTree:!0}),r=t.map((e=>new To(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute())),void 0!==n&&n&&this.runScene.undoEx.addUndo(r),null!=(e=i.lightHelper)&&e.update()}else this.runScene.modelEx.add(i,void 0,n);return this.runScene.modelEx.setSelectByModel(i,{isClone:t}),i}setNull(e){e.userData.light&&this.setNull(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper.visible=!1:"SpotLight"===e.type&&(e.cameraHelper.visible=!1,e.helper.visible=!1))}setSelect(e){e.userData.light&&this.setSelect(e.userData.light),this.isLight(e)&&("DirectionalLight"===e.type?e.cameraHelper.visible=!0:"SpotLight"===e.type&&(e.cameraHelper.visible=!0,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(),e.cameraHelper.update()):null!=(t=null==(e=e.helper)?void 0:e.update)&&t.call(e))}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=>new _o({addTree:t===e,runScene:this.runScene,model:t,parent:t.parent||this.runScene.sceneEx.get()}).execute())):[e,e.helper].map((t=>{if(t)return new _o({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 ac(t,16773120);break;case"DirectionalLight":if(n=new ci.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new ci.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 ci.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 ci.PointLightHelper(t,1,16711935);break;case"SpotLight":n=new ci.SpotLightHelper(t);let o=new ci.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 ci.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 ci.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 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 fo({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 ro({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 ro({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,i.getId)()})}}function fc(e){return(fc="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 mc(e,t){return(mc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function vc(e){return(vc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var gc=new WeakMap,yc=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&&mc(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=vc(e);if(r=t?(r=vc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===fc(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,a=new o.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.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(gc.has(e)){if((l=gc.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)})),gc.set(e,{key:a,promise:l}),l}},{key:"_createGeometry",value:function(e){var t=new o.BufferGeometry;e.index&&t.setIndex(new o.BufferAttribute(e.index.array,1));for(var r=0;r<e.attributes.length;r++){var n=(a=e.attributes[r]).name,i=a.array,a=a.itemSize;t.setAttribute(n,new o.BufferAttribute(i,a))}return t}},{key:"_loadLibrary",value:function(e,t){var r=new o.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":fc(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,g=t.DecodeBufferToMesh(r,i);else{if(s!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");i=new e.PointCloud,g=t.DecodeBufferToPointCloud(r,i)}if(!g.ok()||0===i.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());var l,u,c,h,p,d,f,m,v,g,y,b,x,w={index:null,attributes:[]};for(l in o){var S=self[a[l]],T=void 0,M=void 0;if(n.useUniqueIDs)M=o[l],T=t.GetAttributeByUniqueId(i,M);else{if(-1===(M=t.GetAttributeId(i,e[o[l]])))continue;T=t.GetAttribute(i,M)}w.attributes.push((M=e,u=t,c=i,h=l,p=T.num_components(),f=(d=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}}(M,S),v=M._malloc(f),u.GetAttributeDataArrayForAllPoints(c,T,m,f,v),u=new S(M.HEAPF32.buffer,v,d).slice(),M._free(v),{name:h,array:u,itemSize:p}))}return s===e.TRIANGULAR_MESH&&(w.index=(r=e,g=t,b=4*(y=3*(s=i).num_faces()),x=r._malloc(b),g.GetTrianglesUInt32Array(s,b,x),g=new Uint32Array(r.HEAPF32.buffer,x,y).slice(),r._free(x),{array:g,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}(o.Loader),bc={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 xc=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 wc=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.manager=void 0!==t?t:xc,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 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 Tc(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 Mc(e,t){return(Mc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _c(e){return(_c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ec=function(){var e=n,t=wc;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&&Mc(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=_c(e);if(r=t?(r=_c(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){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=bc.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 Tc(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)?Tc(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],bc.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 Pc(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)||Rc(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 kc(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Rc(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 Rc(e,t){if(e){if("string"==typeof e)return Oc(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)?Oc(e,t):void 0}}function Oc(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 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(){return(Lc="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=Fc(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 Dc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ac(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 Ic(e,t,r){return t&&Ac(e.prototype,t),r&&Ac(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function jc(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&&Uc(e,t)}function Uc(e,t){return(Uc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Bc(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=Fc(e);if(r=t?(r=Fc(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");return Nc(n)}}function Nc(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fc(e){return(Fc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Ec.prototype.isImageBitmapLoader=!0;var zc=function(){jc(t,o.Loader);var e=Bc(t);function t(r){return Dc(this,t),(r=e.call(this,r)).dracoLoader=null,r.ktx2Loader=null,r.meshoptDecoder=null,r.pluginCallbacks=[],r.register((function(e){return new Xc(e)})),r.register((function(e){return new Jc(e)})),r.register((function(e){return new $c(e)})),r.register((function(e){return new qc(e)})),r.register((function(e){return new Yc(e)})),r.register((function(e){return new Zc(e)})),r.register((function(e){return new Qc(e)})),r.register((function(e){return new Kc(e)})),r.register((function(e){return new Gc(e)})),r.register((function(e){return new eh(e)})),r}return Ic(t,[{key:"load",value:function(e,t,r,n){function i(t){n?n(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)}var a=this,s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:o.LoaderUtils.extractUrlBase(e),l=(this.manager.itemStart(e),new o.FileLoader(this.manager));l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(r){try{a.parse(r,s,(function(r){t(r),a.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 a,s={},l={};if("string"==typeof e)a=e;else if(o.LoaderUtils.decodeText(new Uint8Array(e,0,4))===th){try{s[Hc.KHR_BINARY_GLTF]=new rh(e)}catch(e){return void(n&&n(e))}a=s[Hc.KHR_BINARY_GLTF].content}else a=o.LoaderUtils.decodeText(new Uint8Array(e));var u=JSON.parse(a);if(void 0===u.asset||u.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{i.helper.beforeLoader(u);var c=new Sh(u,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:i});c.fileLoader.setRequestHeader(this.requestHeader);for(var h=0;h<this.pluginCallbacks.length;h++){var p=this.pluginCallbacks[h](c);s[(l[p.name]=p).name]=!0}if(u.extensionsUsed)for(var d=0;d<u.extensionsUsed.length;++d){var f=u.extensionsUsed[d],m=u.extensionsRequired||[];switch(f){case Hc.KHR_MATERIALS_UNLIT:s[f]=new Wc;break;case Hc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[f]=new ah;break;case Hc.KHR_DRACO_MESH_COMPRESSION:s[f]=new nh(u,this.dracoLoader);break;case Hc.KHR_TEXTURE_TRANSFORM:s[f]=new ih;break;case Hc.KHR_MESH_QUANTIZATION:s[f]=new sh;break;default:0<=m.indexOf(f)&&void 0===l[f]&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(s),c.setPlugins(l),c.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 Vc(){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 Hc={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"},Gc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}return Ic(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,a=t.json,s=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],l=new o.Color(16777215),u=(void 0!==s.color&&l.fromArray(s.color),void 0!==s.range?s.range:0);switch(s.type){case"directional":(i=new o.DirectionalLight(l)).target.position.set(0,0,-1),i.add(i.target);break;case"point":(i=new o.PointLight(l)).distance=u;break;case"spot":(i=new o.SpotLight(l)).distance=u,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,i.angle=s.spot.outerConeAngle,i.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return i.position.set(0,0,0),i.decay=2,void 0!==s.intensity&&(i.intensity=s.intensity),i.name=t.createUniqueName(s.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}(),Wc=function(){function e(){Dc(this,e),this.name=Hc.KHR_MATERIALS_UNLIT}return Ic(e,[{key:"getMaterialType",value:function(){return o.MeshBasicMaterial}},{key:"extendParams",value:function(e,t,r){var n,i=[];return e.color=new o.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}(),Xc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_CLEARCOAT}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Vector2(r,r))),Promise.all(n)}}]),e}(),qc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_SHEEN}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.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}(),Yc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_TRANSMISSION}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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}(),Zc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_VOLUME}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Color(n[0],n[1],n[2]),Promise.all(r)}}]),e}(),Qc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_IOR}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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}(),Kc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_MATERIALS_SPECULAR}return Ic(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Color(i[0],i[1],i[2]),void 0!==e.specularColorTexture&&n.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=o.sRGBEncoding}))),Promise.all(n)}}]),e}(),Jc=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.KHR_TEXTURE_BASISU}return Ic(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}(),$c=function(){function e(t){Dc(this,e),this.parser=t,this.name=Hc.EXT_TEXTURE_WEBP,this.isSupported=null}return Ic(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}(),eh=function(){function e(t){Dc(this,e),this.name=Hc.EXT_MESHOPT_COMPRESSION,this.parser=t}return Ic(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}(),th="glTF",rh=Ic((function e(t){Dc(this,e),this.name=Hc.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(t,0,12);if(this.header={magic:o.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==th)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),a=0;a<n;){var s,l=i.getUint32(a,!0),u=(a+=4,i.getUint32(a,!0));a+=4,1313821514===u?(s=new Uint8Array(t,12+a,l),this.content=o.LoaderUtils.decodeText(s)):5130562===u&&(this.body=t.slice(s=12+a,s+l)),a+=l}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),nh=function(){function e(t,r){if(Dc(this,e),!r)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Hc.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=r,this.dracoLoader.preload()}return Ic(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=mh[r]||r.toLowerCase();l[h]=s[r]}for(n in e.attributes){var p,d,f=mh[n]||n.toLowerCase();void 0!==s[n]&&(p=i.accessors[e.attributes[n]],d=hh[p.componentType],c[f]=d,u[f]=!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}(),ih=function(){function e(){Dc(this,e),this.name=Hc.KHR_TEXTURE_TRANSFORM}return Ic(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}(),oh=function(){jc(t,o.MeshStandardMaterial);var e=Bc(t);function t(r){Dc(this,t),(n=e.call(this)).isGLTFSpecularGlossinessMaterial=!0;var n,i=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),a=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),s=["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"),l=["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"),u=["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"),c={specular:{value:(new o.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};return n._extraUniforms=c,n.onBeforeCompile=function(e){for(var t in c)e.uniforms[t]=c[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>",a).replace("#include <roughnessmap_fragment>",s).replace("#include <metalnessmap_fragment>",l).replace("#include <lights_physical_fragment>",u)},Object.defineProperties(Nc(n),{specular:{get:function(){return c.specular.value},set:function(e){c.specular.value=e}},specularMap:{get:function(){return c.specularMap.value},set:function(e){(c.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return c.glossiness.value},set:function(e){c.glossiness.value=e}},glossinessMap:{get:function(){return c.glossinessMap.value},set:function(e){(c.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 Ic(t,[{key:"copy",value:function(e){return Lc(Fc(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}(),ah=function(){function e(){Dc(this,e),this.name=Hc.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 Ic(e,[{key:"getMaterialType",value:function(){return oh}},{key:"extendParams",value:function(e,t,r){t=t.extensions[this.name];var n,i=(e.color=new o.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 o.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new o.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 oh(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=o.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}(),sh=Ic((function e(){Dc(this,e),this.name=Hc.KHR_MESH_QUANTIZATION})),lh=function(){jc(t,o.Interpolant);var e=Bc(t);function t(r,n,i,o){return Dc(this,t),e.call(this,r,n,i,o)}return Ic(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}(),uh=(lh.prototype.beforeStart_=lh.prototype.copySampleValue_,lh.prototype.afterEnd_=lh.prototype.copySampleValue_,lh.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,d=t-r,f=1-p,m=d-r+n,v=0;v!==a;v++){var g=o[h+v+a],y=o[h+v+s]*u,b=o[c+v+a],x=o[c+v]*u;i[v]=f*g+m*y+p*b+d*x}return i},new o.Quaternion),ch=function(){jc(t,lh);var e=Bc(t);function t(){return Dc(this,t),e.apply(this,arguments)}return Ic(t,[{key:"interpolate_",value:function(e,r,n,i){return e=Lc(Fc(t.prototype),"interpolate_",this).call(this,e,r,n,i),uh.fromArray(e).normalize().toArray(e),e}}]),t}(),hh={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ph={9728:o.NearestFilter,9729:o.LinearFilter,9984:o.NearestMipmapNearestFilter,9985:o.LinearMipmapNearestFilter,9986:o.NearestMipmapLinearFilter,9987:o.LinearMipmapLinearFilter},dh={33071:o.ClampToEdgeWrapping,33648:o.MirroredRepeatWrapping,10497:o.RepeatWrapping},fh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},mh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},vh={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gh={CUBICSPLINE:void 0,LINEAR:o.InterpolateLinear,STEP:o.InterpolateDiscrete};function yh(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 bh(e,t){void 0!==t.extras&&("object"===Cc(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function xh(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 wh(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 Sh=function(){function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};Dc(this,e),this.json=t,this.extensions={},this.plugins={},this.options=r,this.cache=new Vc,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 Ec(this.options.manager):this.textureLoader=new o.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new o.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}return Ic(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 Oc(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Rc(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:{}};yh(i,o,n),bh(o,n),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){r.options.myOptions.helper.done(o),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),kc(t.children.entries()));try{for(a.s();!(i=a.n()).done;){var s=Pc(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[Hc.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(e,i){r.load(o.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,a=e[0],s=fh[n.type],l=hh[n.componentType],u=l.BYTES_PER_ELEMENT,c=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized,d=h&&h!==u*s?(f=Math.floor(c/h),m="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count,(v=t.cache.get(m))||(i=new l(a,f*h,n.count*h/u),v=new o.InterleavedBuffer(i,h/u),t.cache.add(m,v)),new o.InterleavedBufferAttribute(v,s,c%h/u,p)):(i=null===a?new l(n.count*s):new l(a,c,n.count*s),new o.BufferAttribute(i,s,p));if(void 0!==n.sparse){var f=hh[n.sparse.indices.componentType],m=n.sparse.indices.byteOffset||0,v=n.sparse.values.byteOffset||0,g=new f(e[1],m,n.sparse.count*fh.SCALAR),y=new l(e[2],v,n.sparse.count*s);null!==a&&(d=new o.BufferAttribute(d.array.slice(),d.itemSize,d.normalized));for(var b=0,x=g.length;b<x;b++){var w=g[b];if(d.setX(w,y[b*s]),2<=s&&d.setY(w,y[b*s+1]),3<=s&&d.setZ(w,y[b*s+2]),4<=s&&d.setW(w,y[b*s+3]),5<=s)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return d})))}},{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,a=i.textures[e],s=((s=i.images[t]).uri||s.bufferView)+":"+a.sampler;return this.textureCache[s]?this.textureCache[s]:(t=this.loadImageSource(t,r).then((function(t){t.flipY=!1,a.name&&(t.name=a.name);var r=(i.samplers||{})[a.sampler]||{};return t.magFilter=ph[r.magFilter]||o.LinearFilter,t.minFilter=ph[r.minFilter]||o.LinearMipmapLinearFilter,t.wrapS=dh[r.wrapS]||o.RepeatWrapping,t.wrapT=dh[r.wrapT]||o.RepeatWrapping,n.associations.set(t,{textures:e}),n.options.myOptions.helper.material.processTexture({texture:t,textureDef:a}),t})).catch((function(){return null})),this.textureCache[s]=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],a=self.URL||self.webkitURL,s=i.uri||"";if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then((function(e){return e=new Blob([e],{type:i.mimeType}),s=a.createObjectURL(e)}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return r=Promise.resolve(s).then((function(e){return new Promise((function(r,i){var a=r;!0===t.isImageBitmapLoader&&(a=function(e,t){(e=new o.Texture(e)).needsUpdate=!0,r({texture:e,blob:t})}),t.load(o.LoaderUtils.resolveURL(e,n.path),a,void 0,i)}))})).then((function(e){var t=e.texture;return e=e.blob,t.userData.url=s,t.userData.blob=e,t.url=s,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),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[Hc.KHR_TEXTURE_TRANSFORM]&&(o=void 0!==r.extensions?r.extensions[Hc.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=n.associations.get(i),i=n.extensions[Hc.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,a=void 0===n.attributes.tangent,s=void 0!==n.attributes.color,l=void 0===n.attributes.normal;e.isPoints?(t="PointsMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new o.PointsMaterial,o.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 o.LineBasicMaterial,o.Material.prototype.copy.call(r,i),r.color.copy(i.color),this.cache.add(t,r)),i=r),(a||s||l)&&(t="ClonedMaterial:"+i.uuid+":",i.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),a&&(t+="derivative-tangents:"),s&&(t+="vertex-colors:"),l&&(t+="flat-shading:"),(r=this.cache.get(t))||(r=i.clone(),s&&(r.vertexColors=!0),l&&(r.flatShading=!0),a&&(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 o.MeshStandardMaterial}},{key:"loadMaterial",value:function(e){var t,r=this,n=this.json,i=this.extensions,a=n.materials[e],s={},l=[],u=((n=a.extensions||{})[Hc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]?(u=i[Hc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS],t=u.getMaterialType(),l.push(u.extendParams(s,a,r))):n[Hc.KHR_MATERIALS_UNLIT]?(u=i[Hc.KHR_MATERIALS_UNLIT],t=u.getMaterialType(),l.push(u.extendParams(s,a,r))):(n=a.pbrMetallicRoughness||{},s.color=new o.Color(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)&&(u=n.baseColorFactor,s.color.fromArray(u),s.opacity=u[3]),void 0!==n.baseColorTexture&&l.push(r.assignTexture(s,"map",n.baseColorTexture)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(r.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),l.push(r.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))),!0===a.doubleSided&&(s.side=o.DoubleSide),a.alphaMode||"OPAQUE");return"BLEND"===u?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===u&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==o.MeshBasicMaterial&&(l.push(r.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new o.Vector2(1,1),void 0!==a.normalTexture.scale&&(n=a.normalTexture.scale,s.normalScale.set(n,n))),void 0!==a.occlusionTexture&&t!==o.MeshBasicMaterial&&(l.push(r.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==o.MeshBasicMaterial&&(s.emissive=(new o.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==o.MeshBasicMaterial&&l.push(r.assignTexture(s,"emissiveMap",a.emissiveTexture)),Promise.all(l).then((function(){var n=t===oh?i[Hc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new t(s);return a.name&&(n.name=a.name),n.map&&(n.map.encoding=o.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=o.sRGBEncoding),bh(n,a),r.associations.set(n,{materials:e}),a.extensions&&yh(i,n,a),n}))}},{key:"createUniqueName",value:function(e){for(var t=o.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=[],a=0,s=e.length;a<s;a++){var l=e[a],u=(c=void 0,c=(c=(u=l).extensions&&u.extensions[Hc.KHR_DRACO_MESH_COMPRESSION])?"draco:"+c.bufferView+":"+c.indices+":"+xh(c.attributes):u.indices+":"+xh(u.attributes)+":"+u.mode),c=n[u];c?i.push(c.promise):(c=void 0,c=l.extensions&&l.extensions[Hc.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[Hc.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return Th(r,e,t)}))}(l):Th(new o.BufferGeometry,l,t),n[u]={primitive:l,promise:c},i.push(c))}return Promise.all(i)}},{key:"loadMesh",value:function(e){for(var t=this,r=this.json,n=this.extensions,i=r.meshes[e],a=i.primitives,s=[],l=0,u=a.length;l<u;l++){var c=void 0===a[l].material?(void 0===(c=this.cache).DefaultMaterial&&(c.DefaultMaterial=new o.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:o.FrontSide})),c.DefaultMaterial):this.getDependency("material",a[l].material);c.then((function(e){})),s.push(c)}return s.push(t.loadGeometries(a)),Promise.all(s).then((function(r){for(var s=r.slice(0,r.length-1),l=r[r.length-1],u=[],c=0,h=l.length;c<h;c++){var p=l[c],d=a[c],f=void 0,m=s[c];if(4===d.mode||5===d.mode||6===d.mode||void 0===d.mode)!0!==(f=new(!0===i.isSkinnedMesh?o.SkinnedMesh:o.Mesh)(p,m)).isSkinnedMesh||f.geometry.attributes.skinWeight.normalized||f.normalizeSkinWeights(),5===d.mode?f.geometry=Mh(f.geometry,o.TriangleStripDrawMode):6===d.mode&&(f.geometry=Mh(f.geometry,o.TriangleFanDrawMode));else if(1===d.mode)f=new o.LineSegments(p,m);else if(3===d.mode)f=new o.Line(p,m);else if(2===d.mode)f=new o.LineLoop(p,m);else{if(0!==d.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);f=new o.Points(p,m)}if(0<Object.keys(f.geometry.morphAttributes).length){S=w=x=b=y=v=void 0;var v=f,g=i;if(v.updateMorphTargets(),void 0!==g.weights)for(var y=0,b=g.weights.length;y<b;y++)v.morphTargetInfluences[y]=g.weights[y];if(g.extras&&Array.isArray(g.extras.targetNames)){var x=g.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.")}}f.name=t.createUniqueName(i.name||"mesh_"+e),bh(f,i),d.extensions&&yh(n,f,d),t.assignFinalMaterial(f),u.push(f)}for(var T=0,M=u.length;T<M;T++)t.associations.set(u[T],{meshes:e,primitives:T});if(1===u.length)return u[0];var _=new o.Group;t.associations.set(_,{meshes:e});for(var E=0,P=u.length;E<P;E++)_.add(u[E]);return _}))}},{key:"loadCamera",value:function(e){var t,r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new o.PerspectiveCamera(o.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new o.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),bh(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=[],a=[],s=[],l=0,u=t.channels.length;l<u;l++){var c=t.channels[l],h=t.samplers[c.sampler],p=void 0!==(c=c.target).node?c.node:c.id,d=void 0!==t.parameters?t.parameters[h.input]:h.input,f=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",p)),n.push(this.getDependency("accessor",d)),i.push(this.getDependency("accessor",f)),a.push(h),s.push(c)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(i),Promise.all(a),Promise.all(s)]).then((function(r){for(var n=r[0],i=r[1],a=r[2],s=r[3],l=r[4],u=[],c=0,h=n.length;c<h;c++)!function(e){var t=n[e],r=i[e],c=a[e],h=s[e],p=l[e];if(void 0!==t){t.updateMatrix(),t.matrixAutoUpdate=!0;var d=void 0;switch(vh[p.path]){case vh.weights:d=o.NumberKeyframeTrack;break;case vh.rotation:d=o.QuaternionKeyframeTrack;break;default:d=o.VectorKeyframeTrack}e=t.name||t.uuid;var f=void 0!==h.interpolation?gh[h.interpolation]:o.InterpolateLinear,m=[],v=(vh[p.path]===vh.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name||e.uuid)})):m.push(e),c.array);if(c.normalized){for(var g=wh(v.constructor),y=new Float32Array(v.length),b=0,x=v.length;b<x;b++)y[b]=v[b]*g;v=y}for(var w=0,S=m.length;w<S;w++){var T=new d(m[w]+"."+vh[p.path],r.array,v,f);"CUBICSPLINE"===h.interpolation&&(T.createInterpolant=function(e){return new(this instanceof o.QuaternionKeyframeTrack?ch:lh)(this.times,this.values,this.getValueSize()/3,e)},T.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),u.push(T)}}}(c);return r=t.name||"animation_"+e,new o.AnimationClip(r,void 0,u)}))}},{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,a=r.nodes[e],s=a.name?i.createUniqueName(a.name):"";return t=[],(r=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)})))&&t.push(r),void 0!==a.camera&&t.push(i.getDependency("camera",a.camera).then((function(e){return i._getNodeRef(i.cameraCache,a.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,l=!0===a.isBone?new o.Bone:1<t.length?new o.Group:1===t.length?t[0]:new o.Object3D;if(l!==t[0])for(var u=0,c=t.length;u<c;u++)l.add(t[u]);return a.name&&(l.userData.name=a.name,l.name=s),bh(l,a),a.extensions&&yh(n,l,a),void 0!==a.matrix?((r=new o.Matrix4).fromArray(a.matrix),l.applyMatrix4(r)):(void 0!==a.translation&&l.position.fromArray(a.translation),void 0!==a.rotation&&l.quaternion.fromArray(a.rotation),void 0!==a.scale&&l.scale.fromArray(a.scale)),i.associations.has(l)||i.associations.set(l,{}),i.associations.get(l).nodes=e,i.options.myOptions.helper.processNode({node:l,nodeDef:a})||l}))}},{key:"loadScene",value:function(e){for(var t=this.json,r=this.extensions,n=(e=this.json.scenes[e],this),i=(n.options.myOptions,new o.Group),a=(e.name&&(i.name=n.createUniqueName(e.name)),bh(i,e),e.extensions&&yh(r,i,e),e.nodes||[]),s=[],l=0,u=a.length;l<u;l++)s.push(function e(t,r,n,i){var a=n.nodes[t];return i.getDependency("node",t).then((function(e){return void 0===a.skin?e:i.getDependency("skin",a.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=[],a=0,s=r.length;a<s;a++){var l=r[a];l?(n.push(l),l=new o.Matrix4,void 0!==t.inverseBindMatrices&&l.fromArray(t.inverseBindMatrices.array,16*a),i.push(l)):console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[a])}e.bind(new o.Skeleton(n,i),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var o=[];if(a.children)for(var s=a.children,l=0,u=s.length;l<u;l++){var c=s[l];o.push(e(c,t,n,i))}return Promise.all(o)}))}(a[l],i,t,n));return Promise.all(s).then((function(){var e;return console.log(i,i.children,"scene"),null!=(e=n.options.myOptions)&&e.models.push(i),n.associations=function(e){var t,r=new Map,i=kc(n.associations);try{for(i.s();!(t=i.n()).done;){var a=Pc(t.value,2),s=a[0],l=a[1];(s instanceof o.Material||s instanceof o.Texture)&&r.set(s,l)}}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 Th(e,t,r){var n,i=t.attributes,a=[];for(n in i){var s=mh[n]||n.toLowerCase();s in e.attributes||a.push(function(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}(i[n],s))}void 0===t.indices||e.index||(l=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),a.push(l)),bh(e,t);var l=e,u=t,c=r,h=u.attributes,p=new o.Box3;if(void 0!==h.POSITION){var d=(h=c.json.accessors[h.POSITION]).min,f=h.max;if(void 0===d||void 0===f)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{p.set(new o.Vector3(d[0],d[1],d[2]),new o.Vector3(f[0],f[1],f[2])),h.normalized&&(d=wh(hh[h.componentType]),p.min.multiplyScalar(d),p.max.multiplyScalar(d));var m=u.targets;if(void 0!==m){for(var v=new o.Vector3,g=new o.Vector3,y=0,b=m.length;y<b;y++){var x,w,S=m[y];void 0!==S.POSITION&&(w=(S=c.json.accessors[S.POSITION]).min,x=S.max,void 0!==w&&void 0!==x?(g.setX(Math.max(Math.abs(w[0]),Math.abs(x[0]))),g.setY(Math.max(Math.abs(w[1]),Math.abs(x[1]))),g.setZ(Math.max(Math.abs(w[2]),Math.abs(x[2]))),S.normalized&&(w=wh(hh[S.componentType]),g.multiplyScalar(w)),v.max(g)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}p.expandByVector(v)}l.boundingBox=p,f=new o.Sphere,p.getCenter(f.center),f.radius=p.min.distanceTo(p.max)/2,l.boundingSphere=f}}return Promise.all(a).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=[],d=[],f=[],m=0,v=i.length;m<v;m++){var g,y=i[m];a&&(g=void 0!==y.POSITION?o.getDependency("accessor",y.POSITION):n.attributes.position,p.push(g)),s&&(g=void 0!==y.NORMAL?o.getDependency("accessor",y.NORMAL):n.attributes.normal,d.push(g)),l&&(y=void 0!==y.COLOR_0?o.getDependency("accessor",y.COLOR_0):n.attributes.color,f.push(y))}return Promise.all([Promise.all(p),Promise.all(d),Promise.all(f)]).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 Mh(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 a=0;a<i.count;a++)n.push(a);e.setIndex(n),r=e.getIndex()}var s=r.count-2,l=[];if(t===o.TriangleFanDrawMode)for(var u=1;u<=s;u++)l.push(r.getX(0)),l.push(r.getX(u)),l.push(r.getX(u+1));else for(var c=0;c<s;c++)c%2==0?(l.push(r.getX(c)),l.push(r.getX(c+1)),l.push(r.getX(c+2))):(l.push(r.getX(c+2)),l.push(r.getX(c+1)),l.push(r.getX(c)));return l.length/3!=s&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),(t=e.clone()).setIndex(l),t}class _h{constructor(e){this.materialMap={},this.textureMap={},this.materialIns={},this.textureIns={},this.parser=null,this.baseMaterialTextures=[],this.processBaseMaterialTextures=e=>{const{textures:t,material:r}=e;(0,Fe.js)(t,((e,t)=>{var n;(t=this.textureIns[t])&&(this.runScene.optionsEx.options.lazyLoadTexture&&"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=t=>{var r=this.baseMaterialTextures[t];if(!r)return this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),void this.runScene.optionsEx.log("贴图懒加载完毕","base","success");const{texture:n,type:i,material:o}=r;this.runScene.uniqueEx.texture.addMaterial(n,{material:o,type:i}),o[i]=n,o.needsUpdate=!0,setTimeout((()=>{e(++t)}),this.runScene.optionsEx.options.lazyLoadTextureBetween)};return()=>{if(!this.runScene.optionsEx.options.lazyLoadTexture)return this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),void this.runScene.optionsEx.log("贴图加载完毕","base","success");e(0)}})(),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;e=t.md5,r.userData.md5=t.md5,e&&(e=this.runScene.textureEx.getSameTexture(e,r))?this.textureIns[t.id]=e:this.textureIns[t.id]=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||{};this.processTextureMap(t||{}),this.processMaterialMap(e||{}),setTimeout((()=>{this.lazyLoad()}))}processTextureMap(e){(0,Fe.js)(e,((e,t)=>{var{format:t,center:r,rotation:n,offset:i,repeat:o}=t;const a=this.textureIns[e];a&&(a.format=t,void 0!==o&&(({x:e,y:t}="object"==typeof o?o:{x:o,y:o}),a.repeat.x=e,a.repeat.y=t),void 0!==r&&(({x:o,y:e}="object"==typeof r?r:{x:r,y:r}),a.center.x=o,a.center.y=e),void 0!==i&&(({x:t,y:r}="object"==typeof i?i:{x:i,y:i}),a.offset.x=t,a.offset.y=r),n&&(a.rotation=n),this.runScene.textureEx.bindData(a))}))}processMaterialMap(e){(0,Fe.js)(e,((e,t)=>{const{material:r,models:n}=this.materialIns[e];if(r){var{normal:e,textures:i}=t;if(e.type){const t=(0,Fe.js)(i,((e,t)=>({type:e,texture:this.textureIns[t]}))),o=this.runScene.materialEx.getDataByType(e.type,{normal:e,textures:t,models:n,material:r});if(this.runScene.materialEx.parseNromals(e,o),!o)return;n.map((e=>e.material=o))}else this.runScene.optionsEx.options.notTexture||this.processBaseMaterialTextures({material:r,textures:i}),this.runScene.materialEx.parseNromals(e,r),n.map((e=>e.material=r));r.needsUpdate=!0}}))}}class Eh{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 o.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 Ph{constructor(e){this.parser=null,this.helperModels=[],this.nodeType={MySpriteMaterial:wo},this.cloneMap={},this.runScene=e,this.material=new _h(e),this.scene=new Eh(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*(){try{return yield this.material.processInput(e,t),Promise.resolve()}catch(e){console.log(e,"e")}}))}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,Fe.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;this.material.done(e),"scene"===(null==(t=e.asset.ex)?void 0:t.type)&&(this.scene.done(e),this.sceneEx(e)),this.removeHelperModel()}mergeGeometry(){}mergeClone(){this.runScene.optionsEx.options.instanceClone&&(0,Fe.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=((e,t)=>{var{material:r,geometry:n}=e;const i=new ci.InstancedMesh(n,r,t.length+1);return[e,...t].map(((e,t)=>{i.setMatrixAt(t,e.matrix)})),i})(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:a}=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=this.runScene.textureEx.toThree(i))}i&&(t.background=new o.Color("#"+i)),a&&(({color:r,far:e,near:n}=a),t.fog=new o.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 kh{constructor(e){this.dracoPath="./draco/",this._gltf=new zc,this.runScene=e;const t=new yc;t.setDecoderPath((null==(e=this.runScene.optionsEx.options)?void 0:e.decodePath)||this.dracoPath),this._gltf.dracoLoader=t}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 Ph(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){var{addToScene:r,cleanJSON:n}=r||{};const o=e.models;let a=o;if("material"===t.asset.ex.type){var s,[s]=o;if(!(s=this.runScene.sceneEx.cleanUnlessLevel(s).material))return;this.runScene.materialEx.add(s);var l=this.runScene.modelEx.select;l&&this.runScene.materialEx.resetMaterial(l,s)}else"model"===t.asset.ex.type?(l=o[0].children.filter((e=>{if(!this.runScene.modelEx.isUnless(e))return"model"===t.asset.ex.type&&(e.userData.id=(0,i.getId)()),e})),a=l):(this.runScene.timeLineEx.parseSavedGroupMap(t.asset.ex.timeLine||{}),this.runScene.optionsEx.cb.load.loaded.cb("")),!1!==r&&this.runScene.modelEx.add(a,void 0,!1,!1,!1),this.runScene.modelEx.selectNull(),this.runScene.helperEx.unfocus(),e.helper.mergeClone();return this.runScene.optionsEx.log(t,"detail"),!1!==n&&((0,Fe.js)(t,(e=>delete t[e])),t=null,this.runScene.optionsEx.sceneOptions.loaded=!0),a}}class Rh{constructor(e){this.imgBitMap=new o.ImageBitmapLoader,this.object=new o.ObjectLoader,this.runScene=e,this.gltf=new kh(e)}}var Oh=a(185);class Ch{constructor(e){this.selectors={},this.boxHelperMap={},this.runScene=e,console.log(e,"runScene.events"),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,Oh.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 Eo({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 Eo({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 o.Group;const t=new o.Group;this.runScene.modelEx.add(e,void 0,!1),this.runScene.modelEx.add(t);var r=[...this.getSelectedList("value")],n=(this.runScene.optionsEx.cb.model.multipDrop.cb(this.getSelectedList("value"),e),Qi().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 o.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}}class Lh{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 Dh{constructor(){this.resize=new Lh,this.setSelectMaterial=new Lh,this.setScene=new Lh,this.reset=new Lh,this.render=new Lh,this.baseLog=new Lh,this.inited=new Lh,this.texture={add:new Lh,remove:new Lh},this.model={setSelect:new Lh,add:new Lh,remove:new Lh,multipDrop:new Lh,focus:new Lh,unFocus:new Lh,changeName:new Lh,setOpen:new Lh,setMainStatue:new Lh,setVisible:new Lh,setParent:new Lh,setLayers:new Lh,clone:new Lh,dispose:new Lh},this.material={add:new Lh,dispose:new Lh,setName:new Lh},this.unique={material:{add:new Lh}},this.undo={addUndos:new Lh,removeUndos:new Lh,undoByIndex:new Lh,reset:new Lh},this.scene={save:new Lh,saveNet:new Lh},this.timeLine={setProgress:new Lh,playGroup:new Lh,setGroupMap:new Lh,reset:new Lh,closeGroup:new Lh},this.events={key:{g:new Lh},mouse:{move:new Lh,down:new Lh,up:new Lh},pointer:{down:new Lh,up:new Lh}},this.bloom={glow:{setData:new Lh}},this.load={lazyLoadedTexture:new Lh,loaded:new Lh,models:new Lh,progress:new Lh,getArrayBuffer:new Lh}}}function Ah(){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 Ah.Panel("FPS","#0ff","#002")),u=r(new Ah.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=r(new Ah.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}}Ah.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,d=74*a,f=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,d,f),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h,p,d,f),{dom:m,update:function(l,g){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,d-a,f,h,p,d-a,f),v.fillRect(h+d-a,p,a,f),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h+d-a,p,a,o((1-l/g)*f))}}};const Ih=Ah;class jh{constructor(e){this.options={msg:{show:!0,level:"base"},run:!0,decodePath:"./draco/",showFps:!1,loadInterval:2e3,mode:"running",lazyLoadTexture:!1,lazyLoadTextureBetween:16.6,notTexture:!1,hideLocal:!1,instanceClone:!1,render2:!1,render3:!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 Dh,this.runScene=e}init(e){this.options=Object.assign(this.options,e||{}),this.options.showFps&&(this.addFps(),this.cb.render.add("optionx-ex-render",this.render.bind(this)))}addFps(){this.stats=Ih(),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 Uh{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 o.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=o.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 Bh=(e,t)=>{t=(t||{}).removeDom,!(e.render=()=>{})!==t&&e.domElement.remove(),e.setAnimationLoop(null),e.dispose(),e.renderLists&&e.renderLists.dispose()};class Nh{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,Ki.multiArrToArr)(i(e)))}t.push(new _o({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 o.Group;return e.children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e))).map((e=>{console.log(e,"model"),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 o.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),n=new fo({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=>{((e,t)=>{t=(t||{}).remove;const{geomerty:r,material:n}=e;if(r&&(null!=r&&r.dispose(),delete e.geometry),n){{var i=e.material;i.dispose();const t=xo(i);0!==t.length&&t.map((e=>{(e=>{if(e){const r=e.image;var t=e.userData.url;r.close(),URL.revokeObjectURL(t),e.dispose()}})(e=e.texture)}))}e.material.dispose(),delete e.material}!1!==t&&e.parent&&e.parent.remove(e)})(e,{remove:!1}),this.runScene.optionsEx.cb.model.dispose.cb(e)})),Bh(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(),Bh(e),t.dispose(),this.runScene.bloom.glow.dispose(),o.Cache.clear()}render(){}create(){return new o.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=this.runScene.textureEx.toThree(yield this.runScene.textureEx.parse(t))),null!=t&&t.isTexture&&(r=this.runScene.textureEx.toThree(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 fo({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 o.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 ro({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,Ve.base64ToFile)(a,"screenShot.jpg"),r.width=e,r.height=t,this.runScene.renderEx.setSize(),n.render(i,o),a}}class Fh{constructor(e,t){this.showTransform=!1,this.data=new Proxy({},{set:(e,t,r)=>(e[t]=r,console.log(e,t,r,"a,b,c"),!0)}),this.uuid="",this.getAnimaByModelData=(()=>{const e=(e,t,r,n)=>{const i={},o={};if(e=Fh.isNotNow(e)?this.getAllData():e,(0,Fe.js)(n,((r,n)=>{void 0!==e[r]&&("number"===(n=n.type)?(i[r]=t[r],o[r]=e[r]):"color"===n&&(0,Fe.js)(e[r],((e,n)=>{var a=r+e;i[a]=t[r][e],o[a]=n})))})),!(0,Fe.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,Ki.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,d=o;const t={color(e){const{animaData:t,defType:r}=e,n={};(0,Fe.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,Oh.isTrue)(e)&&(0,Oh.isTrue)(i)&&(0,Oh.isTrue)(o))return n}};return()=>{let r;return{promise:new Promise((n=>{var i=e(h,c,0,d);if(console.log(i,"leftAndRight"),!i)return n(0);var{begin:i,end:o}=i;return r=bi(i,o,p,(e=>{(0,Fe.js)(d,((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,Fe.js)(e,(i=>{n[i]=r?"notNow":Fh.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?Qi().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 Fh.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return Fh.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){Fh.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const n=new(0,Vh[r])(e);return n.data=t,n}reset(){(0,Fe.js)(this.defOptions,((e,t)=>{Fh.SetTargetByData({baseType:t.type,data:Fh.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}remove(){delete this.target.userData.isTimeLineUsed}}Fh.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,n,i,o)=>{(0,Fe.js)(i,((i,a)=>{var s,l,u,c,h,p;a=a.type,void 0!==t[i]&&void 0!==r[i]&&Fh.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 zh=Fh,Vh={model:class extends zh{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}=zh.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,Ki.lastArrayEle)(a),l=i?"0.00":String(n.time)+".00";return s!==l&&(console.log(s,"last"),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=bi(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 zh{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}=zh.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=bi(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:d}=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,d)}),a)})),anima:bi}};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,Ki.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":Qi().model.v3ToMap(t),scale:e?"notNow":Qi().model.v3ToMap(r),rotation:e?"notNow":Qi().model.v3ToMap(n),target:e?"notNow":Qi().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:n}=this.target;let i;if("position"===e)i=Qi().model.v3ToMap(t);else if("scale"===e)i=Qi().model.v3ToMap(r);else if("rotation"===e)i=Qi().model.v3ToMap(n);else{if("target"!==e)throw TypeError("输入值不存在");i=Qi().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 zh{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"}},console.log("new timeLineMap"),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 Hh{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){if(e.userData){let n=e.userData.id;n||(n=(0,i.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 console.log(this.map,e,"this.map[id]?.material"),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),console.log("添加材质到移除列表",e,"material"))}dispose(){(0,Fe.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var Gh=a(1);class Wh 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,i.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),Gh.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=["PerspectiveCamera"];return n=>{if(r.includes(n.type))return n.name=n.type;let i=n.name;if(Gh.valid.isTrue(i)||(i=n.type),this.nameMap[i]){var o=this.nameMap[i];if(this.unique.model.get(o)!==n)return o=-1===(o=e(i))?0:o,o=t(i,o),this.nameMap[o]=this.unique.getId(n),n.name=o}else this.nameMap[i]=this.unique.getId(n)}})()}add(e,t){var{reset:r,hasReset:n}=t||{};if(e instanceof Array)return e.map((e=>this.add(e,t)));if(e){let o=e.userData.id;if(o&&!r||(o=(0,i.getId)(),e.userData.id=o),this.map[o]){if(!n)return;o=(0,i.getId)(),e.userData.id=o}return this.map[o]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):o}}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 Xh{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,i.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,Fe.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}class qh{constructor(e){this.runScene=e,this.model=new Wh(this),this.material=new Hh(this),this.texture=new Xh(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}}const Yh={RunScene:class{constructor(e){this.uniqueEx=new qh(this),this.fileEx=new yu(this),this.optionsEx=new jh(this),this.undoEx=new eo(this),this.textureEx=new vi(this),this.controlsEx=new Be,this.assetsEx=new U(this),this.renderEx=new Uh(this),this.events=new class{constructor(e){this.key=new Yi(this),this.mouse=new Zi(this),this.drag=new Ne(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 Ch(this),this.helperEx=null,this.materialEx=new go(this),this.cameraEx=new ke(this),this.sceneEx=new Nh(this),this.modelEx=new Po(this),this.loaderer=new Rh(this),this.exporter=new la(this),this.lightEx=new dc(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;console.log(e,"groupName"),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,Fe.js)(this.groupMap,((e,t)=>{t.run=!1})),console.log(this.groupMap,"this.groupMap"),this.groupMap}parseSavedGroupMap(e){Object.keys(e).map((t=>{const r=e[t],n={};(0,Fe.js)(r.data,((e,t)=>{var{type:r,data:i}=t;console.log(t,"modelData");const o=Vh[r];if(t=o.getTarget(e,this.runScene),console.log(t,"target"),t){const r=new o(t,this.runScene);r.data=i,n[e]=r}})),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,Ki.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 Pe(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 rc(this),this.helperEx.init();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(""),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 n().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,i.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: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 d(){}function f(){}var m,v,g=(l(m={},o,(function(){return this})),(v=(v=Object.getPrototypeOf)&&v(v(T([]))))&&v!==t&&r.call(v,o)&&(m=v),f.prototype=p.prototype=Object.create(m));function y(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:M}}function M(){return{value:void 0,done:!0}}return l(g,"constructor",d.prototype=f),l(f,"constructor",d),d.displayName=l(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){return!!(e="function"==typeof e&&e.constructor)&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(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()}))},y(g),l(g,s,"Generator"),l(g,o,(function(){return this})),l(g,"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:()=>Qh});var e={},t=(a.r(e),a.d(e,{anima:()=>bi,arrayBufferToBase64:()=>Ri,arrayBufferToBlobUr:()=>Pi,base64ToArrayBuffer:()=>_i,base64ToBlob:()=>Ci,bitMapToCanvas:()=>Bi,blobToFile:()=>Di,canvasToBlob:()=>Wi,compressImgToUrl:()=>Ni,fileAndBlobToCanvas:()=>Ui,fileToBlob:()=>Li,getFilesByDataTransfer:()=>Gi,getImgPixels:()=>Hi,getImgPixels1:()=>Vi,getMd5:()=>ji,getRes:()=>qi,getTruthBase64:()=>Ei,getTypeByBase64:()=>Ai,getWorldLocal:()=>xi,hslToRgb:()=>zi,imgArrayBufferToBlobUrl:()=>ki,imgBitMapToBase64:()=>wi,imgBitMapToBlob:()=>Si,imgBitMapToBlobAndBase64:()=>Mi,mergeObject:()=>Yi,reverseImg:()=>Ti,rgbToHsl:()=>Fi,transByte:()=>Ii,urlToBlob:()=>Oi,vector:()=>Xi}),{}),r=(a.r(t),a.d(t,{AsyncCompress:()=>Is,AsyncDecompress:()=>Qs,AsyncDeflate:()=>Ps,AsyncGunzip:()=>Ns,AsyncGzip:()=>Is,AsyncInflate:()=>Cs,AsyncUnzipInflate:()=>bl,AsyncUnzlib:()=>Xs,AsyncZipDeflate:()=>ml,AsyncZlib:()=>Hs,Compress:()=>As,DecodeUTF8:()=>rl,Decompress:()=>Zs,Deflate:()=>Es,EncodeUTF8:()=>nl,Gunzip:()=>Bs,Gzip:()=>As,Inflate:()=>Os,Unzip:()=>xl,UnzipInflate:()=>yl,UnzipPassThrough:()=>gl,Unzlib:()=>Ws,Zip:()=>vl,ZipDeflate:()=>fl,ZipPassThrough:()=>dl,Zlib:()=>Vs,compress:()=>js,compressSync:()=>Us,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]?Fs:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Ls:qs)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?zs:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Ds:Ys)(e,t)},deflate:()=>ks,deflateSync:()=>Rs,gunzip:()=>Fs,gunzipSync:()=>zs,gzip:()=>js,gzipSync:()=>Us,inflate:()=>Ls,inflateSync:()=>Ds,strFromU8:()=>ol,strToU8:()=>il,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!=gs(e,o);--o)if(!o||65558<e.length-o)return void t("invalid zip file",null);var a=vs(e,o+8);a||t(null,{});var s=a,l=gs(e,o+16),u=4294967295==l;if(u){if(o=gs(e,o-12),101075792!=gs(e,o))return void t("invalid zip file",null);s=a=gs(e,o+32),l=gs(e,o+48)}for(var c=function(o){function s(e,r){e?(n(),t(e,null)):(i[d]=r,--a||t(null,i))}var c=(m=ll(e,l,u))[0],h=m[1],p=m[2],d=m[3],f=m[4],m=m[5];if(m=sl(e,m),l=f,c)if(8==c)if(f=e.subarray(m,m+h),h<32e4)try{s(null,Ds(f,new da(p)))}catch(o){s(o,null)}else r.push(Ls(f,{size:p},s));else s("unknown compression type "+c,null);else s(null,Fa(e,m,m+h))},h=0;h<s;++h)c();return n},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=gs(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var n=vs(e,r+8);if(!n)return{};var i=gs(e,r+16),o=4294967295==i;if(o){if(r=gs(e,r-12),101075792!=gs(e,r))throw"invalid zip file";n=gs(e,r+32),i=gs(e,r+48)}for(var a=0;a<n;++a){var s=(p=ll(e,i,o))[0],l=p[1],u=p[2],c=p[3],h=p[4],p=p[5];if(p=sl(e,p),i=h,s){if(8!=s)throw"unknown compression type "+s;t[c]=Ds(e.subarray(p,p+l),new da(u))}else t[c]=Fa(e,p,p+l)}return t},unzlib:()=>qs,unzlibSync:()=>Ys,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 da(u+22),t=l,n=u-l,i=u=0;i<c;++i){var o=h[i];try{var a=o.c.length,s=(hl(e,u,o,o.f,o.u,a),30+o.f.length+cl(o.extra)),p=u+s;e.set(o.c,p),hl(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)}}pl(e,l,h.length,n,t),r(null,e)}var o={},a=(Ks(e,"",o,t),Object.keys(o)),s=a.length,l=0,u=0,c=s,h=new Array(s),p=[];s||i();for(var d=function(e){function t(t,o){t?(n(),r(t,null)):(t=o.length,h[e]=ns(m,{size:g,crc:v.d(),c:o,f:y,m:w,u:b!=c.length||w&&x.length!=S,compression:M}),l+=30+b+T+t,u+=76+2*(b+T)+(S||0)+t,--s||i())}var c=a[e],d=o[c],f=d[0],m=d[1],v=es(),g=f.length,y=(v.p(f),il(c)),b=y.length,x=m.comment,w=x&&il(x),S=w&&w.length,T=cl(m.extra),M=0==m.level?0:8;if(65535<b&&t("filename too long",null),M)if(g<16e4)try{t(null,Rs(f,m))}catch(d){t(d,null)}else p.push(ks(f,m,t));else t(null,f)},f=0;f<c;++f)d(f);return n},zipSync:()=>function(e,t){var r,n={},i=[],o=(Ks(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=il(r)).length,h=s.comment,p=h&&il(h),d=p&&p.length,f=cl(s.extra);if(65535<c)throw"filename too long";var m=u?Rs(l,s):l,v=m.length,g=es();g.p(l),i.push(ns(s,{size:l.length,crc:g.d(),c:m,f:x,m:p,u:c!=r.length||p&&h.length!=d,o,compression:u})),o+=30+c+f+v,a+=76+2*(c+f)+(d||0)+v}for(var y=new da(a+22),b=(e=o,t=a-o,0);b<i.length;++b){var x=i[b],w=(hl(y,x.o,x,x.f,x.u,x.c.length),30+x.f.length+cl(x.extra));y.set(x.c,x.o+w),hl(y,o,x,x.f,x.u,x.c.length,x.o,x.m),o+=16+w+(x.m?x.m.length:0)}return pl(y,o,i.length,t,e),y},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ls,hs,function(){return[Gs]}],(function(e){return ds(Gs(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>Gs}),a(300)),n=a.n(r),i=a(251),o=a(881);function s(e){return(s="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 l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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 h(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(){return(p="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=v(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 d(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&&f(e,t)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(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=v(e);if(r=t?(r=v(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===s(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 v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var g=new o.Vector3,y=new o.Quaternion,b=new o.Vector3,x=function(){d(t,o.Object3D);var e=m(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.createElement("div");return l(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 h(t,[{key:"copy",value:function(e,r){return p(v(t.prototype),"copy",this).call(this,e,r),this.element=e.element.cloneNode(!0),this}}]),t}();x.prototype.isCSS3DObject=!0,function(){d(t,x);var e=m(t);function t(r){return l(this,t),(r=e.call(this,r)).rotation2D=0,r}return h(t,[{key:"copy",value:function(e,r){return p(v(t.prototype),"copy",this).call(this,e,r),this.rotation2D=e.rotation2D,this}}]),t}().prototype.isCSS3DSprite=!0;var w=new o.Matrix4,S=new o.Matrix4,T=h((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(l(this,e),this),s={camera:{fov:0,style:""},objects:new WeakMap},u=void 0!==o.element?o.element:document.createElement("div"),c=(u.style.overflow="hidden",this.domElement=u,document.createElement("div"));function h(e){return Math.abs(e)<1e-10?0:e}function p(e){return"matrix3d("+h((e=e.elements)[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(e){return"translate(-50%,-50%)matrix3d("+h((e=e.elements)[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}c.style.transformStyle="preserve-3d",c.style.pointerEvents="none",u.appendChild(c),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&&(u.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,l=(t.top+t.bottom)/2),t.isOrthographicCamera?"scale("+r+")translate("+h(o)+"px,"+h(l)+"px)"+p(t.matrixWorldInverse):"translateZ("+r+"px)"+p(t.matrixWorldInverse)),l=o+"translate("+n+"px,"+i+"px)";s.camera.style!==l&&(c.style.transform=l,s.camera.style=l),function e(t,r,n,i){var o,l,u;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?(w.copy(n.matrixWorldInverse),w.transpose(),0!==t.rotation2D&&w.multiply(S.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(g,y,b),w.setPosition(g),w.scale(b),w.elements[3]=0,w.elements[7]=0,w.elements[11]=0,w.elements[15]=1,d(w)):d(t.matrixWorld),l=t.element,void 0!==(u=s.objects.get(t))&&u.style===o||(u={style:l.style.transform=o},s.objects.set(t,u)),l.parentNode!==c&&c.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,u.style.width=e+"px",u.style.height=o+"px",c.style.width=e+"px",c.style.height=o+"px"}}));function M(e){return(M="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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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 P(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function k(){return(k="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=O(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 R(e,t){return(R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}(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&&R(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=O(e);if(r=t?(r=O(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===M(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 _(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 P(n,[{key:"copy",value:function(e,t){return k(O(n.prototype),"copy",this).call(this,e,t),this.element=e.element.cloneNode(!0),this}}]),n})(o.Object3D).prototype.isCSS2DObject=!0;var C=new o.Vector3,L=new o.Matrix4,D=new o.Matrix4,A=new o.Vector3,I=new o.Vector3,j=P((function e(){var t,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(_(this,e),this),s={objects:new WeakMap},l=void 0!==o.element?o.element:document.createElement("div");function u(e,t){return A.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(t.matrixWorld),A.distanceToSquared(I)}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(),L.copy(t.matrixWorldInverse),D.multiplyMatrices(t.projectionMatrix,L),function e(t,r,o){var c;t.isCSS2DObject&&(C.setFromMatrixPosition(t.matrixWorld),C.applyMatrix4(D),c=!0===t.visible&&-1<=C.z&&C.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(C.x*n+n)+"px,"+Math.round(-C.y*i+i)+"px)":c.style.transform="translate(-50%,-50%) translate("+(C.x*n+n)+"px,"+(-C.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 U{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 T;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 j;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,n.domElement),{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 B={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 N(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 z(e,t,r){t&&F(e.prototype,t),r&&F(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var V=function(){function e(){N(this,e),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}return z(e,[{key:"setSize",value:function(){}},{key:"render",value:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}]),e}(),H=new o.OrthographicCamera(-1,1,1,-1,0,1),G=new o.BufferGeometry,W=(G.setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),G.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2)),function(){function e(t){N(this,e),this._mesh=new o.Mesh(G,t)}return z(e,[{key:"dispose",value:function(){this._mesh.geometry.dispose()}},{key:"render",value:function(e){e.render(this._mesh,H)}},{key:"material",get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}]),e}());function X(e){return(X="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 q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Z=function(){var e=n,t=V;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&&q(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=Y(e);if(r=t?(r=Y(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===X(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 o.ShaderMaterial?(i.uniforms=e.uniforms,i.material=e):e&&(i.uniforms=o.UniformsUtils.clone(e.uniforms),i.material=new o.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:i.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),i.fsQuad=new W(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}(),Q={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new o.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 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=V;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,i,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(s=r.call(this)).strength=void 0!==t?t:1,s.radius=i,s.threshold=a,s.resolution=void 0!==e?new o.Vector2(e.x,e.y):new o.Vector2(256,256),s.clearColor=new o.Color(0,0,0),s.renderTargetsHorizontal=[],s.renderTargetsVertical=[],s.nMips=5;var l=Math.round(s.resolution.x/2),u=Math.round(s.resolution.y/2);s.renderTargetBright=new o.WebGLRenderTarget(l,u),s.renderTargetBright.texture.name="UnrealBloomPass.bright",s.renderTargetBright.texture.generateMipmaps=!1;for(var c=0;c<s.nMips;c++){var h;((h=new o.WebGLRenderTarget(l,u)).texture.name="UnrealBloomPass.h"+c,h.texture.generateMipmaps=!1,s.renderTargetsHorizontal.push(h),h=new o.WebGLRenderTarget(l,u)).texture.name="UnrealBloomPass.v"+c,h.texture.generateMipmaps=!1,s.renderTargetsVertical.push(h),l=Math.round(l/2),u=Math.round(u/2)}i=Q;for(var p=(s.highPassUniforms=o.UniformsUtils.clone(i.uniforms),s.highPassUniforms.luminosityThreshold.value=a,s.highPassUniforms.smoothWidth.value=.01,s.materialHighPassFilter=new o.ShaderMaterial({uniforms:s.highPassUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,defines:{}}),s.separableBlurMaterials=[],[3,5,7,9,11]),d=(l=Math.round(s.resolution.x/2),u=Math.round(s.resolution.y/2),0);d<s.nMips;d++)s.separableBlurMaterials.push(s.getSeperableBlurMaterial(p[d])),s.separableBlurMaterials[d].uniforms.texSize.value=new o.Vector2(l,u),l=Math.round(l/2),u=Math.round(u/2);return s.compositeMaterial=s.getCompositeMaterial(s.nMips),s.compositeMaterial.uniforms.blurTexture1.value=s.renderTargetsVertical[0].texture,s.compositeMaterial.uniforms.blurTexture2.value=s.renderTargetsVertical[1].texture,s.compositeMaterial.uniforms.blurTexture3.value=s.renderTargetsVertical[2].texture,s.compositeMaterial.uniforms.blurTexture4.value=s.renderTargetsVertical[3].texture,s.compositeMaterial.uniforms.blurTexture5.value=s.renderTargetsVertical[4].texture,s.compositeMaterial.uniforms.bloomStrength.value=t,s.compositeMaterial.uniforms.bloomRadius.value=.1,s.compositeMaterial.needsUpdate=!0,s.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],s.bloomTintColors=[new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1),new o.Vector3(1,1,1)],s.compositeMaterial.uniforms.bloomTintColors.value=s.bloomTintColors,e=B,s.copyUniforms=o.UniformsUtils.clone(e.uniforms),s.copyUniforms.opacity.value=1,s.materialCopy=new o.ShaderMaterial({uniforms:s.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:o.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),s.enabled=!0,s.needsSwap=!1,s._oldClearColor=new o.Color,s.oldClearAlpha=1,s.basic=new o.MeshBasicMaterial,s.fsQuad=new W(null),s}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 o.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 o.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new o.Vector2(.5,.5)},direction:{value:new o.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 o.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 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 re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ne(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 ie(e,t,r){t&&ne(e.prototype,t),r&&ne(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function oe(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&&ae(e,t)}function ae(e,t){return(ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function se(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=le(e);if(r=t?(r=le(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")}}function le(e){return(le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}ee.BlurDirectionX=new o.Vector2(1,0),ee.BlurDirectionY=new o.Vector2(0,1);var ue=function(){oe(t,V);var e=se(t);function t(r,n){var i;return re(this,t),(i=e.call(this)).scene=r,i.camera=n,i.clear=!0,i.needsSwap=!1,i.inverse=!1,i}return ie(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}(),ce=function(){oe(t,V);var e=se(t);function t(){var r;return re(this,t),(r=e.call(this)).needsSwap=!1,r}return ie(t,[{key:"render",value:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}]),t}();function he(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 pe=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 o.Vector2),this._pixelRatio=t.getPixelRatio(),this._width=n.width,this._height=n.height,(r=new o.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===Z&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Z(B),this.clock=new o.Clock}return function(e,t,r){t&&he(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!==ue&&(s instanceof ue?r=!0:s instanceof ce&&(r=!1)))}this.renderer.setRenderTarget(t)}},{key:"reset",value:function(e){var t;void 0===e&&(t=this.renderer.getSize(new o.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 de(e){return(de="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 fe(e,t){return(fe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function me(e){return(me=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}new o.OrthographicCamera(-1,1,1,-1,0,1),(r=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),r.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2));var ve=function(){var e=n,t=V;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&&fe(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=me(e);if(r=t?(r=me(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===de(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,a){var s;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");return(s=r.call(this)).scene=e,s.camera=t,s.sampleLevel=4,s.unbiased=!0,s.clearColor=void 0!==i?i:0,s.clearAlpha=void 0!==a?a:0,s._oldClearColor=new o.Color,e=B,s.copyUniforms=o.UniformsUtils.clone(e.uniforms),s.copyMaterial=new o.ShaderMaterial({uniforms:s.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:o.AdditiveBlending,depthTest:!1,depthWrite:!1}),s.fsQuad=new W(s.copyMaterial),s}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 o.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var n=ge[Math.max(0,Math.min(this.sampleLevel,5))],i=e.autoClear,a=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),s=1/n.length,l=(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(l,r);for(var u=0;u<n.length;u++){var c=n[u];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*c[0],l.offsetY+.0625*c[1],l.width,l.height),c=s,this.unbiased&&(c+=1/32*((u+.5)/n.length-.5)),this.copyUniforms.opacity.value=c,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===u&&(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,a)}}])&&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}(),ge=[[[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 ye(e){return(ye="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(){return(be="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=we(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 xe(e,t){return(xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function we(e){return(we=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Se=function(){var e=n,t=ve;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&&xe(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=we(e);if(r=t?(r=we(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ye(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 be(we(n.prototype),"render",this).call(this,e,t,r,i),void(this.accumulateIndex=-1);var a=Te[5],s=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new o.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new o.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(be(we(n.prototype),"render",this).call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0),i=e.autoClear,e.autoClear=!1,1/a.length);if(0<=this.accumulateIndex&&this.accumulateIndex<a.length){this.copyUniforms.opacity.value=s,this.copyUniforms.tDiffuse.value=t.texture;for(var l=Math.pow(2,this.sampleLevel),u=0;u<l;u++){var c=a[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*c[0],.0625*c[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>=a.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(s=this.accumulateIndex*s)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),s<1&&(this.copyUniforms.opacity.value=1-s,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==s&&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}(),Te=[[[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 Me extends V{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof o.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=o.UniformsUtils.clone(e.uniforms),this.material=new o.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new W(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 _e extends V{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 o.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 Ee={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 Pe{constructor(e){this.bloomParams={isBloom:!1,bloomStrength:2,bloomThreshold:0,bloomRadius:0},this.runScene=e,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 Pe.instance||(Pe.instance=new Pe(e)),Pe.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?o.ACESFilmicToneMapping:o.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 o.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 o.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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=o.FloatType,this.effectRT.texture.format=o.RGBAFormat,this.effectRT.texture.encoding=o.sRGBEncoding,this.effectRT.texture.minFilter=o.LinearFilter,this.effectRT.texture.magFilter=o.LinearFilter),this.effectRT.depthTexture=new o.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=o.DepthFormat,this.effectRT.depthTexture.type=o.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new Se(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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=o.FloatType,this.sampleRT.texture.format=o.RGBAFormat,this.sampleRT.texture.encoding=o.sRGBEncoding,this.sampleRT.texture.minFilter=o.LinearFilter,this.sampleRT.texture.magFilter=o.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 o.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=o.FloatType,this.holdRT.texture.format=o.RGBAFormat,this.holdRT.texture.encoding=o.sRGBEncoding,this.holdRT.texture.minFilter=o.LinearFilter,this.holdRT.texture.magFilter=o.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 _e(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 ee(new o.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 Me(Ee,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new Z(B),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 pe(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 ke{constructor(e){this.runScene=e}create(){return new o.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 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 Oe(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&&Ce(e,t)}function Ce(e,t){return(Ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Le(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ae={type:"change"},Ie={type:"start"},je={type:"end"},Ue=function(){Oe(t,o.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=De(e);if(r=t?(r=De(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");return Le(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 o.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:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},i.touches={ONE:o.TOUCH.ROTATE,TWO:o.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(Ae),p.update(),f=d.NONE},i.update=(a=new o.Vector3,s=(new o.Quaternion).setFromUnitVectors(r.up,new o.Vector3(0,1,0)),l=s.clone().invert(),u=new o.Vector3,c=new o.Quaternion,h=2*Math.PI,function(){var e=p.object.position,t=(a.copy(e).sub(p.target),a.applyQuaternion(s),v.setFromVector3(a),p.autoRotate&&f===d.NONE&&D(2*Math.PI/60/60*p.autoRotateSpeed),p.enableDamping?(v.theta+=g.theta*p.dampingFactor,v.phi+=g.phi*p.dampingFactor):(v.theta+=g.theta,v.phi+=g.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*=y,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),a.setFromSpherical(v),a.applyQuaternion(l),e.copy(p.target).add(a),p.object.lookAt(p.target),!0===p.enableDamping?(g.theta*=1-p.dampingFactor,g.phi*=1-p.dampingFactor,b.multiplyScalar(1-p.dampingFactor)):(g.set(0,0,0),b.set(0,0,0)),y=1,!(!(x||u.distanceToSquared(p.object.position)>m||8*(1-c.dot(p.object.quaternion))>m)||(p.dispatchEvent(Ae),u.copy(p.object.position),c.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,a,s,l,u,c,h,p=Le(i),d={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},f=d.NONE,m=1e-6,v=new o.Spherical,g=new o.Spherical,y=1,b=new o.Vector3,x=!1,w=new o.Vector2,S=new o.Vector2,T=new o.Vector2,M=new o.Vector2,_=new o.Vector2,E=new o.Vector2,P=new o.Vector2,k=new o.Vector2,R=new o.Vector2,O=[],C={};function L(){return Math.pow(.95,p.zoomSpeed)}function D(e){g.theta-=e}function A(e){g.phi-=e}I=new o.Vector3;var I,j,U,B=function(e,t){I.setFromMatrixColumn(t,0),I.multiplyScalar(-e),b.add(I)},N=(j=new o.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)}),F=(U=new o.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),N(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),N(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 z(e){p.object.isPerspectiveCamera?y/=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?y*=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){M.set(e.clientX,e.clientY)}function W(){var e,t;1===O.length?w.set(O[0].pageX,O[0].pageY):(e=.5*(O[0].pageX+O[1].pageX),t=.5*(O[0].pageY+O[1].pageY),w.set(e,t))}function X(){var e,t;1===O.length?M.set(O[0].pageX,O[0].pageY):(e=.5*(O[0].pageX+O[1].pageX),t=.5*(O[0].pageY+O[1].pageY),M.set(e,t))}function q(){var e=O[0].pageX-O[1].pageX,t=O[0].pageY-O[1].pageY;e=Math.sqrt(e*e+t*t),P.set(0,e)}function Y(e){1==O.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;D(2*Math.PI*T.x/r.clientHeight),A(2*Math.PI*T.y/r.clientHeight),w.copy(S)}function Z(e){var t,r;1===O.length?_.set(e.pageX,e.pageY):(t=ae(e),r=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),_.set(r,e)),E.subVectors(_,M).multiplyScalar(p.panSpeed),F(E.x,E.y),M.copy(_)}function Q(e){var t=ae(e),r=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(r*r+e*e),k.set(0,t),R.set(0,Math.pow(k.y/P.y,p.zoomSpeed)),z(R.y),P.copy(k)}function K(e){if(!1!==p.enabled)if(0===O.length&&(p.domElement.setPointerCapture(e.pointerId),p.domElement.addEventListener("pointermove",J),p.domElement.addEventListener("pointerup",$)),O.push(e),"touch"===e.pointerType){switch(oe(e),O.length){case 1:switch(p.touches.ONE){case o.TOUCH.ROTATE:if(!1===p.enableRotate)return;W(),f=d.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(!1===p.enablePan)return;X(),f=d.TOUCH_PAN;break;default:f=d.NONE}break;case 2:switch(p.touches.TWO){case o.TOUCH.DOLLY_PAN:if(!1===p.enableZoom&&!1===p.enablePan)return;p.enableZoom&&q(),p.enablePan&&X(),f=d.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(!1===p.enableZoom&&!1===p.enableRotate)return;p.enableZoom&&q(),p.enableRotate&&W(),f=d.TOUCH_DOLLY_ROTATE;break;default:f=d.NONE}break;default:f=d.NONE}f!==d.NONE&&p.dispatchEvent(Ie)}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 o.MOUSE.DOLLY:if(!1===p.enableZoom)return;!function(e){P.set(e.clientX,e.clientY)}(r),f=d.DOLLY;break;case o.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enablePan)return;G(r),f=d.PAN}else{if(!1===p.enableRotate)return;H(r),f=d.ROTATE}break;case o.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(!1===p.enableRotate)return;H(r),f=d.ROTATE}else{if(!1===p.enablePan)return;G(r),f=d.PAN}break;default:f=d.NONE}f!==d.NONE&&p.dispatchEvent(Ie)}}function J(e){if(!1!==p.enabled)if("touch"===e.pointerType){var t=e;switch(oe(t),f){case d.TOUCH_ROTATE:if(!1===p.enableRotate)return;Y(t),p.update();break;case d.TOUCH_PAN:if(!1===p.enablePan)return;Z(t),p.update();break;case d.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 d.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:f=d.NONE}}else{var r=e;if(!1!==p.enabled)switch(f){case d.ROTATE:if(!1===p.enableRotate)return;!function(e){S.set(e.clientX,e.clientY),T.subVectors(S,w).multiplyScalar(p.rotateSpeed),e=p.domElement,D(2*Math.PI*T.x/e.clientHeight),A(2*Math.PI*T.y/e.clientHeight),w.copy(S),p.update()}(r);break;case d.DOLLY:if(!1===p.enableZoom)return;!function(e){k.set(e.clientX,e.clientY),R.subVectors(k,P),0<R.y?z(L()):R.y<0&&V(L()),P.copy(k),p.update()}(r);break;case d.PAN:if(!1===p.enablePan)return;!function(e){_.set(e.clientX,e.clientY),E.subVectors(_,M).multiplyScalar(p.panSpeed),F(E.x,E.y),M.copy(_),p.update()}(r)}}}function $(e){ie(e),0===O.length&&(p.domElement.releasePointerCapture(e.pointerId),p.domElement.removeEventListener("pointermove",J),p.domElement.removeEventListener("pointerup",$)),p.dispatchEvent(je),f=d.NONE}function ee(e){ie(e)}function te(e){!1!==p.enabled&&!1!==p.enableZoom&&f===d.NONE&&(e.preventDefault(),p.dispatchEvent(Ie),e.deltaY<0?V(L()):0<e.deltaY&&z(L()),p.update(),p.dispatchEvent(je))}function re(e){if(!1!==p.enabled&&!1!==p.enablePan){var t=!1;switch(e.code){case p.keys.UP:F(0,p.keyPanSpeed),t=!0;break;case p.keys.BOTTOM:F(0,-p.keyPanSpeed),t=!0;break;case p.keys.LEFT:F(p.keyPanSpeed,0),t=!0;break;case p.keys.RIGHT:F(-p.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),p.update())}}function ne(e){!1!==p.enabled&&e.preventDefault()}function ie(e){delete C[e.pointerId];for(var t=0;t<O.length;t++)if(O[t].pointerId==e.pointerId)return void O.splice(t,1)}function oe(e){var t=C[e.pointerId];void 0===t&&(t=new o.Vector2,C[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ae(e){return e=e.pointerId===O[0].pointerId?O[1]:O[0],C[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 Be{create(e,t){return new Ue(e,t)}}class Ne{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 Fe=a(594),ze=a(129),Ve=a(685);function He(){return(He="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=Ye(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 Ge(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&&We(e,t)}function We(e,t){return(We=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Xe(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=Ye(e);if(r=t?(r=Ye(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===et(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return qe(n)}}function qe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ye(e){return(Ye=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ze(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 Qe(e,t,r){return t&&Ze(e.prototype,t),r&&Ze(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Je(e){return function(e){if(Array.isArray(e))return $e(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 $e(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)?$e(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 $e(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 et(e){return(et="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 tt(e){return void 0===e}function rt(){return"undefined"!=typeof window}function nt(e){return Rr(e)||kr(e)}function it(e){return(Hr=dt(e,Vr))&&ui}function ot(e,t){return!t&&console.warn(e)}function at(e,t){return e&&(Vr[e]=t)&&Hr&&(Hr[e]=t)||Vr}function st(){return 0}function lt(e,t,r){return(r=e[t])&&Rr(r)?e[t]():tt(r)&&e.getAttribute&&e.getAttribute(t)||r}function ut(e,t){(e=e.split(",")).forEach(t)}function ct(e,t,r,n){Xr.length&&rn(),e.render(t,r,n),Xr.length&&rn()}function ht(e){var t=parseFloat(e);return(t||0===t)&&(e+"").match(Fr).length<2?t:kr(e)?e.trim():e}function pt(e){return e}function dt(e,t){for(var r in t)e[r]=t[r];return e}function ft(e,t){for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=Cr(t[r])?ft(e[r]||(e[r]={}),t[r]):t[r]);return e}function mt(e){var t,r=e.parent||Yt,n=e.keyframes?(t=Ar(e.keyframes),function(e,r){for(var n in r)n in e||"duration"===n&&t||"ease"===n||(e[n]=r[n])}):nn;if(Lr(e.inherit))for(;r;)n(e,r.vars.defaults),r=r.parent||r._dp;return e}function vt(e){return!e||e._ts&&vt(e.parent)}function gt(e){return e._repeat?yt(e._tTime,e=e.duration()+e._rDelay)*e:0}function yt(e,t){return t=Math.floor(e/=t),e&&t===e?t-1:t}function bt(e,t){return(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur)}function xt(e,t){var r;if((t._time||t._initted&&!t._dur)&&(r=bt(e.rawTime(),t),(!t._dur||Ot(0,t.totalDuration(),r)-t._tTime>wr)&&t.render(r,!0)),ln(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=-wr}}function wt(e,t,r,n){return t.parent&&sn(t),t._start=tn((Or(r)?r:r||e!==Yt?kt(e,r,t):e._time)+t._delay),t._end=tn(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),_t(t)||(e._recent=t),n||xt(e,t),e}function St(e,t){(Vr.ScrollTrigger||Gr("scrollTrigger",t))&&Vr.ScrollTrigger.create(t,e)}function Tt(e,t,r,n){return An(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&$t!==_n.frame?(Xr.push(e),e._lazy=[t,n]):void 0:1}function Mt(e){return(e=e.parent)&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||Mt(e))}function _t(e){return"isFromStart"===(e=e.data)||"isStart"===e}function Et(e,t,r,n){var i=e._repeat,o=tn(t)||0;return(t=e._tTime/e._tDur)&&!n&&(e._time*=o/e._dur),e._dur=o,e._tDur=i?i<0?1e10:tn(o*(i+1)+e._rDelay*i):o,0<t&&!n?cn(e,e._tTime=e._tDur*t):e.parent&&un(e),r||ln(e.parent,e),e}function Pt(e){return e instanceof Xn?ln(e):Et(e,e._dur)}function kt(e,t,r){var n,i,o,a=e.labels,s=e._recent||hn,l=e.duration()>=xr?s.endTime(!1):e._dur;return kr(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*(Ar(r)?r[0]:r).totalDuration()),1<n?kt(e,t.substr(0,n-1),r)+i:l+i)):null==t?l:+t}function Rt(e,t,r){var n,i,o=Or(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=Lr(i.vars.inherit)&&i.parent;s.immediateRender=Lr(n.immediateRender),e<2?s.runBackwards=1:s.startAt=t[a-1]}return new Jn(t[0],s,t[1+a])}function Ot(e,t,r){return r<e?e:t<r?t:r}function Ct(e){if(Rr(e))return e;var t=Cr(e)?e:{each:e},r=Cn(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 kr(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,d,f,m,v,g,y,b,x=(h||t).length,w=o[x];if(!w){if(!(b="auto"===t.grid?0:(t.grid||[1,xr])[1])){for(g=-xr;g<(g=h[b++].getBoundingClientRect().left)&&b<x;);b--}for(w=o[x]=[],p=a?Math.min(b,x)*l-.5:n%b,d=b===xr?0:a?x*u/b-.5:n/b|0,y=xr,v=g=0;v<x;v++)m=v%b-p,f=d-(v/b|0),w[v]=m=s?Math.abs("y"===s?f:m):_r(m*m+f*f),g<m&&(g=m),m<y&&(y=m);"random"===n&&gn(w),w.max=g-y,w.min=y,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=dn(t.amount||t.each)||0,r=r&&x<0?On(r):r}return x=(w[e]-w.min)/w.max||0,tn(w.b+(r?r(x):x)*w.v)+w.u}}function Lt(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+(Or(r)?0:dn(r))}}function Dt(e,t){var r,n,i=Ar(e);return!i&&Cr(e)&&(r=i=e.radius||xr,e.values?(e=vn(e.values),(n=!Or(e[0]))&&(r*=r)):e=Lt(e.increment)),pn(t,i?Rr(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=xr,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||Or(t)?u:u+dn(t)}:Lt(e))}function At(e,t,r,n){return pn(Ar(e)?!t:!0===r?!!(r=0):!n,(function(){return Ar(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 It(e,t,r){return pn(r,(function(r){return e[~~t(r)]}))}function jt(e,t,r,n,i){var o=t-e,a=n-r;return pn(i,(function(t){return r+((t-e)/o*a||0)}))}function Ut(e,t,r){var n,i,o,a=e.labels,s=xr;for(n in a)(i=a[n]-t)<0==!!r&&i&&s>(i=Math.abs(i))&&(o=n,s=i);return o}function Bt(e,t,r){var n=e.vars,i=n[t];i&&(t=n[t+"Params"],n=n.callbackScope||e,r&&Xr.length&&rn(),t?i.apply(n,t):i.call(n))}function Nt(e){return sn(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&Bt(e,"onInterrupt"),e}function Ft(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)*bn+.5|0}function zt(e,t,r){var n,i,o,a,s="",l=(e+s).match(Tn),u=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((function(e){return(e=wn(e,t,1))&&u+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")"})),r&&(o=Sn(e),(n=r.c).join(s)!==o.c.join(s)))for(a=(i=e.replace(Tn,"1").split(Ur)).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(Tn)).length-1;c<a;c++)s+=i[c]+l[c];return s+i[a]}function Vt(e,t){for(var r,n=e._first;n;)n instanceof Xn?Vt(n,t):!n.vars.yoyoEase||n._yoyo&&n._repeat||n._yoyo===t||(n.timeline?Vt(n.timeline,t):(r=n._ease,n._ease=n._yEase,n._yEase=r,n._yoyo=t)),n=n._next}function Ht(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}};ut(e,(function(e){for(var t in Pn[e]=Vr[e]=i,Pn[r=e.toLowerCase()]=n,i)Pn[r+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Pn[e+"."+t]=i[t]}))}function Gt(e){return function(t){return t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2}}function Wt(e,t,r){function n(e){return 1===e?1:i*Math.pow(2,-10*e)*Pr((e-o)*a)+1}var i=1<=t?t:1,o=(a=(r||(e?.3:.45))/(t<1?t:1))/Sr*(Math.asin(1/i)||0),a=(r="out"===e?n:"in"===e?function(e){return 1-n(1-e)}:Gt(n),Sr/a);return r.config=function(t,r){return Wt(e,t,r)},r}function Xt(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)}:Gt(t);return n.config=function(t){return Xt(e,t)},n}var qt,Yt,Zt,Qt,Kt,Jt,$t,er,tr,rr,nr,ir,or,ar,sr,lr,ur,cr,hr,pr,dr,fr,mr,vr,gr,yr={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},br={duration:.5,overwrite:!1,delay:0},xr=1e8,wr=1/xr,Sr=2*Math.PI,Tr=Sr/4,Mr=0,_r=Math.sqrt,Er=Math.cos,Pr=Math.sin,kr=function(e){return"string"==typeof e},Rr=function(e){return"function"==typeof e},Or=function(e){return"number"==typeof e},Cr=function(e){return"object"==et(e)},Lr=function(e){return!1!==e},Dr="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},Ar=Array.isArray,Ir=/(?:-?\.?\d|\.)+/gi,jr=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Ur=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,Br=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,Nr=/[+-]=-?[.\d]+/,Fr=/[^,'"\[\]\s]+/gi,zr=/[\d.+\-=]+(?:e[-+]\d*)*/i,Vr={},Hr={},Gr=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Wr={},Xr=[],qr={},Yr={},Zr={},Qr=30,Kr=[],Jr="",$r=function(e){var t,r,n=e[0];if(Cr(n)||Rr(n)||(e=[e]),!(t=(n._gsap||{}).harness)){for(r=Kr.length;r--&&!Kr[r].targetTest(n););t=Kr[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new Gn(e[r],t)))||e.splice(r,1);return e},en=function(e){return e._gsap||$r(vn(e))[0]._gsap},tn=function(e){return Math.round(1e7*e)/1e7||0},rn=function(){var e,t,r=Xr.length,n=Xr.slice(0);for(qr={},e=Xr.length=0;e<r;e++)(t=n[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},nn=function(e,t){for(var r in t)r in e||(e[r]=t[r]);return e},on=function(e,t){var r,n={};for(r in e)r in t||(n[r]=e[r]);return n},an=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},sn=function(e,t){!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},ln=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},un=function(e){return e._end=tn(e._start+(e._tDur/Math.abs(e._ts||e._rts||wr)||0))},cn=function(e,t){var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=tn(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),un(e),r._dirty||ln(r,e)),e},hn={_start:0,endTime:st,totalDuration:st},pn=function(e,t){return e||0===e?t(e):t},dn=function(e,t){return kr(e)&&(t=zr.exec(e))?e.substr(t.index+t[0].length):""},fn=[].slice,mn=function(e,t){return e&&Cr(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Cr(e[0]))&&!e.nodeType&&e!==Zt},vn=function(e,t,r){return!kr(e)||r||!Qt&&En()?Ar(e)?function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return e.forEach((function(e){return kr(e)&&!t||mn(e,1)?r.push.apply(r,Je(vn(e))):r.push(e)}))||r}(e,r):mn(e)?fn.call(e,0):e?[e]:[]:fn.call((t||Kt).querySelectorAll(e),0)},gn=function(e){return e.sort((function(){return.5-Math.random()}))},yn=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?Fr:Ir),a+=e.substr(o,t-o)+At(i?r:+r[0],i?0:+r[1],+r[2]||1e-5),o=n+1;return a+e.substr(o,e.length-o)},bn=255,xn={aqua:[0,bn,bn],lime:[0,bn,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,bn],navy:[0,0,128],white:[bn,bn,bn],olive:[128,128,0],yellow:[bn,bn,0],orange:[bn,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[bn,0,0],pink:[bn,192,203],cyan:[0,bn,bn],transparent:[bn,bn,bn,0]},wn=function(e,t,r){var n,i,o,a,s,l,u,c=e?Or(e)?[e>>16,e>>8&bn,e&bn]:0:xn.black;if(!c){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),xn[e])c=xn[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&bn,c&bn,parseInt(e.substr(7),16)/255];c=[(e=parseInt(e.substr(1),16))>>16,e>>8&bn,e&bn]}else if("hsl"===e.substr(0,3))if(c=u=e.match(Ir),t){if(~e.indexOf("="))return c=e.match(jr),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]=Ft(a+1/3,n,i),c[1]=Ft(a,n,i),c[2]=Ft(a-1/3,n,i);else c=e.match(Ir)||xn.transparent;c=c.map(Number)}return t&&!u&&(n=c[0]/bn,i=c[1]/bn,o=c[2]/bn,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},Sn=function(e){var t=[],r=[],n=-1;return e.split(Tn).forEach((function(e){e=e.match(Ur)||[],t.push.apply(t,Je(e)),r.push(n+=e.length+1)})),t.c=r,t},Tn=function(){var e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in xn)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),Mn=/hsl[a]?\(/,_n=(sr=Date.now,lr=500,ur=33,cr=sr(),hr=cr,dr=pr=1e3/240,mr={time:0,frame:0,tick:function(){Ln(!0)},deltaRatio:function(e){return or/(1e3/(e||60))},wake:function(){Jt&&(!Qt&&rt()&&(Zt=Qt=window,Kt=Zt.document||{},Vr.gsap=ui,(Zt.gsapVersions||(Zt.gsapVersions=[])).push(ui.version),it(Hr||Zt.GreenSockGlobals||!Zt.gsap&&Zt||{}),ir=Zt.requestAnimationFrame),rr&&mr.sleep(),nr=ir||function(e){return setTimeout(e,dr-1e3*mr.time+1|0)},tr=1,Ln(2))},sleep:function(){(ir?Zt.cancelAnimationFrame:clearTimeout)(rr),tr=0,nr=st},lagSmoothing:function(e,t){lr=e||1/wr,ur=Math.min(t,lr,0)},fps:function(e){pr=1e3/(e||240),dr=1e3*mr.time+pr},add:function(e){fr.indexOf(e)<0&&fr.push(e),En()},remove:function(e,t){~(t=fr.indexOf(e))&&fr.splice(t,1)&&t<=ar&&ar--},_listeners:fr=[]}),En=function(){return!tr&&_n.wake()},Pn={},kn=/^[\d.\-M][\d.\-,\s]/,Rn=/["']/g,On=function(e){return function(t){return 1-e(1-t)}},Cn=function(e,t){return e&&(Rr(e)?e:Pn[e]||function(e){var t,r,n,i=(e+"").split("("),o=Pn[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(Rn,"").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(ht))):Pn._CE&&kn.test(e)?Pn._CE("",e):o}(e))||t};function Ln(e){var t,r,n,i=sr()-hr,o=!0===e;if(lr<i&&(cr+=i-ur),(0<(i=(r=(hr+=i)-cr)-dr)||o)&&(n=++mr.frame,or=r-1e3*mr.time,mr.time=r/=1e3,dr+=i+(pr<=i?4:pr-i),t=1),o||(rr=nr(Ln)),t)for(ar=0;ar<fr.length;ar++)fr[ar](r,or,n,e)}function Dn(e){return e<gr?vr*e*e:e<.7272727272727273?vr*Math.pow(e-1.5/2.75,2)+.75:e<.9090909090909092?vr*(e-=2.25/2.75)*e+.9375:vr*Math.pow(e-2.625/2.75,2)+.984375}function An(e,t){var r,n,i,o,a,s,l,u,c,h,p,d,f,m=e.vars,v=m.ease,g=m.startAt,y=m.immediateRender,b=m.lazy,x=m.onUpdate,w=m.onUpdateParams,S=m.callbackScope,T=m.runBackwards,M=m.yoyoEase,_=m.keyframes,E=m.autoRevert,P=e._dur,k=e._startAt,R=e._targets,O=e.parent,C=O&&"nested"===O.data?O.parent._targets:R,L="auto"===e._overwrite&&!qt,D=e.timeline;if(e._ease=Cn(v=!D||_&&v?v:"none",br.ease),e._yEase=M?On(Cn(!0===M?v:M,br.ease)):0,M&&e._yoyo&&!e._repeat&&(M=e._yEase,e._yEase=e._ease,e._ease=M),e._from=!D&&!!m.runBackwards,!D||_&&!m.stagger){if(d=(u=R[0]?en(R[0]).harness:0)&&m[u.prop],r=on(m,Wr),k&&sn(k.render(-1,!0)),g)if(sn(e._startAt=Jn.set(R,nn({data:"isStart",overwrite:!1,parent:O,immediateRender:!0,lazy:Lr(b),startAt:null,delay:0,onUpdate:x,onUpdateParams:w,callbackScope:S,stagger:0},g))),t<0&&!y&&!E&&e._startAt.render(-1,!0),y){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(k)E||(e._startAt=0);else if(i=nn({overwrite:!1,data:"isFromStart",lazy:(y=!t&&y)&&Lr(b),immediateRender:y,stagger:0,parent:O},r),d&&(i[u.prop]=d),sn(e._startAt=Jn.set(R,i)),t<0&&e._startAt.render(-1,!0),e._zTime=t,y){if(!t)return}else An(e._startAt,wr);for(e._pt=0,b=P&&Lr(b)||b&&!P,n=0;n<R.length;n++){if(l=(a=R[n])._gsap||$r(R)[n]._gsap,e._ptLookup[n]=h={},qr[l.id]&&Xr.length&&rn(),p=C===R?n:C.indexOf(a),u&&!1!==(c=new u).init(a,d||r,e,p,C)&&(e._pt=o=new ai(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||d)for(i in r)Yr[i]&&(c=Zn(i,r,e,p,a,C))?c.priority&&(s=1):h[i]=o=Yn.call(e,a,i,"get",r[i],p,C,0,m.stringFilter);e._op&&e._op[n]&&e.kill(a,e._op[n]),L&&e._pt&&(Hn=e,Yt.killTweensOf(a,h,e.globalTime(t)),f=!e.parent,Hn=0),e._pt&&b&&(qr[l.id]=1)}s&&oi(e),e._onInit&&e._onInit(e)}e._onUpdate=x,e._initted=(!e._op||e._pt)&&!f,_&&t<=0&&D.render(xr,!0,!0)}function In(e,t,r,n,i){return Rr(e)?e.call(t,r,n,i):kr(e)&&~e.indexOf("random(")?yn(e):e}function jn(e,t,r){return e.setAttribute(t,r)}function Un(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 Bn(e,t){for(var r=t._pt;r;)r.r(e,r.d),r=r._next}function Nn(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 Fn(e){for(var t,r,n=this._pt;n;)r=n._next,n.p===e&&!n.op||n.op===e?an(this,n,"_pt"):n.dep||(t=1),n=r;return!t}function zn(e,t,r,n){n.mSet(e,t,n.m.call(n.tween,r,n.mt),n)}function Vn(e,t){return{name:e,rawVars:1,init:function(e,r,n){n._onInit=function(e){var n,i;if(kr(r)&&(n={},ut(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?li(s,o):s)&&s.modifier&&s.modifier(u[o],l,c[a],o)}}}}ut("Linear,Quad,Cubic,Quart,Quint,Strong",(function(e,t){var r=t<5?t+1:t;Ht(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}))})),Pn.Linear.easeNone=Pn.none=Pn.Linear.easeIn,Ht("Elastic",Wt("in"),Wt("out"),Wt()),vr=7.5625,gr=1/2.75,Ht("Bounce",(function(e){return 1-Dn(1-e)}),Dn),Ht("Expo",(function(e){return e?Math.pow(2,10*(e-1)):0})),Ht("Circ",(function(e){return-(_r(1-e*e)-1)})),Ht("Sine",(function(e){return 1===e?1:1-Er(e*Tr)})),Ht("Back",Xt("in"),Xt("out"),Xt()),Pn.SteppedEase=Pn.steps=Vr.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-wr;return function(e){return((n*Ot(0,o,e)|0)+i)*r}}},br.ease=Pn["quad.out"],ut("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(function(e){return Jr+=e+","+e+"Params,"}));var Hn,Gn=Qe((function e(t,r){Ke(this,e),this.id=Mr++,(t._gsap=this).target=t,this.harness=r,this.get=r?r.get:lt,this.set=r?r.getSetter:ri})),Wn=function(){function e(t){Ke(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,Et(this,+t.duration,1,1),this.data=t.data,tr||_n.wake()}return Qe(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,Et(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}},{key:"totalTime",value:function(e,t){if(En(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(cn(this,e),r._dp&&!r.parent&&xt(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)&&wt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===wr||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),ct(this,e,t)),this}},{key:"time",value:function(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+gt(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)+gt(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?yt(this._tTime,r)+1:1}},{key:"timeScale",value:function(e){if(!arguments.length)return this._rts===-wr?0:this._rts;if(this._rts===e)return this;for(var t=this.parent&&this._ts?bt(this.parent._time,this):this._tTime,r=(this._rts=+e||0,this._ts=this._ps||e===-wr?0:this._rts,e=this.totalTime(Ot(-this._delay,this._tDur,t),!0)).parent;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent;return un(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):(En(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==wr&&(this._tTime-=wr)))),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||wt(t,this,e-this._delay),this):this._start}},{key:"endTime",value:function(e){return this._start+(Lr(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?bt(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,Pt(this)):-2===this._repeat?1/0:this._repeat}},{key:"repeatDelay",value:function(e){var t;return arguments.length?(t=this._time,this._rDelay=e,Pt(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(kt(this,e),Lr(t))}},{key:"restart",value:function(e,t){return this.play().totalTime(e?-this._delay:0,Lr(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?-wr:0)),this):this._rts<0}},{key:"invalidate",value:function(){return this._initted=this._act=0,this._zTime=-wr,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)-wr))}},{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,Rr(i)&&(i=i(t))&&(i.then||i===t)&&(t.then=e),r(i),t.then=e}var i=Rr(e)?e:pt;t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?n():t._prom=n}))}},{key:"kill",value:function(){Nt(this)}}]),e}(),Xn=(nn(Wn.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:-wr,_prom:0,_ps:!1,_rts:1}),function(){Ge(t,Wn);var e=Xe(t);function t(){var r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=1<arguments.length?arguments[1]:void 0;return Ke(this,t),(r=e.call(this,n)).labels={},r.smoothChildTiming=!!n.smoothChildTiming,r.autoRemoveChildren=!!n.autoRemoveChildren,r._sort=Lr(n.sortChildren),Yt&&wt(n.parent||Yt,qe(r),i),n.reversed&&r.reverse(),n.paused&&r.paused(!0),n.scrollTrigger&&St(qe(r),n.scrollTrigger),r}return Qe(t,[{key:"to",value:function(e,t,r){return Rt(0,arguments,this),this}},{key:"from",value:function(e,t,r){return Rt(1,arguments,this),this}},{key:"fromTo",value:function(e,t,r,n){return Rt(2,arguments,this),this}},{key:"set",value:function(e,t,r){return t.duration=0,t.parent=this,mt(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new Jn(e,t,kt(this,r),1),this}},{key:"call",value:function(e,t,r){return wt(this,Jn.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 Jn(e,r,kt(this,i)),this}},{key:"staggerFrom",value:function(e,t,r,n,i,o,a){return r.runBackwards=1,mt(r).immediateRender=Lr(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,mt(n).immediateRender=Lr(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,d=this._time,f=this._dirty?this.totalDuration():this._tDur,m=this._dur,v=e<=0?0:tn(e),g=this._zTime<0!=e<0&&(this._initted||!m);if((v=this!==Yt&&f<v&&0<=e?f:v)!==this._tTime||r||g){if(d!==this._time&&m&&(v+=this._time-d,e+=this._time-d),n=v,c=this._start,s=!(u=this._ts),g&&(m||(d=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(g=this._yoyo,a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(n=tn(v%a),v===f?(o=this._repeat,n=m):((o=~~(v/a))&&o===v/a&&(n=m,o--),m<n&&(n=m)),h=yt(this._tTime,a),g&&1&o&&(n=m-n,p=1),o!==(h=!d&&this._tTime&&h!==o?o:h)&&!this._lock){var y=g&&1&h;if(g=y===(g&&1&o),d=(y=o<h?!y:y)?0:m,this._lock=1,this.render(d||(p?0:tn(o*a)),t,!m)._lock=0,this._tTime=v,!t&&this.parent&&Bt(this,"onRepeat"),this.vars.repeatRefresh&&!p&&(this.invalidate()._lock=1),d&&d!==this._time||s!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(m=this._dur,f=this._tDur,g&&(this._lock=2,this.render(d=y?m:-1e-4,!0),this.vars.repeatRefresh&&!p&&this.invalidate()),this._lock=0,!this._ts&&!s)return this;Vt(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,tn(d),tn(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,d=0),!d&&n&&!t&&(Bt(this,"onStart"),this._tTime!==v))return this;if(d<=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=-wr);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?-wr:wr);break}}b=i}if(l&&!t&&(this.pause(),l.render(d<=n?0:-wr)._zTime=d<=n?1:-1,this._ts))return this._start=c,un(this),this.render(e,t,r);this._onUpdate&&!t&&Bt(this,"onUpdate",!0),!(v===f&&f>=this.totalDuration()||!v&&d)||c!==this._start&&Math.abs(u)===Math.abs(this._ts)||this._lock||(!e&&m||!(v===f&&0<this._ts||!v&&this._ts<0)||sn(this,1),t||e<0&&!d||!v&&!d&&f||(Bt(this,v===f&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||v<f&&0<this.timeScale()||this._prom()))}return this}},{key:"add",value:function(e,t){var r=this;if(Or(t)||(t=kt(this,t,e)),!(e instanceof Wn)){if(Ar(e))return e.forEach((function(e){return r.add(e,t)})),this;if(kr(e))return this.addLabel(e,t);if(!Rr(e))return this;e=Jn.delayedCall(0,e)}return this!==e?wt(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]:-xr,i=[],o=this._first;o;)o._start>=n&&(o instanceof Jn?t&&i.push(o):(r&&i.push(o),e&&i.push.apply(i,Je(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 kr(e)?this.removeLabel(e):Rr(e)?this.killTweensOf(e):(an(this,e),e===this._recent&&(this._recent=this._last),ln(this))}},{key:"totalTime",value:function(e,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=tn(_n.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),He(Ye(t.prototype),"totalTime",this).call(this,e,r),this._forcing=0,this):this._tTime}},{key:"addLabel",value:function(e,t){return this.labels[e]=kt(this,t),this}},{key:"removeLabel",value:function(e){return delete this.labels[e],this}},{key:"addPause",value:function(e,t,r){return(t=Jn.delayedCall(0,t||st,r)).data="isPause",this._hasPause=1,wt(this,t,kt(this,e))}},{key:"removePause",value:function(e){var t=this._first;for(e=kt(this,e);t;)t._start===e&&"isPause"===t.data&&sn(t),t=t._next}},{key:"killTweensOf",value:function(e,t,r){for(var n=this.getTweensOf(e,r),i=n.length;i--;)Hn!==n[i]&&n[i].kill(e,t);return this}},{key:"getTweensOf",value:function(e,t){for(var r,n=[],i=vn(e),o=this._first,a=Or(t);o;)o instanceof Jn?function(e,t){for(var r=t.length,n=0;e.indexOf(t[n])<0&&++n<r;);return n<r}(o._targets,i)&&(a?(!Hn||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,Je(r)),o=o._next;return n}},{key:"tweenTo",value:function(e,t){t=t||{};var r,n=this,i=kt(n,e),o=(e=t).startAt,a=e.onStart,s=e.onStartParams,l=(e=e.immediateRender,Jn.to(n,nn({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())||wr,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&&Et(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,nn({startAt:{time:kt(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 Ut(this,kt(this,e))}},{key:"previousLabel",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this._time;return Ut(this,kt(this,e),1)}},{key:"currentLabel",value:function(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+wr)}},{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 ln(this)}},{key:"invalidate",value:function(){var e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return He(Ye(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={}),ln(this)}},{key:"totalDuration",value:function(e){var t,r,n,i=0,o=this,a=o._last,s=xr;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,wt(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;Et(o,o===Yt&&o._time>i?o._time:i,1,1),o._dirty=0}return o._tDur}}],[{key:"updateRoot",value:function(e){if(Yt._ts&&(ct(Yt,bt(e,Yt)),$t=_n.frame),_n.frame>=Qr){Qr+=yr.autoSleep||120;var t=Yt._first;if((!t||!t._ts)&&yr.autoSleep&&_n._listeners.length<2){for(;t&&!t._ts;)t=t._next;t||_n.sleep()}}}}]),t}()),qn=(nn(Xn.prototype,{_lock:0,_hasPause:0,_forcing:0}),function(e,t,r,n,i,o,a){var s,l,u,c,h,p=new ai(this._pt,e,t,0,1,Un,null,i),d=0,f=0;for(p.b=r,p.e=n,r+="",(i=~(n+="").indexOf("random("))&&(n=yn(n)),o&&(o(o=[r,n],e,t),r=o[0],n=o[1]),s=r.match(Br)||[];c=Br.exec(n);)u=c[0],c=n.substring(d,c.index),l?l=(l+1)%5:"rgba("===c.substr(-5)&&(l=1),u!==s[f++]&&(h=parseFloat(s[f-1])||0,p._pt={_next:p._pt,p:c||1===f?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},d=Br.lastIndex);return p.c=d<n.length?n.substring(d,n.length):"",p.fp=a,(Nr.test(n)||i)&&(p.e=0),this._pt=p}),Yn=function(e,t,r,n,i,o,a,s,l){var u;if(Rr(n)&&(n=n(i||0,e,o)),i=e[t],o="get"!==r?r:Rr(i)?l?e[t.indexOf("set")||!Rr(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():i,r=Rr(i)?l?ti:ei:$n,kr(n)&&"="===(n=~n.indexOf("random(")?yn(n):n).charAt(1)&&(!(u=parseFloat(o)+parseFloat(n.substr(2))*("-"===n.charAt(0)?-1:1)+(dn(o)||0))&&0!==u||(n=u)),o!==n)return isNaN(o*n)||""===n?(i||t in e||Gr(t,n),qn.call(this,e,t,o,n,r,s||yr.stringFilter,l)):(u=new ai(this._pt,e,t,+o||0,n-(o||0),"boolean"==typeof i?ii:ni,0,r),l&&(u.fp=l),a&&u.modifier(a,this,e),this._pt=u)},Zn=function(e,t,r,n,i,o){var a,s,l,u;if(Yr[e]&&!1!==(a=new Yr[e]).init(i,a.rawVars?t[e]:function(e,t,r,n,i){if(Rr(e)&&(e=In(e,i,t,r,n)),!Cr(e)||e.style&&e.nodeType||Ar(e)||Dr(e))return kr(e)?In(e,i,t,r,n):e;var o,a={};for(o in e)a[o]=In(e[o],i,t,r,n);return a}(t[e],n,i,o,r),r,n,o)&&(r._pt=s=new ai(r._pt,i,e,0,1,a.render,a,0,a.priority),r!==er))for(l=r._ptLookup[r._targets.indexOf(i)],u=a._props.length;u--;)l[a._props[u]]=s;return a},Qn=Jr+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",Kn={},Jn=(ut(Qn+",id,stagger,delay,duration,paused,scrollTrigger",(function(e){return Kn[e]=1})),function(){Ge(t,Wn);var e=Xe(t);function t(r,n,i,o){Ke(this,t),"number"==typeof n&&(i.duration=n,n=i,i=null);var a,s,l,u,c,h,p,d,f,m=(o=(a=e.call(this,o?n:mt(n))).vars).duration,v=o.delay,g=o.immediateRender,y=o.stagger,b=o.overwrite,x=o.keyframes,w=o.defaults,S=o.scrollTrigger,T=o.yoyoEase,M=(o=n.parent||Yt,(Ar(r)||Dr(r)?Or(r[0]):"length"in n)?[r]:vn(r));if(a._targets=M.length?$r(M):ot("GSAP target "+r+" not found. https://greensock.com",!yr.nullTargetWarn)||[],a._ptLookup=[],a._overwrite=b,x||y||nt(m)||nt(v)){if(n=a.vars,(s=a.timeline=new Xn({data:"nested",defaults:w||{}})).kill(),s.parent=s._dp=qe(a),s._start=0,y||nt(m)||nt(v)){if(c=M.length,d=y&&Ct(y),Cr(y))for(h in y)~Qn.indexOf(h)&&((f=f||{})[h]=y[h]);for(l=0;l<c;l++)(u=on(n,Kn)).stagger=0,T&&(u.yoyoEase=T),f&&dt(u,f),p=M[l],u.duration=+In(m,qe(a),l,p,M),u.delay=(+In(v,qe(a),l,p,M)||0)-a._delay,!y&&1===c&&u.delay&&(a._delay=v=u.delay,a._start+=v,u.delay=0),s.to(p,u,d?d(l,p,M):0),s._ease=Pn.none;s.duration()?m=v=0:a.timeline=0}else if(x){mt(nn(s.vars.defaults,{ease:"none"})),s._ease=Cn(x.ease||n.ease||"none");var _,E,P,k=0;if(Ar(x))x.forEach((function(e){return s.to(M,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(Ar(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(_=u[h].sort((function(e,t){return e.t-t.t})),l=k=0;l<_.length;l++)(P={ease:(E=_[l]).e,duration:(E.t-(l?_[l-1].t:0))/100*m})[h]=E.v,s.to(M,P,k),k+=P.duration;s.duration()<m&&s.to({},{duration:m-s.duration()})}}m||a.duration(m=s.duration())}else a.timeline=0;return!0!==b||qt||(Hn=qe(a),Yt.killTweensOf(M),Hn=0),wt(o,qe(a),i),n.reversed&&a.reverse(),n.paused&&a.paused(!0),(g||!m&&!x&&a._start===tn(o._time)&&Lr(g)&&vt(qe(a))&&"nested"!==o.data)&&(a._tTime=-wr,a.render(Math.max(0,-v))),S&&St(qe(a),S),a}return Qe(t,[{key:"render",value:function(e,t,r){var n,i,o=this._time,a=this._tDur,s=this._dur,l=a-wr<e&&0<=e?a:e<wr?0:e;if(s){if(l!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(m=l,f=this.timeline,this._repeat){if(h=s+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*h+e,t,r);if(m=tn(l%h),l===a?(g=this._repeat,m=s):((g=~~(l/h))&&g===l/h&&(m=s,g--),s<m&&(m=s)),(d=this._yoyo&&1&g)&&(p=this._yEase,m=s-m),y=yt(this._tTime,h),m===o&&!r&&this._initted)return this;g!==y&&(f&&this._yEase&&Vt(f,d),!this.vars.repeatRefresh||d||this._lock||(this._lock=r=1,this.render(tn(h*g),!0).invalidate()._lock=0))}if(!this._initted){if(Tt(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&&(Bt(this,"onStart"),this._tTime!==l))return this;for(n=this._pt;n;)n.r(i,n.d),n=n._next;f&&f.render(e<0?e:!m&&d?-wr:f._dur*f._ease(m/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),Bt(this,"onUpdate")),this._repeat&&g!==y&&this.vars.onRepeat&&!t&&this.parent&&Bt(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)||sn(this,1),t||e<0&&!o||!l&&!o||(Bt(this,l===a?"onComplete":"onReverseComplete",!0),!this._prom||l<a&&0<this.timeScale()||this._prom()))}}else{var u,c,h=this,p=e,d=t,f=r,m=h.ratio,v=p<0||!p&&(!h._start&&Mt(h)&&(h._initted||!_t(h))||(h._ts<0||h._dp._ts<0)&&!_t(h))?0:1,g=h._rDelay,y=0;if(g&&h._repeat&&(c=yt(y=Ot(0,h._tDur,p),g),h._yoyo&&1&c&&(v=1-v),c!==yt(h._tTime,g)&&(m=1-v,h.vars.repeatRefresh&&h._initted&&h.invalidate())),v!==m||f||h._zTime===wr||!p&&h._zTime){if(h._initted||!Tt(h,p,f,d)){for(c=h._zTime,h._zTime=p||(d?wr:0),d=d||p&&!c,h.ratio=v,h._from&&(v=1-v),h._time=0,h._tTime=y,u=h._pt;u;)u.r(v,u.d),u=u._next;h._startAt&&p<0&&h._startAt.render(p,!0,!0),h._onUpdate&&!d&&Bt(h,"onUpdate"),y&&h._repeat&&!d&&h.parent&&Bt(h,"onRepeat"),(p>=h._tDur||p<0)&&h.ratio===v&&(v&&sn(h,1),d||(Bt(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(),He(Ye(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?Nt(this):this;if(this.timeline)return p=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,Hn&&!0!==Hn.vars.overwrite)._first||Nt(this),this.parent&&p!==this.timeline.totalDuration()&&Et(this,this._dur*this.timeline._tDur/p,0,1),this;var r,n,i,o,a,s,l,u=this._targets,c=e?vn(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),Nt(this);for(r=this._op=this._op||[],"all"!==t&&(kr(t)&&(a={},ut(t,(function(e){return a[e]=1})),t=a),t=function(e,t){var r,n,i,o,a=(e=e[0]?en(e[0]).harness:0)&&e.aliases;if(!a)return t;for(n in r=dt({},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)||an(this,s,"_pt"),delete n[a]),"all"!==i&&(i[a]=1);return this._initted&&!this._pt&&p&&Nt(this),this}}],[{key:"to",value:function(e,r){return new t(e,r,arguments[2])}},{key:"from",value:function(e,t){return Rt(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 Rt(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 Yt.killTweensOf(e,t,r)}}]),t}()),$n=(nn(Jn.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),ut("staggerTo,staggerFrom,staggerFromTo",(function(e){Jn[e]=function(){var t=new Xn,r=fn.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}),ei=function(e,t,r){return e[t](r)},ti=function(e,t,r,n){return e[t](n.fp,r)},ri=function(e,t){return Rr(e[t])?ei:tt(e[t])&&e.setAttribute?jn:$n},ni=function(e,t){return t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t)},ii=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},oi=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},ai=function(){function e(t,r,n,i,o,a,s,l,u){Ke(this,e),this.t=r,this.s=i,this.c=o,this.p=n,this.r=a||ni,this.d=s||this,this.set=l||$n,this.pr=u||0,(this._next=t)&&(t._prev=this)}return Qe(e,[{key:"modifier",value:function(e,t,r){this.mSet=this.mSet||this.set,this.set=zn,this.m=e,this.mt=r,this.tween=t}}]),e}(),si=(ut(Jr+"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 Wr[e]=1})),Vr.TweenMax=Vr.TweenLite=Jn,Vr.TimelineLite=Vr.TimelineMax=Xn,Yt=new Xn({sortChildren:!1,defaults:br,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),yr.stringFilter=function(e){var t=e.join(" ");if(Tn.lastIndex=0,Tn.test(t))return t=Mn.test(t),e[1]=zt(e[1],t),e[0]=zt(e[0],t,Sn(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=Rr(e),n=(r=t&&!r&&e.init?function(){this._props=[]}:e,{init:st,render:Bn,add:Yn,kill:Fn,modifier:Nn,rawVars:0}),i={targetTest:0,get:0,getSetter:ri,aliases:{},register:0};if(En(),e!==r){if(Yr[t])return;nn(r,nn(on(e,n),i)),dt(r.prototype,dt(n,on(e,i))),Yr[r.prop=t]=r,e.targetTest&&(Kr.push(r),Wr[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}at(t,r),e.register&&e.register(ui,r,ai)}))},timeline:function(e){return new Xn(e)},getTweensOf:function(e,t){return Yt.getTweensOf(e,t)},getProperty:function(e,t,r,n){kr(e)&&(e=vn(e)[0]);var i=en(e||{}).get,o=r?pt:ht;return"native"===r&&(r=""),e&&(t?o((Yr[t]&&Yr[t].get||i)(e,t,r,n)):function(t,r,n){return o((Yr[t]&&Yr[t].get||i)(e,t,r,n))})},quickSetter:function(e,t,r){var n,i;if(1<(e=vn(e)).length)return n=e.map((function(e){return ui.quickSetter(e,t,r)})),i=n.length,function(e){for(var t=i;t--;)n[t](e)};e=e[0]||{};var o=Yr[t],a=en(e),s=a.harness&&(a.harness.aliases||{})[t]||t,l=o?function(t){var n=new o;er._pt=0,n.init(e,r?t+r:t,er,0,[e]),n.render(1,n),er._pt&&Bn(1,er)}:a.set(e,s);return o?l:function(t){return l(e,s,r?t+r:t,a,1)}},isTweening:function(e){return 0<Yt.getTweensOf(e,!0).length},defaults:function(e){return e&&e.ease&&(e.ease=Cn(e.ease,br.ease)),ft(br,e||{})},config:function(e){return ft(yr,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&&!Yr[e]&&!Vr[e]&&ot(t+" effect requires "+e+" plugin.")})),Zr[t]=function(e,t,n){return r(vn(e),nn(t||{},i),n)},e&&(Xn.prototype[t]=function(e,r,n){return this.add(Zr[t](e,Cr(r)?r:(n=r)&&{},this),n)})},registerEase:function(e,t){Pn[e]=Cn(t)},parseEase:function(e,t){return arguments.length?Cn(e,t):Pn},getById:function(e){return Yt.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 Xn(r);for(i.smoothChildTiming=Lr(r.smoothChildTiming),Yt.remove(i),i._dp=0,i._time=i._tTime=Yt._time,e=Yt._first;e;)t=e._next,!n&&!e._dur&&e instanceof Jn&&e.vars.onComplete===e._targets[0]||wt(i,e,e._start-e._delay),e=t;return wt(Yt,i,0),i},utils:{wrap:function e(t,r,n){var i=r-t;return Ar(t)?It(t,e(0,t.length),r):pn(n,(function(e){return(i+(e-t)%i)%i+t}))},wrapYoyo:function e(t,r,n){var i=r-t,o=2*i;return Ar(t)?It(t,e(0,t.length-1),r):pn(n,(function(e){return t+(i<(e=(o+(e-t)%o)%o||0)?o-e:e)}))},distribute:Ct,random:At,snap:Dt,normalize:function(e,t,r){return jt(e,t,0,1,r)},getUnit:dn,clamp:function(e,t,r){return pn(r,(function(r){return Ot(e,t,r)}))},splitColor:wn,toArray:vn,selector:function(e){return e=vn(e)[0]||ot("Invalid scope")||{},function(t){var r=e.current||e.nativeElement||e;return vn(t,r.querySelectorAll?r:r===e?ot("Invalid scope")||Kt.createElement("div"):e)}},mapRange:jt,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||dn(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=kr(t),p={};if(!0===n&&(i=1)&&(n=null),h)t={p:t},r={p:r};else if(Ar(t)&&!Ar(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=dt(Ar(t)?[]:{},t));if(!l){for(a in r)Yn.call(p,t,a,"get",r[a]);o=function(e){return Bn(e,p),h?t.p:t}}}return pn(n,o)},shuffle:gn},install:it,effects:Zr,ticker:_n,updateRoot:Xn.updateRoot,plugins:Yr,globalTimeline:Yt,core:{PropTween:ai,globals:at,Tween:Jn,Timeline:Xn,Animation:Wn,getCache:en,_removeLinkedListItem:an,suppressOverwrites:function(e){return qt=e}}}),li=(ut("to,from,fromTo,delayedCall,set,killTweensOf",(function(e){return si[e]=Jn[e]})),_n.add(Xn.updateRoot),er=si.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}),ui=si.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])}},Vn("roundProps",Lt),Vn("modifiers"),Vn("snap",Dt))||si;Jn.version=Xn.version=ui.version="3.9.1",Jt=1,rt()&&En(),Pn.Power0,Pn.Power1,Pn.Power2,Pn.Power3,Pn.Power4,Pn.Linear,Pn.Quad,Pn.Cubic,Pn.Quart,Pn.Quint,Pn.Strong,Pn.Elastic,Pn.Back,Pn.SteppedEase,Pn.Bounce,Pn.Sine,Pn.Expo,Pn.Circ;const ci=o,hi=["map","normalMap","aoMap"],pi=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"];class di{}const fi=class extends di{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){console.log(this,e,"this,data"),this.target[this.info]=e,this.target.needsUpdate=!0,pi.includes(this.info)&&(console.log(this.info,"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 mi=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 vi{constructor(e){this.allTextures=new Set,this.runScene=e}loadImagBit(e){return createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"})}load(e){return mi(this,void 0,void 0,(function*(){var t=yield this.loadImagBit(yield Oi(e));return t=new o.Texture(t),this.afterLoad(e,t)}))}clone(e){const t=new o.Texture(e.image);return t.userData=Object.assign({},e.userData),this._afterLoad(t)}getDef(e){return e=new o.Texture(e),this._afterLoad(e)}toThree(e){return e.mapping=ci.EquirectangularReflectionMapping,e.needsUpdate=!0,e}toTwo(e){return e.mapping=300,e.needsUpdate=!0,e}_afterLoad(e){const{md5:t,blob:r}=e.userData;var n=this.getSameTexture(t,e);return n?(e.dispose(),n):(e.userData.url=URL.createObjectURL(r),e.userData.md5=t,e.userData.gm=gi(e),e.format=-1!==r.type.indexOf("png")?1023:1022,e.needsUpdate=!0,e.flipY=!1,e.minFilter=ci.LinearMipmapLinearFilter,this.addToAllTextures(e),e)}afterLoad(e,t){return mi(this,void 0,void 0,(function*(){const r=yield Oi(e);t.userData.blob=r;var n=ji(yield r.arrayBuffer());return t.userData.url=URL.createObjectURL(r),t.userData.md5=n,this._afterLoad(t)}))}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}}bindData(e){return mi(this,void 0,void 0,(function*(){if(this.setTexture(e),this.addToAllTextures(e),e.userData.gm=gi(e),!e.userData.blob){const t=yield this.getBlob(e);return e.userData.md5=ji(yield t.arrayBuffer()),e.userData.blob=t,e.userData.url=URL.createObjectURL(t),e}}))}setTexture(e){return e.magFilter=1003,e.wrapS=ci.RepeatWrapping,e.wrapT=ci.RepeatWrapping,e.encoding=3e3,e.needsUpdate=!0,e.version=3,e.minFilter=ci.LinearMipmapLinearFilter,e}addToAllTextures(e){var t=this.runScene.uniqueEx.texture.getLength();this.runScene.uniqueEx.texture.add(e),this.runScene.uniqueEx.texture.getLength()!==t&&(this.setTexture(e),this.runScene.optionsEx.cb.texture.add.cb(e))}parse(e){return mi(this,void 0,void 0,(function*(){var t=yield Li(e);return this.afterLoad(URL.createObjectURL(t),new o.Texture(yield this.loadImagBit(t)))}))}getBlob(e){return e.userData.blob||Si(e.image)}getUrl(e){return console.log(e,"texture"),e.userData.url}getBlobAndBase64(e){return e.userData.blob?e.userData:Mi(e)}dispose(e){e.dispose()}reverseY(e){return createImageBitmap(e,{imageOrientation:"flipY"})}coverByImage(e,t){return mi(this,void 0,void 0,(function*(){let r;r=t instanceof o.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,Fe.js)(n,((n,i)=>{const o=this.runScene.uniqueEx.material.get(n);o&&i.forEach((n=>{t.push(new fi({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 gi=e=>{var{width:e,height:t}=e.image;return e*t*4*1.33};var yi=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 bi=(e,t,r,n,i)=>{let o=Object.assign({},e),a=new Jn(o,r,t).eventCallback("onUpdate",(e=>n&&n(o))).eventCallback("onComplete",(e=>{i&&i(),Jn.killTweensOf(a)}));return a},xi=(e,t)=>(t.updateMatrixWorld(!0),t=new ci.Vector3,e.getWorldPosition(t),t),wi=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()},Si=e=>yi(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)}))}))})),Ti=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)},Mi=e=>yi(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=1023===e.format?"image/png":"image/jpeg";return n.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(i)})}),i)}))})),_i=e=>yi(void 0,void 0,void 0,(function*(){-1!==e.indexOf(",")&&(e=Ei(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})),Ei=e=>e.substring(e.indexOf(",")+1),Pi=e=>URL.createObjectURL(new Blob([e])),ki=(e,t)=>URL.createObjectURL(new Blob([e],t)),Ri=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)},Oi=e=>yi(void 0,void 0,void 0,(function*(){return(yield n().get(e,{responseType:"blob"})).data})),Ci=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})},Li=e=>yi(void 0,void 0,void 0,(function*(){return Ci(yield(0,Ve.toResult)(e,"base64"))})),Di=(e,t)=>new File([e],t),Ai=e=>e.substring(e.indexOf(":")+1,e.indexOf(";")),Ii=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},ji=e=>(0,ze.md5)(e),Ui=(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})}}))},Bi=e=>{const t=document.createElement("canvas"),r=t.getContext("2d");return r.drawImage(e,0,0,e.width,e.height),{ctx:r,canvas:t}},Ni=(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)}))},Fi=(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]},zi=(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]},Vi=e=>yi(void 0,void 0,void 0,(function*(){var{bitmap:t,texture:r}=e;const{ctx:n,canvas:i}=yield Ui(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=Fi(o.data[a],o.data[a+1],o.data[a+2]))[0]/100,u=c[1]/100,c=c[2]/100;l=zi(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 ci.Texture(i)})),Hi=e=>{for(var t=(e=e.bitmap).width,r=e.height,n=Bi(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)))},Gi=e=>new Array(e.files.length).fill(0).map(((t,r)=>e.files.item(r))).filter((e=>null!==e)),Wi=e=>new Promise((t=>{e.toBlob((e=>{t(e)}))})),Xi={parse(e){var{x:e,y:t,z:r}=e;return void 0===r?new o.Vector2(e,t):new o.Vector3(e,t,r)},toJSON(e){var{x:t,y:r}=e;return e instanceof o.Vector2?{x:t,y:r}:{x:t,y:r,z:e.z}}},qi=(e,t)=>n().get(e,{responseType:t||"arraybuffer"}).then((e=>e.data)).catch((e=>{console.log(e,"加载出错")})),Yi=(e,t)=>Object.assign(e,t||{});class Zi{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:a}=this.events.runScene.assetsEx.get(),s=new o.Vector3,l=new o.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 a=new o.Vector3;t=e.geometry.attributes.position.array,a.set(Math.abs(t[0]-t[3]),Math.abs(t[1]-t[7]),Math.abs(t[2]-t[14])),l.x=.5*(t[0]+t[3]),l.y=.5*(t[1]+t[7]),l.z=.5*(t[2]+t[14]);let u=new o.Vector3;u.subVectors(n.position,l),u.projectOnPlane(new o.Vector3(0,1,0)),u.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*n.fov*Math.PI/180),t=a.length()/r/t,s.addVectors(l,u.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new o.Vector3,e.getWorldPosition(t),l.set(t.x,t.y,t.z);let i=new o.Vector3;i.subVectors(n.position,l),i.projectOnPlane(new o.Vector3(0,1,0)),i.normalize(),s.addVectors(l,i.multiplyScalar(3))}bi({positionX:n.position.x,positionY:n.position.y,positionZ:n.position.z,targetX:a.target.x,targetY:a.target.y,targetZ:a.target.z},{positionX:s.x,positionY:s.y,positionZ:s.z,targetX:l.x,targetY:l.y,targetZ:l.z},.5,(e=>{n.position.set(e.positionX,e.positionY,e.positionZ),n.lookAt(e.targetX,e.targetY,e.targetZ),a.target.set(e.targetX,e.targetY,e.targetZ),a.update(),n.updateProjectionMatrix()}))}},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,Fe.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,Fe.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 Qi{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.down=e=>{(0,Fe.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,Fe.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 o.Raycaster,r=new o.Vector2,{engineDom:n,camera:i,scene:a}=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=a.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)}}r=a(356);var Ki=a.n(r),Ji=a(298);const $i=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"];class eo{static create(){return new o.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],n=e[t];if(r instanceof o.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 pi)if(e[t])return!1;return!0}}eo.defVal={color:new o.Color(16777215),emissive:new o.Color(0),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new o.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class to{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];console.log(e,"last"),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){if(e>this.dataMap.index){const t=this.undos.slice(this.dataMap.index+1,e+1);t.map((e=>{e instanceof Array?e.map((e=>e.redo())):e.redo()})),console.log(t,"0")}else if(e<this.dataMap.index){const t=this.undos.slice(e+1,this.dataMap.index+1);t.reverse().map((e=>{e instanceof Array?e.map((e=>e.undo())):e.undo()})),console.log(t,this.undos,"ls1")}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];console.log(e,"last"),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(""),console.log(this,"this")}}function ro(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=ro(e[t]),n[t]=r);return n}}const no=class extends di{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,Fe.qR)(e.target,this.typeList)[(0,Ji.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,Fe.qR)(this.target,this.typeList);t[(0,Ji.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 io{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 o.ShaderMaterial({uniforms:ro(oo.uniforms),vertexShader:oo.vertexShader,fragmentShader:oo.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=>!io.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];n.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new o.Vector4(t.x,t.y,t.z,t.w):t})),n.userData.tools=this.tools,n},toNormal:e=>{const t=bo(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),{}),n=e.uniforms,i=oo.uniforms;return Object.keys(n).filter((e=>!io.TextureNames.includes(e))).map((e=>{var t,a,s,l,u,c,h=n[e].value,p=i[e].value;h instanceof o.Vector4?(({x:t,y:a,z:s}=h),({x:l,y:u,z:c}=p),t===l&&a===u&&s===c||(r[e]=h)):(console.log(h,p,"val,defVal"),h!==p&&(r[e]=h))})),console.log(r,"uniforms"),t.userData.normal.uniforms=r,console.log(t,"newMaterial"),t},clone:function(e,t){return e}},this.runScene=e}create(){const e=new o.ShaderMaterial({uniforms:ro(oo.uniforms),vertexShader:oo.vertexShader,fragmentShader:oo.fragmentShader});return e.userData.tools=this.tools,e}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new no({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}io.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"];const oo={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new o.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 o.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new o.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 "},ao={uniforms:{tDiffuse:new o.Uniform(null),h:new o.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}"},so={uniforms:{tDiffuse:new o.Uniform(null),v:new o.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 o.Uniform(null),new o.Uniform(null),new o.Uniform(0),new o.Uniform(0),new o.Uniform(0),new o.Uniform(new o.Vector2),new o.Uniform(.1),new o.Uniform(1e3);class lo{constructor(e){this.materials={},this.render=()=>{(0,Fe.js)(this.materials,((e,t)=>{const{model:r,material:n}=t;n.update(r)}))},this.tools={type:"Reflector",getTextures:e=>wo(e),parseData:e=>{const{textures:t,normal:r,models:n,material:i}=e,o=xo(i,new uo(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=>!lo.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=xo(e,bo()),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=co.uniforms;return Object.keys(n).filter((e=>!lo.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,i.getId)();t.userData.id=r,this.materials[r]=e}create(e){const t=new uo(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 no({target:e,typeList:[...t],newVal:r}).execute())}dispose(){this.materials={}}}lo.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"];class uo extends o.MeshStandardMaterial{constructor(e,t,r){e?super(e):(super(),this.opacity=co.uniforms.opacity.value,this.transparent=co.uniforms.transparent.value,this.roughness=co.uniforms.roughness.value,this.metalness=co.uniforms.metalness.value),this.runScene=r,t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new o.Uniform(t.mirror),this.mixBlur=new o.Uniform(t.mixBlur),this.mixStrength=new o.Uniform(t.mixStrength),this.mixContrast=new o.Uniform(t.mixContrast)):(this.resolution=co.uniforms.resolution.value,this.blurSize=co.uniforms.blurSize.value,this.mirror=new o.Uniform(co.uniforms.mirror.value),this.mixBlur=new o.Uniform(co.uniforms.mixBlur.value),this.mixStrength=new o.Uniform(co.uniforms.mixStrength.value),this.mixContrast=new o.Uniform(co.uniforms.mixContrast.value)),this.textureMatrix=new o.Uniform(new o.Matrix4),this.reflectorWorldPosition=new o.Vector3,this.cameraWorldPosition=new o.Vector3,this.rotationMatrix=new o.Matrix4,this.normal=new o.Vector3,this.view=new o.Vector3,this.lookAtPosition=new o.Vector3,this.target=new o.Vector3,this.tempQuaternion=new o.Vector4,this.virtualCamera=new o.PerspectiveCamera,this.reflectorPlane=new o.Plane,this.clipPlane=new o.Vector4,e={minFilter:o.LinearFilter,magFilter:o.LinearFilter,type:o.HalfFloatType,encoding:this.runScene.assetsEx.get().renderer.outputEncoding},this.glRT1=new o.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new o.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new o.Uniform(this.glRT1.texture),this.tDiffuseBlur=new o.Uniform(this.glRT2.texture),this.hBlurPass=new Z(ao),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 Z(so),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=co.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",co.vertexShader),e.fragmentShader=co.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",co.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 co={uniforms:{opacity:new o.Uniform(1),transparent:new o.Uniform(!1),roughness:new o.Uniform(1),metalness:new o.Uniform(.6),resolution:new o.Uniform(1024),blurSize:new o.Uniform(1024),mirror:new o.Uniform(0),mixBlur:new o.Uniform(10),mixStrength:new o.Uniform(2),mixContrast:new o.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 ho{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=xo(n,new po(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=>!ho.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.insertFresnelShader(),i.userData.tools=this.tools,i},toNormal:e=>{const t=xo(e,bo()),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=fo.uniforms;return Object.keys(n).filter((e=>!ho.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){console.log("Fresnel Create");const t=new po(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 no({target:e,typeList:[...t],newVal:r}).execute())}}ho.TextureNames=["envMap"];class po extends o.MeshPhysicalMaterial{constructor(e,t,r){if(e?super(e):(super(),this.emissive=new o.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 o.Uniform(t.fresnelBias),this.fresnelScale=new o.Uniform(t.fresnelScale),this.fresnelPower=new o.Uniform(t.fresnelPower)):(this.fresnelBias=new o.Uniform(fo.uniforms.fresnelBias.value),this.fresnelScale=new o.Uniform(fo.uniforms.fresnelScale.value),this.fresnelPower=new o.Uniform(fo.uniforms.fresnelPower.value)),!this.cubeCamera){const e=new o.WebGLCubeRenderTarget(2048);e.texture.mapping=o.CubeRefractionMapping,this.cubeCamera=new o.CubeCamera(.1,1e5,e),this.runScene.assetsEx.scene.add(this.cubeCamera),console.log("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,fo.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,fo.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,fo.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,fo.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 fo={uniforms:{fresnelBias:new o.Uniform(0),fresnelScale:new o.Uniform(1),fresnelPower:new o.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 "},mo=class extends di{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),this.runScene.optionsEx.cb.model.changeName.cb({model:this.target,name:e=t||e})):"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)}},vo={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},go=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];class yo{constructor(e){this.defMaterialMap={BaseMaterial:eo,SpriteMaterial:So,FakeInterior:io,Reflector:lo,Fresnel:ho},this.defMaterial=bo(),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:eo,SpriteMaterial:So,FakeInterior:new io(e),Reflector:new lo(e),Fresnel:new ho(e)}}add(e,t,r){this.runScene.uniqueEx.material.add(e,t,r)}create(){var e=new o.MeshStandardMaterial;return this.add(e),e}clone(e){const t=e.clone();return t.userData.id=(0,i.getId)(),t}setNormal(e,t=!0){return e=new fi(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&&this.runScene.textureEx.toThree(e.newVal),new fi(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 mo({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,Fe.js)(vo,((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,Fe.js)(e,((e,r)=>{var n,i,o,a,s;void 0!==vo[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&&eo.isDefval(e)}}const bo=()=>{const e=new o.MeshStandardMaterial;return e.userData.id=(0,i.getId)(),e},xo=(e,t)=>(go.map((r=>{const n=e[r];"object"==typeof n&&(t[r]=n.clone()),t[r]=n})),t),wo=e=>{var t=e.userData.textures||pi.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t};class So{static create(){const e=new o.SpriteMaterial;return e.userData.tools=this.tools,e}}So.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=Ro("Box");return t.userData.normal={type:"MySpriteMaterial"},So.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=Ro("Sprite");return So.modelTools.merge(e,r),r.material=e.material,r}},So.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=xo(r,So.create());return t.map((e=>{var{type:e,texture:t}=e;n[e]=t})),n},toNormal:e=>{const t=xo(e,bo());return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:So.tools.type},textures:So.tools.getTextures(e)}),t},clone:function(e,t){return e}};class To{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 Mo extends To{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 _o=class extends di{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 Eo extends To{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 Po=class extends di{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){console.log(e,"data"),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(){console.log(1,"1"),this._execute(this.newV3)}};class ko{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}=Yi({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 Mo({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 Eo({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 Ki().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 _o({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 Po({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 mo({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 mo({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(Ro(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new o.MeshBasicMaterial,t=new o.SphereGeometry(.7,150,150);return new o.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 no({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const n=t||new o.Group,i=[];i.push(new Mo({model:n,runScene:this.runScene,parent:r||this.runScene.assetsEx.get().scene}).execute()),e instanceof Array?i.push(...e.map((e=>new _o({target:e,oldParent:e.parent,newParent:n,runScene:this.runScene}).execute()))):i.push(new _o({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,Ji.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 _o({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 Eo({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===Ki().model.deepFindParentByUuid(n,t)&&n.uuid!==e.uuid&&i.push(n):n.uuid!==e.uuid&&i.push(n)}))}));var o=i.map((e=>new mo({target:e,info:"visible",newVal:!1,runScene:this.runScene,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(o),Ki().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 mo({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 Eo({runScene:this.runScene,model:e,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(r)}}const Ro=e=>{if($i.includes(e)){const t=Ki().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=So.tools),t}throw TypeError("")};class Oo{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 Co{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;r.md5=t.userData.md5,r.id=t.userData.id}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 Lo{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 o.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 Do{constructor(e,t){this.helperModels=[],this.runScene=t,this.type=e,this.material=new Co(t),this.scene=new Lo(t)}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,Fe.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}),console.log(e,"json"),"scene"===this.type&&(yield this.scene.done(e)),yield this.material.done(e)}))}}var Ao=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 Io{constructor(e,t){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.modelType={Sprite:So},this.type=e,this.runScene=t}parse(e){return Ao(this,void 0,void 0,(function*(){const t=new o.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 o.Texture||t.environment instanceof o.Texture){this.runScene.bloom.glow.setUpdate(!1),t.userData.ex={};var{background:r,environment:n}=t;this.runScene.bloom.glow.setUpdate(!0);const a=this.runScene.modelEx.create(),s=bo();a.material=s,e.add(a),e=(0,i.getId)(),t.userData.ex.materialId=e,s.userData.id=e,this.materialMap[e]={material:s},r instanceof o.Texture&&303===(s.map=r).mapping&&(t.userData.ex.backgroundMapping=303),n instanceof o.Texture&&(s.envMap=n)}}_processMaterial(e){if(e.material){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))):(console.log(e.material.userData.id,"material.userData.id"),r=t||this.runScene.optionsEx.exporterOptions.notMaterial?this.runScene.materialEx.defMaterial:this.runScene.materialEx.toNromal(e.material),e.material=r,console.log(r.userData.id,"material.userData.id"),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,Fe.js)(this.materialMap,((e,t)=>Ao(this,void 0,void 0,(function*(){var e=t.material,r=wo(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 Ao(this,void 0,void 0,(function*(){return e.map((e=>{const{type:r,texture:n}=e;this.runScene.uniqueEx.texture.add(n),t[r]=null;var{isSame:e,texture:i}=this.mergeSame(n);if(e)this.runScene.textureEx.dispose(n);else if(!this.json.textureMap[n.userData.id]){var o,{format:a,repeat:s,center:l,rotation:u,offset:c}=n;const e={format:a};this.runScene.modelEx.isNavieV2(s,1)||(({x:a,y:o}=s),e.repeat=a===o?a:s),this.runScene.modelEx.isNavieV2(l,0)||(({x:o,y:a}=l),e.center=o===a?o:l),this.runScene.modelEx.isNavieV2(c,0)||(({x:s,y:a}=c),e.offset=s===a?s:c),0!==u&&(e.rotation=u),this.json.textureMap[n.userData.id]=e}"normalMap"!==r||n.userData.isNormalMap||(n.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[r]=i.userData.id}))}))}setMultipMaterial(e,t){const r=this.runScene.modelEx.create(),n=bo();r.material=n,e.add(r);for(const e of hi){if(!t.length)return;var i=t.pop();if(!i)return;n[e]=this.textureMap[i].texture}t.length&&this.setMultipMaterial(e,t)}}function jo(){jo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=(d="function"==typeof Symbol?Symbol:{}).iterator||"@@iterator",i=d.asyncIterator||"@@asyncIterator",o=d.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 d,f,m=(a(d={},n,(function(){return this})),(f=(f=Object.getPrototypeOf)&&f(f(w([]))))&&f!==t&&r.call(f,n)&&(d=f),p.prototype=c.prototype=Object.create(d));function v(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function g(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"==Bo(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 y(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(y,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(g.prototype),a(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(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 Uo(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 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 No(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fo(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 zo(e,t,r){t&&Fo(e.prototype,t),r&&Fo(e,r),Object.defineProperty(e,"prototype",{writable:!1})}var Vo=function(){function e(){No(this,e),this.pluginCallbacks=[],this.register((function(e){return new ta(e)})),this.register((function(e){return new ra(e)})),this.register((function(e){return new na(e)})),this.register((function(e){return new oa(e)})),this.register((function(e){return new aa(e)})),this.register((function(e){return new ia(e)}))}return zo(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"===Bo(r)&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),n=r);for(var i=new ea,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}(),Ho=5121,Go=5123,Wo=(r=9728,9729),Xo=9984,qo=9986,Yo={},Zo=(Yo[o.NearestFilter]=r,Yo[o.NearestMipmapNearestFilter]=Xo,Yo[o.NearestMipmapLinearFilter]=qo,Yo[o.LinearFilter]=Wo,Yo[o.LinearMipmapNearestFilter]=9985,Yo[o.LinearMipmapLinearFilter]=9987,Yo[o.ClampToEdgeWrapping]=33071,Yo[o.RepeatWrapping]=10497,Yo[o.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function Qo(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Ko(e){return 4*Math.ceil(e/4)}function Jo(e,t){var r=1<arguments.length&&void 0!==t?t:0,n=Ko(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 $o=null,ea=function(){function e(){No(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 zo(e,[{key:"setPlugins",value:function(e){this.plugins=e}},{key:"write",value:(t=jo().mark((function e(t,r,n){var i,o,a,s,l,u,c;return jo().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=Jo(u.result),t=new DataView(new ArrayBuffer(8)),n=(t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0),Jo(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){Uo(o,n,i,a,s,"next",e)}function s(e){Uo(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 o.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 o.Vector3,i=0,a=r.count;i<a;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),a=document.createElement("canvas"),s=(a.width=e,a.height=i,a.getContext("2d")),l=(s.fillStyle="#ffffff",s.fillRect(0,0,e,i),s.getImageData(0,0,e,i));if(t){s.drawImage(t,0,0,e,i);for(var u=s.getImageData(0,0,e,i).data,c=0;c<u.length;c+=4)l.data[c]=u[c]}if(r){s.drawImage(r,0,0,e,i);for(var h=s.getImageData(0,0,e,i).data,p=1;p<h.length;p+=4)l.data[p]=h[p]}if(n){s.drawImage(n,0,0,e,i);for(var d=s.getImageData(0,0,e,i).data,f=2;f<d.length;f+=4)l.data[f]=d[f]}return s.putImageData(l,0,0),new o.Texture(a)}}},{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===Ho?1:t===Go?2:4,Ko(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===Go?l.setUint16(u,p,!0):t===Ho&&l.setUint8(u,p),u+=o}var d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};return void 0!==i&&(d.target=i),34962===i&&(d.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(d),{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=Jo(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=Go;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");i=Ho}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,a=this,s=a.cache,l=a.json,u=a.options,c=a.pending,h=(s.images.has(e)||s.images.set(e,{}),s=s.images.get(e),null==(h=n.userData)?void 0:h.blob),p=n.userData.isNormalMap,d=(i=a.options.myOptions.optionsEx.exporterOptions.compressTexture)?"image/webp":"image/png";if(void 0!==s[(i&&(h=!!p),i=d+":flipY/"+r.toString())])return s[i];l.images||(l.images=[]);var f={mimeType:d};if(!0===u.binary&&h)c.push(new Promise((function(e){a.processBufferViewImage(n.userData.blob).then((function(t){f.bufferView=t,e()}))})));else if(u.embedImages){var m=$o=$o||document.createElement("canvas");if((m.width=Math.min(e.width,u.maxTextureSize),m.height=Math.min(e.height,u.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!==o.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);for(var v=new Uint8ClampedArray(e.height*e.width*4),g=0;g<v.length;g+=4)v[g+0]=e.data[g+0],v[g+1]=e.data[g+1],v[g+2]=e.data[g+2],v[g+3]=e.data[g+3];p.putImageData(new ImageData(v,e.width,e.height),0,0)}!0===u.binary?c.push(new Promise((function(e){m.toBlob((function(t){a.processBufferViewImage(t).then((function(t){f.bufferView=t,e()}))}),d)}))):f.uri=m.toDataURL(d)}else f.uri=e.src;return r=l.images.push(f)-1,s[i]=r}},{key:"processSampler",value:function(e){var t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:Yo[e.magFilter],minFilter:Yo[e.minFilter],wrapS:Yo[e.wrapS],wrapT:Yo[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:{}},a=(Qo((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."),a=e.color.toArray().concat([e.opacity])),[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=a),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(a={index:this.processTexture(null)},this.applyTextureTransform(a,e.metalnessMap||e.roughnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=a),e.map&&(a={index:this.processTexture(e.map)},this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a),e.emissive&&(a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),1<(n=Math.max(a.r,a.g,a.b))&&(a.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<n&&(i.emissiveFactor=a.toArray()),e.emissiveMap&&(n={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(n,e.emissiveMap),i.emissiveTexture=n)),e.normalMap&&(a={index:this.processTexture(e.normalMap)},e.normalScale&&1!==e.normalScale.x&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a),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===o.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,a),a}},{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,a=e.material.length;i<a;i++)n.push(e.material[i].uuid);else n.push(e.material.uuid);var s=n.join(":");if(t.meshes.has(s))return t.meshes.get(s);var l=e.geometry,u=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4;if(!0!==l.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");var c,h,p,d={},f={},m=[],v=[],g={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},y=l.getAttribute("normal"),b=(void 0===y||this.isNormalizedNormalAttribute(y)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),l.setAttribute("normal",this.createNormalizedNormalAttribute(y))),null);for(h in l.attributes)"morph"!==h.slice(0,5)&&(c=l.attributes[h],h=g[h]||h.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(h)||(h="_"+h),t.attributes.has(this.getUID(c))?f[h]=t.attributes.get(this.getUID(c)):(b=null,p=c.array,"JOINTS_0"!==h||p instanceof Uint16Array||p instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=new o.BufferAttribute(new Uint16Array(p),c.itemSize,c.normalized)),null!==(p=this.processAccessor(b||c,l))&&(f[h]=p,t.attributes.set(this.getUID(c),p))));if(void 0!==y&&l.setAttribute("normal",y),0===Object.keys(f).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 M=0;M<e.morphTargetInfluences.length;++M){var _,E={},P=!1;for(_ in l.morphAttributes)if("position"!==_&&"normal"!==_)P||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),P=!0);else{var k=l.morphAttributes[_][M],R=_.toUpperCase(),O=l.attributes[_];if(t.attributes.has(this.getUID(k)))E[R]=t.attributes.get(this.getUID(k));else{var C=k.clone();if(!l.morphTargetsRelative)for(var L=0,D=k.count;L<D;L++)C.setXYZ(L,k.getX(L)-O.getX(L),k.getY(L)-O.getY(L),k.getZ(L)-O.getZ(L));E[R]=this.processAccessor(C,l),t.attributes.set(this.getUID(O),E[R])}}v.push(E),x.push(e.morphTargetInfluences[M]),void 0!==e.morphTargetDictionary&&w.push(S[M])}d.weights=x,0<w.length&&(d.extras={},d.extras.targetNames=w)}if((y=Array.isArray(e.material))&&0===l.groups.length)return null;for(var A=y?e.material:[e.material],I=y?l.groups:[{materialIndex:0,start:void 0,count:void 0}],j=0,U=I.length;j<U;j++){var B={mode:u,attributes:f},N=(this.serializeUserData(l,B),0<v.length&&(B.targets=v),null!==l.index&&(N=this.getUID(l.index),void 0===I[j].start&&void 0===I[j].count||(N+=":"+I[j].start+":"+I[j].count),t.attributes.has(N)?B.indices=t.attributes.get(N):(B.indices=this.processAccessor(l.index,l,I[j].start,I[j].count),t.attributes.set(N,B.indices)),null===B.indices&&delete B.indices),this.processMaterial(A[I[j].materialIndex]));null!==N&&(B.material=N),m.push(B)}return d.primitives=m,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,d)})),y=r.meshes.push(d)-1,t.meshes.set(s,y),y}},{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:o.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=Vo.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks),a=[],s=[],l=0;l<i.length;++l){var u=i[l],c=o.PropertyBinding.parseTrackName(u.name),h=o.PropertyBinding.findNode(t,c.nodeName),p=Zo[c.propertyName];if(!(h="bones"===c.objectName?!0===h.isSkinnedMesh?h.skeleton.getBoneByName(c.objectIndex):void 0:h)||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;c=u.values.length/u.times.length;var d=void(p===Zo.morphTargetInfluences&&(c/=h.morphTargetInfluences.length));!0===u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",c/=3):d=u.getInterpolation()===o.InterpolateDiscrete?"STEP":"LINEAR",s.push({input:this.processAccessor(new o.BufferAttribute(u.times,1)),output:this.processAccessor(new o.BufferAttribute(u.values,c)),interpolation:d}),a.push({sampler:s.length-1,target:{node:n.get(h),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:s,channels:a}),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 a=e.skeleton.bones[0];if(void 0===a)return null;for(var s=[],l=new Float32Array(16*i.bones.length),u=new o.Matrix4,c=0;c<i.bones.length;++c)s.push(r.get(i.bones[c])),u.copy(i.boneInverses[c]),u.multiply(e.bindMatrix).toArray(l,16*c);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new o.BufferAttribute(l,16)),joints:s,skeleton:r.get(a)}),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(),Qo(r,[0,0,0,1])||(a.rotation=r),Qo(h,[0,0,0])||(a.translation=h),Qo(t,[1,1,1])||(a.scale=t)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===Qo(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 o.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)})),[]),a=0;a<e.length;a++)e[a]instanceof o.Scene?this.processScene(e[a]):i.push(e[a]);1===i.length?(t=i[0],["Group","Object3D"].includes(t.type)||((r=new o.Group).name="glb_model",r.add(t),t=r),this.processScene(t)):1<i.length&&this.processObjects(i);for(var s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(var l=0;l<n.animations.length;++l)this.processAnimation(n.animations[l],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}(),ta=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_lights_punctual"}return zo(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}(),ra=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_materials_unlit"}return zo(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}(),na=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_materials_pbrSpecularGlossiness"}return zo(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}(),ia=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_materials_clearcoat"}return zo(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}(),oa=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_materials_transmission"}return zo(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}(),aa=function(){function e(t){No(this,e),this.writer=t,this.name="KHR_materials_volume"}return zo(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}(),sa=(Vo.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,a=0;a<i.length;++a){var s=i[a],l=o.PropertyBinding.parseTrackName(s.name),u=o.PropertyBinding.findNode(t,l.nodeName);if("morphTargetInfluences"!==l.propertyName||void 0===l.propertyIndex)r.push(s);else{if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.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."),(s=s.clone()).setInterpolation(o.InterpolateLinear)}var c=u.morphTargetInfluences.length,h=u.morphTargetDictionary[l.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);var p=void 0;if(void 0===n[u.uuid]){for(var d=new((p=s.clone()).ValueBufferType)(c*p.times.length),f=0;f<p.times.length;f++)d[f*c+h]=p.values[f];p.name=(l.nodeName||"")+".morphTargetInfluences",p.values=d,n[u.uuid]=p,r.push(p)}else{var m=s.createInterpolant(new s.ValueBufferType(1));p=n[u.uuid];for(var v=0;v<p.times.length;v++)p.values[v*c+h]=m.evaluate(p.times[v]);for(var g=0;g<s.times.length;g++){var y=this.insertKeyframe(p,s.times[g]);p.values[y*c+h]=s.values[g]}}}}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 la{constructor(e){this._gltf=new Vo,this.options=new Oo,this.runScene=e}getArrayBuffer(e=this.runScene.sceneEx.getClear(),t="scene"){return sa(this,void 0,void 0,(function*(){const r=new Do(t,this.runScene),n=new Io(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 sa(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,Ve.downloadFile)(new Blob([t]),"scene.glb")}))}model(){return sa(this,void 0,void 0,(function*(){const e=this.runScene.modelEx.select;var t;e&&(t=yield this.getArrayBuffer(e.clone(),"model"),(0,Ve.downloadFile)(new Blob([t]),"scene.glb"))}))}material(){var e;return sa(this,void 0,void 0,(function*(){var t=null==(e=this.runScene.modelEx.select)?void 0:e.material;if(t){const e=Ro("Box");e.material=t,t=yield this.getArrayBuffer(e,"material"),(0,Ve.downloadFile)(new Blob([t]),"material.glb")}}))}scene(){return sa(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,Ve.downloadFile)(new Blob([e]),"scene.glb")}))}}class ua{constructor(e){this.runScene=e,this.gltf=new la(e)}}var ca={},ha=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},pa=function(e){return new Worker(e)};try{URL.revokeObjectURL(ha(""))}catch(Ma){ha=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},pa=function(e){return new Worker(e,{type:"module"})}}for(var da=Uint8Array,fa=Uint16Array,ma=Uint32Array,va=new da([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]),ga=new da([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]),ya=new da([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ba=(r=function(e,t){for(var r=new fa(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new ma(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]},(Xo=r(va,2))[0]),xa=Xo[1],wa=(ba[28]=258,xa[258]=28,qo=r(ga,0))[0],Sa=qo[1],Ta=new fa(32768),Ma=0;Ma<32768;++Ma){var _a=(43690&Ma)>>>1|(21845&Ma)<<1;Ta[Ma]=((65280&(_a=(61680&(_a=(52428&_a)>>>2|(13107&_a)<<2))>>>4|(3855&_a)<<4))>>>8|(255&_a)<<8)>>>1}var Ea=function(e,t,r){for(var n=e.length,i=0,o=new fa(t);i<n;++i)++o[e[i]-1];var a=new fa(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(r){var s=new fa(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[Ta[h]>>>l]=u}else for(s=new fa(n),i=0;i<n;++i)e[i]&&(s[i]=Ta[a[e[i]-1]++]>>>15-e[i]);return s},Pa=new da(288);for(Ma=0;Ma<144;++Ma)Pa[Ma]=8;for(Ma=144;Ma<256;++Ma)Pa[Ma]=9;for(Ma=256;Ma<280;++Ma)Pa[Ma]=7;for(Ma=280;Ma<288;++Ma)Pa[Ma]=8;var ka=new da(32);for(Ma=0;Ma<32;++Ma)ka[Ma]=5;function Ra(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 Oa(e,t,r,n,i){var o,a=as(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 Ca(e,t){return gs(e,t)+4294967296*gs(e,t+4)}var La=Ea(Pa,9,0),Da=Ea(Pa,9,1),Aa=Ea(ka,5,0),Ia=Ea(ka,5,1),ja=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Ua=function(e,t,r){var n=t/8|0;return(e[n]|e[1+n]<<8)>>(7&t)&r},Ba=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},Na=function(e){return(e/8|0)+(7&e&&1)},Fa=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof fa?fa:e instanceof ma?ma:da)(r-(t=null==t||t<0?0:t));return n.set(e.subarray(t,r)),n},za=function(e,t,r){var n=e.length;if(!n||r&&!r.l&&n<5)return t||new da(0);function i(e){var r=t.length;r<e&&((r=new da(Math.max(2*r,e))).set(t),t=r)}var o=!t||r,a=!r||r.i,s=(r=r||{},t=t||new da(3*n),r.f||0),l=r.p||0,u=r.b||0,c=r.l,h=r.d,p=r.m,d=r.n,f=8*n;do{if(!c){r.f=s=Ua(e,l,1);var m=Ua(e,l+1,3);if(l+=3,!m){var v=e[(_=Na(l)+4)-4]|e[_-3]<<8;if(n<(S=_+v)){if(a)throw"unexpected EOF";break}o&&i(u+v),t.set(e.subarray(_,S),u),r.b=u+=v,r.p=l=8*S;continue}if(1==m)c=Da,h=Ia,p=9,d=5;else{if(2!=m)throw"invalid block type";v=Ua(e,l,31)+257;for(var g=Ua(e,l+10,15)+4,y=v+Ua(e,l+5,31)+1,b=(l+=14,new da(y)),x=new da(19),w=0;w<g;++w)x[ya[w]]=Ua(e,l+3*w,7);l+=3*g;var S,T=(1<<(S=ja(x)))-1,M=Ea(x,S,1);for(w=0;w<y;){var _,E=M[Ua(e,l,T)];if(l+=15&E,(_=E>>>4)<16)b[w++]=_;else{var P=0,k=0;for(16==_?(k=3+Ua(e,l,3),l+=2,P=b[w-1]):17==_?(k=3+Ua(e,l,7),l+=3):18==_&&(k=11+Ua(e,l,127),l+=7);k--;)b[w++]=P}}m=b.subarray(0,v);var R=b.subarray(v);p=ja(m),d=ja(R),c=Ea(m,p,1),h=Ea(R,d,1)}if(f<l){if(a)throw"unexpected EOF";break}}o&&i(u+131072);for(var O=(1<<p)-1,C=(1<<d)-1,L=l;;L=l){var D=(P=c[Ba(e,l)&O])>>>4;if(f<(l+=15&P)){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(D<256)t[u++]=D;else{if(256==D){L=l,c=null;break}var A,I=D-254,j=(264<D&&(A=va[w=D-257],I=Ua(e,l,(1<<A)-1)+ba[w],l+=A),(D=h[Ba(e,l)&C])>>>4);if(!D)throw"invalid distance";if(l+=15&D,R=wa[j],3<j&&(A=ga[j],R+=Ba(e,l)&(1<<A)-1,l+=A),f<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=L,r.b=u,c&&(s=1,r.m=p,r.d=h,r.n=d)}while(!s);return u==t.length?t:Fa(t,0,u)},Va=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8},Ha=function(e,t,r){var n=t/8|0;e[n]|=r<<=7&t,e[1+n]|=r>>>8,e[2+n]|=r>>>16},Ga=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[Ka,0];if(1==i)return(m=new da(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 fa(h+1),d=Wa(r[u-1],p,0);if(t<d){n=0;var f=0,m=d-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 g=o[n].s;if(!(p[g]>t))break;f+=v-(1<<d-p[g]),p[g]=t}for(f>>>=m;0<f;){var y=o[n].s;p[y]<t?f-=1<<t-p[y]++-1:++n}for(;0<=n&&f;--n){var b=o[n].s;p[b]==t&&(--p[b],++f)}d=t}return[new da(p),d]},Wa=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},Xa=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new fa(++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]},qa=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},Ya=function(e,t,r){var n=r.length,i=Na(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)},Za=function(e,t,r,n,i,o,a,s,l,u,c){Va(t,c++,r),++i[256];for(var h=(r=Ga(i,15))[0],p=(r=r[1],(d=Ga(o,15))[0]),d=d[1],f=(m=Xa(h))[0],m=m[1],v=(g=Xa(p))[0],g=g[1],y=new fa(19),b=0;b<f.length;++b)y[31&f[b]]++;for(b=0;b<v.length;++b)y[31&v[b]]++;for(var x=(w=Ga(y,7))[0],w=w[1],S=19;4<S&&!x[ya[S-1]];--S);var T,M=u+5<<3,_=qa(i,Pa)+qa(o,ka)+a;if(i=qa(i,h)+qa(o,p)+a+14+3*S+qa(y,x)+(2*y[16]+3*y[17]+7*y[18]),M<=_&&M<=i)return Ya(t,c,e.subarray(l,l+u));if(Va(t,c,1+(i<_)),c+=2,i<_){var E=Ea(h,r,0),P=h,k=Ea(p,d,0),R=p,O=Ea(x,w,0);for(Va(t,c,m-257),Va(t,c+5,g-1),Va(t,c+10,S-4),c+=14,b=0;b<S;++b)Va(t,c+3*b,x[ya[b]]);c+=3*S;for(var C=[f,v],L=0;L<2;++L){var D=C[L];for(b=0;b<D.length;++b){var A=31&D[b];Va(t,c,O[A]),c+=x[A],15<A&&(Va(t,c,D[b]>>>5&127),c+=D[b]>>>12)}}}else E=La,P=Pa,k=Aa,R=ka;for(b=0;b<s;++b)255<n[b]?(A=n[b]>>>18&31,Ha(t,c,E[A+257]),c+=P[A+257],7<A&&(Va(t,c,n[b]>>>23&31),c+=va[A]),T=31&n[b],Ha(t,c,k[T]),c+=R[T],3<T&&(Ha(t,c,n[b]>>>5&8191),c+=ga[T])):(Ha(t,c,E[n[b]]),c+=P[n[b]]);return Ha(t,c,E[256]),c+P[256]},Qa=new ma([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ka=new da(0),Ja=function(e,t,r,n,i,o){var a=e.length,s=new da(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?Ya(l,u,e.subarray(c,h)):(l[c]=o,Ya(l,u,e.subarray(c,a)))}else{for(var p=(t=Qa[t-1])>>>13,d=8191&t,f=(1<<r)-1,m=new fa(32768),v=new fa(1+f),g=Math.ceil(r/3),y=2*g,b=function(t){return(e[t]^e[t+1]<<g^e[t+2]<<y)&f},x=new ma(25e3),w=new fa(288),S=new fa(32),T=0,M=0,_=(c=0,0),E=0,P=0;c<a;++c){var k=b(c),R=32767&c,O=v[k];if(m[R]=O,v[k]=R,E<=c){var C=a-c;if((7e3<T||24576<_)&&423<C){u=Za(e,l,0,x,w,S,M,_,P,c-P,u),_=T=M=0,P=c;for(var L=0;L<286;++L)w[L]=0;for(L=0;L<30;++L)S[L]=0}var D=2,A=0,I=d,j=R-O&32767;if(2<C&&k==b(c-j))for(var U=Math.min(p,C)-1,B=Math.min(32767,c),N=Math.min(258,C);j<=B&&--I&&R!=O;){if(e[c+D]==e[c+D-j]){for(var F=0;F<N&&e[c+F]==e[c+F-j];++F);if(D<F){if(A=j,U<(D=F))break;var z=Math.min(j,F-2),V=0;for(L=0;L<z;++L){var H=c-j+L+32768&32767,G=H-m[H]+32768&32767;V<G&&(V=G,O=H)}}}j+=(R=O)-(O=m[R])+32768&32767}A?(x[_++]=268435456|xa[D]<<18|Sa[A],k=31&xa[D],C=31&Sa[A],M+=va[k]+ga[C],++w[257+k],++S[C],E=c+D,++T):(x[_++]=e[c],++w[e[c]])}}u=Za(e,l,o,x,w,S,M,_,P,c-P,u),!o&&7&u&&(u=Ya(l,u+1,Ka))}return Fa(s,0,n+Na(u)+i)},$a=function(){for(var e=new ma(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),es=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=$a[255&r^t[n]]^r>>>8;e=r},d:function(){return~e}}},ts=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}}},rs=function(e,t,r,n,i){return Ja(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)},ns=function(e,t){var r,n={};for(r in e)n[r]=e[r];for(r in t)n[r]=t[r];return n},is=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]},os=[],as=function(e,t,r,n){var i;if(!os[r]){for(var o="",a={},s=e.length-1,l=0;l<s;++l)o=(i=is(e[l],o,a))[0],a=i[1];os[r]=is(e[s],o,a)}var u=ns({},os[r][1]);return function(e,t,r,n,i){return(t=pa(ca[t]||(ca[t]=ha(e)))).onerror=function(e){return i(e.error,null)},t.onmessage=function(e){return i(null,e.data)},t.postMessage(r,n),t}(os[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 da||e[t]instanceof fa||e[t]instanceof ma)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(u),n)},ss=function(){return[da,fa,ma,va,ga,ya,ba,wa,Da,Ia,Ta,Ea,ja,Ua,Ba,Na,Fa,za,Ds,ds,fs]},ls=function(){return[da,fa,ma,va,ga,ya,xa,Sa,La,Pa,Aa,ka,Ta,Qa,Ka,Ea,Va,Ha,Ga,Wa,Xa,qa,Ya,Za,Na,Fa,Ja,rs,Rs,ds]},us=function(){return[bs,Ss,ys,es,$a]},cs=function(){return[xs,ws]},hs=function(){return[Ts,ys,ts]},ps=function(){return[Ms]},ds=function(e){return postMessage(e,[e.buffer])},fs=function(e){return e&&e.size&&new da(e.size)},ms=function(e,t,r,n,i,o){var a=as(r,n,i,(function(e,t){a.terminate(),o(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},vs=function(e,t){return e[t]|e[t+1]<<8},gs=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ys=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},bs=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&&ys(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)}},xs=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)},ws=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Ss=function(e){return 10+(e.filename&&e.filename.length+1||0)},Ts=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)},Ms=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 _s(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var Es=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(rs(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}(),Ps=function(e,t){Oa([ls,function(){return[Ra,Es]}],this,_s.call(this,e,t),(function(e){e=new Es(e.data),onmessage=Ra(e)}),6)};function ks(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ls],(function(e){return ds(Rs(e.data[0],e.data[1]))}),0,r)}function Rs(e,t){return rs(e,t||{},0,0)}var Os=function(){function e(e){this.s={},this.p=new da(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 da(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=za(this.p,this.o,this.s);this.ondata(Fa(t,e,this.s.b),this.d),this.o=Fa(t,this.s.b-32768),this.s.b=this.o.length,this.p=Fa(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),Cs=function(e){this.ondata=e,Oa([ss,function(){return[Ra,Os]}],this,0,(function(){var e=new Os;onmessage=Ra(e)}),7)};function Ls(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ss],(function(e){return ds(Ds(e.data[0],fs(e.data[1])))}),1,r)}function Ds(e,t){return za(e,t)}var As=function(){function e(e,t){this.c=es(),this.l=0,this.v=1,Es.call(this,e,t)}return e.prototype.push=function(e,t){Es.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=rs(e,this.o,this.v&&Ss(this.o),t&&8,!t),this.v&&(bs(e,this.o),this.v=0),t&&(ys(e,e.length-8,this.c.d()),ys(e,e.length-4,this.l)),this.ondata(e,t)},e}(),Is=function(e,t){Oa([ls,us,function(){return[Ra,Es,As]}],this,_s.call(this,e,t),(function(e){e=new As(e.data),onmessage=Ra(e)}),8)};function js(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ls,us,function(){return[Us]}],(function(e){return ds(Us(e.data[0],e.data[1]))}),2,r)}function Us(e,t){t=t||{};var r=es(),n=e.length,i=(r.p(e),e=rs(e,t,Ss(t),8)).length;return bs(e,t),ys(e,i-8,r.d()),ys(e,i-4,n),e}var Bs=function(){function e(e){this.v=1,Os.call(this,e)}return e.prototype.push=function(e,t){if(Os.prototype.e.call(this,e),this.v){if((e=3<this.p.length?xs(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)}Os.prototype.c.call(this,t)},e}(),Ns=function(e){this.ondata=e,Oa([ss,cs,function(){return[Ra,Os,Bs]}],this,0,(function(){var e=new Bs;onmessage=Ra(e)}),9)};function Fs(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ss,cs,function(){return[zs]}],(function(e){return ds(zs(e.data[0]))}),3,r)}function zs(e,t){return za(e.subarray(xs(e),-8),t||new da(ws(e)))}var Vs=function(){function e(e,t){this.c=ts(),this.v=1,Es.call(this,e,t)}return e.prototype.push=function(e,t){Es.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=rs(e,this.o,this.v&&2,t&&4,!t),this.v&&(Ts(e,this.o),this.v=0),t&&ys(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),Hs=function(e,t){Oa([ls,hs,function(){return[Ra,Es,Vs]}],this,_s.call(this,e,t),(function(e){e=new Vs(e.data),onmessage=Ra(e)}),10)};function Gs(e,t){t=t||{};var r=ts();return r.p(e),e=rs(e,t,2,4),Ts(e,t),ys(e,e.length-4,r.d()),e}var Ws=function(){function e(e){this.v=1,Os.call(this,e)}return e.prototype.push=function(e,t){if(Os.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)}Os.prototype.c.call(this,t)},e}(),Xs=function(e){this.ondata=e,Oa([ss,ps,function(){return[Ra,Os,Ws]}],this,0,(function(){var e=new Ws;onmessage=Ra(e)}),11)};function qs(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ms(e,t,[ss,ps,function(){return[Ys]}],(function(e){return ds(Ys(e.data[0],fs(e.data[1])))}),5,r)}function Ys(e,t){return za((Ms(e),e.subarray(2,-4)),t)}var Zs=function(){function e(e){this.G=Bs,this.I=Os,this.Z=Ws,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 da(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}(),Qs=function(){function e(e){this.G=Ns,this.I=Cs,this.Z=Xs,this.ondata=e}return e.prototype.push=function(e,t){Zs.prototype.push.call(this,e,t)},e}(),Ks=function e(t,r,n,i){for(var o in t){var a=t[o];o=r+o,a instanceof da?n[o]=[a,i]:Array.isArray(a)?n[o]=[a[0],ns(i,a[1])]:e(a,o+"/",n,i)}},Js="undefined"!=typeof TextEncoder&&new TextEncoder,$s="undefined"!=typeof TextDecoder&&new TextDecoder,el=0;try{$s.decode(Ka,{stream:!0}),el=1}catch(Ma){}var tl=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,Fa(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)}},rl=function(){function e(e){this.ondata=e,el?this.t=new TextDecoder:this.p=Ka}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 da(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=tl(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}(),nl=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(il(e),this.d=t||!1)},e}();function il(e,t){if(t){for(var r=new da(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(Js)return Js.encode(e);var i=e.length,o=new da(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 da(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 Fa(o,0,a)}function ol(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($s)return $s.decode(e);var i=(t=tl(e))[0];if(t[1].length)throw"invalid utf-8 data";return i}function al(e){return 1==e?3:e<6?2:9==e?1:0}var sl=function(e,t){return t+30+vs(e,t+26)+vs(e,t+28)},ll=function(e,t,r){var n=vs(e,t+28),i=ol(e.subarray(t+46,t+46+n),!(2048&vs(e,t+8))),o=(n=t+46+n,gs(e,t+20)),a=(o=(r=r&&4294967295==o?ul(e,n):[o,gs(e,t+24),gs(e,t+42)])[0],r[1]);return r=r[2],[vs(e,t+10),o,a,i,n+vs(e,t+30)+vs(e,t+32),r]},ul=function(e,t){for(;1!=vs(e,t);t+=4+vs(e,t+2));return[Ca(e,t+12),Ca(e,t+4),Ca(e,t+20)]},cl=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},hl=function(e,t,r,n,i,o,a,s){var l=n.length,u=r.extra,c=s&&s.length,h=cl(u),p=(ys(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(ys(e,t,p<<25|i.getMonth()+1<<21|i.getDate()<<16|i.getHours()<<11|i.getMinutes()<<5|i.getSeconds()>>>1),t+=4,null!=o&&(ys(e,t,r.crc),ys(e,t+4,o),ys(e,t+8,r.size)),ys(e,t+12,l),ys(e,t+14,h),t+=16,null!=a&&(ys(e,t,c),ys(e,t+6,r.attrs),ys(e,t+10,a),t+=14),e.set(n,t),t+=l,h)for(var d in u){var f=u[d],m=f.length;ys(e,t,+d),ys(e,t+2,m),e.set(f,t+4),t+=4+m}return c&&(e.set(s,t),t+=c),t},pl=function(e,t,r,n,i){ys(e,t,101010256),ys(e,t+8,r),ys(e,t+10,r),ys(e,t+12,n),ys(e,t+16,i)},dl=function(){function e(e){this.filename=e,this.c=es(),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}(),fl=function(){function e(e,t){var r=this;t=t||{},dl.call(this,e),this.d=new Es(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=al(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){dl.prototype.push.call(this,e,t)},e}(),ml=function(){function e(e,t){var r=this;t=t||{},dl.call(this,e),this.d=new Ps(t,(function(e,t,n){r.ondata(e,t,n)})),this.compression=8,this.flag=al(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){dl.prototype.push.call(this,e,t)},e}(),vl=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=il(e.filename),n=r.length,i=(o=e.comment)&&il(o),o=n!=e.filename.length||i&&o.length!=i.length,a=n+cl(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 da(a);var l=(hl(n,0,e,r,o),[n]),u=this.d,c=(this.d=0,this.u.length),h=ns(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 da(16),ys(r,0,134695760),ys(r,4,e.crc),ys(r,8,p),ys(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+cl(l.extra)+(l.o?l.o.length:0);for(var o=new da(r+22),a=0,s=this.u;a<s.length;a++){var l=s[a];hl(o,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+cl(l.extra)+(l.o?l.o.length:0),t+=l.b}pl(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}(),gl=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),yl=function(){function e(){var e=this;this.i=new Os((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}(),bl=function(){function e(e,t){var r=this;t<32e4?this.i=new Os((function(e,t){r.ondata(null,e,t)})):(this.i=new Cs((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=Fa(e,0)),this.i.push(e,t)},e.compression=8,e}(),xl=function(){function e(e){this.onfile=e,this.k=[],this.o={0:gl},this.p=Ka}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 da(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,d,f,m,v,g,y,b=gs(l,a);return 67324752==b?(o=1,s=a,h.d=null,h.c=0,n=vs(l,a+6),e=vs(l,a+8),t=2048&n,n&=8,i=vs(l,a+26),p=vs(l,a+28),a+30+i+p<u&&(h.k.unshift(d=[]),o=2,f=gs(l,a+18),m=gs(l,a+22),v=ol(l.subarray(a+30,a+=30+i),!t),4294967295==f?(i=n?[-2]:ul(l,a),f=i[0],m=i[1]):n&&(f=-1),a+=p,h.c=f,y={name:v,compression:e,start:function(){if(!y.ondata)throw"no callback";if(f){var t=r.o[e];if(!t)throw"unknown compression type "+e;(g=f<0?new t(v):new t(v,f,m)).ondata=function(e,t,r){y.ondata(e,t,r)};for(var n=0,i=d;n<i.length;n++)g.push(i[n],!1);r.k[0]==d&&r.c?r.d=g:g.push(Ka,!0)}else y.ondata(null,Ka,!0)},terminate:function(){g&&g.terminate&&g.terminate()}},0<=f&&(y.size=f,y.originalSize=m),h.onfile(y)),"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=Ka,c<0&&(n=o?l.subarray(0,s-12-(-2==c&&8)-(134695760==gs(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 wl(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 Sl(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 Tl(e,t,r,n,i){for(var a=i<e?i:e,s=[],l=wl(e,n,t),u=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),d=1;d<=r;++d){h[d]=t-i[e+1-d],p[d]=i[e+d]-t;for(var f=0,m=0;m<d;++m){var v=p[m+1],g=h[d-m],y=(u[d][m]=v+g,u[m][d-1]/u[d][m]);u[m][d]=f+v*y,f=g*y}u[d][d]=f}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=[],M=0;M<=r;++M)T[M]=o.slice(0);for(var _=T[0][0]=1;_<=n;++_){var E=0,P=x-_,k=r-_;_<=x&&(T[S][0]=T[w][0]/u[1+k][P],E=T[S][0]*u[P][k]);for(var R=x-1<=k?_-1:r-x,O=-1<=P?1:-P;O<=R;++O)T[S][O]=(T[w][O]-T[w][O-1])/u[1+k][P+O],E+=T[S][O]*u[P+O][k];x<=k&&(T[S][_]=-T[w][_-1]/u[1+k][x],E+=T[S][_]*u[x][k]),s[_][x]=E;var C=w;w=S,S=C}}for(var L=r,D=1;D<=n;++D){for(var A=0;A<=r;++A)s[D][A]*=L;L*=r-D}return s}(l,n,e,a,t),c=[],h=0;h<r.length;++h){var p=r[h].clone(),d=p.w;p.x*=d,p.y*=d,p.z*=d,c[h]=p}for(var f=0;f<=a;++f){for(var m=c[l-e].clone().multiplyScalar(u[f][0]),v=1;v<=e;++v)m.add(c[l-e+v].clone().multiplyScalar(u[f][v]));s[f]=m}for(var g=a+1;g<=i+1;++g)s[g]=new o.Vector4(0,0,0);return s}function Ml(e){for(var t=e.length,r=[],n=[],i=0;i<t;++i){var a=e[i];r[i]=new o.Vector3(a.x,a.y,a.z),n[i]=a.w}for(var s=[],l=0;l<t;++l){for(var u=r[l].clone(),c=1;c<=l;++c)u.sub(s[l-c].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}(l,c)*n[c]));s[l]=u.divideScalar(n[0])}return s}function _l(e){return(_l="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 El(e,t){return(El=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Pl(e){return(Pl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var kl,Rl,Ol,Cl=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&&El(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=Pl(e);if(r=t?(r=Pl(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===_l(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,a,s){var l;if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");(l=r.call(this)).degree=e,l.knots=t,l.controlPoints=[],l.startKnot=a||0,l.endKnot=s||l.knots.length-1;for(var u=0;u<i.length;++u){var c=i[u];l.controlPoints[u]=new o.Vector4(c.x,c.y,c.z,c.w)}return l}return t=n,(e=[{key:"getPoint",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new o.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=wl(e,n,t),a=Sl(i,n,e,t),s=new o.Vector4(0,0,0,0),l=0;l<=e;++l){var u=r[i-e+l],c=a[l],h=u.w*c;s.x+=u.x*h,s.y+=u.y*h,s.z+=u.z*h,s.w+=u.w*c}return s}(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 o.Vector3,r=(e=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),Ml(Tl(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}(o.Curve);function Ll(e){return(Ll="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 Dl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Al(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 Il(e,t,r){t&&Al(e.prototype,t),r&&Al(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function jl(e,t){return(jl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ul(e){return(Ul=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Bl=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&&jl(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=Ul(e);if(r=t?(r=Ul(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Ll(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 Dl(this,n),r.call(this,e)}return Il(n,[{key:"load",value:function(e,t,r,n){var i=this,a=""===i.path?o.LoaderUtils.extractUrlBase(e):i.path,s=new o.FileLoader(this.manager);s.setPath(i.path),s.setResponseType("arraybuffer"),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(r){try{t(i.parse(r,a))}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===tu(r,0,n.length))kl=(new Hl).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=tu(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(Xl(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Xl(r));kl=(new Vl).parse(r)}var r,n=new o.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Nl(n,this.manager).parse(kl)}}]),n}(o.Loader),Nl=function(){function e(t,r){Dl(this,e),this.textureLoader=t,this.manager=r}return Il(e,[{key:"parse",value:function(){Rl=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new Fl).parse(t);return this.parseScene(t,r,e),Ol}},{key:"parseConnections",value:function(){var e=new Map;return"Connections"in kl&&kl.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 kl.Objects){var n,i=kl.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 kl.Objects){var r,n=kl.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?o.RepeatWrapping:o.ClampToEdgeWrapping,t.wrapT=0===n?o.RepeatWrapping:o.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=Rl.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 o.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 o.Texture):this.textureLoader.load(r),this.textureLoader.setPath(n),i}},{key:"parseMaterials",value:function(e){var t=new Map;if("Material"in kl.Objects){var r,n=kl.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,a=e.ShadingModel;if("object"===Ll(a)&&(a=a.value),!Rl.has(n))return null;switch(e=this.parseParameters(e,t,n),a.toLowerCase()){case"phong":r=new o.MeshPhongMaterial;break;case"lambert":r=new o.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),r=new o.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 o.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new o.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new o.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new o.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 o.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new o.Color).fromArray(e.SpecularColor.value)),this);return Rl.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=o.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=o.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=o.EquirectangularReflectionMapping,n.envMap.encoding=o.sRGBEncoding);break;case"SpecularColor":n.specularMap=i.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.encoding=o.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 kl.Objects&&t in kl.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Rl.get(t).children[0].ID),e.get(t)}},{key:"parseDeformers",value:function(){var e={},t={};if("Deformer"in kl.Objects){var r,n=kl.Objects.Deformer;for(r in n){var i,o=n[r],a=Rl.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 o.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=Rl.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){Ol=new o.Group;var n=this.parseModels(e.skeletons,t,r),i=kl.Objects.Model,a=this;n.forEach((function(e){var t=i[e.ID];a.setLookAtProperties(e,t),Rl.get(e.ID).parents.forEach((function(t){void 0!==(t=n.get(t.ID))&&t.add(e)})),null===e.parent&&Ol.add(e)})),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),Ol.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=Jl(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new zl).parse(),1===Ol.children.length&&Ol.children[0].isGroup&&(Ol.children[0].animations=r,Ol=Ol.children[0]),Ol.animations=r}},{key:"parseModels",value:function(e,t,r){var n,i=new Map,a=kl.Objects.Model;for(n in a){var s=parseInt(n),l=a[n],u=Rl.get(s),c=this.buildSkeleton(u,e,s,l.attrName);if(!c){switch(l.attrType){case"Camera":c=this.createCamera(u);break;case"Light":c=this.createLight(u);break;case"Mesh":c=this.createMesh(u,t,r);break;case"NurbsCurve":c=this.createCurve(u,t);break;case"LimbNode":case"Root":c=new o.Bone;break;default:c=new o.Group}c.name=l.attrName?o.PropertyBinding.sanitizeNodeName(l.attrName):"",c.ID=s}this.getTransformData(c,l),i.set(s,c)}return i}},{key:"buildSkeleton",value:function(e,t,r,n){var i=null;return e.parents.forEach((function(e){for(var a in t)!function(a){var s=t[a];s.rawBones.forEach((function(t,a){var l;t.ID===e.ID&&(l=i,(i=new o.Bone).matrixWorld.copy(t.transformLink),i.name=n?o.PropertyBinding.sanitizeNodeName(n):"",i.ID=r,s.bones[a]=i,null!==l&&i.add(l))}))}(a)})),i}},{key:"createCamera",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=kl.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new o.Object3D;else{var n=0,i=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(n=1),1),a=(void 0!==r.NearPlane&&(i=r.NearPlane.value/1e3),1e3),s=(void 0!==r.FarPlane&&(a=r.FarPlane.value/1e3),window.innerWidth),l=window.innerHeight,u=(void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(s=r.AspectWidth.value,l=r.AspectHeight.value),s/l),c=45,h=(void 0!==r.FieldOfView&&(c=r.FieldOfView.value),r.FocalLength?r.FocalLength.value:null);switch(n){case 0:t=new o.PerspectiveCamera(c,u,i,a),null!==h&&t.setFocalLength(h);break;case 1:t=new o.OrthographicCamera(-s/2,s/2,l/2,-l/2,i,a);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new o.Object3D}}return t}},{key:"createLight",value:function(e){var t,r;if(e.children.forEach((function(e){void 0!==(e=kl.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new o.Object3D;else{e=void 0===r.LightType?0:r.LightType.value;var n=16777215,i=(void 0!==r.Color&&(n=(new o.Color).fromArray(r.Color.value)),void 0===r.Intensity?1:r.Intensity.value/100),a=(void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(i=0),0);switch(void 0!==r.FarAttenuationEnd&&(a=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value),e){case 0:t=new o.PointLight(n,i,a,1);break;case 1:t=new o.DirectionalLight(n,i);break;case 2:var s=Math.PI/3,l=(void 0!==r.InnerAngle&&(s=o.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(l=o.MathUtils.degToRad(r.OuterAngle.value),l=Math.max(l,1)),t=new o.SpotLight(n,i,a,s,l,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new o.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,a=null,s=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),r.has(e.ID)&&s.push(r.get(e.ID))})),1<s.length?a=s:0<s.length?a=s[0]:(a=new o.MeshPhongMaterial({color:13421772}),s.push(a)),"color"in i.attributes&&s.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(n=new o.SkinnedMesh(i,a)).normalizeSkinWeights():n=new o.Mesh(i,a),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 o.LineBasicMaterial({color:3342591,linewidth:1});return new o.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?$l(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&&Rl.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=kl.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),Ol.add(e.target)):e.lookAt((new o.Vector3).fromArray(t)))}))}},{key:"bindSkeleton",value:function(e,t,r){var n,i=this.parsePoseNodes();for(n in e)!function(n){var a=e[n];Rl.get(parseInt(a.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,Rl.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new o.Skeleton(a.bones),i[e.ID])})))}))}(n)}},{key:"parsePoseNodes",value:function(){var e={};if("Pose"in kl.Objects){var t,r,n=kl.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 o.Matrix4).fromArray(t.Matrix.a)})):e[r.Node]=(new o.Matrix4).fromArray(r.Matrix.a))}return e}},{key:"createAmbientLight",value:function(){var e,t,r;"GlobalSettings"in kl&&"AmbientColor"in kl.GlobalSettings&&(r=(t=kl.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new o.Color(r,e,t),Ol.add(new o.AmbientLight(r,1))))}}]),e}(),Fl=function(){function e(){Dl(this,e)}return Il(e,[{key:"parse",value:function(e){var t=new Map;if("Geometry"in kl.Objects){var r,n=kl.Objects.Geometry;for(r in n){var i=Rl.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 kl.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=$l(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=Jl(a),this.genGeometry(t,n,o,e)}},{key:"genGeometry",value:function(e,t,r,n){var i,a,s=new o.BufferGeometry,l=(e.attrName&&(s.name=e.attrName),this.parseGeoNode(e,t)),u=this.genBuffers(l),c=new o.Float32BufferAttribute(u.vertex,3);return c.applyMatrix4(n),s.setAttribute("position",c),0<u.colors.length&&s.setAttribute("color",new o.Float32BufferAttribute(u.colors,3)),t&&(s.setAttribute("skinIndex",new o.Uint16BufferAttribute(u.weightsIndices,4)),s.setAttribute("skinWeight",new o.Float32BufferAttribute(u.vertexWeights,4)),s.FBX_Deformer=t),0<u.normal.length&&(c=(new o.Matrix3).getNormalMatrix(n),(t=new o.Float32BufferAttribute(u.normal,3)).applyNormalMatrix(c),s.setAttribute("normal",t)),u.uvs.forEach((function(e,t){var r="uv"+(t+1).toString();s.setAttribute(r=0===t?"uv":r,new o.Float32BufferAttribute(u.uvs[t],2))})),l.material&&"AllSame"!==l.material.mappingType&&(i=u.materialIndex[0],a=0,u.materialIndex.forEach((function(e,t){e!==i&&(s.addGroup(a,t-a,i),i=e,a=t)})),0<s.groups.length&&(t=(c=s.groups[s.groups.length-1]).start+c.count)!==u.materialIndex.length&&s.addGroup(t,u.materialIndex.length-t,i),0===s.groups.length&&s.addGroup(0,u.materialIndex.length,u.materialIndex[0])),this.addMorphTargets(s,e,r,n),s}},{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,d){var f,m,v,g,y=!1,b=(p<0&&(p^=-1,y=!0),[]),x=[];if(o.push(3*p,3*p+1,3*p+2),e.color&&(g=Zl(d,r,p,e.color),s.push(g[0],g[1],g[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&&(g=Zl(d,r,p,e.normal),a.push(g[0],g[1],g[2])),e.material&&"AllSame"!==e.material.mappingType&&(f=Zl(d,r,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=Zl(d,r,p,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),n++,y&&(h.genFace(t,e,o,f,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=kl.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 a=void 0!==r.Vertices?r.Vertices.a:[],s=void 0!==r.Indexes?r.Indexes.a:[],l=3*e.attributes.position.count,u=new Float32Array(l),c=0;c<s.length;c++){var h=3*s[c];u[h]=a[3*c],u[1+h]=a[3*c+1],u[2+h]=a[3*c+2]}l=this.genBuffers({vertexIndices:t,vertexPositions:u}),(t=new o.Float32BufferAttribute(l.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===Cl)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 o.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 o.BufferGeometry;for(var r=t-1,n=(t=e.KnotVector.a,[]),i=e.Points.a,a=0,s=i.length;a<s;a+=4)n.push((new o.Vector4).fromArray(i,a));if("Closed"===e.Form)n.push(n[0]);else if("Periodic"===e.Form)for(var l=r,u=t.length-1-l,c=0;c<r;++c)n.push(n[c]);return e=new Cl(r,t,n,l,u).getPoints(12*n.length),(new o.BufferGeometry).setFromPoints(e)}}]),e}(),zl=function(){function e(){Dl(this,e)}return Il(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!==kl.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}},{key:"parseAnimationCurveNodes",value:function(){var e,t=kl.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=kl.Objects.AnimationCurve;for(t in r){var n,i={id:r[t].id,times:r[t].KeyTime.a.map(ql),values:r[t].KeyValueFloat.a},o=Rl.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=kl.Objects.AnimationLayer,n=new Map;for(t in r)!function(t){var r=[],i=Rl.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 a=Rl.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==a){var s=kl.Objects.Model[a.toString()];if(void 0===s)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",t);var l={modelName:s.attrName?o.PropertyBinding.sanitizeNodeName(s.attrName):"",ID:s.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Ol.traverse((function(e){e.ID===s.id&&(l.transform=e.matrix,e.userData.transformData&&(l.eulerOrder=e.userData.transformData.eulerOrder))})),l.transform||(l.transform=new o.Matrix4),"PreRotation"in s&&(l.preRotation=s.PreRotation.value),"PostRotation"in s&&(l.postRotation=s.PostRotation.value),r[n]=l}}r[n]&&(r[n][i.attr]=i)}else void 0!==i.curves.morph&&(void 0===r[n]&&(a=Rl.get(t.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,t=Rl.get(a).parents[0].ID,t=Rl.get(t).parents[0].ID,t=Rl.get(t).parents[0].ID,t={modelName:(t=kl.Objects.Model[t]).attrName?o.PropertyBinding.sanitizeNodeName(t.attrName):"",morphName:kl.Objects.Deformer[a].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=kl.Objects.AnimationStack,n={};for(t in r){var i=(1<(i=Rl.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 o.AnimationClip(e.name,-1,t)}},{key:"generateTracks",value:function(e){var t=[],r=new o.Vector3,n=new o.Quaternion,i=new o.Vector3;return e.transform&&e.transform.decompose(r,n,i),r=r.toArray(),n=(new o.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 o.VectorKeyframeTrack(e+"."+n,i,t)}},{key:"generateRotationTrack",value:function(e,t,r,n,i,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(o.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(o.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(o.MathUtils.degToRad));for(var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,r),u=(void 0!==n&&((n=n.map(o.MathUtils.degToRad)).push(a),n=(new o.Euler).fromArray(n),n=(new o.Quaternion).setFromEuler(n)),void 0!==i&&((i=i.map(o.MathUtils.degToRad)).push(a),i=(new o.Euler).fromArray(i),i=(new o.Quaternion).setFromEuler(i).invert()),new o.Quaternion),c=new o.Euler,h=[],p=0;p<l.length;p+=3)c.set(l[p],l[p+1],l[p+2],a),u.setFromEuler(c),void 0!==n&&u.premultiply(n),void 0!==i&&u.multiply(i),u.toArray(h,p/3*4);return new o.QuaternionKeyframeTrack(e+".quaternion",s,h)}},{key:"generateMorphTrack",value:function(e){var t=e.DeformPercent.curves.morph,r=t.values.map((function(e){return e/100})),n=Ol.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new o.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=ru(e.times,t,u),e.values=ru(e.values,t,c)}}}}]),e}(),Vl=function(){function e(){Dl(this,e)}return Il(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 Wl,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=eu(t))}}},{key:"parseNodePropertyContinued",value:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=eu(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=eu(s)}this.getPrevNode()[n]={type:i,type2:o,flag:a,value:s},this.setCurrentProp(this.getPrevNode(),n)}}]),e}(),Hl=function(){function e(){Dl(this,e)}return Il(e,[{key:"parse",value:function(e){var t=new Gl(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 Wl;!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 r=e.getString(1);switch(r){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 i=e.getUint32(),e.getArrayBuffer(i);case"S":return i=e.getUint32(),e.getString(i);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var n=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(0===i)switch(r){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}void 0===t&&console.error("THREE.FBXLoader: External library fflate.min.js required."),i=Ys(new Uint8Array(e.getArrayBuffer(o)));var a=new Gl(i.buffer);switch(r){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+r)}}}]),e}(),Gl=function(){function e(t,r){Dl(this,e),this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===r||r}return Il(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)),o.LoaderUtils.decodeText(new Uint8Array(t))}}]),e}(),Wl=function(){function e(){Dl(this,e)}return Il(e,[{key:"add",value:function(e,t){this[e]=t}}]),e}();function Xl(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 ql(e){return e/46186158e3}var Yl=[];function Zl(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=Yl,l=n.buffer,u=a,c=o,h=0;c<u;c++,h++)s[h]=l[c];return s}var Ql=new o.Euler,Kl=new o.Vector3;function Jl(e){var t=new o.Matrix4,r=new o.Matrix4,n=new o.Matrix4,i=new o.Matrix4,a=new o.Matrix4,s=new o.Matrix4,l=new o.Matrix4,u=new o.Matrix4,c=new o.Matrix4,h=new o.Matrix4,p=new o.Matrix4,d=new o.Matrix4,f=e.inheritType||0,m=(e.translation&&t.setPosition(Kl.fromArray(e.translation)),e.preRotation&&((m=e.preRotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),r.makeRotationFromEuler(Ql.fromArray(m))),e.rotation&&((m=e.rotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),n.makeRotationFromEuler(Ql.fromArray(m))),e.postRotation&&((m=e.postRotation.map(o.MathUtils.degToRad)).push(e.eulerOrder),i.makeRotationFromEuler(Ql.fromArray(m)),i.invert()),e.scale&&a.scale(Kl.fromArray(e.scale)),e.scalingOffset&&l.setPosition(Kl.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(Kl.fromArray(e.scalingPivot)),e.rotationOffset&&u.setPosition(Kl.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(Kl.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),h.copy(e.parentMatrixWorld)),r.clone().multiply(n).multiply(i)),v=(((e=new o.Matrix4).extractRotation(h),v=new o.Matrix4).copyPosition(h),v.clone().invert().multiply(h)),g=(v=e.clone().invert().multiply(v),a),y=new o.Matrix4;return 0===f?y.copy(e).multiply(m).multiply(v).multiply(g):1===f?y.copy(e).multiply(v).multiply(m).multiply(g):(f=(new o.Matrix4).scale((new o.Vector3).setFromMatrixScale(p)).clone().invert(),p=v.clone().multiply(f),y.copy(e).multiply(m).multiply(p).multiply(g)),v=c.clone().invert(),f=s.clone().invert(),e=t.clone().multiply(u).multiply(c).multiply(r).multiply(n).multiply(i).multiply(v).multiply(l).multiply(s).multiply(a).multiply(f),m=(new o.Matrix4).copyPosition(e),p=h.clone().multiply(m),d.copyPosition(p),(e=d.clone().multiply(y)).premultiply(h.invert()),e}function $l(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 eu(e){return e.split(",").map((function(e){return parseFloat(e)}))}function tu(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),o.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function ru(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}function nu(e){return(nu="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 iu(e,t){return(iu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ou(e){return(ou=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var au=/^[og]\s*(.+)?/,su=/^mtllib /,lu=/^usemtl /,uu=/^usemap /,cu=new o.Vector3,hu=new o.Vector3,pu=new o.Vector3,du=new o.Vector3,fu=new o.Vector3,mu=new o.Color;function vu(){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;cu.fromArray(n,e),hu.fromArray(n,t),pu.fromArray(n,r),fu.subVectors(pu,hu),du.subVectors(cu,hu),fu.cross(du),fu.normalize(),i.push(fu.x,fu.y,fu.z),i.push(fu.x,fu.y,fu.z),i.push(fu.x,fu.y,fu.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 gu=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&&iu(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=ou(e);if(r=t?(r=ou(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===nu(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,a=new o.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.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 vu,a=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n"),s="",l=[],u="function"==typeof"".trimLeft,c=0,h=a.length;c<h;c++)if(s=a[c],0!==(s=u?s.trimLeft():s.trim()).length&&"#"!==(t=s.charAt(0)))if("v"===t){var p=s.split(/\s+/);switch(p[0]){case"v":i.vertices.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),7<=p.length?(mu.setRGB(parseFloat(p[4]),parseFloat(p[5]),parseFloat(p[6])).convertSRGBToLinear(),i.colors.push(mu.r,mu.g,mu.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 d=s.slice(1).trim().split(/\s+/),f=[],m=0,v=d.length;m<v;m++){var g=d[m];0<g.length&&(g=g.split("/"),f.push(g))}for(var y=f[0],b=1,x=f.length-1;b<x;b++){var w=f[b],S=f[b+1];i.addFace(y[0],w[0],S[0],y[1],w[1],S[1],y[2],w[2],S[2])}}else if("l"===t){var T=s.substring(1).trim().split(" "),M=[],_=[];if(-1===s.indexOf("/"))M=T;else for(var E=0,P=T.length;E<P;E++){var k=T[E].split("/");""!==k[0]&&M.push(k[0]),""!==k[1]&&_.push(k[1])}i.addLineGeometry(M,_)}else"p"===t?(r=s.slice(1).trim().split(" "),i.addPointGeometry(r)):null!==(l=au.exec(s))?(r=(" "+l[0].slice(1).trim()).slice(1),i.startObject(r)):lu.test(s)?i.object.startMaterial(s.substring(7).trim(),i.materialLibraries):su.test(s)?i.materialLibraries.push(s.substring(7).trim()):uu.test(s)?console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.'):"s"===t?(1<(l=s.split(" ")).length?(n=l[1].trim().toLowerCase(),i.object.smooth="0"!==n&&"off"!==n):i.object.smooth=!0,(n=i.object.currentMaterial())&&(n.smooth=i.object.smooth)):"\0"!==s&&console.warn('THREE.OBJLoader: Unexpected line: "'+s+'"');i.finalize();var R,O=new o.Group;if(1==(O.materialLibraries=[].concat(i.materialLibraries),e=!(1===i.objects.length&&0===i.objects[0].geometry.vertices.length)))for(var C=0,L=i.objects.length;C<L;C++){var D=i.objects[C],A=D.geometry,I=D.materials,j="Line"===A.type,U="Points"===A.type,B=!1;if(0!==A.vertices.length){for(var N=new o.BufferGeometry,F=(N.setAttribute("position",new o.Float32BufferAttribute(A.vertices,3)),0<A.normals.length&&N.setAttribute("normal",new o.Float32BufferAttribute(A.normals,3)),0<A.colors.length&&(B=!0,N.setAttribute("color",new o.Float32BufferAttribute(A.colors,3))),!0===A.hasUVIndices&&N.setAttribute("uv",new o.Float32BufferAttribute(A.uvs,2)),[]),z=0,V=I.length;z<V;z++){var H,G=I[z],W=G.name+"_"+G.smooth+"_"+B,X=i.materials[W];null!==this.materials&&(X=this.materials.create(G.name),!j||!X||X instanceof o.LineBasicMaterial?!U||!X||X instanceof o.PointsMaterial||(H=new o.PointsMaterial({size:10,sizeAttenuation:!1}),o.Material.prototype.copy.call(H,X),H.color.copy(X.color),H.map=X.map,X=H):(H=new o.LineBasicMaterial,o.Material.prototype.copy.call(H,X),H.color.copy(X.color),X=H)),void 0===X&&((X=j?new o.LineBasicMaterial:U?new o.PointsMaterial({size:1,sizeAttenuation:!1}):new o.MeshPhongMaterial).name=G.name,X.flatShading=!G.smooth,X.vertexColors=B,i.materials[W]=X),F.push(X)}if(A=void 0,1<F.length){for(var q=0,Y=I.length;q<Y;q++){var Z=I[q];N.addGroup(Z.groupStart,Z.groupCount,q)}A=new(j?o.LineSegments:U?o.Points:o.Mesh)(N,F)}else A=new(j?o.LineSegments:U?o.Points:o.Mesh)(N,F[0]);A.name=D.name,O.add(A)}}else 0<i.vertices.length&&(e=new o.PointsMaterial({size:1,sizeAttenuation:!1}),(R=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute(i.vertices,3)),0<i.colors.length&&void 0!==i.colors[0]&&(R.setAttribute("color",new o.Float32BufferAttribute(i.colors,3)),e.vertexColors=!0),R=new o.Points(R,e),O.add(R));return 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)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),n}(o.Loader),yu=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 bu{constructor(e){this.parses={fbx:new Bl,obj:new gu},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)}return t}img(e){console.log(e,"file")}glb(e){return yu(this,void 0,void 0,(function*(){var t=yield(0,Ve.toResult)(e,"arrayBuffer");return this.runScene.loaderer.gltf.parse(t)}))}fbx(e){return yu(this,void 0,void 0,(function*(){var t=yield(0,Ve.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 yu(this,void 0,void 0,(function*(){var t=yield(0,Ve.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))}))}}function xu(e){return(xu="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 wu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Su(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 Tu(e,t,r){t&&Su(e.prototype,t),r&&Su(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function Mu(){return(Mu="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=Ru(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 _u(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&&Eu(e,t)}function Eu(e,t){return(Eu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Pu(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=Ru(e);if(r=t?(r=Ru(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===xu(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return ku(n)}}function ku(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ru(e){return(Ru=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ou=new o.Raycaster,Cu=new o.Vector3,Lu=new o.Vector3,Du=new o.Quaternion,Au={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},Iu={type:"change"},ju={type:"mouseDown"},Uu={type:"mouseUp",mode:null},Bu={type:"objectChange"};function Nu(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}Wo=function(){_u(t,o.Object3D);var e=Pu(t);function t(r,n){wu(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,a=new ec,s=(i._gizmo=a,i.add(a),new tc),l=(i._plane=s,i.add(s),ku(i));function u(e,t){var r=t;Object.defineProperty(l,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,s[e]=t,a[e]=t,l.dispatchEvent({type:e+"-changed",value:t}),l.dispatchEvent(Iu))}}),l[e]=t,s[e]=t,a[e]=t}u("camera",r),u("object",void 0),u("enabled",!0),u("axis",null),u("mode","translate"),u("translationSnap",null),u("rotationSnap",null),u("scaleSnap",null),u("space","world"),u("size",1),u("dragging",!1),u("showX",!0),u("showY",!0),u("showZ",!0),n=new o.Vector3,r=new o.Vector3;var c=new o.Quaternion,h=new o.Quaternion,p=new o.Vector3,d=new o.Quaternion,f=new o.Vector3,m=new o.Vector3,v=new o.Vector3,g=new o.Vector3;return u("worldPosition",n),u("worldPositionStart",r),u("worldQuaternion",c),u("worldQuaternionStart",h),u("cameraPosition",p),u("cameraQuaternion",d),u("pointStart",f),u("pointEnd",m),u("rotationAxis",v),u("rotationAngle",0),u("eye",g),i._offset=new o.Vector3,i._startNorm=new o.Vector3,i._endNorm=new o.Vector3,i._cameraScale=new o.Vector3,i._parentPosition=new o.Vector3,i._parentQuaternion=new o.Quaternion,i._parentQuaternionInv=new o.Quaternion,i._parentScale=new o.Vector3,i._worldScaleStart=new o.Vector3,i._worldQuaternionInv=new o.Quaternion,i._worldScale=new o.Vector3,i._positionStart=new o.Vector3,i._quaternionStart=new o.Quaternion,i._scaleStart=new o.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(ku(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(ku(i)),i._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(ku(i)),i._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(ku(i)),i._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(ku(i)),i.domElement.addEventListener("pointerdown",i._onPointerDown),i.domElement.addEventListener("pointermove",i._onPointerHover),i.domElement.addEventListener("pointerup",i._onPointerUp),i}return Tu(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(),Mu(Ru(t.prototype),"updateMatrixWorld",this).call(this,this)}},{key:"pointerHover",value:function(e){void 0!==this.object&&!0!==this.dragging&&(Ou.setFromCamera(e,this.camera),e=Nu(this._gizmo.picker[this.mode],Ou),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&&(Ou.setFromCamera(e,this.camera),(e=Nu(this._plane,Ou,!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,ju.mode=this.mode,this.dispatchEvent(ju))}},{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&&(Ou.setFromCamera(e,this.camera),(e=Nu(this._plane,Ou,!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(Du.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(Cu.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(Cu.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),Lu.set(e,e,e)):(Cu.copy(this.pointStart),Lu.copy(this.pointEnd),Cu.applyQuaternion(this._worldQuaternionInv),Lu.applyQuaternion(this._worldQuaternionInv),Lu.divide(Cu),-1===t.search("X")&&(Lu.x=1),-1===t.search("Y")&&(Lu.y=1),-1===t.search("Z")&&(Lu.z=1)),n.scale.copy(this._scaleStart).multiply(Lu),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(Cu.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(Cu.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Au[t]),Cu.copy(Au[t]),"local"===i&&Cu.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(Cu.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(Du.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Du.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())),this.dispatchEvent(Iu),this.dispatchEvent(Bu)))}},{key:"pointerUp",value:function(e){0===e.button&&(this.dragging&&null!==this.axis&&(Uu.mode=this.mode,this.dispatchEvent(Uu)),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(Iu),this.dispatchEvent(Bu),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return Ou}},{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}(),Wo.prototype.isTransformControls=!0;var Fu=new o.Euler,zu=new o.Vector3(0,1,0),Vu=new o.Vector3(0,0,0),Hu=new o.Matrix4,Gu=new o.Quaternion,Wu=new o.Quaternion,Xu=new o.Vector3,qu=new o.Matrix4,Yu=new o.Vector3(1,0,0),Zu=new o.Vector3(0,1,0),Qu=new o.Vector3(0,0,1),Ku=new o.Vector3,Ju=new o.Vector3,$u=new o.Vector3,ec=function(){_u(t,o.Object3D);var e=Pu(t);function t(){wu(this,t),(r=e.call(this)).type="TransformControlsGizmo";var r,n=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),a=n.clone(),s=((((a.opacity=.15,i=i.clone()).opacity=.5,x=n.clone()).color.setHex(16711680),w=n.clone()).color.setHex(65280),n.clone()),l=(s.color.setHex(255),n.clone()),u=(l.color.setHex(16711680),l.opacity=.5,n.clone()),c=(u.color.setHex(65280),u.opacity=.5,n.clone()),h=(c.color.setHex(255),c.opacity=.5,n.clone());(h.opacity=.25,y=n.clone()).color.setHex(16776960),y.opacity=.25,n.clone().color.setHex(16776960);var p=(((n=n.clone()).color.setHex(7895160),m=new o.CylinderGeometry(0,.04,.1,12)).translate(0,.05,0),new o.BoxGeometry(.08,.08,.08)),d=(p.translate(0,.04,0),new o.BufferGeometry);function f(e,t){return(e=new o.TorusGeometry(e,.0075,3,64,t*Math.PI*2)).rotateY(Math.PI/2),e.rotateX(Math.PI/2),e}(d.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3)),S=new o.CylinderGeometry(.0075,.0075,.5,3)).translate(0,.25,0);var m={X:[[new o.Mesh(m,x),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(m,x),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(m,w),[0,.5,0]],[new o.Mesh(m,w),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(S,w)]],Z:[[new o.Mesh(m,s),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(m,s),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(S,s),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),h.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),a)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]]},g={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new o.Line(((g=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),g),i),null,null,null,"helper"]],X:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(d,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(d,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},y=(n={XYZE:[[new o.Mesh(f(.5,1),n),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(f(.5,.5),x)]],Y:[[new o.Mesh(f(.5,.5),w),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(f(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(f(.75,1),y),null,[0,Math.PI/2,0]]]},{AXIS:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]}),b={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),a)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),a),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),a)]]},x={X:[[new o.Mesh(p,x),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(S,x),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(p,x),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(p,w),[0,.5,0]],[new o.Mesh(S,w)],[new o.Mesh(p,w),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(p,s),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(S,s),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(p,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),h.clone())]]},w={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),a),[0,0,0]]]},S={X:[[new o.Line(d,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(d,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(d,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(e){var t,r=new o.Object3D;for(t in e)for(var n=e[t].length;n--;){var i=e[t][n][0].clone(),a=e[t][n][1],s=e[t][n][2],l=e[t][n][3],u=e[t][n][4];(i.name=t,i.tag=u,a&&i.position.set(a[0],a[1],a[2]),s&&i.rotation.set(s[0],s[1],s[2]),l&&i.scale.set(l[0],l[1],l[2]),i.updateMatrix(),u=i.geometry.clone()).applyMatrix4(i.matrix),i.geometry=u,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(g)),r.add(r.helper.rotate=T(y)),r.add(r.helper.scale=T(S)),r.picker.translate.visible=!1,r.picker.rotate.visible=!1,r.picker.scale.visible=!1,r}return Tu(t,[{key:"updateMatrixWorld",value:function(e){var r=this,n="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Wu,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&&(Du.setFromEuler(Fu.set(0,0,0)),t.quaternion.copy(n).multiply(Du),.9<Math.abs(zu.copy(Yu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Y"===r.axis&&(Du.setFromEuler(Fu.set(0,0,Math.PI/2)),t.quaternion.copy(n).multiply(Du),.9<Math.abs(zu.copy(Zu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"Z"===r.axis&&(Du.setFromEuler(Fu.set(0,Math.PI/2,0)),t.quaternion.copy(n).multiply(Du),.9<Math.abs(zu.copy(Qu).applyQuaternion(n).dot(r.eye))&&(t.visible=!1)),"XYZE"===r.axis&&(Du.setFromEuler(Fu.set(0,Math.PI/2,0)),zu.copy(r.rotationAxis),t.quaternion.setFromRotationMatrix(Hu.lookAt(Vu,zu,Zu)),t.quaternion.multiply(Du),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),Cu.set(1e-10,1e-10,1e-10).add(r.worldPositionStart).sub(r.worldPosition).multiplyScalar(-1),Cu.applyQuaternion(r.worldQuaternionStart.clone().invert()),t.scale.copy(Cu),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(zu.copy(Yu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Y"===t.name&&.99<Math.abs(zu.copy(Zu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"Z"===t.name&&.99<Math.abs(zu.copy(Qu).applyQuaternion(n).dot(r.eye))&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XY"===t.name&&Math.abs(zu.copy(Qu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"YZ"===t.name&&Math.abs(zu.copy(Yu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),"XZ"===t.name&&Math.abs(zu.copy(Zu).applyQuaternion(n).dot(r.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1)):"rotate"===r.mode&&(Gu.copy(n),zu.copy(r.eye).applyQuaternion(Du.copy(n).invert()),-1!==t.name.search("E")&&t.quaternion.setFromRotationMatrix(Hu.lookAt(r.eye,Vu,Zu)),"X"===t.name&&(Du.setFromAxisAngle(Yu,Math.atan2(-zu.y,zu.z)),Du.multiplyQuaternions(Gu,Du),t.quaternion.copy(Du)),"Y"===t.name&&(Du.setFromAxisAngle(Zu,Math.atan2(zu.x,zu.z)),Du.multiplyQuaternions(Gu,Du),t.quaternion.copy(Du)),"Z"===t.name&&(Du.setFromAxisAngle(Qu,Math.atan2(zu.y,zu.x)),Du.multiplyQuaternions(Gu,Du),t.quaternion.copy(Du))),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);Mu(Ru(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}(),tc=(ec.prototype.isTransformControlsGizmo=!0,function(){_u(t,o.Mesh);var e=Pu(t);function t(){var r;return wu(this,t),(r=e.call(this,new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1}))).type="TransformControlsPlane",r}return Tu(t,[{key:"updateMatrixWorld",value:function(e){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),Ku.copy(Yu).applyQuaternion("local"===r?this.worldQuaternion:Wu),Ju.copy(Zu).applyQuaternion("local"===r?this.worldQuaternion:Wu),$u.copy(Qu).applyQuaternion("local"===r?this.worldQuaternion:Wu),zu.copy(Ju),this.mode){case"translate":case"scale":switch(this.axis){case"X":zu.copy(this.eye).cross(Ku),Xu.copy(Ku).cross(zu);break;case"Y":zu.copy(this.eye).cross(Ju),Xu.copy(Ju).cross(zu);break;case"Z":zu.copy(this.eye).cross($u),Xu.copy($u).cross(zu);break;case"XY":Xu.copy($u);break;case"YZ":Xu.copy(Ku);break;case"XZ":zu.copy($u),Xu.copy(Ju);break;case"XYZ":case"E":Xu.set(0,0,0)}break;default:Xu.set(0,0,0)}0===Xu.length()?this.quaternion.copy(this.cameraQuaternion):(qu.lookAt(Cu.set(0,0,0),Xu,zu),this.quaternion.setFromRotationMatrix(qu)),Mu(Ru(t.prototype),"updateMatrixWorld",this).call(this,e)}}]),t}());tc.prototype.isTransformControlsPlane=!0;class rc extends Wo{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new o.Vector3,this.beginScale=new o.Vector3,this.posStart=new o.Vector2,this.posEnd=new o.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 nc{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 o.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 ci.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new ci.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=xi(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=xi(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=xi(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=xi(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 rc(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(),console.log(this.transContro,"this.transContro "))}init(){"running"!==this.runScene.optionsEx.options.mode&&(this.transContro.init(),this.runScene.assetsEx.get().scene.add(this.grid))}createGrid(){const e=new ci.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof o.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 ic(e){return(ic="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 oc(e,t){return(oc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ac(e){return(ac=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var sc=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&&oc(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=ac(e);if(r=t?(r=ac(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===ic(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 o.BufferGeometry,a=(i.setAttribute("position",new o.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),new o.LineBasicMaterial({fog:!1}));return((i=r.call(this,i,a)).light=e,i.color=t,i.type="RectAreaLightHelper",a=new o.BufferGeometry).setAttribute("position",new o.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),i.add(new o.Mesh(a,new o.MeshBasicMaterial({side:o.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}(o.Line);class lc{constructor(e){this.runScene=e}}class uc extends lc{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 ci.Color("#"+o),t}}class cc extends lc{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:d}=h;return{type:n,intensity:t,name:r,visible:o,color:a.getHexString(),castShadow:s,shadow:{mapSize:e.x,camera:{near:p,far:d,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:d}=h;return t.intensity=r,t.type=c,t.name=n,t.visible=o,t.castShadow=s,t.color=new ci.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=d,t.shadow.camera.updateProjectionMatrix(),null!=(r=t.cameraHelper)&&r.update(),t}}class hc extends lc{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 ci.Color("#"+o),t.groundColor=new ci.Color("#"+a),t.position.set(s.x,s.y,s.z),t}}class pc extends lc{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:d,radius:f}=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:f,bias:d},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:d,radius:f}=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 ci.Color("#"+s),t.position.set(h.x,h.y,h.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=d,t.decay=o,t.shadow.radius=f,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 dc{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 ci.Color("#"+o),t.position.set(a.x,a.y,a.z),t}}class fc{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:d,target:f}=e;var{bias:e,camera:m,normalBias:v,mapSize:g,radius:y}=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:g.x,camera:{near:m},radius:y},position:{x:d.x,y:d.y,z:d.z},targetPosition:{x:f.position.x,y:f.position.y,z:f.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:d,targetPosition:f}=e,{bias:h,camera:m,normalBias:v,mapSize:g,radius:y}=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 ci.Color("#"+n),t.position.set(d.x,d.y,d.z),t.shadow.mapSize.x=g,t.shadow.mapSize.y=g,t.shadow.camera.near=m,t.target.position.set(f.x,f.y,f.z),t.shadow.bias=h,t.shadow.normalBias=v,t.shadow.radius=y,t.shadow.camera.updateProjectionMatrix(),t}}class mc{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 cc(e),PointLight:new pc(e),SpotLight:new fc(e),RectAreaLight:new dc(e),HemisphereLight:new hc(e),AmbientLight:new uc(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:o}=Yi({isClone:!1,id:(0,i.getId)(),addUndo:!0,addToScene:!0},t);let a=new ci[e];if(a.position.y=10,a.name=e,a.userData.id=r,this.shadowList.includes(e)&&(a.castShadow=!0),this.setLight(a),!o)return a;if(this.helperList.includes(a.type)){const t=this.setLightHelper(a);t.push({model:a,parent:this.runScene.sceneEx.get(),addTree:!0}),r=t.map((e=>new Mo(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute())),n&&this.runScene.undoEx.addUndo(r),null!=(e=null==a?void 0:a.lightHelper)&&e.update()}else this.runScene.modelEx.add(a,void 0,{addUndo:n});return this.runScene.modelEx.setSelectByModel(a,{isClone:t}),a}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 Eo({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 Eo({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 sc(t,16773120);break;case"DirectionalLight":if(n=new ci.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new ci.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 ci.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 ci.PointLightHelper(t,1,16711935);break;case"SpotLight":n=new ci.SpotLightHelper(t);let o=new ci.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 ci.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 ci.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 mo({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 no({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 no({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,i.getId)()})}}function vc(e){return(vc="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 gc(e,t){return(gc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function yc(e){return(yc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var bc=new WeakMap,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&&gc(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=yc(e);if(r=t?(r=yc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===vc(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,a=new o.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.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(bc.has(e)){if((l=bc.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)})),bc.set(e,{key:a,promise:l}),l}},{key:"_createGeometry",value:function(e){var t=new o.BufferGeometry;e.index&&t.setIndex(new o.BufferAttribute(e.index.array,1));for(var r=0;r<e.attributes.length;r++){var n=(a=e.attributes[r]).name,i=a.array,a=a.itemSize;t.setAttribute(n,new o.BufferAttribute(i,a))}return t}},{key:"_loadLibrary",value:function(e,t){var r=new o.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":vc(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,g=t.DecodeBufferToMesh(r,i);else{if(s!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");i=new e.PointCloud,g=t.DecodeBufferToPointCloud(r,i)}if(!g.ok()||0===i.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());var l,u,c,h,p,d,f,m,v,g,y,b,x,w={index:null,attributes:[]};for(l in o){var S=self[a[l]],T=void 0,M=void 0;if(n.useUniqueIDs)M=o[l],T=t.GetAttributeByUniqueId(i,M);else{if(-1===(M=t.GetAttributeId(i,e[o[l]])))continue;T=t.GetAttribute(i,M)}w.attributes.push((M=e,u=t,c=i,h=l,p=T.num_components(),f=(d=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}}(M,S),v=M._malloc(f),u.GetAttributeDataArrayForAllPoints(c,T,m,f,v),u=new S(M.HEAPF32.buffer,v,d).slice(),M._free(v),{name:h,array:u,itemSize:p}))}return s===e.TRIANGULAR_MESH&&(w.index=(r=e,g=t,b=4*(y=3*(s=i).num_faces()),x=r._malloc(b),g.GetTrianglesUInt32Array(s,b,x),g=new Uint32Array(r.HEAPF32.buffer,x,y).slice(),r._free(x),{array:g,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}(o.Loader),wc={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 Sc=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 Tc=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.manager=void 0!==t?t:Sc,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 Mc(e){return(Mc="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 _c(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 Ec(e,t){return(Ec=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 kc=function(){var e=n,t=Tc;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&&Ec(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=Pc(e);if(r=t?(r=Pc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Mc(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=wc.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 _c(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)?_c(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],wc.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 Rc(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)||Cc(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 Oc(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Cc(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 Cc(e,t){if(e){if("string"==typeof e)return Lc(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)?Lc(e,t):void 0}}function Lc(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 Dc(e){return(Dc="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 Ac(){return(Ac="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=Vc(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 Ic(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jc(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){return t&&jc(e.prototype,t),r&&jc(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Bc(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&&Nc(e,t)}function Nc(e,t){return(Nc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Fc(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=Vc(e);if(r=t?(r=Vc(this).constructor,Reflect.construct(n,arguments,r)):n.apply(this,arguments),n=this,r&&("object"===Dc(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return zc(n)}}function zc(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vc(e){return(Vc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}kc.prototype.isImageBitmapLoader=!0;var Hc=function(){Bc(t,o.Loader);var e=Fc(t);function t(r){return Ic(this,t),(r=e.call(this,r)).dracoLoader=null,r.ktx2Loader=null,r.meshoptDecoder=null,r.pluginCallbacks=[],r.register((function(e){return new Yc(e)})),r.register((function(e){return new eh(e)})),r.register((function(e){return new th(e)})),r.register((function(e){return new Zc(e)})),r.register((function(e){return new Qc(e)})),r.register((function(e){return new Kc(e)})),r.register((function(e){return new Jc(e)})),r.register((function(e){return new $c(e)})),r.register((function(e){return new Xc(e)})),r.register((function(e){return new rh(e)})),r}return Uc(t,[{key:"load",value:function(e,t,r,n){function i(t){n?n(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)}var a=this,s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:o.LoaderUtils.extractUrlBase(e),l=(this.manager.itemStart(e),new o.FileLoader(this.manager));l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(r){try{a.parse(r,s,(function(r){t(r),a.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 a,s={},l={};if("string"==typeof e)a=e;else if(o.LoaderUtils.decodeText(new Uint8Array(e,0,4))===nh){try{s[Wc.KHR_BINARY_GLTF]=new ih(e)}catch(e){return void(n&&n(e))}a=s[Wc.KHR_BINARY_GLTF].content}else a=o.LoaderUtils.decodeText(new Uint8Array(e));var u=JSON.parse(a);if(void 0===u.asset||u.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{i.helper.beforeLoader(u);var c=new Mh(u,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:i});c.fileLoader.setRequestHeader(this.requestHeader);for(var h=0;h<this.pluginCallbacks.length;h++){var p=this.pluginCallbacks[h](c);s[(l[p.name]=p).name]=!0}if(u.extensionsUsed)for(var d=0;d<u.extensionsUsed.length;++d){var f=u.extensionsUsed[d],m=u.extensionsRequired||[];switch(f){case Wc.KHR_MATERIALS_UNLIT:s[f]=new qc;break;case Wc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[f]=new lh;break;case Wc.KHR_DRACO_MESH_COMPRESSION:s[f]=new oh(u,this.dracoLoader);break;case Wc.KHR_TEXTURE_TRANSFORM:s[f]=new ah;break;case Wc.KHR_MESH_QUANTIZATION:s[f]=new uh;break;default:0<=m.indexOf(f)&&void 0===l[f]&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(s),c.setPlugins(l),c.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 Gc(){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 Wc={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"},Xc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}return Uc(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,a=t.json,s=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],l=new o.Color(16777215),u=(void 0!==s.color&&l.fromArray(s.color),void 0!==s.range?s.range:0);switch(s.type){case"directional":(i=new o.DirectionalLight(l)).target.position.set(0,0,-1),i.add(i.target);break;case"point":(i=new o.PointLight(l)).distance=u;break;case"spot":(i=new o.SpotLight(l)).distance=u,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,i.angle=s.spot.outerConeAngle,i.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return i.position.set(0,0,0),i.decay=2,void 0!==s.intensity&&(i.intensity=s.intensity),i.name=t.createUniqueName(s.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}(),qc=function(){function e(){Ic(this,e),this.name=Wc.KHR_MATERIALS_UNLIT}return Uc(e,[{key:"getMaterialType",value:function(){return o.MeshBasicMaterial}},{key:"extendParams",value:function(e,t,r){var n,i=[];return e.color=new o.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}(),Yc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_CLEARCOAT}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Vector2(r,r))),Promise.all(n)}}]),e}(),Zc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_SHEEN}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.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}(),Qc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_TRANSMISSION}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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}(),Kc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_VOLUME}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Color(n[0],n[1],n[2]),Promise.all(r)}}]),e}(),Jc=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_IOR}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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}(),$c=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_MATERIALS_SPECULAR}return Uc(e,[{key:"getMaterialType",value:function(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?o.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 o.Color(i[0],i[1],i[2]),void 0!==e.specularColorTexture&&n.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=o.sRGBEncoding}))),Promise.all(n)}}]),e}(),eh=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.KHR_TEXTURE_BASISU}return Uc(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}(),th=function(){function e(t){Ic(this,e),this.parser=t,this.name=Wc.EXT_TEXTURE_WEBP,this.isSupported=null}return Uc(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}(),rh=function(){function e(t){Ic(this,e),this.name=Wc.EXT_MESHOPT_COMPRESSION,this.parser=t}return Uc(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}(),nh="glTF",ih=Uc((function e(t){Ic(this,e),this.name=Wc.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(t,0,12);if(this.header={magic:o.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==nh)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),a=0;a<n;){var s,l=i.getUint32(a,!0),u=(a+=4,i.getUint32(a,!0));a+=4,1313821514===u?(s=new Uint8Array(t,12+a,l),this.content=o.LoaderUtils.decodeText(s)):5130562===u&&(this.body=t.slice(s=12+a,s+l)),a+=l}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),oh=function(){function e(t,r){if(Ic(this,e),!r)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Wc.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=r,this.dracoLoader.preload()}return Uc(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=gh[r]||r.toLowerCase();l[h]=s[r]}for(n in e.attributes){var p,d,f=gh[n]||n.toLowerCase();void 0!==s[n]&&(p=i.accessors[e.attributes[n]],d=dh[p.componentType],c[f]=d,u[f]=!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}(),ah=function(){function e(){Ic(this,e),this.name=Wc.KHR_TEXTURE_TRANSFORM}return Uc(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}(),sh=function(){Bc(t,o.MeshStandardMaterial);var e=Fc(t);function t(r){Ic(this,t),(n=e.call(this)).isGLTFSpecularGlossinessMaterial=!0;var n,i=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),a=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),s=["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"),l=["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"),u=["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"),c={specular:{value:(new o.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};return n._extraUniforms=c,n.onBeforeCompile=function(e){for(var t in c)e.uniforms[t]=c[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>",a).replace("#include <roughnessmap_fragment>",s).replace("#include <metalnessmap_fragment>",l).replace("#include <lights_physical_fragment>",u)},Object.defineProperties(zc(n),{specular:{get:function(){return c.specular.value},set:function(e){c.specular.value=e}},specularMap:{get:function(){return c.specularMap.value},set:function(e){(c.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return c.glossiness.value},set:function(e){c.glossiness.value=e}},glossinessMap:{get:function(){return c.glossinessMap.value},set:function(e){(c.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 Uc(t,[{key:"copy",value:function(e){return Ac(Vc(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}(),lh=function(){function e(){Ic(this,e),this.name=Wc.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 Uc(e,[{key:"getMaterialType",value:function(){return sh}},{key:"extendParams",value:function(e,t,r){t=t.extensions[this.name];var n,i=(e.color=new o.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 o.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new o.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 sh(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=o.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}(),uh=Uc((function e(){Ic(this,e),this.name=Wc.KHR_MESH_QUANTIZATION})),ch=function(){Bc(t,o.Interpolant);var e=Fc(t);function t(r,n,i,o){return Ic(this,t),e.call(this,r,n,i,o)}return Uc(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}(),hh=(ch.prototype.beforeStart_=ch.prototype.copySampleValue_,ch.prototype.afterEnd_=ch.prototype.copySampleValue_,ch.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,d=t-r,f=1-p,m=d-r+n,v=0;v!==a;v++){var g=o[h+v+a],y=o[h+v+s]*u,b=o[c+v+a],x=o[c+v]*u;i[v]=f*g+m*y+p*b+d*x}return i},new o.Quaternion),ph=function(){Bc(t,ch);var e=Fc(t);function t(){return Ic(this,t),e.apply(this,arguments)}return Uc(t,[{key:"interpolate_",value:function(e,r,n,i){return e=Ac(Vc(t.prototype),"interpolate_",this).call(this,e,r,n,i),hh.fromArray(e).normalize().toArray(e),e}}]),t}(),dh={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},fh={9728:o.NearestFilter,9729:o.LinearFilter,9984:o.NearestMipmapNearestFilter,9985:o.LinearMipmapNearestFilter,9986:o.NearestMipmapLinearFilter,9987:o.LinearMipmapLinearFilter},mh={33071:o.ClampToEdgeWrapping,33648:o.MirroredRepeatWrapping,10497:o.RepeatWrapping},vh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},yh={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},bh={CUBICSPLINE:void 0,LINEAR:o.InterpolateLinear,STEP:o.InterpolateDiscrete};function xh(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 wh(e,t){void 0!==t.extras&&("object"===Dc(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Sh(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 Th(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 Mh=function(){function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};Ic(this,e),this.json=t,this.extensions={},this.plugins={},this.options=r,this.cache=new Gc,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 kc(this.options.manager):this.textureLoader=new o.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new o.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}return Uc(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 Lc(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Cc(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:{}};xh(i,o,n),wh(o,n),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){r.options.myOptions.helper.done(o),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),Oc(t.children.entries()));try{for(a.s();!(i=a.n()).done;){var s=Rc(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[Wc.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(e,i){r.load(o.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,a=e[0],s=vh[n.type],l=dh[n.componentType],u=l.BYTES_PER_ELEMENT,c=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized,d=h&&h!==u*s?(f=Math.floor(c/h),m="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count,(v=t.cache.get(m))||(i=new l(a,f*h,n.count*h/u),v=new o.InterleavedBuffer(i,h/u),t.cache.add(m,v)),new o.InterleavedBufferAttribute(v,s,c%h/u,p)):(i=null===a?new l(n.count*s):new l(a,c,n.count*s),new o.BufferAttribute(i,s,p));if(void 0!==n.sparse){var f=dh[n.sparse.indices.componentType],m=n.sparse.indices.byteOffset||0,v=n.sparse.values.byteOffset||0,g=new f(e[1],m,n.sparse.count*vh.SCALAR),y=new l(e[2],v,n.sparse.count*s);null!==a&&(d=new o.BufferAttribute(d.array.slice(),d.itemSize,d.normalized));for(var b=0,x=g.length;b<x;b++){var w=g[b];if(d.setX(w,y[b*s]),2<=s&&d.setY(w,y[b*s+1]),3<=s&&d.setZ(w,y[b*s+2]),4<=s&&d.setW(w,y[b*s+3]),5<=s)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return d})))}},{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,a=i.textures[e],s=((s=i.images[t]).uri||s.bufferView)+":"+a.sampler;return this.textureCache[s]?this.textureCache[s]:(t=this.loadImageSource(t,r).then((function(t){t.flipY=!1,a.name&&(t.name=a.name);var r=(i.samplers||{})[a.sampler]||{};return t.magFilter=fh[r.magFilter]||o.LinearFilter,t.minFilter=fh[r.minFilter]||o.LinearMipmapLinearFilter,t.wrapS=mh[r.wrapS]||o.RepeatWrapping,t.wrapT=mh[r.wrapT]||o.RepeatWrapping,n.associations.set(t,{textures:e}),n.options.myOptions.helper.material.processTexture({texture:t,textureDef:a}),t})).catch((function(){return null})),this.textureCache[s]=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],a=self.URL||self.webkitURL,s=i.uri||"";if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then((function(e){return e=new Blob([e],{type:i.mimeType}),s=a.createObjectURL(e)}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return r=Promise.resolve(s).then((function(e){return new Promise((function(r,i){var a=r;!0===t.isImageBitmapLoader&&(a=function(e,t){(e=new o.Texture(e)).needsUpdate=!0,r({texture:e,blob:t})}),t.load(o.LoaderUtils.resolveURL(e,n.path),a,void 0,i)}))})).then((function(e){var t=e.texture;return e=e.blob,t.userData.url=s,t.userData.blob=e,t.url=s,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),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[Wc.KHR_TEXTURE_TRANSFORM]&&(o=void 0!==r.extensions?r.extensions[Wc.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=n.associations.get(i),i=n.extensions[Wc.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,a=void 0===n.attributes.tangent,s=void 0!==n.attributes.color,l=void 0===n.attributes.normal;e.isPoints?(t="PointsMaterial:"+i.uuid,(r=this.cache.get(t))||(r=new o.PointsMaterial,o.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 o.LineBasicMaterial,o.Material.prototype.copy.call(r,i),r.color.copy(i.color),this.cache.add(t,r)),i=r),(a||s||l)&&(t="ClonedMaterial:"+i.uuid+":",i.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),a&&(t+="derivative-tangents:"),s&&(t+="vertex-colors:"),l&&(t+="flat-shading:"),(r=this.cache.get(t))||(r=i.clone(),s&&(r.vertexColors=!0),l&&(r.flatShading=!0),a&&(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 o.MeshStandardMaterial}},{key:"loadMaterial",value:function(e){var t,r=this,n=this.json,i=this.extensions,a=n.materials[e],s={},l=[],u=((n=a.extensions||{})[Wc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]?(u=i[Wc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS],t=u.getMaterialType(),l.push(u.extendParams(s,a,r))):n[Wc.KHR_MATERIALS_UNLIT]?(u=i[Wc.KHR_MATERIALS_UNLIT],t=u.getMaterialType(),l.push(u.extendParams(s,a,r))):(n=a.pbrMetallicRoughness||{},s.color=new o.Color(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)&&(u=n.baseColorFactor,s.color.fromArray(u),s.opacity=u[3]),void 0!==n.baseColorTexture&&l.push(r.assignTexture(s,"map",n.baseColorTexture)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(r.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),l.push(r.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))),!0===a.doubleSided&&(s.side=o.DoubleSide),a.alphaMode||"OPAQUE");return"BLEND"===u?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===u&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==o.MeshBasicMaterial&&(l.push(r.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new o.Vector2(1,1),void 0!==a.normalTexture.scale&&(n=a.normalTexture.scale,s.normalScale.set(n,n))),void 0!==a.occlusionTexture&&t!==o.MeshBasicMaterial&&(l.push(r.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==o.MeshBasicMaterial&&(s.emissive=(new o.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==o.MeshBasicMaterial&&l.push(r.assignTexture(s,"emissiveMap",a.emissiveTexture)),Promise.all(l).then((function(){var n=t===sh?i[Wc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new t(s);return a.name&&(n.name=a.name),n.map&&(n.map.encoding=o.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=o.sRGBEncoding),wh(n,a),r.associations.set(n,{materials:e}),a.extensions&&xh(i,n,a),n}))}},{key:"createUniqueName",value:function(e){for(var t=o.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=[],a=0,s=e.length;a<s;a++){var l=e[a],u=(c=void 0,c=(c=(u=l).extensions&&u.extensions[Wc.KHR_DRACO_MESH_COMPRESSION])?"draco:"+c.bufferView+":"+c.indices+":"+Sh(c.attributes):u.indices+":"+Sh(u.attributes)+":"+u.mode),c=n[u];c?i.push(c.promise):(c=void 0,c=l.extensions&&l.extensions[Wc.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[Wc.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return _h(r,e,t)}))}(l):_h(new o.BufferGeometry,l,t),n[u]={primitive:l,promise:c},i.push(c))}return Promise.all(i)}},{key:"loadMesh",value:function(e){for(var t=this,r=this.json,n=this.extensions,i=r.meshes[e],a=i.primitives,s=[],l=0,u=a.length;l<u;l++){var c=void 0===a[l].material?(void 0===(c=this.cache).DefaultMaterial&&(c.DefaultMaterial=new o.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:o.FrontSide})),c.DefaultMaterial):this.getDependency("material",a[l].material);c.then((function(e){})),s.push(c)}return s.push(t.loadGeometries(a)),Promise.all(s).then((function(r){for(var s=r.slice(0,r.length-1),l=r[r.length-1],u=[],c=0,h=l.length;c<h;c++){var p=l[c],d=a[c],f=void 0,m=s[c];if(4===d.mode||5===d.mode||6===d.mode||void 0===d.mode)!0!==(f=new(!0===i.isSkinnedMesh?o.SkinnedMesh:o.Mesh)(p,m)).isSkinnedMesh||f.geometry.attributes.skinWeight.normalized||f.normalizeSkinWeights(),5===d.mode?f.geometry=Eh(f.geometry,o.TriangleStripDrawMode):6===d.mode&&(f.geometry=Eh(f.geometry,o.TriangleFanDrawMode));else if(1===d.mode)f=new o.LineSegments(p,m);else if(3===d.mode)f=new o.Line(p,m);else if(2===d.mode)f=new o.LineLoop(p,m);else{if(0!==d.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);f=new o.Points(p,m)}if(0<Object.keys(f.geometry.morphAttributes).length){S=w=x=b=y=v=void 0;var v=f,g=i;if(v.updateMorphTargets(),void 0!==g.weights)for(var y=0,b=g.weights.length;y<b;y++)v.morphTargetInfluences[y]=g.weights[y];if(g.extras&&Array.isArray(g.extras.targetNames)){var x=g.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.")}}f.name=t.createUniqueName(i.name||"mesh_"+e),wh(f,i),d.extensions&&xh(n,f,d),t.assignFinalMaterial(f),u.push(f)}for(var T=0,M=u.length;T<M;T++)t.associations.set(u[T],{meshes:e,primitives:T});if(1===u.length)return u[0];var _=new o.Group;t.associations.set(_,{meshes:e});for(var E=0,P=u.length;E<P;E++)_.add(u[E]);return _}))}},{key:"loadCamera",value:function(e){var t,r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new o.PerspectiveCamera(o.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new o.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),wh(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=[],a=[],s=[],l=0,u=t.channels.length;l<u;l++){var c=t.channels[l],h=t.samplers[c.sampler],p=void 0!==(c=c.target).node?c.node:c.id,d=void 0!==t.parameters?t.parameters[h.input]:h.input,f=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",p)),n.push(this.getDependency("accessor",d)),i.push(this.getDependency("accessor",f)),a.push(h),s.push(c)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(i),Promise.all(a),Promise.all(s)]).then((function(r){for(var n=r[0],i=r[1],a=r[2],s=r[3],l=r[4],u=[],c=0,h=n.length;c<h;c++)!function(e){var t=n[e],r=i[e],c=a[e],h=s[e],p=l[e];if(void 0!==t){t.updateMatrix(),t.matrixAutoUpdate=!0;var d=void 0;switch(yh[p.path]){case yh.weights:d=o.NumberKeyframeTrack;break;case yh.rotation:d=o.QuaternionKeyframeTrack;break;default:d=o.VectorKeyframeTrack}e=t.name||t.uuid;var f=void 0!==h.interpolation?bh[h.interpolation]:o.InterpolateLinear,m=[],v=(yh[p.path]===yh.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name||e.uuid)})):m.push(e),c.array);if(c.normalized){for(var g=Th(v.constructor),y=new Float32Array(v.length),b=0,x=v.length;b<x;b++)y[b]=v[b]*g;v=y}for(var w=0,S=m.length;w<S;w++){var T=new d(m[w]+"."+yh[p.path],r.array,v,f);"CUBICSPLINE"===h.interpolation&&(T.createInterpolant=function(e){return new(this instanceof o.QuaternionKeyframeTrack?ph:ch)(this.times,this.values,this.getValueSize()/3,e)},T.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),u.push(T)}}}(c);return r=t.name||"animation_"+e,new o.AnimationClip(r,void 0,u)}))}},{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,a=r.nodes[e],s=a.name?i.createUniqueName(a.name):"";return t=[],(r=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)})))&&t.push(r),void 0!==a.camera&&t.push(i.getDependency("camera",a.camera).then((function(e){return i._getNodeRef(i.cameraCache,a.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,l=!0===a.isBone?new o.Bone:1<t.length?new o.Group:1===t.length?t[0]:new o.Object3D;if(l!==t[0])for(var u=0,c=t.length;u<c;u++)l.add(t[u]);return a.name&&(l.userData.name=a.name,l.name=s),wh(l,a),a.extensions&&xh(n,l,a),void 0!==a.matrix?((r=new o.Matrix4).fromArray(a.matrix),l.applyMatrix4(r)):(void 0!==a.translation&&l.position.fromArray(a.translation),void 0!==a.rotation&&l.quaternion.fromArray(a.rotation),void 0!==a.scale&&l.scale.fromArray(a.scale)),i.associations.has(l)||i.associations.set(l,{}),i.associations.get(l).nodes=e,i.options.myOptions.helper.processNode({node:l,nodeDef:a})||l}))}},{key:"loadScene",value:function(e){for(var t=this.json,r=this.extensions,n=(e=this.json.scenes[e],this),i=(n.options.myOptions,new o.Group),a=(e.name&&(i.name=n.createUniqueName(e.name)),wh(i,e),e.extensions&&xh(r,i,e),e.nodes||[]),s=[],l=0,u=a.length;l<u;l++)s.push(function e(t,r,n,i){var a=n.nodes[t];return i.getDependency("node",t).then((function(e){return void 0===a.skin?e:i.getDependency("skin",a.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=[],a=0,s=r.length;a<s;a++){var l=r[a];l?(n.push(l),l=new o.Matrix4,void 0!==t.inverseBindMatrices&&l.fromArray(t.inverseBindMatrices.array,16*a),i.push(l)):console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[a])}e.bind(new o.Skeleton(n,i),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var o=[];if(a.children)for(var s=a.children,l=0,u=s.length;l<u;l++){var c=s[l];o.push(e(c,t,n,i))}return Promise.all(o)}))}(a[l],i,t,n));return Promise.all(s).then((function(){var e;return console.log(i,i.children,"scene"),null!=(e=n.options.myOptions)&&e.models.push(i),n.associations=function(e){var t,r=new Map,i=Oc(n.associations);try{for(i.s();!(t=i.n()).done;){var a=Rc(t.value,2),s=a[0],l=a[1];(s instanceof o.Material||s instanceof o.Texture)&&r.set(s,l)}}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 _h(e,t,r){var n,i=t.attributes,a=[];for(n in i){var s=gh[n]||n.toLowerCase();s in e.attributes||a.push(function(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}(i[n],s))}void 0===t.indices||e.index||(l=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),a.push(l)),wh(e,t);var l=e,u=t,c=r,h=u.attributes,p=new o.Box3;if(void 0!==h.POSITION){var d=(h=c.json.accessors[h.POSITION]).min,f=h.max;if(void 0===d||void 0===f)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{p.set(new o.Vector3(d[0],d[1],d[2]),new o.Vector3(f[0],f[1],f[2])),h.normalized&&(d=Th(dh[h.componentType]),p.min.multiplyScalar(d),p.max.multiplyScalar(d));var m=u.targets;if(void 0!==m){for(var v=new o.Vector3,g=new o.Vector3,y=0,b=m.length;y<b;y++){var x,w,S=m[y];void 0!==S.POSITION&&(w=(S=c.json.accessors[S.POSITION]).min,x=S.max,void 0!==w&&void 0!==x?(g.setX(Math.max(Math.abs(w[0]),Math.abs(x[0]))),g.setY(Math.max(Math.abs(w[1]),Math.abs(x[1]))),g.setZ(Math.max(Math.abs(w[2]),Math.abs(x[2]))),S.normalized&&(w=Th(dh[S.componentType]),g.multiplyScalar(w)),v.max(g)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}p.expandByVector(v)}l.boundingBox=p,f=new o.Sphere,p.getCenter(f.center),f.radius=p.min.distanceTo(p.max)/2,l.boundingSphere=f}}return Promise.all(a).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=[],d=[],f=[],m=0,v=i.length;m<v;m++){var g,y=i[m];a&&(g=void 0!==y.POSITION?o.getDependency("accessor",y.POSITION):n.attributes.position,p.push(g)),s&&(g=void 0!==y.NORMAL?o.getDependency("accessor",y.NORMAL):n.attributes.normal,d.push(g)),l&&(y=void 0!==y.COLOR_0?o.getDependency("accessor",y.COLOR_0):n.attributes.color,f.push(y))}return Promise.all([Promise.all(p),Promise.all(d),Promise.all(f)]).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 Eh(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 a=0;a<i.count;a++)n.push(a);e.setIndex(n),r=e.getIndex()}var s=r.count-2,l=[];if(t===o.TriangleFanDrawMode)for(var u=1;u<=s;u++)l.push(r.getX(0)),l.push(r.getX(u)),l.push(r.getX(u+1));else for(var c=0;c<s;c++)c%2==0?(l.push(r.getX(c)),l.push(r.getX(c+1)),l.push(r.getX(c+2))):(l.push(r.getX(c+2)),l.push(r.getX(c+1)),l.push(r.getX(c)));return l.length/3!=s&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),(t=e.clone()).setIndex(l),t}class Ph{constructor(e){this.materialMap={},this.textureMap={},this.materialIns={},this.textureIns={},this.parser=null,this.baseMaterialTextures=[],this.processBaseMaterialTextures=e=>{const{textures:t,material:r}=e;(0,Fe.js)(t,((e,t)=>{var n;(t=this.textureIns[t])&&(this.runScene.optionsEx.options.lazyLoadTexture&&"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=t=>{var r=this.baseMaterialTextures[t];if(!r)return this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),void this.runScene.optionsEx.log("贴图懒加载完毕","base","success");const{texture:n,type:i,material:o}=r;this.runScene.uniqueEx.texture.addMaterial(n,{material:o,type:i}),o[i]=n,o.needsUpdate=!0,setTimeout((()=>{e(++t)}),this.runScene.optionsEx.options.lazyLoadTextureBetween)};return()=>{if(!this.runScene.optionsEx.options.lazyLoadTexture)return this.runScene.optionsEx.cb.load.lazyLoadedTexture.cb(""),void this.runScene.optionsEx.log("贴图加载完毕","base","success");e(0)}})(),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;e=t.md5,r.userData.md5=t.md5,e&&(e=this.runScene.textureEx.getSameTexture(e,r))?this.textureIns[t.id]=e:this.textureIns[t.id]=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||{};this.processTextureMap(t||{}),this.processMaterialMap(e||{}),setTimeout((()=>{this.lazyLoad()}))}processTextureMap(e){(0,Fe.js)(e,((e,t)=>{var{format:t,center:r,rotation:n,offset:i,repeat:o}=t;const a=this.textureIns[e];a&&(a.format=t,void 0!==o&&(({x:e,y:t}="object"==typeof o?o:{x:o,y:o}),a.repeat.x=e,a.repeat.y=t),void 0!==r&&(({x:o,y:e}="object"==typeof r?r:{x:r,y:r}),a.center.x=o,a.center.y=e),void 0!==i&&(({x:t,y:r}="object"==typeof i?i:{x:i,y:i}),a.offset.x=t,a.offset.y=r),n&&(a.rotation=n),this.runScene.textureEx.bindData(a))}))}processMaterialMap(e){(0,Fe.js)(e,((e,t)=>{const{material:r,models:n}=this.materialIns[e];if(r){var{normal:e,textures:i}=t;if(e.type){const t=(0,Fe.js)(i,((e,t)=>({type:e,texture:this.textureIns[t]}))),o=this.runScene.materialEx.getDataByType(e.type,{normal:e,textures:t,models:n,material:r});if(this.runScene.materialEx.parseNromals(e,o),!o)return;n.map((e=>e.material=o))}else this.runScene.optionsEx.options.notTexture||this.processBaseMaterialTextures({material:r,textures:i}),this.runScene.materialEx.parseNromals(e,r),n.map((e=>e.material=r));r.needsUpdate=!0}}))}}class kh{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 o.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 Rh{constructor(e){this.parser=null,this.helperModels=[],this.nodeType={MySpriteMaterial:So},this.cloneMap={},this.runScene=e,this.material=new Ph(e),this.scene=new kh(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*(){try{return yield this.material.processInput(e,t),Promise.resolve()}catch(e){console.log(e,"e")}}))}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,Fe.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;this.material.done(e),"scene"===(null==(t=e.asset.ex)?void 0:t.type)&&(this.scene.done(e),this.sceneEx(e)),this.removeHelperModel()}mergeGeometry(){}mergeClone(){this.runScene.optionsEx.options.instanceClone&&(0,Fe.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=((e,t)=>{var{material:r,geometry:n}=e;const i=new ci.InstancedMesh(n,r,t.length+1);return[e,...t].map(((e,t)=>{i.setMatrixAt(t,e.matrix)})),i})(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:a}=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=this.runScene.textureEx.toThree(i))}i&&(t.background=new o.Color("#"+i)),a&&(({color:r,far:e,near:n}=a),t.fog=new o.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 Oh{constructor(e){this.dracoPath="./draco/",this._gltf=new Hc,this.runScene=e;const t=new xc;t.setDecoderPath((null==(e=this.runScene.optionsEx.options)?void 0:e.decodePath)||this.dracoPath),this._gltf.dracoLoader=t}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 Rh(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){var{addToScene:r,cleanJSON:n}=r||{};const o=e.models;let a=o;if("material"===t.asset.ex.type){var s,[s]=o;if(!(s=this.runScene.sceneEx.cleanUnlessLevel(s).material))return;this.runScene.materialEx.add(s);var l=this.runScene.modelEx.select;l&&this.runScene.materialEx.resetMaterial(l,s)}else a=o[0].children.filter((e=>{if(!this.runScene.modelEx.isUnless(e))return"model"===t.asset.ex.type&&(e.userData.id=(0,i.getId)()),e})),"scene"===t.asset.ex.type&&(this.runScene.timeLineEx.parseSavedGroupMap(t.asset.ex.timeLine||{}),this.runScene.optionsEx.cb.load.loaded.cb("")),!1!==r&&this.runScene.modelEx.add(a,void 0,{addUndo:!1,select:!1}),this.runScene.modelEx.selectNull(),this.runScene.helperEx.unfocus(),e.helper.mergeClone();return this.runScene.optionsEx.log(t,"detail"),!1!==n&&((0,Fe.js)(t,(e=>delete t[e])),t=null,this.runScene.optionsEx.sceneOptions.loaded=!0),a}}class Ch{constructor(e){this.imgBitMap=new o.ImageBitmapLoader,this.object=new o.ObjectLoader,this.runScene=e,this.gltf=new Oh(e)}}var Lh=a(185);class Dh{constructor(e){this.selectors={},this.boxHelperMap={},this.runScene=e,console.log(e,"runScene.events"),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,Lh.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 Po({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 Po({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 o.Group;const t=new o.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),Ki().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 o.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}}class Ah{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 Ih{constructor(){this.resize=new Ah,this.setSelectMaterial=new Ah,this.setScene=new Ah,this.reset=new Ah,this.render=new Ah,this.baseLog=new Ah,this.inited=new Ah,this.texture={add:new Ah,remove:new Ah},this.model={setSelect:new Ah,add:new Ah,remove:new Ah,multipDrop:new Ah,focus:new Ah,unFocus:new Ah,changeName:new Ah,setOpen:new Ah,setMainStatue:new Ah,setVisible:new Ah,setParent:new Ah,setLayers:new Ah,clone:new Ah,dispose:new Ah},this.material={add:new Ah,dispose:new Ah,setName:new Ah},this.unique={material:{add:new Ah}},this.undo={addUndos:new Ah,removeUndos:new Ah,undoByIndex:new Ah,reset:new Ah},this.scene={save:new Ah,saveNet:new Ah},this.timeLine={setProgress:new Ah,playGroup:new Ah,setGroupMap:new Ah,reset:new Ah,closeGroup:new Ah},this.events={key:{g:new Ah},mouse:{move:new Ah,down:new Ah,up:new Ah},pointer:{down:new Ah,up:new Ah}},this.bloom={glow:{setData:new Ah}},this.load={lazyLoadedTexture:new Ah,loaded:new Ah,models:new Ah,progress:new Ah,getArrayBuffer:new Ah}}}function jh(){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 jh.Panel("FPS","#0ff","#002")),u=r(new jh.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=r(new jh.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}}jh.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,d=74*a,f=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,d,f),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h,p,d,f),{dom:m,update:function(l,g){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,d-a,f,h,p,d-a,f),v.fillRect(h+d-a,p,a,f),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(h+d-a,p,a,o((1-l/g)*f))}}};const Uh=jh;class Bh{constructor(e){this.options={msg:{show:!0,level:"base"},run:!0,decodePath:"./draco/",showFps:!1,loadInterval:2e3,mode:"running",lazyLoadTexture:!1,lazyLoadTextureBetween:16.6,notTexture:!1,hideLocal:!1,instanceClone:!1,render2:!1,render3:!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 Ih,this.runScene=e}init(e){this.options=Object.assign(this.options,e||{}),this.options.showFps&&(this.addFps(),this.cb.render.add("optionx-ex-render",this.render.bind(this)))}addFps(){this.stats=Uh(),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 Nh{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 o.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=o.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 Fh=(e,t)=>{t=(t||{}).removeDom,!(e.render=()=>{})!==t&&e.domElement.remove(),e.setAnimationLoop(null),e.dispose(),e.renderLists&&e.renderLists.dispose()};class zh{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,Ji.multiArrToArr)(i(e)))}t.push(new Eo({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 o.Group;return e.children.filter((e=>!this.runScene.helperEx.isHelper(e)&&!this.runScene.lightEx.isLight(e))).map((e=>{console.log(e,"model"),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 o.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),n=new mo({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=>{((e,t)=>{t=(t||{}).remove;const{geomerty:r,material:n}=e;if(r&&(null!=r&&r.dispose(),delete e.geometry),n){{var i=e.material;i.dispose();const t=wo(i);0!==t.length&&t.map((e=>{(e=>{if(e){const r=e.image;var t=e.userData.url;r.close(),URL.revokeObjectURL(t),e.dispose()}})(e=e.texture)}))}e.material.dispose(),delete e.material}!1!==t&&e.parent&&e.parent.remove(e)})(e,{remove:!1}),this.runScene.optionsEx.cb.model.dispose.cb(e)})),Fh(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(),Fh(e),t.dispose(),this.runScene.bloom.glow.dispose(),o.Cache.clear()}render(){}create(){return new o.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=this.runScene.textureEx.toThree(yield this.runScene.textureEx.parse(t))),null!=t&&t.isTexture&&(r=this.runScene.textureEx.toThree(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 mo({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 o.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 no({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,Ve.base64ToFile)(a,"screenShot.jpg"),r.width=e,r.height=t,this.runScene.renderEx.setSize(),n.render(i,o),a}}class Vh{constructor(e,t){this.showTransform=!1,this.data=new Proxy({},{set:(e,t,r)=>(e[t]=r,console.log(e,t,r,"a,b,c"),!0)}),this.uuid="",this.getAnimaByModelData=(()=>{const e=(e,t,r,n)=>{const i={},o={};if(e=Vh.isNotNow(e)?this.getAllData():e,(0,Fe.js)(n,((r,n)=>{void 0!==e[r]&&("number"===(n=n.type)?(i[r]=t[r],o[r]=e[r]):"color"===n&&(0,Fe.js)(e[r],((e,n)=>{var a=r+e;i[a]=t[r][e],o[a]=n})))})),!(0,Fe.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,Ji.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,d=o;const t={color(e){const{animaData:t,defType:r}=e,n={};(0,Fe.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,Lh.isTrue)(e)&&(0,Lh.isTrue)(i)&&(0,Lh.isTrue)(o))return n}};return()=>{let r;return{promise:new Promise((n=>{var i=e(h,c,0,d);if(console.log(i,"leftAndRight"),!i)return n(0);var{begin:i,end:o}=i;return r=bi(i,o,p,(e=>{(0,Fe.js)(d,((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,Fe.js)(e,(i=>{n[i]=r?"notNow":Vh.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?Ki().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 Vh.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return Vh.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){Vh.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const n=new(0,Gh[r])(e);return n.data=t,n}reset(){(0,Fe.js)(this.defOptions,((e,t)=>{Vh.SetTargetByData({baseType:t.type,data:Vh.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}remove(){delete this.target.userData.isTimeLineUsed}}Vh.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,n,i,o)=>{(0,Fe.js)(i,((i,a)=>{var s,l,u,c,h,p;a=a.type,void 0!==t[i]&&void 0!==r[i]&&Vh.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 Hh=Vh,Gh={model:class extends Hh{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}=Hh.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,Ji.lastArrayEle)(a),l=i?"0.00":String(n.time)+".00";return s!==l&&(console.log(s,"last"),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=bi(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 Hh{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}=Hh.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=bi(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:d}=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,d)}),a)})),anima:bi}};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,Ji.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":Ki().model.v3ToMap(t),scale:e?"notNow":Ki().model.v3ToMap(r),rotation:e?"notNow":Ki().model.v3ToMap(n),target:e?"notNow":Ki().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:n}=this.target;let i;if("position"===e)i=Ki().model.v3ToMap(t);else if("scale"===e)i=Ki().model.v3ToMap(r);else if("rotation"===e)i=Ki().model.v3ToMap(n);else{if("target"!==e)throw TypeError("输入值不存在");i=Ki().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 Hh{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"}},console.log("new timeLineMap"),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 Wh{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){if(e.userData){let n=e.userData.id;n||(n=(0,i.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 console.log(this.map,e,"this.map[id]?.material"),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),console.log("添加材质到移除列表",e,"material"))}dispose(){(0,Fe.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var Xh=a(1);class qh 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,i.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),Xh.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(Xh.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 o=e.userData.id;if(o&&!r||(o=(0,i.getId)(),e.userData.id=o),this.map[o]){if(!n)return;o=(0,i.getId)(),e.userData.id=o}return this.map[o]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):o}}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 Yh{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,i.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,Fe.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}class Zh{constructor(e){this.runScene=e,this.model=new qh(this),this.material=new Wh(this),this.texture=new Yh(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}}const Qh={RunScene:class{constructor(e){this.uniqueEx=new Zh(this),this.fileEx=new bu(this),this.optionsEx=new Bh(this),this.undoEx=new to(this),this.textureEx=new vi(this),this.controlsEx=new Be,this.assetsEx=new U(this),this.renderEx=new Nh(this),this.events=new class{constructor(e){this.key=new Zi(this),this.mouse=new Qi(this),this.drag=new Ne(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 Dh(this),this.helperEx=null,this.materialEx=new yo(this),this.cameraEx=new ke(this),this.sceneEx=new zh(this),this.modelEx=new ko(this),this.loaderer=new Ch(this),this.exporter=new ua(this),this.lightEx=new mc(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;console.log(e,"groupName"),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,Fe.js)(this.groupMap,((e,t)=>{t.run=!1})),console.log(this.groupMap,"this.groupMap"),this.groupMap}parseSavedGroupMap(e){Object.keys(e).map((t=>{const r=e[t],n={};(0,Fe.js)(r.data,((e,t)=>{var{type:r,data:i}=t;console.log(t,"modelData");const o=Gh[r];if(t=o.getTarget(e,this.runScene),console.log(t,"target"),t){const r=new o(t,this.runScene);r.data=i,n[e]=r}})),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,Ji.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 Pe(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 nc(this),this.helperEx.init();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(""),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 n().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,i.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: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}));