run-scene-v2 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +2 -3
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("three"),require("uuid1"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):"function"==typeof define&&define.amd?define(["axios","three","uuid1","@allex/md5","js-funcs-three","js-funcs"],t):"object"==typeof exports?exports.RunScene=t(require("axios"),require("three"),require("uuid1"),require("@allex/md5"),require("js-funcs-three"),require("js-funcs")):e.RunScene=t(e.axios,e.three,e.uuid1,e["@allex/md5"],e["js-funcs-three"],e["js-funcs"])}(self,((e,t,r,s,i,n)=>{return o={218:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};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;const i=s(r(300));t.base64ToFile=(e,t)=>{let r=e.split(","),s=r[0].match(/:(.*?);/)[1],i=atob(r[1]),n=i.length,a=new Uint8Array(n);for(;n--;)a[n]=i.charCodeAt(n);return new File([a],t,{type:s})},t.bufferToArrayBuffer=e=>{for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),s=0;s<e.length;++s)r[s]=e[s];return t},t.blobToDataUrl=e=>i.default.get(e,{baseURL:"",responseType:"blob",timeout:5e3}).then((e=>(0,t.toResult)(e.data))).catch((e=>!1)),t.toUrl=(e,t="any.json")=>{let r;return r=e instanceof File?e:(e=JSON.stringify(e),new File([e],t)),window.URL.createObjectURL(r)},t.strToArrayBuffer=e=>{let t="";for(let 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=e=>new Promise((t=>{var r=new Blob([e]),s=new FileReader;s.readAsText(r,"utf-8"),s.onload=function(){t(s.result)}})),t.bToMB=(e,t=!1)=>{const r=e/1024/1024;return t?r:r.toFixed(2)+"MB"},t.getBackWord=e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),t.getPrefixWord=e=>e.substr(0,e.lastIndexOf(".")),t.toResult=(e,t="text")=>{var r=new FileReader;return"text"===t?r.readAsText(e):"arrayBuffer"===t?r.readAsArrayBuffer(e):"base64"===t&&r.readAsDataURL(e),new Promise((e=>{r.onload=t=>e(t.target.result)}))},t.urlToBase64=e=>i.default.get(e,{responseType:"arraybuffer"}).then((e=>`data:${e.headers["content-type"]};base64,`+new Buffer(e.data,"binary").toString("base64"))),t.getFileName=e=>e.substring(e.lastIndexOf("-")+1),t.downloadFile=(e,t="any.text")=>{let 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()}},399:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deepArrByMaps=t.map=t.multiArrToArr=t.eachTriggerArray=t.eachTriggerArrGetControls=t.emptyArray=t.delArrEle=t.lastArrayEle=void 0;const i=r(639);t.lastArrayEle=e=>e.slice(-1)[0],t.delArrEle=(e,t)=>{var r=e.slice(0,t);return e=e.slice(t+1),[...r,...e]},t.emptyArray=e=>0===e.length,t.eachTriggerArrGetControls=e=>{const r=new Proxy({run:!0,clean:!1,target:e,index:0,runningAnima:null,eachCb:(e,t)=>{e.anima&&(r.runningAnima=e.anima),r.index=t}},{set:(e,t,s)=>("clean"===t&&!0===s&&!1===e[t]&&(r.run=!1,r.target.splice(0)),"run"===t&&!1===s&&!0===e[t]&&(console.log(r,"controls"),r.runningAnima&&r.runningAnima.pause()),"run"===t&&!0===s&&!1===e[t]&&r.runningAnima&&r.runningAnima.resume(),e[t]=s,!0)});return e=(0,t.eachTriggerArray)(e,r),{controls:r,promise:e}},t.eachTriggerArray=(()=>{const e=(t,r,i,n)=>s(void 0,void 0,void 0,(function*(){const s=t[r++];if(!s)return i();var a,o=s();o instanceof Promise?(a=yield o,null!=n&&n.eachCb(a,r)):o.promise&&o.promise instanceof Promise?(null!=n&&n.eachCb(o,r),yield o.promise):null!=n&&n.eachCb(o,r),e(t,r,i,n)}));return(t,r)=>new Promise((s=>e(t,0,s,r)))})(),t.multiArrToArr=(()=>{const e=(t,r)=>{t.map((t=>{if("array"===(0,i.getType)(t))return e(t,r);r.push(t)}))};return t=>{var r=[];return e(t,r),r}})(),t.map=(e,t)=>e.map(((r,s)=>t(r,s,e))).filter((e=>e)),t.deepArrByMaps=e=>{const{arr:r,typeList:s,findType:i,mapType:n}=e;if(!r||!s||!i)return r;const a=[...s];return(e=r.find((e=>e[i]===s[0])))?1!==s.length&&e[n]instanceof Array?(a.shift(),(0,t.deepArrByMaps)({arr:e[n],typeList:a,findType:i,mapType:n})):e:r}},414:(e,t,r)=>{"use strict";t.qR=t.js=t.CV=void 0,r(639),t.CV=e=>0===Object.values(e).length,t.js=(e,t)=>Object.keys(e).map(((r,s)=>{var i=e[r];return t(r,i,s)})),t.qR=(e,t)=>{let r=-1,s=e=>(r++,t.length===r+1?e:s(e[t[r]]));return s(e)}},799:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getId=t.getMacro=t.getUuid=void 0;const i=s(r(937)),n=s(r(670));t.getUuid=()=>i.default.UUID1(),t.getMacro=(e,t=0)=>{let r=setTimeout((()=>(clearTimeout(r),r=null,e())),t)},t.getId=()=>(0,n.default)()},639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTrue=t.getType=void 0,t.getType=e=>{if(void 0!==e){if(null===e)return null;let 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=e=>!(null==e||!1===e)},921:e=>{e.exports=function(e,t,r){for(var s=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*s*r/t.length),n="";;)for(var a=e(i),o=i;o--;)if((n+=t[a[o]&s]||"").length===+r)return n}},670:(e,t,r)=>{"use strict";e.exports=r(607)},829:(e,t,r)=>{"use strict";var s,i,n,a=r(946),o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function l(){n=!1}function h(e){if(e){if(e!==s){if(e.length!==o.length)throw new Error("Custom alphabet for shortid must be "+o.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 "+o.length+" unique characters. These characters were not unique: "+t.join(", "));s=e,l()}}else s!==o&&(s=o,l())}function c(){return n=n||function(){s||h(o);var e,t=s.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 s||o},characters:function(e){return h(e),s},seed:function(e){a.seed(e),i!==e&&(l(),i=e)},lookup:function(e){return c()[e]},shuffled:c}},480:(e,t,r)=>{"use strict";var s,i,n=r(416);r(829),e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===i?s++:(s=0,i=r),t=(t+=n(7))+n(e),0<s&&(t+=n(s)),t+n(r)}},416:(e,t,r)=>{"use strict";var s=r(829),i=r(766),n=r(921);e.exports=function(e){for(var t,r=0,a="";!t;)a+=n(i,s.get(),1),t=e<Math.pow(16,r+1),r++;return a}},607:(e,t,r)=>{"use strict";var s=r(829),i=r(480),n=r(82),a=r(636)||0;function o(){return i(a)}e.exports=o,e.exports.generate=o,e.exports.seed=function(t){return s.seed(t),e.exports},e.exports.worker=function(t){return a=t,e.exports},e.exports.characters=function(e){return void 0!==e&&s.characters(e),s.shuffled()},e.exports.isValid=n},82:(e,t,r)=>{"use strict";var s=r(829);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+s.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},766:e=>{"use strict";var t="object"==typeof window&&(window.crypto||window.msCrypto),r=t&&t.getRandomValues?function(e){return t.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=r},946:e=>{"use strict";var t=1;e.exports={nextValue:function(){return(t=(9301*t+49297)%233280)/233280},seed:function(e){t=e}}},636:e=>{"use strict";e.exports=0},129:e=>{"use strict";e.exports=s},300:t=>{"use strict";t.exports=e},1:e=>{"use strict";e.exports=n},356:e=>{"use strict";e.exports=i},881:e=>{"use strict";e.exports=t},937:e=>{"use strict";e.exports=r}},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})},h={},(()=>{"use strict";a.d(h,{default:()=>Dl});var e={},t=(a.r(e),a.d(e,{AsyncCompress:()=>Wi,AsyncDecompress:()=>on,AsyncDeflate:()=>Bi,AsyncGunzip:()=>Qi,AsyncGzip:()=>Wi,AsyncInflate:()=>ji,AsyncUnzipInflate:()=>En,AsyncUnzlib:()=>rn,AsyncZipDeflate:()=>Pn,AsyncZlib:()=>$i,Compress:()=>Gi,DecodeUTF8:()=>pn,Decompress:()=>an,Deflate:()=>ki,EncodeUTF8:()=>mn,Gunzip:()=>Zi,Gzip:()=>Gi,Inflate:()=>zi,Unzip:()=>Dn,UnzipInflate:()=>An,UnzipPassThrough:()=>Rn,Unzlib:()=>tn,Zip:()=>Cn,ZipDeflate:()=>Sn,ZipPassThrough:()=>_n,Zlib:()=>Ji,compress:()=>Xi,compressSync:()=>Yi,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]?qi:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Vi:sn)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?Ki:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Hi:nn)(e,t)},deflate:()=>Ni,deflateSync:()=>Fi,gunzip:()=>qi,gunzipSync:()=>Ki,gzip:()=>Xi,gzipSync:()=>Yi,inflate:()=>Vi,inflateSync:()=>Hi,strFromU8:()=>gn,strToU8:()=>fn,unzip:()=>function(e,t){if("function"!=typeof t)throw"no callback";for(var r=[],s=function(){for(var e=0;e<r.length;++e)r[e]()},i={},n=e.length-22;101010256!=Ci(e,n);--n)if(!n||65558<e.length-n)return void t("invalid zip file",null);var a=Pi(e,n+8);a||t(null,{});var o=a,l=Ci(e,n+16),h=4294967295==l;if(h){if(n=Ci(e,n-12),101075792!=Ci(e,n))return void t("invalid zip file",null);o=a=Ci(e,n+32),l=Ci(e,n+48)}for(var c=function(n){function o(e,r){e?(s(),t(e,null)):(i[p]=r,--a||t(null,i))}var c=(f=xn(e,l,h))[0],u=f[1],d=f[2],p=f[3],m=f[4],f=f[5];if(f=yn(e,f),l=m,c)if(8==c)if(m=e.subarray(f,f+u),u<32e4)try{o(null,Hi(m,new Ms(d)))}catch(n){o(n,null)}else r.push(Vi(m,{size:d},o));else o("unknown compression type "+c,null);else o(null,qs(e,f,f+u))},u=0;u<o;++u)c();return s},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=Ci(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var s=Pi(e,r+8);if(!s)return{};var i=Ci(e,r+16),n=4294967295==i;if(n){if(r=Ci(e,r-12),101075792!=Ci(e,r))throw"invalid zip file";s=Ci(e,r+32),i=Ci(e,r+48)}for(var a=0;a<s;++a){var o=(d=xn(e,i,n))[0],l=d[1],h=d[2],c=d[3],u=d[4],d=d[5];if(d=yn(e,d),i=u,o){if(8!=o)throw"unknown compression type "+o;t[c]=Hi(e.subarray(d,d+l),new Ms(h))}else t[c]=qs(e,d,d+l)}return t},unzlib:()=>sn,unzlibSync:()=>nn,zip:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";function s(){for(var e=0;e<d.length;++e)d[e]()}function i(){for(var e=new Ms(h+22),t=l,s=h-l,i=h=0;i<c;++i){var n=u[i];try{var a=n.c.length,o=(Tn(e,h,n,n.f,n.u,a),30+n.f.length+bn(n.extra)),d=h+o;e.set(n.c,d),Tn(e,l,n,n.f,n.u,a,h,n.m),l+=16+o+(n.m?n.m.length:0),h=d+a}catch(e){return r(e,null)}}Mn(e,l,u.length,s,t),r(null,e)}var n={},a=(ln(e,"",n,t),Object.keys(n)),o=a.length,l=0,h=0,c=o,u=new Array(o),d=[];o||i();for(var p=function(e){function t(t,n){t?(s(),r(t,null)):(t=n.length,u[e]=pi(f,{size:v,crc:g.d(),c:n,f:y,m:b,u:x!=c.length||b&&w.length!=T,compression:_}),l+=30+x+M+t,h+=76+2*(x+M)+(T||0)+t,--o||i())}var c=a[e],p=n[c],m=p[0],f=p[1],g=ci(),v=m.length,y=(g.p(m),fn(c)),x=y.length,w=f.comment,b=w&&fn(w),T=b&&b.length,M=bn(f.extra),_=0==f.level?0:8;if(65535<x&&t("filename too long",null),_)if(v<16e4)try{t(null,Fi(m,f))}catch(p){t(p,null)}else d.push(Ni(m,f,t));else t(null,m)},m=0;m<c;++m)p(m);return s},zipSync:()=>function(e,t){var r,s={},i=[],n=(ln(e,"",s,t=t||{}),0),a=0;for(r in s){var o,l=(o=s[r])[0],h=0==(o=o[1]).level?0:8,c=(w=fn(r)).length,u=o.comment,d=u&&fn(u),p=d&&d.length,m=bn(o.extra);if(65535<c)throw"filename too long";var f=h?Fi(l,o):l,g=f.length,v=ci();v.p(l),i.push(pi(o,{size:l.length,crc:v.d(),c:f,f:w,m:d,u:c!=r.length||d&&u.length!=p,o:n,compression:h})),n+=30+c+m+g,a+=76+2*(c+m)+(p||0)+g}for(var y=new Ms(a+22),x=(e=n,t=a-n,0);x<i.length;++x){var w=i[x],b=(Tn(y,w.o,w,w.f,w.u,w.c.length),30+w.f.length+bn(w.extra));y.set(w.c,w.o+b),Tn(y,n,w,w.f,w.u,w.c.length,w.o,w.m),n+=16+b+(w.m?w.m.length:0)}return Mn(y,n,i.length,t,e),y},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[yi,bi,function(){return[en]}],(function(e){return Mi(en(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>en}),a(300)),r=a.n(t),s=a(881);const i={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}"};class n{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const o=new s.OrthographicCamera(-1,1,1,-1,0,1),l=new s.BufferGeometry;l.setAttribute("position",new s.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new s.Float32BufferAttribute([0,2,0,0,2,0],2));class c{constructor(e){this._mesh=new s.Mesh(l,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,o)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class u extends n{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof s.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=s.UniformsUtils.clone(e.uniforms),this.material=new s.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new c(this.material)}render(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)}}const d={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new s.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}"};class p extends n{constructor(e,t,r,n){super(),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=n,this.resolution=void 0!==e?new s.Vector2(e.x,e.y):new s.Vector2(256,256),this.clearColor=new s.Color(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new s.WebGLRenderTarget(a,o),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){const t=new s.WebGLRenderTarget(a,o),r=(t.texture.name="UnrealBloomPass.h"+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t),new s.WebGLRenderTarget(a,o));r.texture.name="UnrealBloomPass.v"+e,r.texture.generateMipmaps=!1,this.renderTargetsVertical.push(r),a=Math.round(a/2),o=Math.round(o/2)}r=d;var l=(this.highPassUniforms=s.UniformsUtils.clone(r.uniforms),this.highPassUniforms.luminosityThreshold.value=n,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new s.ShaderMaterial({uniforms:this.highPassUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,defines:{}}),this.separableBlurMaterials=[],[3,5,7,9,11]);a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[e])),this.separableBlurMaterials[e].uniforms.texSize.value=new s.Vector2(a,o),a=Math.round(a/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0,this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new s.Vector3(1,1,1),new s.Vector3(1,1,1),new s.Vector3(1,1,1),new s.Vector3(1,1,1),new s.Vector3(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e=i,this.copyUniforms=s.UniformsUtils.clone(e.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new s.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:s.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new s.Color,this.oldClearAlpha=1,this.basic=new s.MeshBasicMaterial,this.fsQuad=new c(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()}setSize(e,t){let r=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(r,i);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(r,i),this.renderTargetsVertical[e].setSize(r,i),this.separableBlurMaterials[e].uniforms.texSize.value=new s.Vector2(r,i),r=Math.round(r/2),i=Math.round(i/2)}render(e,t,r,s,i){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();var n=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),i&&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);let a=this.renderTargetBright;for(let t=0;t<this.nMips;t++)this.fsQuad.material=this.separableBlurMaterials[t],this.separableBlurMaterials[t].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[t].uniforms.direction.value=p.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[t]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[t].uniforms.colorTexture.value=this.renderTargetsHorizontal[t].texture,this.separableBlurMaterials[t].uniforms.direction.value=p.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[t]),e.clear(),this.fsQuad.render(e),a=this.renderTargetsVertical[t];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,i&&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=n}getSeperableBlurMaterial(e){return new s.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new s.Vector2(.5,.5)},direction:{value:new s.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}"})}getCompositeMaterial(e){return new s.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}"})}}p.BlurDirectionX=new s.Vector2(1,0),p.BlurDirectionY=new s.Vector2(0,1);class m extends n{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){var s=e.getContext();const i=e.state;let n,a;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0),a=this.inverse?(n=0,1):(n=1,0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),i.buffers.stencil.setFunc(s.ALWAYS,n,4294967295),i.buffers.stencil.setClear(a),i.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),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(s.EQUAL,1,4294967295),i.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),i.buffers.stencil.setLocked(!0)}}class f extends n{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class g{constructor(e,t){var r;this.renderer=e,void 0===t?(r=e.getSize(new s.Vector2),this._pixelRatio=e.getPixelRatio(),this._width=r.width,this._height=r.height,(t=new s.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio)).texture.name="EffectComposer.rt1"):(this._pixelRatio=1,this._width=t.width,this._height=t.height),this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===u&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new u(i),this.clock=new s.Clock}swapBuffers(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){-1!==(e=this.passes.indexOf(e))&&this.passes.splice(e,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){void 0===e&&(e=this.clock.getDelta());var t=this.renderer.getRenderTarget();let r=!1;for(let t=0,i=this.passes.length;t<i;t++){const i=this.passes[t];if(!1!==i.enabled){if(i.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),i.render(this.renderer,this.writeBuffer,this.readBuffer,e,r),i.needsSwap){if(r){var s=this.renderer.getContext();const t=this.renderer.state.buffers.stencil;t.setFunc(s.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),t.setFunc(s.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==m&&(i instanceof m?r=!0:i instanceof f&&(r=!1))}}this.renderer.setRenderTarget(t)}reset(e){var t;void 0===e&&(t=this.renderer.getSize(new s.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}setSize(e,t){this._width=e,this._height=t;var r=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(r,s),this.renderTarget2.setSize(r,s);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}}new s.OrthographicCamera(-1,1,1,-1,0,1);const v=new s.BufferGeometry;v.setAttribute("position",new s.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),v.setAttribute("uv",new s.Float32BufferAttribute([0,2,0,0,2,0],2));class y extends n{constructor(e,t,r,n){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==r?r:0,this.clearAlpha=void 0!==n?n:0,this._oldClearColor=new s.Color,e=i,this.copyUniforms=s.UniformsUtils.clone(e.uniforms),this.copyMaterial=new s.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:s.AdditiveBlending,depthTest:!1,depthWrite:!1}),this.fsQuad=new c(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}setSize(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}render(e,t,r){this.sampleRenderTarget||(this.sampleRenderTarget=new s.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var i=x[Math.max(0,Math.min(this.sampleLevel,5))],n=e.autoClear,a=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),o=1/i.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(let r=0;r<i.length;r++){var h=i[r];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*h[0],l.offsetY+.0625*h[1],l.width,l.height);let s=o;this.unbiased&&(h=(r+.5)/i.length-.5,s+=1/32*h),this.copyUniforms.opacity.value=s,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===r&&(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=n,e.setClearColor(this._oldClearColor,a)}}const x=[[[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 w extends y{constructor(e,t,r,s){super(e,t,r,s),this.sampleLevel=0,this.accumulate=!1}render(e,t,r,i){if(!1===this.accumulate)return super.render(e,t,r,i),void(this.accumulateIndex=-1);var n=b[5],a=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new s.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new s.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(super.render(e,this.holdRenderTarget,r,i),this.accumulateIndex=0),i=e.autoClear,e.autoClear=!1,1/n.length);if(0<=this.accumulateIndex&&this.accumulateIndex<n.length){this.copyUniforms.opacity.value=a,this.copyUniforms.tDiffuse.value=t.texture;var o=Math.pow(2,this.sampleLevel);for(let s=0;s<o;s++){var l=n[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*l[0],.0625*l[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>=n.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(a=this.accumulateIndex*a)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),a<1&&(this.copyUniforms.opacity.value=1-a,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==a&&e.clear(),this.fsQuad.render(e)),e.autoClear=i}}const b=[[[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 T extends n{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof s.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=s.UniformsUtils.clone(e.uniforms),this.material=new s.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new c(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 M extends n{constructor(e,t,r,i,n){super(),this.scene=e,this.camera=t,this.layerIndex=0,this.overrideMaterial=r,this.clearColor=i,this.clearAlpha=void 0!==n?n:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.oldClearColor=new s.Color,this.oldCameraLayer=t.layers.mask}render(e,t,r){var s=e.autoClear;let i,n;e.autoClear=!1,void 0!==this.overrideMaterial&&(n=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=n),this.scene.background=this.sceneBg,e.autoClear=s}}const _={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 "};var S=a(799);class P extends s.Line{constructor(e,t){const r=new s.BufferGeometry;r.setAttribute("position",new s.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new s.LineBasicMaterial({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new s.BufferGeometry;i.setAttribute("position",new s.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new s.Mesh(i,new s.MeshBasicMaterial({side:s.BackSide,fog:!1})))}updateMatrixWorld(){if(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);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const t=this.material.color;var e=Math.max(t.r,t.g,t.b);1<e&&t.multiplyScalar(1/e),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)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const C=s;class R{constructor(e){this.addTree=!0,this.isClone=!1;var{model:e,parent:t,cb:r,addTree:s,isClone:i}=e;this.model=e,this.parent=t,!1===s&&(this.addTree=s),!0===i&&(this.isClone=i),r&&(R.cb=r)}static remove(e){const{model:t,parent:r,addTree:s}=e;r.remove(t),s&&pl.model.remove(t),s&&ml.cb.model.remove.cb({model:t,parent:r}),this.cb(t,"remove"),pl.material.addModel(t,void 0,t.material)}static add(e){const{model:t,parent:r,addTree:s,isClone:i}=e;r.add(t),s&&pl.model.add(t),s&&ml.cb.model.add.cb({model:t,parent:r,isClone:i}),this.cb(t,"add"),pl.material.addModel(t,t.material)}}R.cb=(e,t)=>{};class A extends R{constructor(e){super(e),this.type="添加模型"}_execute(e){return Promise.reject()}undo(){R.remove({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone})}redo(){R.add({model:this.model,parent:this.parent,addTree:this.addTree,isClone:this.isClone})}execute(){return this.redo(),this}}var E=a(399),D=a(414);class L{}const I=class extends L{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,D.qR)(e.target,this.typeList)[(0,E.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,D.qR)(this.target,this.typeList);t[(0,E.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)}},O=class extends L{constructor(e){super(),this.type="修改属性",this.cb=e=>{};var{target:e,info:t,oldVal:r,newVal:s,cb:i,executeCb:n}=e;this.target=e,this.info=t,this.newVal=s,this.oldVal=r,i&&(this.cb=i),n&&(this.executeCb=n)}_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=pl.model.parseName(this.target))&&(e=t),ml.cb.model.changeName.cb({model:this.target,name:e})):"material"===this.info?pl.material.addModel(this.target,e,e===this.newVal?this.oldVal:this.newVal):"visible"===this.info&&ml.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)}};class U extends R{constructor(e){super(e),this.type="移除模型"}undo(){R.add({model:this.model,parent:this.parent,addTree:this.addTree})}redo(){R.remove({model:this.model,parent:this.parent,addTree:this.addTree})}_execute(e){return Promise.reject()}execute(){return this.redo(),this}}const k={DirectionalLight:new class{toJSON(e){const{intensity:t,name:r,type:s,position:i,visible:n,color:a,castShadow:o,shadow:l,rotation:h,target:c}=e;var{mapSize:e,camera:u}=l,{scale:u,near:d,far:p}=u;return{type:s,intensity:t,name:r,visible:n,color:a.getHexString(),castShadow:o,shadow:{mapSize:e.x,camera:{near:d,far:p,scale:u.x}},position:{x:i.x,y:i.y,z:i.z},rotation:{x:h.x,y:h.y,z:h.z},targetPosition:{x:c.position.x,y:c.position.y,z:c.position.z}}}parseJSON(e){const t=Al.get("DirectionalLight",{addUndo:!1});var{targetPosition:e,intensity:r,name:s,position:i,visible:n,color:a,castShadow:o,shadow:l,rotation:h,type:c}=e,{mapSize:l,camera:u}=l,{scale:u,near:d,far:p}=u;return t.intensity=r,t.type=c,t.name=s,t.visible=n,t.castShadow=o,t.color=new C.Color("#"+a),t.position.set(i.x,i.y,i.z),t.rotation.set(h.x,h.y,h.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=u,t.shadow.camera.scale.y=u,t.shadow.camera.scale.z=u,t.shadow.camera.near=d,t.shadow.camera.far=p,t.shadow.camera.updateProjectionMatrix(),t.cameraHelper.update(),t}},PointLight:new class{toJSON(e){const{name:t,type:r,intensity:s,distance:i,decay:n,renderOrder:a,color:o,visible:l,castShadow:h,shadow:c,position:u}=e;var{mapSize:e,camera:d,bias:p,radius:m}=c,{scale:d,near:f,far:g}=d;return{name:t,type:r,intensity:s,visible:l,color:o.getHexString(),castShadow:h,distance:i,decay:n,renderOrder:a,shadow:{mapSize:e.x,camera:{near:f,far:g,scale:d.x},radius:m,bias:p},position:{x:u.x,y:u.y,z:u.z}}}parseJSON(e){const t=Al.get("PointLight",{addUndo:!1});var{name:e,type:r,intensity:s,distance:i,decay:n,renderOrder:a,color:o,visible:l,castShadow:h,shadow:c,position:u}=e,{mapSize:c,camera:d,bias:p,radius:m}=c,{scale:d,near:f,far:g}=d;return t.intensity=s,t.type=r,t.name=e,t.visible=l,t.castShadow=h,t.distance=i,t.renderOrder=a,t.color=new C.Color("#"+o),t.position.set(u.x,u.y,u.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=p,t.decay=n,t.shadow.radius=m,t.shadow.camera.scale.x=d,t.shadow.camera.scale.y=d,t.shadow.camera.scale.z=d,t.shadow.camera.near=f,t.shadow.camera.far=g,t.shadow.camera.updateProjectionMatrix(),t}},SpotLight:new class{toJSON(e){const{name:t,type:r,color:s,distance:i,decay:n,intensity:a,angle:o,penumbra:l,visible:h,castShadow:c,shadow:u,renderOrder:d,position:p,target:m}=e;var{bias:e,camera:f,normalBias:g,mapSize:v,radius:y}=u,f=f.near;return{type:r,intensity:a,name:t,visible:h,distance:i,angle:o,decay:n,penumbra:l,renderOrder:d,color:s.getHexString(),castShadow:c,shadow:{bias:e,normalBias:g,mapSize:v.x,camera:{near:f},radius:y},position:{x:p.x,y:p.y,z:p.z},targetPosition:{x:m.position.x,y:m.position.y,z:m.position.z}}}parseJSON(e){const t=Al.get("SpotLight",{addUndo:!1});var{name:e,type:r,color:s,distance:i,decay:n,intensity:a,angle:o,penumbra:l,visible:h,castShadow:c,shadow:u,renderOrder:d,position:p,targetPosition:m}=e,{bias:u,camera:f,normalBias:g,mapSize:v,radius:y}=u,f=f.near;return t.intensity=a,t.type=r,t.name=e,t.visible=h,t.distance=i,t.decay=n,t.angle=o,t.penumbra=l,t.renderOrder=d,t.castShadow=c,t.color=new C.Color("#"+s),t.position.set(p.x,p.y,p.z),t.shadow.mapSize.x=v,t.shadow.mapSize.y=v,t.shadow.camera.near=f,t.target.position.set(m.x,m.y,m.z),t.shadow.bias=u,t.shadow.normalBias=g,t.shadow.radius=y,t.shadow.camera.updateProjectionMatrix(),t}},RectAreaLight:new class{toJSON(e){const{type:t,intensity:r,name:s,visible:i,color:n,position:a}=e;return{name:s,type:t,intensity:r,visible:i,position:{x:a.x,y:a.y,z:a.z},color:n.getHexString()}}parseJSON(e){const t=Al.get("RectAreaLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:i,color:n,position:a}=e;return t.type=e,t.intensity=r,t.name=s,t.visible=i,t.color=new C.Color("#"+n),t.position.set(a.x,a.y,a.z),t}},HemisphereLight:new class{toJSON(e){const{type:t,intensity:r,name:s,visible:i,color:n,groundColor:a,position:o}=e;return{name:s,type:t,intensity:r,visible:i,position:{x:o.x,y:o.y,z:o.z},groundColor:a.getHexString(),color:n.getHexString()}}parseJSON(e){const t=Al.get("HemisphereLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:i,color:n,groundColor:a,position:o}=e;return t.type=e,t.intensity=r,t.name=s,t.visible=i,t.color=new C.Color("#"+n),t.groundColor=new C.Color("#"+a),t.position.set(o.x,o.y,o.z),t}},AmbientLight:new class{toJSON(e){const{type:t,intensity:r,name:s,visible:i,color:n}=e;return{type:t,intensity:r,name:s,visible:i,color:n.getHexString()}}parseJSON(e){const t=Al.get("AmbientLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:i,color:n}=e;return t.intensity=r,t.type=e,t.name=s,t.visible=i,t.color=new C.Color("#"+n),t}}};class B{init(){}done(e){var t=Sl.get();e.asset.ex=Object.assign(Object.assign({},e.asset.ex),{lights:this.getLights(),camera:this.getCamera(),sceneEx:this.getSceneEx(t),timeLine:El.getSavedData(),controls:this.getControls(),options:B.getOptions(t)})}static getParse(e){return this.optionsConfigs[e]}static addOption(e){var t=e.type;if(this.optionsConfigs[t])throw TypeError("该配置项已被挂载");this.optionsConfigs[t]=e}static getOptions(e){return Object.values(this.optionsConfigs).map((t=>{const{process:r,type:s}=t;return{type:s,data:r(e)}}))}getSceneEx(e){const t=Object.assign({},e.userData.ex);return e.fog&&(t.fog=Sl.getFogJson(e.fog)),e.background instanceof s.Color&&(t.backgroundColor=e.background.getHexString()),t}getLights(){return Al.getLightsByScene().map((e=>{var t=e.type;return k[t].toJSON(e)}))}getCamera(){return _l.get().toJSON()}getControls(){return yl.controls.target}}B.optionsConfigs={};class N{constructor(){this.bloomParams={isBloom:!1,bloomStrength:2,bloomThreshold:0,bloomRadius:0},this.BLOOM_SCENE=1,this.bloomParams.isBloom=!1,this.isUpdate=!0,this.sceneBackground=null,B.addOption({type:"bloom-glow",process:e=>this.toJSON(),parse:e=>{e=JSON.parse(e),this.setData(e)}})}static getInstance(){return N.instance||(N.instance=new N),N.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?s.ACESFilmicToneMapping:s.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 s.Vector2),this.rtSize={width:t.width,height:t.height},this.postProcessing())}setData(e){e=e.bloomParams;var{bloomRadius:e,bloomStrength:t,bloomThreshold:r,isBloom:s}=e;this.bloomParams.isBloom=s,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),ml.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 s.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 s.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=s.FloatType,this.effectRT.texture.format=s.RGBAFormat,this.effectRT.texture.encoding=s.sRGBEncoding,this.effectRT.texture.minFilter=s.LinearFilter,this.effectRT.texture.magFilter=s.LinearFilter),this.effectRT.depthTexture=new s.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=s.DepthFormat,this.effectRT.depthTexture.type=s.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new w(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 s.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=s.FloatType,this.sampleRT.texture.format=s.RGBAFormat,this.sampleRT.texture.encoding=s.sRGBEncoding,this.sampleRT.texture.minFilter=s.LinearFilter,this.sampleRT.texture.magFilter=s.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 s.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=s.FloatType,this.holdRT.texture.format=s.RGBAFormat,this.holdRT.texture.encoding=s.sRGBEncoding,this.holdRT.texture.minFilter=s.LinearFilter,this.holdRT.texture.magFilter=s.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 M(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 p(new s.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 T(_,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new u(i),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 g(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.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(){xl.glow.bloomParams.isBloom=!1,xl.glow.rendererTone=!1,this.setBackground(null)}}const F={type:"change"},z={type:"start"},j={type:"end"};class V extends s.EventDispatcher{constructor(e,t){super(),void 0===t&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new s.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN},this.touches={ONE:s.TOUCH.ROTATE,TWO:s.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",Y),this._domElementKeyEvents=e},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(F),r.update(),n=i.NONE},this.update=function(){const t=new s.Vector3,d=(new s.Quaternion).setFromUnitVectors(e.up,new s.Vector3(0,1,0)),p=d.clone().invert(),m=new s.Vector3,f=new s.Quaternion,g=2*Math.PI;return function(){const e=r.object.position;t.copy(e).sub(r.target),t.applyQuaternion(d),o.setFromVector3(t),r.autoRotate&&n===i.NONE&&_(2*Math.PI/60/60*r.autoRotateSpeed),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let s=r.minAzimuthAngle,v=r.maxAzimuthAngle;return isFinite(s)&&isFinite(v)&&(s<-Math.PI?s+=g:s>Math.PI&&(s-=g),v<-Math.PI?v+=g:v>Math.PI&&(v-=g),o.theta=s<=v?Math.max(s,Math.min(v,o.theta)):o.theta>(s+v)/2?Math.max(s,o.theta):Math.min(v,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=h,o.radius=Math.max(r.minDistance,Math.min(r.maxDistance,o.radius)),!0===r.enableDamping?r.target.addScaledVector(c,r.dampingFactor):r.target.add(c),t.setFromSpherical(o),t.applyQuaternion(p),e.copy(r.target).add(t),r.object.lookAt(r.target),!0===r.enableDamping?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,c.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),c.set(0,0,0)),h=1,!(!(u||m.distanceToSquared(r.object.position)>a||8*(1-f.dot(r.object.quaternion))>a)||(r.dispatchEvent(F),m.copy(r.object.position),f.copy(r.object.quaternion),u=!1))}}(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",Z),r.domElement.removeEventListener("pointerdown",V),r.domElement.removeEventListener("pointercancel",W),r.domElement.removeEventListener("wheel",X),r.domElement.removeEventListener("pointermove",H),r.domElement.removeEventListener("pointerup",G),null!==r._domElementKeyEvents&&r._domElementKeyEvents.removeEventListener("keydown",Y)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let n=i.NONE;const a=1e-6,o=new s.Spherical,l=new s.Spherical;let h=1;const c=new s.Vector3;let u=!1;const d=new s.Vector2,p=new s.Vector2,m=new s.Vector2,f=new s.Vector2,g=new s.Vector2,v=new s.Vector2,y=new s.Vector2,x=new s.Vector2,w=new s.Vector2,b=[],T={};function M(){return Math.pow(.95,r.zoomSpeed)}function _(e){l.theta-=e}function S(e){l.phi-=e}const P=function(){const e=new s.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),c.add(e)}}(),C=function(){const e=new s.Vector3;return function(t,s){!0===r.screenSpacePanning?e.setFromMatrixColumn(s,1):(e.setFromMatrixColumn(s,0),e.crossVectors(r.object.up,e)),e.multiplyScalar(t),c.add(e)}}(),R=function(){const e=new s.Vector3;return function(t,s){var i,n=r.domElement;r.object.isPerspectiveCamera?(i=r.object.position,e.copy(i).sub(r.target),i=e.length(),i*=Math.tan(r.object.fov/2*Math.PI/180),P(2*t*i/n.clientHeight,r.object.matrix),C(2*s*i/n.clientHeight,r.object.matrix)):r.object.isOrthographicCamera?(P(t*(r.object.right-r.object.left)/r.object.zoom/n.clientWidth,r.object.matrix),C(s*(r.object.top-r.object.bottom)/r.object.zoom/n.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}}();function A(e){r.object.isPerspectiveCamera?h/=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*e)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function E(e){r.object.isPerspectiveCamera?h*=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/e)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function D(e){d.set(e.clientX,e.clientY)}function L(e){f.set(e.clientX,e.clientY)}function I(){var e,t;1===b.length?d.set(b[0].pageX,b[0].pageY):(e=.5*(b[0].pageX+b[1].pageX),t=.5*(b[0].pageY+b[1].pageY),d.set(e,t))}function O(){var e,t;1===b.length?f.set(b[0].pageX,b[0].pageY):(e=.5*(b[0].pageX+b[1].pageX),t=.5*(b[0].pageY+b[1].pageY),f.set(e,t))}function U(){var e=b[0].pageX-b[1].pageX,t=b[0].pageY-b[1].pageY;e=Math.sqrt(e*e+t*t),y.set(0,e)}function k(e){1==b.length?p.set(e.pageX,e.pageY):(s=K(e),t=.5*(e.pageX+s.x),e=.5*(e.pageY+s.y),p.set(t,e)),m.subVectors(p,d).multiplyScalar(r.rotateSpeed);var t,s=r.domElement;_(2*Math.PI*m.x/s.clientHeight),S(2*Math.PI*m.y/s.clientHeight),d.copy(p)}function B(e){var t,s;1===b.length?g.set(e.pageX,e.pageY):(t=K(e),s=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),g.set(s,e)),v.subVectors(g,f).multiplyScalar(r.panSpeed),R(v.x,v.y),f.copy(g)}function N(e){var t=K(e),s=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(s*s+e*e),x.set(0,t),w.set(0,Math.pow(x.y/y.y,r.zoomSpeed)),A(w.y),y.copy(x)}function V(e){var t;if(!1!==r.enabled)if(0===b.length&&(r.domElement.setPointerCapture(e.pointerId),r.domElement.addEventListener("pointermove",H),r.domElement.addEventListener("pointerup",G)),t=e,b.push(t),"touch"!==e.pointerType){var a=e;let t;switch(a.button){case 0:t=r.mouseButtons.LEFT;break;case 1:t=r.mouseButtons.MIDDLE;break;case 2:t=r.mouseButtons.RIGHT;break;default:t=-1}switch(t){case s.MOUSE.DOLLY:if(!1===r.enableZoom)return;!function(e){y.set(e.clientX,e.clientY)}(a),n=i.DOLLY;break;case s.MOUSE.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(!1===r.enablePan)return;L(a),n=i.PAN}else{if(!1===r.enableRotate)return;D(a),n=i.ROTATE}break;case s.MOUSE.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(!1===r.enableRotate)return;D(a),n=i.ROTATE}else{if(!1===r.enablePan)return;L(a),n=i.PAN}break;default:n=i.NONE}n!==i.NONE&&r.dispatchEvent(z)}else{switch(q(e),b.length){case 1:switch(r.touches.ONE){case s.TOUCH.ROTATE:if(!1===r.enableRotate)return;I(),n=i.TOUCH_ROTATE;break;case s.TOUCH.PAN:if(!1===r.enablePan)return;O(),n=i.TOUCH_PAN;break;default:n=i.NONE}break;case 2:switch(r.touches.TWO){case s.TOUCH.DOLLY_PAN:if(!1===r.enableZoom&&!1===r.enablePan)return;r.enableZoom&&U(),r.enablePan&&O(),n=i.TOUCH_DOLLY_PAN;break;case s.TOUCH.DOLLY_ROTATE:if(!1===r.enableZoom&&!1===r.enableRotate)return;r.enableZoom&&U(),r.enableRotate&&I(),n=i.TOUCH_DOLLY_ROTATE;break;default:n=i.NONE}break;default:n=i.NONE}n!==i.NONE&&r.dispatchEvent(z)}}function H(e){if(!1!==r.enabled)if("touch"===e.pointerType){var t=e;switch(q(t),n){case i.TOUCH_ROTATE:if(!1===r.enableRotate)return;k(t),r.update();break;case i.TOUCH_PAN:if(!1===r.enablePan)return;B(t),r.update();break;case i.TOUCH_DOLLY_PAN:if(!1===r.enableZoom&&!1===r.enablePan)return;!function(e){r.enableZoom&&N(e),r.enablePan&&B(e)}(t),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(!1===r.enableZoom&&!1===r.enableRotate)return;!function(e){r.enableZoom&&N(e),r.enableRotate&&k(e)}(t),r.update();break;default:n=i.NONE}}else{var s=e;if(!1!==r.enabled)switch(n){case i.ROTATE:if(!1===r.enableRotate)return;!function(e){p.set(e.clientX,e.clientY),m.subVectors(p,d).multiplyScalar(r.rotateSpeed),e=r.domElement,_(2*Math.PI*m.x/e.clientHeight),S(2*Math.PI*m.y/e.clientHeight),d.copy(p),r.update()}(s);break;case i.DOLLY:if(!1===r.enableZoom)return;!function(e){x.set(e.clientX,e.clientY),w.subVectors(x,y),0<w.y?A(M()):w.y<0&&E(M()),y.copy(x),r.update()}(s);break;case i.PAN:if(!1===r.enablePan)return;!function(e){g.set(e.clientX,e.clientY),v.subVectors(g,f).multiplyScalar(r.panSpeed),R(v.x,v.y),f.copy(g),r.update()}(s)}}}function G(e){Q(e),0===b.length&&(r.domElement.releasePointerCapture(e.pointerId),r.domElement.removeEventListener("pointermove",H),r.domElement.removeEventListener("pointerup",G)),r.dispatchEvent(j),n=i.NONE}function W(e){Q(e)}function X(e){!1!==r.enabled&&!1!==r.enableZoom&&n===i.NONE&&(e.preventDefault(),r.dispatchEvent(z),e.deltaY<0?E(M()):0<e.deltaY&&A(M()),r.update(),r.dispatchEvent(j))}function Y(e){if(!1!==r.enabled&&!1!==r.enablePan){let t=!1;switch(e.code){case r.keys.UP:R(0,r.keyPanSpeed),t=!0;break;case r.keys.BOTTOM:R(0,-r.keyPanSpeed),t=!0;break;case r.keys.LEFT:R(r.keyPanSpeed,0),t=!0;break;case r.keys.RIGHT:R(-r.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),r.update())}}function Z(e){!1!==r.enabled&&e.preventDefault()}function Q(e){delete T[e.pointerId];for(let t=0;t<b.length;t++)if(b[t].pointerId==e.pointerId)return void b.splice(t,1)}function q(e){let t=T[e.pointerId];void 0===t&&(t=new s.Vector2,T[e.pointerId]=t),t.set(e.pageX,e.pageY)}function K(e){return e=e.pointerId===b[0].pointerId?b[1]:b[0],T[e.pointerId]}r.domElement.addEventListener("contextmenu",Z),r.domElement.addEventListener("pointerdown",V),r.domElement.addEventListener("pointercancel",W),r.domElement.addEventListener("wheel",X,{passive:!1}),this.update()}}class H{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 G=a(129),W=a(218);let X,Y,Z,Q,q,K,J,$,ee,te={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},re={duration:.5,overwrite:!1,delay:0},se=1e8,ie=1e-8,ne=2*Math.PI,ae=ne/4,oe=0,le=Math.sqrt,he=Math.cos,ce=Math.sin,ue=e=>"string"==typeof e,de=e=>"function"==typeof e,pe=e=>"number"==typeof e,me=e=>void 0===e,fe=e=>"object"==typeof e,ge=e=>!1!==e,ve=()=>"undefined"!=typeof window,ye=e=>de(e)||ue(e),xe="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},we=Array.isArray,be=/(?:-?\.?\d|\.)+/gi,Te=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Me=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,_e=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,Se=/[+-]=-?[.\d]+/,Pe=/[^,'"\[\]\s]+/gi,Ce=/[\d.+\-=]+(?:e[-+]\d*)*/i,Re={},Ae={},Ee=e=>(Ae=$e(e,Re))&&Br,De=(e,t)=>console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()"),Le=(e,t)=>!t&&console.warn(e),Ie=(e,t)=>e&&(Re[e]=t)&&Ae&&(Ae[e]=t)||Re,Oe=()=>0,Ue={},ke=[],Be={},Ne={},Fe={},ze=30,je=[],Ve="",He=e=>{let t,r,s=e[0];if(fe(s)||de(s)||(e=[e]),!(t=(s._gsap||{}).harness)){for(r=je.length;r--&&!je[r].targetTest(s););t=je[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new hr(e[r],t)))||e.splice(r,1);return e},Ge=e=>e._gsap||He(Rt(e))[0]._gsap,We=(e,t,r)=>(r=e[t])&&de(r)?e[t]():me(r)&&e.getAttribute&&e.getAttribute(t)||r,Xe=(e,t)=>(e=e.split(",")).forEach(t)||e,Ye=e=>Math.round(1e7*e)/1e7||0,Ze=()=>{let e,t,r=ke.length,s=ke.slice(0);for(Be={},ke.length=0,e=0;e<r;e++)(t=s[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},Qe=(e,t,r,s)=>{ke.length&&Ze(),e.render(t,r,s),ke.length&&Ze()},qe=e=>{var t=parseFloat(e);return(t||0===t)&&(e+"").match(Pe).length<2?t:ue(e)?e.trim():e},Ke=e=>e,Je=(e,t)=>{for(var r in t)r in e||(e[r]=t[r]);return e},$e=(e,t)=>{for(var r in t)e[r]=t[r];return e},et=(e,t)=>{for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=fe(t[r])?et(e[r]||(e[r]={}),t[r]):t[r]);return e},tt=(e,t)=>{let r,s={};for(r in e)r in t||(s[r]=e[r]);return s},rt=e=>{let t=e.parent||Y,r=e.keyframes?(s=we(e.keyframes),(e,t)=>{for(var r in t)r in e||"duration"===r&&s||"ease"===r||(e[r]=t[r])}):Je;var s;if(ge(e.inherit))for(;t;)r(e,t.vars.defaults),t=t.parent||t._dp;return e},st=(e,t,r="_first",s="_last")=>{let i=t._prev,n=t._next;i?i._next=n:e[r]===t&&(e[r]=n),n?n._prev=i:e[s]===t&&(e[s]=i),t._next=t._prev=t.parent=null},it=(e,t)=>{!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},nt=(e,t)=>{if(e&&(!t||t._end>e._dur||t._start<0)){let t=e;for(;t;)t._dirty=1,t=t.parent}return e},at=e=>!e||e._ts&&at(e.parent),ot=e=>e._repeat?lt(e._tTime,e=e.duration()+e._rDelay)*e:0,lt=(e,t)=>(t=Math.floor(e/=t),e&&t===e?t-1:t),ht=(e,t)=>(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur),ct=e=>e._end=Ye(e._start+(e._tDur/Math.abs(e._ts||e._rts||ie)||0)),ut=(e,t)=>{var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=Ye(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),ct(e),r._dirty||nt(r,e)),e},dt=(e,t)=>{let r;if((t._time||t._initted&&!t._dur)&&(r=ht(e.rawTime(),t),(!t._dur||_t(0,t.totalDuration(),r)-t._tTime>ie)&&t.render(r,!0)),nt(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=-ie}},pt=(e,t,r,s)=>{t.parent&&it(t),t._start=Ye((pe(r)?r:r||e!==Y?bt(e,r,t):e._time)+t._delay),t._end=Ye(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0));{var i=t,n="_first",a="_last",o=(r=e)._sort?"_start":0;let s,l=r[a];if(o)for(s=i[o];l&&l[o]>s;)l=l._prev;l?(i._next=l._next,l._next=i):(i._next=r[n],r[n]=i),i._next?i._next._prev=i:r[a]=i,i._prev=l,i.parent=i._dp=r}return vt(t)||(e._recent=t),s||dt(e,t),e},mt=(e,t)=>(Re.ScrollTrigger||De("scrollTrigger",t))&&Re.ScrollTrigger.create(t,e),ft=(e,t,r,s)=>(gr(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&J!==qt.frame?(ke.push(e),e._lazy=[t,s],1):void 0:1),gt=({parent:e})=>e&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||gt(e)),vt=({data:e})=>"isFromStart"===e||"isStart"===e,yt=(e,t,r,s)=>{var i=e._repeat,n=Ye(t)||0;return(t=e._tTime/e._tDur)&&!s&&(e._time*=n/e._dur),e._dur=n,e._tDur=i?i<0?1e10:Ye(n*(i+1)+e._rDelay*i):n,0<t&&!s?ut(e,e._tTime=e._tDur*t):e.parent&&ct(e),r||nt(e.parent,e),e},xt=e=>e instanceof ur?nt(e):yt(e,e._dur),wt={_start:0,endTime:Oe,totalDuration:Oe},bt=(e,t,r)=>{let s,i,n,a=e.labels,o=e._recent||wt,l=e.duration()>=se?o.endTime(!1):e._dur;return ue(t)&&(isNaN(t)||t in a)?(i=t.charAt(0),n="%"===t.substr(-1),s=t.indexOf("="),"<"===i||">"===i?(0<=s&&(t=t.replace(/=/,"")),("<"===i?o._start:o.endTime(0<=o._repeat))+(parseFloat(t.substr(1))||0)*(n?(s<0?o:r).totalDuration()/100:1)):s<0?(t in a||(a[t]=l),a[t]):(i=parseFloat(t.charAt(s-1)+t.substr(s+1)),n&&r&&(i=i/100*(we(r)?r[0]:r).totalDuration()),1<s?bt(e,t.substr(0,s-1),r)+i:l+i)):null==t?l:+t},Tt=(e,t,r)=>{let s,i,n=pe(t[1]),a=(n?2:1)+(e<2?0:1),o=t[a];if(n&&(o.duration=t[1]),o.parent=r,e){for(s=o,i=r;i&&!("immediateRender"in s);)s=i.vars.defaults||{},i=ge(i.vars.inherit)&&i.parent;o.immediateRender=ge(s.immediateRender),e<2?o.runBackwards=1:o.startAt=t[a-1]}return new wr(t[0],o,t[1+a])},Mt=(e,t)=>e||0===e?t(e):t,_t=(e,t,r)=>r<e?e:t<r?t:r,St=(e,t)=>ue(e)&&(t=Ce.exec(e))?e.substr(t.index+t[0].length):"",Pt=[].slice,Ct=(e,t)=>e&&fe(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&fe(e[0]))&&!e.nodeType&&e!==Z,Rt=(e,t,r)=>!ue(e)||r||!Q&&Kt()?we(e)?((e,t,r=[])=>e.forEach((e=>ue(e)&&!t||Ct(e,1)?r.push(...Rt(e)):r.push(e)))||r)(e,r):Ct(e)?Pt.call(e,0):e?[e]:[]:Pt.call((t||q).querySelectorAll(e),0),At=e=>e.sort((()=>.5-Math.random())),Et=e=>{if(de(e))return e;let t=fe(e)?e:{each:e},r=sr(t.ease),s=t.from||0,i=parseFloat(t.base)||0,n={},a=0<s&&s<1,o=isNaN(s)||a,l=t.axis,h=s,c=s;return ue(s)?h=c={center:.5,edges:.5,end:1}[s]||0:!a&&o&&(h=s[0],c=s[1]),(e,a,u)=>{let d,p,m,f,g,v,y,x,w,b=(u||t).length,T=n[b];if(!T){if(!(w="auto"===t.grid?0:(t.grid||[1,se])[1])){for(y=-se;y<(y=u[w++].getBoundingClientRect().left)&&w<b;);w--}for(T=n[b]=[],d=o?Math.min(w,b)*h-.5:s%w,p=w===se?0:o?b*c/w-.5:s/w|0,y=0,x=se,v=0;v<b;v++)m=v%w-d,f=p-(v/w|0),T[v]=g=l?Math.abs("y"===l?f:m):le(m*m+f*f),g>y&&(y=g),g<x&&(x=g);"random"===s&&At(T),T.max=y-x,T.min=x,T.v=b=(parseFloat(t.amount)||parseFloat(t.each)*(w>b?b-1:l?"y"===l?b/w:w:Math.max(w,b/w))||0)*("edges"===s?-1:1),T.b=b<0?i-b:i,T.u=St(t.amount||t.each)||0,r=r&&b<0?tr(r):r}return b=(T[e]-T.min)/T.max||0,Ye(T.b+(r?r(b):b)*T.v)+T.u}},Dt=e=>{let t=Math.pow(10,((e+"").split(".")[1]||"").length);return r=>{var s=Math.round(parseFloat(r)/e)*e*t;return(s-s%1)/t+(pe(r)?0:St(r))}},Lt=(e,t)=>{let r,s,i=we(e);return!i&&fe(e)&&(r=i=e.radius||se,e.values?(e=Rt(e.values),(s=!pe(e[0]))&&(r*=r)):e=Dt(e.increment)),Mt(t,i?de(e)?t=>(s=e(t),Math.abs(s-t)<=r?s:t):t=>{let i,n,a=parseFloat(s?t.x:t),o=parseFloat(s?t.y:0),l=se,h=0,c=e.length;for(;c--;)(i=s?(i=e[c].x-a,n=e[c].y-o,i*i+n*n):Math.abs(e[c]-a))<l&&(l=i,h=c);return h=!r||l<=r?e[h]:t,s||h===t||pe(t)?h:h+St(t)}:Dt(e))},It=(e,t,r,s)=>Mt(we(e)?!t:!0===r?!!(r=0):!s,(()=>we(e)?e[~~(Math.random()*e.length)]:(r=r||1e-5)&&(s=r<1?10**((r+"").length-2):1)&&Math.floor(Math.round((e-r/2+Math.random()*(t-e+.99*r))/r)*r*s)/s)),Ot=(e,t,r)=>Mt(r,(r=>e[~~t(r)])),Ut=(e,t,r)=>{let s=t-e,i=2*s;return we(e)?Ot(e,Ut(0,e.length-1),t):Mt(r,(t=>e+((t=(i+(t-e)%i)%i||0)>s?i-t:t)))},kt=e=>{let t,r,s,i,n=0,a="";for(;~(t=e.indexOf("random(",n));)s=e.indexOf(")",t),i="["===e.charAt(t+7),r=e.substr(t+7,s-t-7).match(i?Pe:be),a+=e.substr(n,t-n)+It(i?r:+r[0],i?0:+r[1],+r[2]||1e-5),n=s+1;return a+e.substr(n,e.length-n)},Bt=(e,t,r,s,i)=>{let n=t-e,a=s-r;return Mt(i,(t=>r+((t-e)/n*a||0)))},Nt=(e,t,r,s)=>{let i=isNaN(e+t)?0:r=>(1-r)*e+r*t;if(!i){let n,a,o,l,h,c=ue(e),u={};if(!0===r&&(s=1)&&(r=null),c)e={p:e},t={p:t};else if(we(e)&&!we(t)){for(o=[],l=e.length,h=l-2,a=1;a<l;a++)o.push(Nt(e[a-1],e[a]));l--,i=e=>{e*=l;var t=Math.min(h,~~e);return o[t](e-t)},r=t}else s||(e=$e(we(e)?[]:{},e));if(!o){for(n in t)mr.call(u,e,n,"get",t[n]);i=t=>(Tr(t,u),c?e.p:e)}}return Mt(r,i)},Ft=(e,t,r)=>{let s,i,n,a=e.labels,o=se;for(s in a)i=a[s]-t,i<0==!!r&&i&&o>(i=Math.abs(i))&&(n=s,o=i);return n},zt=(e,t,r)=>{let s,i,n=e.vars,a=n[t];if(a)return s=n[t+"Params"],i=n.callbackScope||e,r&&ke.length&&Ze(),s?a.apply(i,s):a.call(i)},jt=e=>(it(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&zt(e,"onInterrupt"),e),Vt=255,Ht={aqua:[0,Vt,Vt],lime:[0,Vt,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,Vt],navy:[0,0,128],white:[Vt,Vt,Vt],olive:[128,128,0],yellow:[Vt,Vt,0],orange:[Vt,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[Vt,0,0],pink:[Vt,192,203],cyan:[0,Vt,Vt],transparent:[Vt,Vt,Vt,0]},Gt=(e,t,r)=>(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)*Vt+.5|0,Wt=(e,t,r)=>{let s,i,n,a,o,l,h,c,u,d,p=e?pe(e)?[e>>16,e>>8&Vt,e&Vt]:0:Ht.black;if(!p){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),Ht[e])p=Ht[e];else if("#"===e.charAt(0)){if(e.length<6&&(s=e.charAt(1),i=e.charAt(2),n=e.charAt(3),e="#"+s+s+i+i+n+n+(5===e.length?e.charAt(4)+e.charAt(4):"")),9===e.length)return[(p=parseInt(e.substr(1,6),16))>>16,p>>8&Vt,p&Vt,parseInt(e.substr(7),16)/255];p=[(e=parseInt(e.substr(1),16))>>16,e>>8&Vt,e&Vt]}else if("hsl"===e.substr(0,3))if(p=d=e.match(be),t){if(~e.indexOf("="))return p=e.match(Te),r&&p.length<4&&(p[3]=1),p}else a=+p[0]%360/360,o=+p[1]/100,l=+p[2]/100,i=l<=.5?l*(o+1):l+o-l*o,s=2*l-i,3<p.length&&(p[3]*=1),p[0]=Gt(a+1/3,s,i),p[1]=Gt(a,s,i),p[2]=Gt(a-1/3,s,i);else p=e.match(be)||Ht.transparent;p=p.map(Number)}return t&&!d&&(s=p[0]/Vt,i=p[1]/Vt,n=p[2]/Vt,h=Math.max(s,i,n),c=Math.min(s,i,n),l=(h+c)/2,h===c?a=o=0:(u=h-c,o=.5<l?u/(2-h-c):u/(h+c),a=h===s?(i-n)/u+(i<n?6:0):h===i?(n-s)/u+2:(s-i)/u+4,a*=60),p[0]=~~(a+.5),p[1]=~~(100*o+.5),p[2]=~~(100*l+.5)),r&&p.length<4&&(p[3]=1),p},Xt=e=>{let t=[],r=[],s=-1;return e.split(Zt).forEach((e=>{e=e.match(Me)||[],t.push(...e),r.push(s+=e.length+1)})),t.c=r,t},Yt=(e,t,r)=>{let s,i,n,a,o="",l=(e+o).match(Zt),h=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((e=>(e=Wt(e,t,1))&&h+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")")),r&&(n=Xt(e),(s=r.c).join(o)!==n.c.join(o)))for(i=e.replace(Zt,"1").split(Me),a=i.length-1;c<a;c++)o+=i[c]+(~s.indexOf(c)?l.shift()||h+"0,0,0,0)":(n.length?n:l.length?l:r).shift());if(!i)for(i=e.split(Zt),a=i.length-1;c<a;c++)o+=i[c]+l[c];return o+i[a]},Zt=function(){let e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in Ht)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),Qt=/hsl[a]?\(/,qt=function(){let e,t,r,s,i,n,a=Date.now,o=500,l=33,h=a(),c=h,u=1e3/240,d=u,p=[],m=r=>{let f,g,v,y,x=a()-c,w=!0===r;if(x>o&&(h+=x-l),c+=x,(0<(f=(v=c-h)-d)||w)&&(y=++s.frame,i=v-1e3*s.time,s.time=v/=1e3,d+=f+(f>=u?4:u-f),g=1),w||(e=t(m)),g)for(n=0;n<p.length;n++)p[n](v,i,y,r)};return s={time:0,frame:0,tick(){m(!0)},deltaRatio:e=>i/(1e3/(e||60)),wake(){K&&(!Q&&ve()&&(Z=Q=window,q=Z.document||{},Re.gsap=Br,(Z.gsapVersions||(Z.gsapVersions=[])).push(Br.version),Ee(Ae||Z.GreenSockGlobals||!Z.gsap&&Z||{}),r=Z.requestAnimationFrame),e&&s.sleep(),t=r||(e=>setTimeout(e,d-1e3*s.time+1|0)),ee=1,m(2))},sleep(){(r?Z.cancelAnimationFrame:clearTimeout)(e),ee=0,t=Oe},lagSmoothing(e,t){o=e||1/ie,l=Math.min(t,o,0)},fps(e){u=1e3/(e||240),d=1e3*s.time+u},add(e){p.indexOf(e)<0&&p.push(e),Kt()},remove(e,t){~(t=p.indexOf(e))&&p.splice(t,1)&&n>=t&&n--},_listeners:p}}(),Kt=()=>!ee&&qt.wake(),Jt={},$t=/^[\d.\-M][\d.\-,\s]/,er=/["']/g,tr=e=>t=>1-e(1-t),rr=(e,t)=>{let r,s=e._first;for(;s;)s instanceof ur?rr(s,t):!s.vars.yoyoEase||s._yoyo&&s._repeat||s._yoyo===t||(s.timeline?rr(s.timeline,t):(r=s._ease,s._ease=s._yEase,s._yEase=r,s._yoyo=t)),s=s._next},sr=(e,t)=>e&&(de(e)?e:Jt[e]||(e=>{let t=(e+"").split("("),r=Jt[t[0]];return r&&1<t.length&&r.config?r.config.apply(null,~e.indexOf("{")?[(e=>{let t,r,s,i={},n=e.substr(1,e.length-3).split(":"),a=n[0],o=1,l=n.length;for(;o<l;o++)r=n[o],t=o!==l-1?r.lastIndexOf(","):r.length,s=r.substr(0,t),i[a]=isNaN(s)?s.replace(er,"").trim():+s,a=r.substr(t+1).trim();return i})(t[1])]:(i=(s=e).indexOf("(")+1,n=s.indexOf(")"),a=s.indexOf("(",i),s.substring(i,~a&&a<n?s.indexOf(")",n+1):n).split(",").map(qe))):Jt._CE&&$t.test(e)?Jt._CE("",e):r;var s,i,n,a})(e))||t,ir=(e,t,r=(e=>1-t(1-e)),s=(e=>e<.5?t(2*e)/2:1-t(2*(1-e))/2))=>{let i,n={easeIn:t,easeOut:r,easeInOut:s};return Xe(e,(e=>{for(var t in Jt[e]=Re[e]=n,Jt[i=e.toLowerCase()]=r,n)Jt[i+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Jt[e+"."+t]=n[t]})),n},nr=e=>t=>t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2,ar=(e,t,r)=>{let s=1<=t?t:1,i=(r||(e?.3:.45))/(t<1?t:1),n=i/ne*(Math.asin(1/s)||0),a=e=>1===e?1:s*2**(-10*e)*ce((e-n)*i)+1,o="out"===e?a:"in"===e?e=>1-a(1-e):nr(a);return i=ne/i,o.config=(t,r)=>ar(e,t,r),o},or=(e,t=1.70158)=>{let r=e=>e?--e*e*((t+1)*e+t)+1:0,s="out"===e?r:"in"===e?e=>1-r(1-e):nr(r);return s.config=t=>or(e,t),s};Xe("Linear,Quad,Cubic,Quart,Quint,Strong",((e,t)=>{let r=t<5?t+1:t;ir(e+",Power"+(r-1),t?e=>e**r:e=>e,(e=>1-(1-e)**r),(e=>e<.5?(2*e)**r/2:1-(2*(1-e))**r/2))})),Jt.Linear.easeNone=Jt.none=Jt.Linear.easeIn,ir("Elastic",ar("in"),ar("out"),ar());{var lr=7.5625;let e=1/2.75,t=t=>t<e?lr*t*t:t<.7272727272727273?lr*(t-1.5/2.75)**2+.75:t<.9090909090909092?lr*(t-=2.25/2.75)*t+.9375:lr*(t-2.625/2.75)**2+.984375;ir("Bounce",(e=>1-t(1-e)),t)}ir("Expo",(e=>e?2**(10*(e-1)):0)),ir("Circ",(e=>-(le(1-e*e)-1))),ir("Sine",(e=>1===e?1:1-he(e*ae))),ir("Back",or("in"),or("out"),or()),Jt.SteppedEase=Jt.steps=Re.SteppedEase={config(e=1,t){let r=1/e,s=e+(t?0:1),i=t?1:0;return e=>((s*_t(0,.99999999,e)|0)+i)*r}},re.ease=Jt["quad.out"],Xe("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(e=>Ve+=e+","+e+"Params,"));class hr{constructor(e,t){this.id=oe++,(e._gsap=this).target=e,this.harness=t,this.get=t?t.get:We,this.set=t?t.getSetter:Rr}}class cr{constructor(e){this.vars=e,this._delay=+e.delay||0,(this._repeat=e.repeat===1/0?-2:e.repeat||0)&&(this._rDelay=e.repeatDelay||0,this._yoyo=!!e.yoyo||!!e.yoyoEase),this._ts=1,yt(this,+e.duration,1,1),this.data=e.data,ee||qt.wake()}delay(e){return e||0===e?(this.parent&&this.parent.smoothChildTiming&&this.startTime(this._start+e-this._delay),this._delay=e,this):this._delay}duration(e){return arguments.length?this.totalDuration(0<this._repeat?e+(e+this._rDelay)*this._repeat:e):this.totalDuration()&&this._dur}totalDuration(e){return arguments.length?(this._dirty=0,yt(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}totalTime(e,t){if(Kt(),!arguments.length)return this._tTime;let r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(ut(this,e),r._dp&&!r.parent&&dt(r,this);r&&r.parent;)r.parent._time!==r._start+(0<=r._ts?r._tTime/r._ts:(r.totalDuration()-r._tTime)/-r._ts)&&r.totalTime(r._tTime,!0),r=r.parent;!this.parent&&this._dp.autoRemoveChildren&&(0<this._ts&&e<this._tDur||this._ts<0&&0<e||!this._tDur&&!e)&&pt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===ie||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),Qe(this,e,t)),this}time(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+ot(this))%(this._dur+this._rDelay)||(e?this._dur:0),t):this._time}totalProgress(e,t){return arguments.length?this.totalTime(this.totalDuration()*e,t):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.ratio}progress(e,t){return arguments.length?this.totalTime(this.duration()*(!this._yoyo||1&this.iteration()?e:1-e)+ot(this),t):this.duration()?Math.min(1,this._time/this._dur):this.ratio}iteration(e,t){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(e-1)*r,t):this._repeat?lt(this._tTime,r)+1:1}timeScale(e){if(!arguments.length)return this._rts===-ie?0:this._rts;if(this._rts===e)return this;var t=this.parent&&this._ts?ht(this.parent._time,this):this._tTime;this._rts=+e||0,this._ts=this._ps||e===-ie?0:this._rts;{let r=(e=this.totalTime(_t(-this._delay,this._tDur,t),!0)).parent;for(;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent}return ct(this),this}paused(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):(Kt(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==ie&&(this._tTime-=ie)))),this):this._ps}startTime(e){var t;return arguments.length?(this._start=e,!(t=this.parent||this._dp)||!t._sort&&this.parent||pt(t,this,e-this._delay),this):this._start}endTime(e){return this._start+(ge(e)?this.totalDuration():this.duration())/Math.abs(this._ts||1)}rawTime(e){let 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?ht(t.rawTime(e),this):this._tTime:this._tTime}globalTime(e){let t=this,r=arguments.length?e:t.rawTime();for(;t;)r=t._start+r/(t._ts||1),t=t._dp;return r}repeat(e){return arguments.length?(this._repeat=e===1/0?-2:e,xt(this)):-2===this._repeat?1/0:this._repeat}repeatDelay(e){var t;return arguments.length?(t=this._time,this._rDelay=e,xt(this),t?this.time(t):this):this._rDelay}yoyo(e){return arguments.length?(this._yoyo=e,this):this._yoyo}seek(e,t){return this.totalTime(bt(this,e),ge(t))}restart(e,t){return this.play().totalTime(e?-this._delay:0,ge(t))}play(e,t){return null!=e&&this.seek(e,t),this.reversed(!1).paused(!1)}reverse(e,t){return null!=e&&this.seek(e||this.totalDuration(),t),this.reversed(!0).paused(!1)}pause(e,t){return null!=e&&this.seek(e,t),this.paused(!0)}resume(){return this.paused(!1)}reversed(e){return arguments.length?(!!e!==this.reversed()&&this.timeScale(-this._rts||(e?-ie:0)),this):this._rts<0}invalidate(){return this._initted=this._act=0,this._zTime=-ie,this}isActive(){let e,t=this.parent||this._dp,r=this._start;return!(t&&!(this._ts&&this._initted&&t.isActive()&&(e=t.rawTime(!0))>=r&&e<this.endTime(!0)-ie))}eventCallback(e,t,r){let s=this.vars;return 1<arguments.length?(t?(s[e]=t,r&&(s[e+"Params"]=r),"onUpdate"===e&&(this._onUpdate=t)):delete s[e],this):s[e]}then(e){let t=this;return new Promise((r=>{let s=de(e)?e:Ke,i=()=>{var e=t.then;t.then=null,de(s)&&(s=s(t))&&(s.then||s===t)&&(t.then=e),r(s),t.then=e};t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?i():t._prom=i}))}kill(){jt(this)}}Je(cr.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:-ie,_prom:0,_ps:!1,_rts:1});class ur extends cr{constructor(e={},t){super(e),this.labels={},this.smoothChildTiming=!!e.smoothChildTiming,this.autoRemoveChildren=!!e.autoRemoveChildren,this._sort=ge(e.sortChildren),Y&&pt(e.parent||Y,this,t),e.reversed&&this.reverse(),e.paused&&this.paused(!0),e.scrollTrigger&&mt(this,e.scrollTrigger)}to(e,t,r){return Tt(0,arguments,this),this}from(e,t,r){return Tt(1,arguments,this),this}fromTo(e,t,r,s){return Tt(2,arguments,this),this}set(e,t,r){return t.duration=0,t.parent=this,rt(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new wr(e,t,bt(this,r),1),this}call(e,t,r){return pt(this,wr.delayedCall(0,e,t),r)}staggerTo(e,t,r,s,i,n,a){return r.duration=t,r.stagger=r.stagger||s,r.onComplete=n,r.onCompleteParams=a,r.parent=this,new wr(e,r,bt(this,i)),this}staggerFrom(e,t,r,s,i,n,a){return r.runBackwards=1,rt(r).immediateRender=ge(r.immediateRender),this.staggerTo(e,t,r,s,i,n,a)}staggerFromTo(e,t,r,s,i,n,a,o){return s.startAt=r,rt(s).immediateRender=ge(s.immediateRender),this.staggerTo(e,t,s,i,n,a,o)}render(e,t,r){let s,i,n,a,o,l,h,c,u,d,p,m,f=this._time,g=this._dirty?this.totalDuration():this._tDur,v=this._dur,y=e<=0?0:Ye(e),x=this._zTime<0!=e<0&&(this._initted||!v);if((y=this!==Y&&y>g&&0<=e?g:y)!==this._tTime||r||x){if(f!==this._time&&v&&(y+=this._time-f,e+=this._time-f),s=y,u=this._start,l=!(c=this._ts),x&&(v||(f=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(p=this._yoyo,o=v+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*o+e,t,r);if(s=Ye(y%o),y===g?(a=this._repeat,s=v):((a=~~(y/o))&&a===y/o&&(s=v,a--),s>v&&(s=v)),d=lt(this._tTime,o),!f&&this._tTime&&d!==a&&(d=a),p&&1&a&&(s=v-s,m=1),a!==d&&!this._lock){let e=p&&1&d,r=e===(p&&1&a);if(a<d&&(e=!e),f=e?0:v,this._lock=1,this.render(f||(m?0:Ye(a*o)),t,!v)._lock=0,this._tTime=y,!t&&this.parent&&zt(this,"onRepeat"),this.vars.repeatRefresh&&!m&&(this.invalidate()._lock=1),f&&f!==this._time||l!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(v=this._dur,g=this._tDur,r&&(this._lock=2,f=e?v:-1e-4,this.render(f,!0),this.vars.repeatRefresh&&!m&&this.invalidate()),this._lock=0,!this._ts&&!l)return this;rr(this,m)}}if(this._hasPause&&!this._forcing&&this._lock<2&&(h=((e,t,r)=>{let s;if(t<r)for(s=e._first;s&&s._start<=r;){if("isPause"===s.data&&s._start>t)return s;s=s._next}else for(s=e._last;s&&s._start>=r;){if("isPause"===s.data&&s._start<t)return s;s=s._prev}})(this,Ye(f),Ye(s)))&&(y-=s-(s=h._start)),this._tTime=y,this._time=s,this._act=!c,this._initted||(this._onUpdate=this.vars.onUpdate,this._initted=1,this._zTime=e,f=0),!f&&s&&!t&&(zt(this,"onStart"),this._tTime!==y))return this;if(s>=f&&0<=e)for(i=this._first;i;){if(n=i._next,(i._act||s>=i._start)&&i._ts&&h!==i){if(i.parent!==this)return this.render(e,t,r);if(i.render(0<i._ts?(s-i._start)*i._ts:(i._dirty?i.totalDuration():i._tDur)+(s-i._start)*i._ts,t,r),s!==this._time||!this._ts&&!l){h=0,n&&(y+=this._zTime=-ie);break}}i=n}else{i=this._last;for(var w=e<0?e:s;i;){if(n=i._prev,(i._act||w<=i._end)&&i._ts&&h!==i){if(i.parent!==this)return this.render(e,t,r);if(i.render(0<i._ts?(w-i._start)*i._ts:(i._dirty?i.totalDuration():i._tDur)+(w-i._start)*i._ts,t,r),s!==this._time||!this._ts&&!l){h=0,n&&(y+=this._zTime=w?-ie:ie);break}}i=n}}if(h&&!t&&(this.pause(),h.render(s>=f?0:-ie)._zTime=s>=f?1:-1,this._ts))return this._start=u,ct(this),this.render(e,t,r);this._onUpdate&&!t&&zt(this,"onUpdate",!0),!(y===g&&g>=this.totalDuration()||!y&&f)||u!==this._start&&Math.abs(c)===Math.abs(this._ts)||this._lock||(!e&&v||!(y===g&&0<this._ts||!y&&this._ts<0)||it(this,1),t||e<0&&!f||!y&&!f&&g||(zt(this,y===g&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||y<g&&0<this.timeScale()||this._prom()))}return this}add(e,t){if(pe(t)||(t=bt(this,t,e)),!(e instanceof cr)){if(we(e))return e.forEach((e=>this.add(e,t))),this;if(ue(e))return this.addLabel(e,t);if(!de(e))return this;e=wr.delayedCall(0,e)}return this!==e?pt(this,e,t):this}getChildren(e=!0,t=!0,r=!0,s=-se){let i=[],n=this._first;for(;n;)n._start>=s&&(n instanceof wr?t&&i.push(n):(r&&i.push(n),e&&i.push(...n.getChildren(!0,t,r)))),n=n._next;return i}getById(e){let t=this.getChildren(1,1,1),r=t.length;for(;r--;)if(t[r].vars.id===e)return t[r]}remove(e){return ue(e)?this.removeLabel(e):de(e)?this.killTweensOf(e):(st(this,e),e===this._recent&&(this._recent=this._last),nt(this))}totalTime(e,t){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=Ye(qt.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),super.totalTime(e,t),this._forcing=0,this):this._tTime}addLabel(e,t){return this.labels[e]=bt(this,t),this}removeLabel(e){return delete this.labels[e],this}addPause(e,t,r){let s=wr.delayedCall(0,t||Oe,r);return s.data="isPause",this._hasPause=1,pt(this,s,bt(this,e))}removePause(e){let t=this._first;for(e=bt(this,e);t;)t._start===e&&"isPause"===t.data&&it(t),t=t._next}killTweensOf(e,t,r){let s=this.getTweensOf(e,r),i=s.length;for(;i--;)dr!==s[i]&&s[i].kill(e,t);return this}getTweensOf(e,t){let r,s=[],i=Rt(e),n=this._first,a=pe(t);for(;n;)n instanceof wr?((e,t)=>{let r=t.length,s=0;for(;e.indexOf(t[s])<0&&++s<r;);return s<r})(n._targets,i)&&(a?(!dr||n._initted&&n._ts)&&n.globalTime(0)<=t&&n.globalTime(n.totalDuration())>t:!t||n.isActive())&&s.push(n):(r=n.getTweensOf(i,t)).length&&s.push(...r),n=n._next;return s}tweenTo(e,t){t=t||{};let r,s=this,i=bt(s,e),{startAt:n,onStart:a,onStartParams:o,immediateRender:l}=t,h=wr.to(s,Je({ease:t.ease||"none",lazy:!1,immediateRender:!1,time:i,overwrite:"auto",duration:t.duration||Math.abs((i-(n&&"time"in n?n.time:s._time))/s.timeScale())||ie,onStart:()=>{var e;s.pause(),r||(e=t.duration||Math.abs((i-(n&&"time"in n?n.time:s._time))/s.timeScale()),h._dur!==e&&yt(h,e,0,1).render(h._time,!0,!0),r=1),a&&a.apply(h,o||[])}},t));return l?h.render(0):h}tweenFromTo(e,t,r){return this.tweenTo(t,Je({startAt:{time:bt(this,e)}},r))}recent(){return this._recent}nextLabel(e=this._time){return Ft(this,bt(this,e))}previousLabel(e=this._time){return Ft(this,bt(this,e),1)}currentLabel(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+ie)}shiftChildren(e,t,r=0){let s,i=this._first,n=this.labels;for(;i;)i._start>=r&&(i._start+=e,i._end+=e),i=i._next;if(t)for(s in n)n[s]>=r&&(n[s]+=e);return nt(this)}invalidate(){let e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return super.invalidate()}clear(e=!0){let t,r=this._first;for(;r;)t=r._next,this.remove(r),r=t;return this._dp&&(this._time=this._tTime=this._pTime=0),e&&(this.labels={}),nt(this)}totalDuration(e){let t,r,s,i=0,n=this,a=n._last,o=se;if(arguments.length)return n.timeScale((n._repeat<0?n.duration():n.totalDuration())/(n.reversed()?-e:e));if(n._dirty){for(s=n.parent;a;)t=a._prev,a._dirty&&a.totalDuration(),(r=a._start)>o&&n._sort&&a._ts&&!n._lock?(n._lock=1,pt(n,a,r-a._delay,1)._lock=0):o=r,r<0&&a._ts&&(i-=r,(!s&&!n._dp||s&&s.smoothChildTiming)&&(n._start+=r/n._ts,n._time-=r,n._tTime-=r),n.shiftChildren(-r,!1,-1/0),o=0),a._end>i&&a._ts&&(i=a._end),a=t;yt(n,n===Y&&n._time>i?n._time:i,1,1),n._dirty=0}return n._tDur}static updateRoot(e){if(Y._ts&&(Qe(Y,ht(e,Y)),J=qt.frame),qt.frame>=ze){ze+=te.autoSleep||120;let e=Y._first;if((!e||!e._ts)&&te.autoSleep&&qt._listeners.length<2){for(;e&&!e._ts;)e=e._next;e||qt.sleep()}}}}Je(ur.prototype,{_lock:0,_hasPause:0,_forcing:0});let dr,pr=function(e,t,r,s,i,n,a){let o,l,h,c,u,d,p,m,f=new Ir(this._pt,e,t,0,1,br,null,i),g=0,v=0;for(f.b=r,f.e=s,r+="",(p=~(s+="").indexOf("random("))&&(s=kt(s)),n&&(n(m=[r,s],e,t),r=m[0],s=m[1]),l=r.match(_e)||[];o=_e.exec(s);)c=o[0],u=s.substring(g,o.index),h?h=(h+1)%5:"rgba("===u.substr(-5)&&(h=1),c!==l[v++]&&(d=parseFloat(l[v-1])||0,f._pt={_next:f._pt,p:u||1===v?u:",",s:d,c:"="===c.charAt(1)?parseFloat(c.substr(2))*("-"===c.charAt(0)?-1:1):parseFloat(c)-d,m:h&&h<4?Math.round:0},g=_e.lastIndex);return f.c=g<s.length?s.substring(g,s.length):"",f.fp=a,(Se.test(s)||p)&&(f.e=0),this._pt=f},mr=function(e,t,r,s,i,n,a,o,l){de(s)&&(s=s(i||0,e,n));let h,c=e[t],u="get"!==r?r:de(c)?l?e[t.indexOf("set")||!de(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():c,d=de(c)?l?Cr:Pr:Sr;if(ue(s)&&"="===(s=~s.indexOf("random(")?kt(s):s).charAt(1)&&(!(h=parseFloat(u)+parseFloat(s.substr(2))*("-"===s.charAt(0)?-1:1)+(St(u)||0))&&0!==h||(s=h)),u!==s)return isNaN(u*s)||""===s?(c||t in e||De(t,s),pr.call(this,e,t,u,s,d,o||te.stringFilter,l)):(h=new Ir(this._pt,e,t,+u||0,s-(u||0),"boolean"==typeof c?Er:Ar,0,d),l&&(h.fp=l),a&&h.modifier(a,this,e),this._pt=h)},fr=(e,t,r,s,i,n)=>{let a,o,l,h;if(Ne[e]&&!1!==(a=new Ne[e]).init(i,a.rawVars?t[e]:((e,t,r,s,i)=>{if(de(e)&&(e=vr(e,i,t,r,s)),!fe(e)||e.style&&e.nodeType||we(e)||xe(e))return ue(e)?vr(e,i,t,r,s):e;let n,a={};for(n in e)a[n]=vr(e[n],i,t,r,s);return a})(t[e],s,i,n,r),r,s,n)&&(r._pt=o=new Ir(r._pt,i,e,0,1,a.render,a,0,a.priority),r!==$))for(l=r._ptLookup[r._targets.indexOf(i)],h=a._props.length;h--;)l[a._props[h]]=o;return a},gr=(e,t)=>{let r,s,i,n,a,o,l,h,c,u,d,p,m,f=e.vars,{ease:g,startAt:v,immediateRender:y,lazy:x,onUpdate:w,onUpdateParams:b,callbackScope:T,runBackwards:M,yoyoEase:_,keyframes:S,autoRevert:P}=f,C=e._dur,R=e._startAt,A=e._targets,E=e.parent,D=E&&"nested"===E.data?E.parent._targets:A,L="auto"===e._overwrite&&!X,I=e.timeline;if(!I||S&&g||(g="none"),e._ease=sr(g,re.ease),e._yEase=_?tr(sr(!0===_?g:_,re.ease)):0,_&&e._yoyo&&!e._repeat&&(_=e._yEase,e._yEase=e._ease,e._ease=_),e._from=!I&&!!f.runBackwards,!I||S&&!f.stagger){if(p=(h=A[0]?Ge(A[0]).harness:0)&&f[h.prop],r=tt(f,Ue),R&&it(R.render(-1,!0)),v)if(it(e._startAt=wr.set(A,Je({data:"isStart",overwrite:!1,parent:E,immediateRender:!0,lazy:ge(x),startAt:null,delay:0,onUpdate:w,onUpdateParams:b,callbackScope:T,stagger:0},v))),t<0&&!y&&!P&&e._startAt.render(-1,!0),y){if(0<t&&!P&&(e._startAt=0),C&&t<=0)return void(t&&(e._zTime=t))}else!1===P&&(e._startAt=0);else if(M&&C)if(R)P||(e._startAt=0);else if(t&&(y=!1),i=Je({overwrite:!1,data:"isFromStart",lazy:y&&ge(x),immediateRender:y,stagger:0,parent:E},r),p&&(i[h.prop]=p),it(e._startAt=wr.set(A,i)),t<0&&e._startAt.render(-1,!0),e._zTime=t,y){if(!t)return}else gr(e._startAt,ie);for(e._pt=0,x=C&&ge(x)||x&&!C,s=0;s<A.length;s++){if(l=(a=A[s])._gsap||He(A)[s]._gsap,e._ptLookup[s]=u={},Be[l.id]&&ke.length&&Ze(),d=D===A?s:D.indexOf(a),h&&!1!==(c=new h).init(a,p||r,e,d,D)&&(e._pt=n=new Ir(e._pt,a,c.name,0,1,c.render,c,0,c.priority),c._props.forEach((e=>{u[e]=n})),c.priority&&(o=1)),!h||p)for(i in r)Ne[i]&&(c=fr(i,r,e,d,a,D))?c.priority&&(o=1):u[i]=n=mr.call(e,a,i,"get",r[i],d,D,0,f.stringFilter);e._op&&e._op[s]&&e.kill(a,e._op[s]),L&&e._pt&&(dr=e,Y.killTweensOf(a,u,e.globalTime(t)),m=!e.parent,dr=0),e._pt&&x&&(Be[l.id]=1)}o&&Lr(e),e._onInit&&e._onInit(e)}e._onUpdate=w,e._initted=(!e._op||e._pt)&&!m,S&&t<=0&&I.render(se,!0,!0)},vr=(e,t,r,s,i)=>de(e)?e.call(t,r,s,i):ue(e)&&~e.indexOf("random(")?kt(e):e,yr=Ve+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",xr={};Xe(yr+",id,stagger,delay,duration,paused,scrollTrigger",(e=>xr[e]=1));class wr extends cr{constructor(e,t,r,s){"number"==typeof t&&(r.duration=t,t=r,r=null),super(s?t:rt(t));let i,n,a,o,l,h,c,u,{duration:d,delay:p,immediateRender:m,stagger:f,overwrite:g,keyframes:v,defaults:y,scrollTrigger:x,yoyoEase:w}=this.vars,b=t.parent||Y,T=(we(e)||xe(e)?pe(e[0]):"length"in t)?[e]:Rt(e);if(this._targets=T.length?He(T):Le("GSAP target "+e+" not found. https://greensock.com",!te.nullTargetWarn)||[],this._ptLookup=[],this._overwrite=g,v||f||ye(d)||ye(p)){if(t=this.vars,(i=this.timeline=new ur({data:"nested",defaults:y||{}})).kill(),i.parent=i._dp=this,i._start=0,f||ye(d)||ye(p)){if(o=T.length,c=f&&Et(f),fe(f))for(l in f)~yr.indexOf(l)&&(u=u||{},u[l]=f[l]);for(n=0;n<o;n++)(a=tt(t,xr)).stagger=0,w&&(a.yoyoEase=w),u&&$e(a,u),h=T[n],a.duration=+vr(d,this,n,h,T),a.delay=(+vr(p,this,n,h,T)||0)-this._delay,!f&&1===o&&a.delay&&(this._delay=p=a.delay,this._start+=p,a.delay=0),i.to(h,a,c?c(n,h,T):0),i._ease=Jt.none;i.duration()?d=p=0:this.timeline=0}else if(v){rt(Je(i.vars.defaults,{ease:"none"})),i._ease=sr(v.ease||t.ease||"none");let e,r,s,o=0;if(we(v))v.forEach((e=>i.to(T,e,">")));else{for(l in a={},v)"ease"!==l&&"easeEach"!==l&&((e,t,r,s)=>{let i,n,a=t.ease||s||"power1.inOut";if(we(t))n=r[e]||(r[e]=[]),t.forEach(((e,r)=>n.push({t:r/(t.length-1)*100,v:e,e:a})));else for(i in t)n=r[i]||(r[i]=[]),"ease"!==i&&n.push({t:parseFloat(e),v:t[i],e:a})})(l,v[l],a,v.easeEach);for(l in a)for(e=a[l].sort(((e,t)=>e.t-t.t)),o=0,n=0;n<e.length;n++)r=e[n],s={ease:r.e,duration:(r.t-(n?e[n-1].t:0))/100*d},s[l]=r.v,i.to(T,s,o),o+=s.duration;i.duration()<d&&i.to({},{duration:d-i.duration()})}}d||this.duration(d=i.duration())}else this.timeline=0;!0!==g||X||(dr=this,Y.killTweensOf(T),dr=0),pt(b,this,r),t.reversed&&this.reverse(),t.paused&&this.paused(!0),(m||!d&&!v&&this._start===Ye(b._time)&&ge(m)&&at(this)&&"nested"!==b.data)&&(this._tTime=-ie,this.render(Math.max(0,-p))),x&&mt(this,x)}render(e,t,r){let s,i,n,a,o,l,h,c,u,d=this._time,p=this._tDur,m=this._dur,f=e>p-ie&&0<=e?p:e<ie?0:e;if(m){if(f!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(s=f,c=this.timeline,this._repeat){if(a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(s=Ye(f%a),f===p?(n=this._repeat,s=m):((n=~~(f/a))&&n===f/a&&(s=m,n--),s>m&&(s=m)),(l=this._yoyo&&1&n)&&(u=this._yEase,s=m-s),o=lt(this._tTime,a),s===d&&!r&&this._initted)return this;n!==o&&(c&&this._yEase&&rr(c,l),!this.vars.repeatRefresh||l||this._lock||(this._lock=r=1,this.render(Ye(a*n),!0).invalidate()._lock=0))}if(!this._initted){if(ft(this,e<0?e:s,r,t))return this._tTime=0,this;if(m!==this._dur)return this.render(e,t,r)}if(this._tTime=f,this._time=s,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=h=(u||this._ease)(s/m),this._from&&(this.ratio=h=1-h),s&&!d&&!t&&(zt(this,"onStart"),this._tTime!==f))return this;for(i=this._pt;i;)i.r(h,i.d),i=i._next;c&&c.render(e<0?e:!s&&l?-ie:c._dur*c._ease(s/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),zt(this,"onUpdate")),this._repeat&&n!==o&&this.vars.onRepeat&&!t&&this.parent&&zt(this,"onRepeat"),f!==this._tDur&&f||this._tTime!==f||(e<0&&this._startAt&&!this._onUpdate&&this._startAt.render(e,!0,!0),!e&&m||!(f===this._tDur&&0<this._ts||!f&&this._ts<0)||it(this,1),t||e<0&&!d||!f&&!d||(zt(this,f===p?"onComplete":"onReverseComplete",!0),!this._prom||f<p&&0<this.timeScale()||this._prom()))}}else{var g=this;let s,i,n,a=g.ratio,o=e<0||!e&&(!g._start&>(g)&&(g._initted||!vt(g))||(g._ts<0||g._dp._ts<0)&&!vt(g))?0:1,l=g._rDelay,h=0;if(l&&g._repeat&&(h=_t(0,g._tDur,e),i=lt(h,l),g._yoyo&&1&i&&(o=1-o),i!==lt(g._tTime,l)&&(a=1-o,g.vars.repeatRefresh&&g._initted&&g.invalidate())),o!==a||r||g._zTime===ie||!e&&g._zTime){if(g._initted||!ft(g,e,r,t)){for(n=g._zTime,g._zTime=e||(t?ie:0),t=t||e&&!n,g.ratio=o,g._from&&(o=1-o),g._time=0,g._tTime=h,s=g._pt;s;)s.r(o,s.d),s=s._next;g._startAt&&e<0&&g._startAt.render(e,!0,!0),g._onUpdate&&!t&&zt(g,"onUpdate"),h&&g._repeat&&!t&&g.parent&&zt(g,"onRepeat"),(e>=g._tDur||e<0)&&g.ratio===o&&(o&&it(g,1),t||(zt(g,o?"onComplete":"onReverseComplete",!0),g._prom&&g._prom()))}}else g._zTime||(g._zTime=e)}return this}targets(){return this._targets}invalidate(){return this._pt=this._op=this._startAt=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(),super.invalidate()}kill(e,t="all"){if(!(e||t&&"all"!==t))return this._lazy=this._pt=0,this.parent?jt(this):this;var r;if(this.timeline)return r=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,dr&&!0!==dr.vars.overwrite)._first||jt(this),this.parent&&r!==this.timeline.totalDuration()&&yt(this,this._dur*this.timeline._tDur/r,0,1),this;let s,i,n,a,o,l,h,c=this._targets,u=e?Rt(e):c,d=this._ptLookup,p=this._pt;if((!t||"all"===t)&&((e,t)=>{let r=e.length,s=r===t.length;for(;s&&r--&&e[r]===t[r];);return r<0})(c,u))return"all"===t&&(this._pt=0),jt(this);for((s=this._op=this._op||[],"all"!==t&&(ue(t)&&(o={},Xe(t,(e=>o[e]=1)),t=o),t=((e,t)=>{let r,s,i,n,a=e[0]?Ge(e[0]).harness:0,o=a&&a.aliases;if(!o)return t;for(s in r=$e({},t),o)if(s in r)for(n=o[s].split(","),i=n.length;i--;)r[n[i]]=r[s];return r})(c,t)),h=c.length);h--;)if(~u.indexOf(c[h]))for(o in i=d[h],"all"===t?(s[h]=t,a=i,n={}):(n=s[h]=s[h]||{},a=t),a)l=i&&i[o],l&&("kill"in l.d&&!0!==l.d.kill(o)||st(this,l,"_pt"),delete i[o]),"all"!==n&&(n[o]=1);return this._initted&&!this._pt&&p&&jt(this),this}static to(e,t){return new wr(e,t,arguments[2])}static from(e,t){return Tt(1,arguments)}static delayedCall(e,t,r,s){return new wr(t,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:e,onComplete:t,onReverseComplete:t,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:s})}static fromTo(e,t,r){return Tt(2,arguments)}static set(e,t){return t.duration=0,t.repeatDelay||(t.repeat=0),new wr(e,t)}static killTweensOf(e,t,r){return Y.killTweensOf(e,t,r)}}function br(e,t){let r=t._pt,s="";if(!e&&t.b)s=t.b;else if(1===e&&t.e)s=t.e;else{for(;r;)s=r.p+(r.m?r.m(r.s+r.c*e):Math.round(1e4*(r.s+r.c*e))/1e4)+s,r=r._next;s+=t.c}t.set(t.t,t.p,s,t)}function Tr(e,t){let r=t._pt;for(;r;)r.r(e,r.d),r=r._next}function Mr(e,t,r,s){let i,n=this._pt;for(;n;)i=n._next,n.p===s&&n.modifier(e,t,r),n=i}function _r(e){let t,r,s=this._pt;for(;s;)r=s._next,s.p===e&&!s.op||s.op===e?st(this,s,"_pt"):s.dep||(t=1),s=r;return!t}Je(wr.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),Xe("staggerTo,staggerFrom,staggerFromTo",(e=>{wr[e]=function(){let t=new ur,r=Pt.call(arguments,0);return r.splice("staggerFromTo"===e?5:4,0,0),t[e].apply(t,r)}}));let Sr=(e,t,r)=>e[t]=r,Pr=(e,t,r)=>e[t](r),Cr=(e,t,r,s)=>e[t](s.fp,r),Rr=(e,t)=>de(e[t])?Pr:me(e[t])&&e.setAttribute?(e,t,r)=>e.setAttribute(t,r):Sr,Ar=(e,t)=>t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t),Er=(e,t)=>t.set(t.t,t.p,!!(t.s+t.c*e),t),Dr=(e,t,r,s)=>{s.mSet(e,t,s.m.call(s.tween,r,s.mt),s)},Lr=e=>{let t,r,s,i,n=e._pt;for(;n;){for(t=n._next,r=s;r&&r.pr>n.pr;)r=r._next;(n._prev=r?r._prev:i)?n._prev._next=n:s=n,(n._next=r)?r._prev=n:i=n,n=t}e._pt=s};class Ir{constructor(e,t,r,s,i,n,a,o,l){this.t=t,this.s=s,this.c=i,this.p=r,this.r=n||Ar,this.d=a||this,this.set=o||Sr,this.pr=l||0,(this._next=e)&&(e._prev=this)}modifier(e,t,r){this.mSet=this.mSet||this.set,this.set=Dr,this.m=e,this.mt=r,this.tween=t}}Xe(Ve+"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",(e=>Ue[e]=1)),Re.TweenMax=Re.TweenLite=wr,Re.TimelineLite=Re.TimelineMax=ur,Y=new ur({sortChildren:!1,defaults:re,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),te.stringFilter=e=>{var t=e.join(" ");if(Zt.lastIndex=0,Zt.test(t))return t=Qt.test(t),e[1]=Yt(e[1],t),e[0]=Yt(e[0],t,Xt(e[1])),!0};const Or={registerPlugin(...e){e.forEach((e=>{{let t=(e=!e.name&&e.default||e).name,r=de(e),s=t&&!r&&e.init?function(){this._props=[]}:e,i={init:Oe,render:Tr,add:mr,kill:_r,modifier:Mr,rawVars:0},n={targetTest:0,get:0,getSetter:Rr,aliases:{},register:0};if(Kt(),e!==s){if(Ne[t])return;Je(s,Je(tt(e,i),n)),$e(s.prototype,$e(i,tt(e,n))),Ne[s.prop=t]=s,e.targetTest&&(je.push(s),Ue[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}return Ie(t,s),void(e.register&&e.register(Br,s,Ir))}}))},timeline:e=>new ur(e),getTweensOf:(e,t)=>Y.getTweensOf(e,t),getProperty(e,t,r,s){ue(e)&&(e=Rt(e)[0]);let i=Ge(e||{}).get,n=r?Ke:qe;return"native"===r&&(r=""),e&&(t?n((Ne[t]&&Ne[t].get||i)(e,t,r,s)):(t,r,s)=>n((Ne[t]&&Ne[t].get||i)(e,t,r,s)))},quickSetter(e,t,r){if(1<(e=Rt(e)).length){let s=e.map((e=>Br.quickSetter(e,t,r))),i=s.length;return e=>{let t=i;for(;t--;)s[t](e)}}e=e[0]||{};let s=Ne[t],i=Ge(e),n=i.harness&&(i.harness.aliases||{})[t]||t,a=s?t=>{let i=new s;$._pt=0,i.init(e,r?t+r:t,$,0,[e]),i.render(1,i),$._pt&&Tr(1,$)}:i.set(e,n);return s?a:t=>a(e,n,r?t+r:t,i,1)},isTweening:e=>0<Y.getTweensOf(e,!0).length,defaults:e=>(e&&e.ease&&(e.ease=sr(e.ease,re.ease)),et(re,e||{})),config:e=>et(te,e||{}),registerEffect({name:e,effect:t,plugins:r,defaults:s,extendTimeline:i}){(r||"").split(",").forEach((t=>t&&!Ne[t]&&!Re[t]&&Le(e+" effect requires "+t+" plugin."))),Fe[e]=(e,r,i)=>t(Rt(e),Je(r||{},s),i),i&&(ur.prototype[e]=function(t,r,s){return this.add(Fe[e](t,fe(r)?r:(s=r)&&{},this),s)})},registerEase(e,t){Jt[e]=sr(t)},parseEase(e,t){return arguments.length?sr(e,t):Jt},getById:e=>Y.getById(e),exportRoot(e={},t){let r,s,i=new ur(e);for(i.smoothChildTiming=ge(e.smoothChildTiming),Y.remove(i),i._dp=0,i._time=i._tTime=Y._time,r=Y._first;r;)s=r._next,!t&&!r._dur&&r instanceof wr&&r.vars.onComplete===r._targets[0]||pt(i,r,r._start-r._delay),r=s;return pt(Y,i,0),i},utils:{wrap:function e(t,r,s){let i=r-t;return we(t)?Ot(t,e(0,t.length),r):Mt(s,(e=>(i+(e-t)%i)%i+t))},wrapYoyo:Ut,distribute:Et,random:It,snap:Lt,normalize:(e,t,r)=>Bt(e,t,0,1,r),getUnit:St,clamp:(e,t,r)=>Mt(r,(r=>_t(e,t,r))),splitColor:Wt,toArray:Rt,selector:e=>(e=Rt(e)[0]||Le("Invalid scope")||{},t=>{var r=e.current||e.nativeElement||e;return Rt(t,r.querySelectorAll?r:r===e?Le("Invalid scope")||q.createElement("div"):e)}),mapRange:Bt,pipe:(...e)=>t=>e.reduce(((e,t)=>t(e)),t),unitize:(e,t)=>r=>e(parseFloat(r))+(t||St(r)),interpolate:Nt,shuffle:At},install:Ee,effects:Fe,ticker:qt,updateRoot:ur.updateRoot,plugins:Ne,globalTimeline:Y,core:{PropTween:Ir,globals:Ie,Tween:wr,Timeline:ur,Animation:cr,getCache:Ge,_removeLinkedListItem:st,suppressOverwrites:e=>X=e}};Xe("to,from,fromTo,delayedCall,set,killTweensOf",(e=>Or[e]=wr[e])),qt.add(ur.updateRoot),$=Or.to({},{duration:0});let Ur=(e,t)=>{let r=e._pt;for(;r&&r.p!==t&&r.op!==t&&r.fp!==t;)r=r._next;return r},kr=(e,t)=>({name:e,rawVars:1,init(e,r,s){s._onInit=e=>{let s,i;if(ue(r)&&(s={},Xe(r,(e=>s[e]=1)),r=s),t){for(i in s={},r)s[i]=t(r[i]);r=s}{var n=e,a=r;let t,s,i,o=n._targets;for(t in a)for(s=o.length;s--;)i=n._ptLookup[s][t],(i=i&&i.d)&&(i._pt&&(i=Ur(i,t)),i&&i.modifier&&i.modifier(a[t],n,o[s],t));return}}}});const Br=Or.registerPlugin({name:"attr",init(e,t,r,s,i){let n,a;for(n in t)a=this.add(e,"setAttribute",(e.getAttribute(n)||0)+"",t[n],s,i,0,0,n),a&&(a.op=n),this._props.push(n)}},{name:"endArray",init(e,t){let r=t.length;for(;r--;)this.add(e,r,e[r]||0,t[r])}},kr("roundProps",Dt),kr("modifiers"),kr("snap",Lt))||Or;wr.version=ur.version=Br.version="3.9.1",K=1,ve()&&Kt();var{}=Jt;const Nr=["map","normalMap","aoMap"],Fr=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"],zr=class extends L{constructor(e){super(),this.type="修改材质";var{target:e,info:t,newVal:r,oldVal:s}=e;this.target=e,this.info=t,this.newVal=r,this.oldVal=s}_execute(e,t){console.log(this,e,"this,data"),this.target[this.info]=e,this.target.needsUpdate=!0,Fr.includes(this.info)&&(console.log(this.info,"this.info"),e&&pl.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 jr=function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))},Vr=function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))};const Hr=(e,t,r,s,i)=>{let n=Object.assign({},e),a=new wr(n,r,t).eventCallback("onUpdate",(e=>s&&s(n))).eventCallback("onComplete",(e=>{i&&i(),wr.killTweensOf(a)}));return a},Gr=(e,t)=>(t.updateMatrixWorld(!0),t=new C.Vector3,e.getWorldPosition(t),t),Wr=e=>Vr(void 0,void 0,void 0,(function*(){return(yield r().get(e,{responseType:"blob"})).data})),Xr=e=>(0,G.md5)(e);class Yr{constructor(e){this.alt=!1,this.ctrl=!1,this.shift=!1,this.eventsMap={down:{},up:{}},this.allFn={s_saveScene:()=>function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){ml.log("正在保存","base","info");var e=yield ml.cb.scene.saveNet.cb("");console.log(e,"res"),ml.log("保存成功","base","success")})),d_exporter_Gltf:()=>{Rl.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=Pl.select;if(e){const{scene:r,camera:i,renderer:n,controls:a}=yl.get(),o=new s.Vector3,l=new s.Vector3;if("Mesh"===e.type){const e=Tl.boxHelper;if(e.update(),!e||!e.object)return;var t=n.domElement.getBoundingClientRect();let r=t.width/t.height;const a=new s.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 h=new s.Vector3;h.subVectors(i.position,l),h.projectOnPlane(new s.Vector3(0,1,0)),h.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*i.fov*Math.PI/180),t=a.length()/r/t,o.addVectors(l,h.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new s.Vector3,e.getWorldPosition(t),l.set(t.x,t.y,t.z);let n=new s.Vector3;n.subVectors(i.position,l),n.projectOnPlane(new s.Vector3(0,1,0)),n.normalize(),o.addVectors(l,n.multiplyScalar(3))}Hr({positionX:i.position.x,positionY:i.position.y,positionZ:i.position.z,targetX:a.target.x,targetY:a.target.y,targetZ:a.target.z},{positionX:o.x,positionY:o.y,positionZ:o.z,targetX:l.x,targetY:l.y,targetZ:l.z},.5,(e=>{i.position.set(e.positionX,e.positionY,e.positionZ),i.lookAt(e.targetX,e.targetY,e.targetZ),a.target.set(e.targetX,e.targetY,e.targetZ),a.update(),i.updateProjectionMatrix()}))}},z_undo:e=>{fl.undo()},y_redo:e=>{fl.redo()}},this.events=e}bindEvent(e,t,r){if(void 0!==this.eventsMap[e][t])throw SyntaxError("该函数名已存在");this.eventsMap[e][t]=r}init(e){document.addEventListener("keydown",this.keyDown.bind(this)),document.addEventListener("keyup",this.keyUp.bind(this))}keyDown(e){const t=e.key.toLowerCase();switch((0,D.js)(this.eventsMap.down,((r,s)=>{s(t,e)})),t){case"s":this.ctrl&&(e.preventDefault(),this.allFn.s_saveScene());break;case"d":if(this.ctrl){e.preventDefault();var r=Pl.select;if(!r)return;Pl.selectNull();var s=Pl.clone(r);if(!s)return;Pl.add(s,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":Tl.transContro.changeMode("position");break;case"e":Tl.transContro.changeMode("rotation");break;case"r":if(Tl.transContro.changeMode("scale"),!this.ctrl)return;e.preventDefault(),this.allFn.r_runScript();break;case"g":ml.cb.events.key.g.cb({event:e,eventKey:this});break;case"f":this.allFn.f_focusModel();break;case"delete":console.log("删除"),Tl.unfocus(),s=bl.getSelectedList("value"),Sl.remove(Pl.select||s),s&&bl.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,D.js)(this.eventsMap.up,((r,s)=>{s(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 Zr{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.e=null,this.down=e=>{(0,D.js)(this.fnMap.local.down,((t,r)=>{r(e)})),this.downPosition={x:e.offsetX,y:e.offsetY}},this.up=e=>{var t,r,s,i;2===e.button||Tl.transContro.isDraggingChange||((0,D.js)(this.fnMap.local.up,((t,r)=>{r(e)})),t=e.offsetX,r=e.offsetY,({x:s,y:i}=this.downPosition),t===s&&r===i&&this.trigger(e))},this.events=e}bindEvent(e){var{type:e,name:t,fn:r,local:s}=e;this.fnMap[s][e][t]=r}init(e){e.addEventListener("pointerdown",this.down.bind(this)),e.addEventListener("pointerup",this.up.bind(this)),window.addEventListener("pointerdown",(e=>{(0,D.js)(this.fnMap.global.down,((t,r)=>{r(e)}))})),window.addEventListener("pointerup",(e=>{(0,D.js)(this.fnMap.global.up,((t,r)=>{r(e)}))}))}getTriggerModels(e){const t=new s.Raycaster,r=new s.Vector2,{engineDom:i,camera:n,scene:a}=yl.get();return r.x=e.offsetX/i.clientWidth*2-1,r.y=-e.offsetY/i.clientHeight*2+1,t.setFromCamera(r,n),e=a.children.filter((e=>{if((!Tl.isHelper(e)||e.userData.id)&&!e.userData.unClick)return e})),t.intersectObjects(e,!0).map((e=>e.object))}removeHideModel(e){return e.find((e=>Pl.deepIsVisible(e)))}trigger(e){let t=this.removeHideModel(this.getTriggerModels(e));if(console.log("鼠标按下的模型:",t),!t)return bl.setEmpty(),void Pl.selectNull();if(Tl.isHelper(t)&&(e=pl.getId(t),t=pl.model.get(e)),!this.enableUp){if(t===Tl.transContro.multipObj)return;this.enableUp=!0}if(console.log("鼠标按下选中的模型:",t),Qr.key.ctrl)return this.enableUp=!1,bl.add(t);if(Qr.key.shift){const e=t.parent;return e?void e.children.map((e=>{bl.add(e)})):void 0}Pl.setSelectByModel(t),Al.isLight(t)&&Al.setSelect(t)}}const Qr=new class{constructor(){this.key=new Yr(this),this.mouse=new Zr(this),this.drag=new H(this),this.e=null,this.mouseEventMap={move:{timeLineMove:e=>{}},down:{},up:{timeLineUp:e=>{}}},this.mouseDown=e=>{},this.mouseUp=e=>{Object.values(this.mouseEventMap.up).map((t=>t(e)))},this.mouseMove=e=>{Object.values(this.mouseEventMap.move).map((t=>t(e)))}}init(e){this.key.init(e),this.mouse.init(e),window.addEventListener("resize",(()=>{wl.setSize(),ml.cb.resize.cb("")})),window.addEventListener("mousemove",this.mouseMove),window.addEventListener("mousedown",this.mouseDown),window.addEventListener("mouseup",this.mouseUp)}};class qr{constructor(){this.JsonMaterialMap={},this.materialMap={},this.textureMap={}}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),Ml.getDefNromals(e))}setMaterialDef(e){const{type:t,data:r,normal:s}=e;s[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,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.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 Kr{constructor(e){this.helperModels=[],this.type=e,this.material=new qr,this.scene=new B}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,D.js)(Pl.defNodeMap,((e,s)=>{t[e]!==s&&(r[e]=t[e])})),t.material&&t.material.wireframe&&(t.material.wireframe=!1,r.wireframe=!0)}parseSprite(){}done(e){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.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)}))}}class Jr{static create(){const e=new s.SpriteMaterial;return e.userData.tools=this.tools,e}}Jr.e=null,Jr.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=Pl.create();return t.userData.normal={type:"MySpriteMaterial"},Jr.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=Pl.createDef("Sprite");return Jr.modelTools.merge(e,r),r.material=e.material,r}},Jr.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 t=e.textures,r=Jr.create();return t.map((e=>{var{type:e,texture:t}=e;r[e]=t})),r},toNormal:e=>{const t=Ml.createNotHis();return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Jr.tools.type},textures:Jr.tools.getTextures(e)}),t},clone:function(e,t){return e}};var $r=function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))};class es{constructor(e){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.defMaterial=Ml.createNotHis(),this.modelType={Sprite:Jr},this.type=e}parse(e){return $r(this,void 0,void 0,(function*(){const t=new s.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=Sl.get();if(t.background instanceof s.Texture||t.environment instanceof s.Texture){xl.glow.setUpdate(!1),t.userData.ex={};var{background:r,environment:i}=t;xl.glow.setUpdate(!0);const n=Pl.create(),a=Ml.createNotHis();n.material=a,e.add(n),e=(0,S.getId)(),t.userData.ex.materialId=e,a.userData.id=e,this.materialMap[e]={material:a},r instanceof s.Texture&&303===(a.map=r).mapping&&(t.userData.ex.backgroundMapping=303),i instanceof s.Texture&&(a.envMap=i)}}_processMaterial(e){if(e.material){var t=Ml.isBaseMaterial(e.material),r=this.materialMap[e.material.userData.id];return r?(r.normalMaterial&&(e.material=r.normalMaterial),void(null!=(r=r.models)&&r.push(e))):(r=t||ml.exporterOptions.notMaterial?this.defMaterial:Ml.toNromal(e.material),e.material=r,this.materialMap[r.userData.id]={material:r,normalMaterial:r,models:[e]},r)}}_processModel(e,t){const r=this.modelType[e.type];if(!r)return e;const s=r.modelTools.toNormal(e);t&&(s.material=t),e.parent.add(s),e.parent.remove(e)}parseMaterial(e){const t=new Set;e.traverse((e=>t.add(e))),t.forEach((e=>{var t=this._processMaterial(e);this._processModel(e,t)}))}materialMapToJson(){return(0,D.js)(this.materialMap,((e,t)=>$r(this,void 0,void 0,(function*(){var e=t.material,r=Ml.getAllTextures(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:s}=this.textureMap[i];if(t.md5===r&&e.mapping===s.mapping)return{isSame:!0,texture:s}}return this.textureMap[e.userData.id]=Object.assign(Object.assign({},t),{texture:e}),{isSame:!1,texture:e}}mergeAndRemoveTexture(e,t){return $r(this,void 0,void 0,(function*(){return e.map((e=>{const{type:r,texture:s}=e;pl.texture.add(s),t[r]=null;var{isSame:e,texture:i}=this.mergeSame(s);if(e)gl.dispose(s);else if(!this.json.textureMap[s.userData.id]){var n,{format:a,repeat:o,center:l,rotation:h,offset:c}=s;const e={format:a};Pl.isNavieV2(o,1)||(({x:a,y:n}=o),e.repeat=a===n?a:o),Pl.isNavieV2(l,0)||(({x:n,y:a}=l),e.center=n===a?n:l),Pl.isNavieV2(c,0)||(({x:o,y:a}=c),e.offset=o===a?o:c),0!==h&&(e.rotation=h),this.json.textureMap[s.userData.id]=e}"normalMap"!==r||s.userData.isNormalMap||(s.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[r]=i.userData.id}))}))}setMultipMaterial(e,t){const r=Pl.create(),s=Ml.createNotHis();r.material=s,e.add(r);for(const e of Nr){if(!t.length)return;var i=t.pop();if(!i)return;s[e]=this.textureMap[i].texture}t.length&&this.setMultipMaterial(e,t)}}class ts{constructor(){this.pluginCallbacks=[],this.register((function(e){return new us(e)})),this.register((function(e){return new ds(e)})),this.register((function(e){return new ps(e)})),this.register((function(e){return new fs(e)})),this.register((function(e){return new gs(e)})),this.register((function(e){return new ms(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){"object"==typeof r&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),s=r);const i=new cs,n=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)n.push(this.pluginCallbacks[e](i));i.setPlugins(n),i.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise((function(s,i){r.parse(e,s,i,t)}))}}const rs=5121,ss=5123,is={},ns=(is[s.NearestFilter]=9728,is[s.NearestMipmapNearestFilter]=9984,is[s.NearestMipmapLinearFilter]=9986,is[s.LinearFilter]=9729,is[s.LinearMipmapNearestFilter]=9985,is[s.LinearMipmapLinearFilter]=9987,is[s.ClampToEdgeWrapping]=33071,is[s.RepeatWrapping]=10497,is[s.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function as(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function os(e){return 4*Math.ceil(e/4)}function ls(e,t=0){var r=os(e.byteLength);if(r===e.byteLength)return e;{const s=new Uint8Array(r);if(s.set(new Uint8Array(e)),0!==t)for(let i=e.byteLength;i<r;i++)s[i]=t;return s.buffer}}let hs=null;class cs{constructor(){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}}setPlugins(e){this.plugins=e}async write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);var s=(e=this).buffers;const i=e.json;if(r=e.options,await e.options.myOptions.helper.done(i),e=e.extensionsUsed,s=new Blob(s,{type:"application/octet-stream"}),0<(e=Object.keys(e)).length&&(i.extensionsUsed=e),i.buffers&&0<i.buffers.length&&(i.buffers[0].byteLength=s.size),!0===r.binary){const e=new window.FileReader;e.readAsArrayBuffer(s),e.onloadend=function(){var r=ls(e.result);const s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);var n=ls(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;const t=new Uint8Array(new ArrayBuffer(e.length));for(let s=0,i=e.length;s<i;s++){var r=e.charCodeAt(s);t[s]=255<r?32:r}return t.buffer}(JSON.stringify(i)),32);const a=new DataView(new ArrayBuffer(8));a.setUint32(0,n.byteLength,!0),a.setUint32(4,1313821514,!0);var o=new ArrayBuffer(12);const l=new DataView(o);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0);var h=12+a.byteLength+n.byteLength+s.byteLength+r.byteLength;l.setUint32(8,h,!0),h=new Blob([o,a,n,s,r],{type:"application/octet-stream"});const c=new window.FileReader;c.readAsArrayBuffer(h),c.onloadend=function(){t(c.result)}}}else if(i.buffers&&0<i.buffers.length){const e=new window.FileReader;e.readAsDataURL(s),e.onloadend=function(){var r=e.result;i.buffers[0].uri=r,t(i)}}else t(i)}serializeUserData(e,t){if(0!==Object.keys(e.userData).length){var r=this.options;const s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&i.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],s[e]=!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)}}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new s.Vector3;for(let r=0,s=e.count;r<s;r++)if(5e-4<Math.abs(t.fromBufferAttribute(e,r).length()-1))return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),i=new s.Vector3;for(let e=0,t=r.count;e<t;e++)i.fromBufferAttribute(r,e),0===i.x&&0===i.y&&0===i.z?i.setX(1):i.normalize(),r.setXYZ(e,i.x,i.y,i.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};0===t.offset.x&&0===t.offset.y||(s.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(s.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(s.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildORMTexture(e){var t=e.aoMap?.image,r=e.roughnessMap?.image,i=e.metalnessMap?.image;if(t===r&&r===i)return e.aoMap;if(t||r||i){e=Math.max(t?.width||0,r?.width||0,i?.width||0);var n=Math.max(t?.height||0,r?.height||0,i?.height||0);const h=document.createElement("canvas"),c=(h.width=e,h.height=n,h.getContext("2d")),u=(c.fillStyle="#ffffff",c.fillRect(0,0,e,n),c.getImageData(0,0,e,n));if(t){c.drawImage(t,0,0,e,n);var a=c.getImageData(0,0,e,n).data;for(let e=0;e<a.length;e+=4)u.data[e]=a[e]}if(r){c.drawImage(r,0,0,e,n);var o=c.getImageData(0,0,e,n).data;for(let e=1;e<o.length;e+=4)u.data[e]=o[e]}if(i){c.drawImage(i,0,0,e,n);var l=c.getImageData(0,0,e,n).data;for(let e=2;e<l.length;e+=4)u.data[e]=l[e]}return c.putImageData(u,0,0),new s.Texture(h)}}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,i){const n=this.json;let a;n.bufferViews||(n.bufferViews=[]),a=t===rs?1:t===ss?2:4;var o=os(s*e.itemSize*a);const l=new DataView(new ArrayBuffer(o));let h=0;for(let i=r;i<r+s;i++)for(let r=0;r<e.itemSize;r++){let s;4<e.itemSize?s=e.array[i*e.itemSize+r]:0===r?s=e.getX(i):1===r?s=e.getY(i):2===r?s=e.getZ(i):3===r&&(s=e.getW(i)),5126===t?l.setFloat32(h,s,!0):5125===t?l.setUint32(h,s,!0):t===ss?l.setUint16(h,s,!0):t===rs&&l.setUint8(h,s),h+=a}const c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==i&&(c.target=i),34962===i&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,n.bufferViews.push(c),{id:n.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(s,i){const n=new window.FileReader;if(!(e instanceof Blob))return i();n.readAsArrayBuffer(e),n.onloadend=function(){var e=ls(n.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,s(r.bufferViews.push(i)-1)}}))}processAccessor(e,t,r,s){var i=this.options;const n=this.json;let a,o;if(e.array.constructor===Float32Array)a=5126;else if(e.array.constructor===Uint32Array)a=5125;else if(e.array.constructor===Uint16Array)a=ss;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");a=rs}if(void 0===r&&(r=0),void 0===s&&(s=e.count),i.truncateDrawRange&&void 0!==t&&null===t.index&&(i=r+s,l=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count,r=Math.max(r,t.drawRange.start),(s=Math.min(i,l)-r)<0&&(s=0)),0===s)return null;i=function(e,t,r){const s={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i<t+r;i++)for(let t=0;t<e.itemSize;t++){let r;4<e.itemSize?r=e.array[i*e.itemSize+t]:0===t?r=e.getX(i):1===t?r=e.getY(i):2===t?r=e.getZ(i):3===t&&(r=e.getW(i)),s.min[t]=Math.min(s.min[t],r),s.max[t]=Math.max(s.max[t],r)}return s}(e,r,s),void 0!==t&&(o=e===t.index?34963:34962);var l=this.processBufferView(e,a,r,s,o);const h={bufferView:l.id,byteOffset:l.byteOffset,componentType:a,count:s,max:i.max,min:i.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),n.accessors||(n.accessors=[]),n.accessors.push(h)-1}processImage(e,t,r,i){const n=this,a=n.cache,o=n.json;var l=n.options;const h=n.pending,c=(a.images.has(e)||a.images.set(e,{}),a.images.get(e));let u=i.userData?.blob;var d=i.userData.isNormalMap,p=n.options.myOptions.optionsEx.exporterOptions.compressTexture;const m=p?"image/webp":"image/png";if(p&&(u=!!d),void 0!==c[p=m+":flipY/"+r.toString()])return c[p];o.images||(o.images=[]);const f={mimeType:m};if(!0===l.binary&&u)h.push(new Promise((e=>{n.processBufferViewImage(i.userData.blob).then((function(t){f.bufferView=t,e()}))})));else if(l.embedImages){const r=hs=hs||document.createElement("canvas"),i=(r.width=Math.min(e.width,l.maxTextureSize),r.height=Math.min(e.height,l.maxTextureSize),r.getContext("2d"));if(i.translate(0,r.height),i.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)i.drawImage(e,0,0,r.width,r.height);else{t!==s.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const r=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<r.length;t+=4)r[t+0]=e.data[t+0],r[t+1]=e.data[t+1],r[t+2]=e.data[t+2],r[t+3]=e.data[t+3];i.putImageData(new ImageData(r,e.width,e.height),0,0)}!0===l.binary?h.push(new Promise((function(e){r.toBlob((function(t){n.processBufferViewImage(t).then((function(t){f.bufferView=t,e()}))}),m)}))):f.uri=r.toDataURL(m)}else f.uri=e.src;return d=o.images.push(f)-1,c[p]=d}processSampler(e){const t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:is[e.magFilter],minFilter:is[e.minFilter],wrapS:is[e.wrapS],wrapT:is[e.wrapT]},t.samplers.push(e)-1}processTexture(e){const t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);const s={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,e)};e.name&&(s.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,s)}));var i=r.textures.push(s)-1;return t.textures.set(e,i),this.options.myOptions.helper.material.processTexture({texture:e,textureDef:s}),i}processMaterial(e){const 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=[]);const i={pbrMetallicRoughness:{}};if(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."),as(n=e.color.toArray().concat([e.opacity]),[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(n={index:this.processTexture(null)},this.applyTextureTransform(n,e.metalnessMap||e.roughnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=n),e.map&&(n={index:this.processTexture(e.map)},this.applyTextureTransform(n,e.map),i.pbrMetallicRoughness.baseColorTexture=n),e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity);var n=Math.max(t.r,t.g,t.b);1<n&&(t.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<n&&(i.emissiveFactor=t.toArray()),e.emissiveMap&&(n={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(n,e.emissiveMap),i.emissiveTexture=n)}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}return e.transparent?i.alphaMode="BLEND":0<e.alphaTest&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===s.DoubleSide&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)})),n=r.materials.push(i)-1,t.materials.set(e,n),n}processMesh(e){const t=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);var n=i.join(":");if(t.meshes.has(n))return t.meshes.get(n);const a=e.geometry;let o;if(o=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4,!0!==a.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");const l={},h={},c=[],u=[];var d,p={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},m=a.getAttribute("normal");void 0===m||this.isNormalizedNormalAttribute(m)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(m)));let f=null;for(d in a.attributes)if("morph"!==d.slice(0,5)){var g,v=a.attributes[d];d=p[d]||d.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(d)||(d="_"+d),t.attributes.has(this.getUID(v))?h[d]=t.attributes.get(this.getUID(v)):(f=null,g=v.array,"JOINTS_0"!==d||g instanceof Uint16Array||g instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new s.BufferAttribute(new Uint16Array(g),v.itemSize,v.normalized)),null!==(g=this.processAccessor(f||v,a))&&(h[d]=g,t.attributes.set(this.getUID(v),g)))}if(void 0!==m&&a.setAttribute("normal",m),0===Object.keys(h).length)return null;if(void 0!==e.morphTargetInfluences&&0<e.morphTargetInfluences.length){const r=[],s=[],i={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let n=0;n<e.morphTargetInfluences.length;++n){const o={};let l=!1;for(const e in a.morphAttributes)if("position"!==e&&"normal"!==e)l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);else{const r=a.morphAttributes[e][n];var y=e.toUpperCase();const s=a.attributes[e];if(t.attributes.has(this.getUID(r)))o[y]=t.attributes.get(this.getUID(r));else{const e=r.clone();if(!a.morphTargetsRelative)for(let t=0,i=r.count;t<i;t++)e.setXYZ(t,r.getX(t)-s.getX(t),r.getY(t)-s.getY(t),r.getZ(t)-s.getZ(t));o[y]=this.processAccessor(e,a),t.attributes.set(this.getUID(s),o[y])}}u.push(o),r.push(e.morphTargetInfluences[n]),void 0!==e.morphTargetDictionary&&s.push(i[n])}l.weights=r,0<s.length&&(l.extras={},l.extras.targetNames=s)}if((m=Array.isArray(e.material))&&0===a.groups.length)return null;var x=m?e.material:[e.material],w=m?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=w.length;e<r;e++){const r={mode:o,attributes:h};if(this.serializeUserData(a,r),0<u.length&&(r.targets=u),null!==a.index){let s=this.getUID(a.index);void 0===w[e].start&&void 0===w[e].count||(s+=":"+w[e].start+":"+w[e].count),t.attributes.has(s)?r.indices=t.attributes.get(s):(r.indices=this.processAccessor(a.index,a,w[e].start,w[e].count),t.attributes.set(s,r.indices)),null===r.indices&&delete r.indices}var b=this.processMaterial(x[w[e].materialIndex]);null!==b&&(r.material=b),c.push(r)}return l.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,l)})),m=r.meshes.push(l)-1,t.meshes.set(n,m),m}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);var r=e.isOrthographicCamera;const i={type:r?"orthographic":"perspective"};return r?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:s.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const r=this.json,i=this.nodeMap;r.animations||(r.animations=[]);var n=(e=ts.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks;const a=[],o=[];for(let e=0;e<n.length;++e){const r=n[e];var l=s.PropertyBinding.parseTrackName(r.name);let c=s.PropertyBinding.findNode(t,l.nodeName);var h=ns[l.propertyName];if(!(c="bones"===l.objectName?!0===c.isSkinnedMesh?c.skeleton.getBoneByName(l.objectIndex):void 0:c)||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',r.name),null;let u,d=r.values.length/r.times.length;h===ns.morphTargetInfluences&&(d/=c.morphTargetInfluences.length),!0===r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",d/=3):u=r.getInterpolation()===s.InterpolateDiscrete?"STEP":"LINEAR",o.push({input:this.processAccessor(new s.BufferAttribute(r.times,1)),output:this.processAccessor(new s.BufferAttribute(r.values,d)),interpolation:u}),a.push({sampler:o.length-1,target:{node:i.get(c),path:h}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:o,channels:a}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,i=t.nodes[r.get(e)];var n=e.skeleton;if(void 0===n)return null;var a=e.skeleton.bones[0];if(void 0===a)return null;const o=[];var l=new Float32Array(16*n.bones.length);const h=new s.Matrix4;for(let t=0;t<n.bones.length;++t)o.push(r.get(n.bones[t])),h.copy(n.boneInverses[t]),h.multiply(e.bindMatrix).toArray(l,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new s.BufferAttribute(l,16)),joints:o,skeleton:r.get(a)}),i.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap,i=(t.nodes||(t.nodes=[]),{});var n,a,o;if(r.myOptions.helper.parseNode({object:e,nodeDef:i,options:this}),r.trs?(o=e.quaternion.toArray(),n=e.position.toArray(),a=e.scale.toArray(),as(o,[0,0,0,1])||(i.rotation=o),as(n,[0,0,0])||(i.translation=n),as(a,[1,1,1])||(i.scale=a)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===as(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(i.matrix=e.matrix.elements)),""!==e.name&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints?null!==(o=this.processMesh(e))&&(i.mesh=o):e.isCamera&&(i.camera=this.processCamera(e)),e.isSkinnedMesh&&this.skins.push(e),0<e.children.length){const t=[];for(let s=0,i=e.children.length;s<i;s++){var l=e.children[s];if(l.visible||!1===r.onlyVisible){const e=this.processNode(l);null!==e&&t.push(e)}}0<t.length&&(i.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,i)}));const h=t.nodes.push(i)-1;return s.set(e,h),h}processScene(e){const t=this.json;var r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={},i=(""!==e.name&&(s.name=e.name),t.scenes.push(s),[]);for(let t=0,s=e.children.length;t<s;t++){var n=e.children[t];!n.visible&&!1!==r.onlyVisible||null!==(n=this.processNode(n))&&i.push(n)}0<i.length&&(s.nodes=i),this.serializeUserData(e,s)}processObjects(e){const t=new s.Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){var t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const r=[];for(let t=0;t<e.length;t++)e[t]instanceof s.Scene?this.processScene(e[t]):r.push(e[t]);if(1===r.length){let[e]=r;if(!["Group","Object3D"].includes(e.type)){const t=new s.Group;t.name="glb_model",t.add(e),e=t}this.processScene(e)}else 1<r.length&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class us{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(e.isLight)if(e.isDirectionalLight||e.isPointLight||e.isSpotLight){var r=this.writer;const s=r.json,i=r.extensionsUsed,n={},a=(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]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0),s.extensions[this.name].lights);a.push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}else console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e)}}class ds{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(e.isMeshBasicMaterial){const e=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},e[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}}class ps{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(e.isGLTFSpecularGlossinessMaterial){const s=this.writer,i=s.extensionsUsed,n={};t.pbrMetallicRoughness.baseColorFactor&&(n.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);var r=[1,1,1];e.specular.toArray(r,0),n.specularFactor=r,n.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(n.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap&&(r={index:s.processTexture(e.specularMap)},s.applyTextureTransform(r,e.specularMap),n.specularGlossinessTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}}class ms{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial){const s=this.writer,i=s.extensionsUsed,n={};var r;n.clearcoatFactor=e.clearcoat,e.clearcoatMap&&(r={index:s.processTexture(e.clearcoatMap)},s.applyTextureTransform(r,e.clearcoatMap),n.clearcoatTexture=r),n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap&&(r={index:s.processTexture(e.clearcoatRoughnessMap)},s.applyTextureTransform(r,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=r),e.clearcoatNormalMap&&(r={index:s.processTexture(e.clearcoatNormalMap)},s.applyTextureTransform(r,e.clearcoatNormalMap),n.clearcoatNormalTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}}class fs{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial&&0!==e.transmission){const s=this.writer,i=s.extensionsUsed,n={};var r;n.transmissionFactor=e.transmission,e.transmissionMap&&(r={index:s.processTexture(e.transmissionMap)},s.applyTextureTransform(r,e.transmissionMap),n.transmissionTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}}class gs{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial&&0!==e.transmission){const s=this.writer,i=s.extensionsUsed,n={};var r;n.thicknessFactor=e.thickness,e.thicknessMap&&(r={index:s.processTexture(e.thicknessMap)},s.applyTextureTransform(r,e.thicknessMap),n.thicknessTexture=r),n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}}ts.Utils={insertKeyframe:function(e,t){var r=e.getValueSize();const s=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+r),n=e.createInterpolant(new e.ValueBufferType(r));let a;if(0===e.times.length){s[0]=t;for(let e=0;e<r;e++)i[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;s[0]=t,s.set(e.times,1),i.set(n.evaluate(t),0),i.set(e.values,r),a=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;s[s.length-1]=t,s.set(e.times,0),i.set(e.values,0),i.set(n.evaluate(t),e.values.length),a=s.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){s.set(e.times.slice(0,o+1),0),s[o+1]=t,s.set(e.times.slice(o+1),o+2),i.set(e.values.slice(0,(o+1)*r),0),i.set(n.evaluate(t),(o+1)*r),i.set(e.values.slice((o+1)*r),(o+2)*r),a=o+1;break}}return e.times=s,e.values=i,a},mergeMorphTargetTracks:function(e,t){const r=[],i={};var n=e.tracks;for(let e=0;e<n.length;++e){let u=n[e];var a=s.PropertyBinding.parseTrackName(u.name),o=s.PropertyBinding.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex)r.push(u);else{if(u.createInterpolant!==u.InterpolantFactoryMethodDiscrete&&u.createInterpolant!==u.InterpolantFactoryMethodLinear){if(u.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."),(u=u.clone()).setInterpolation(s.InterpolateLinear)}var l=o.morphTargetInfluences.length,h=o.morphTargetDictionary[a.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let e;if(void 0===i[o.uuid]){const t=new((e=u.clone()).ValueBufferType)(l*e.times.length);for(let r=0;r<e.times.length;r++)t[r*l+h]=e.values[r];e.name=(a.nodeName||"")+".morphTargetInfluences",e.values=t,i[o.uuid]=e,r.push(e)}else{const t=u.createInterpolant(new u.ValueBufferType(1));e=i[o.uuid];for(let r=0;r<e.times.length;r++)e.values[r*l+h]=t.evaluate(e.times[r]);for(let t=0;t<u.times.length;t++){var c=this.insertKeyframe(e,u.times[t]);e.values[c*l+h]=u.values[t]}}}}return e.tracks=r,e}};var vs=function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))};class ys{constructor(){this._gltf=new ts}getArrayBuffer(e=Sl.getClear(),t="scene"){return vs(this,void 0,void 0,(function*(){const r=new Kr(t),s=new es(t);var i=yield s.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:ml}})}))}))}export(e){return vs(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,W.downloadFile)(new Blob([t]),"scene.glb")}))}model(){return vs(this,void 0,void 0,(function*(){const e=Pl.select;var t;e&&(t=yield this.getArrayBuffer(e.clone(),"model"),(0,W.downloadFile)(new Blob([t]),"scene.glb"))}))}material(){}scene(){return vs(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,W.downloadFile)(new Blob([e]),"scene.glb")}))}}var xs={},ws=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},bs=function(e){return new Worker(e)};try{URL.revokeObjectURL(ws(""))}catch(Os){ws=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},bs=function(e){return new Worker(e,{type:"module"})}}for(var Ts,Ms=Uint8Array,_s=Uint16Array,Ss=Uint32Array,Ps=new Ms([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]),Cs=new Ms([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]),Rs=new Ms([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),As=(t=function(e,t){for(var r=new _s(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];var i=new Ss(r[30]);for(s=1;s<30;++s)for(var n=r[s];n<r[s+1];++n)i[n]=n-r[s]<<5|s;return[r,i]},(Ts=t(Ps,2))[0]),Es=Ts[1],Ds=(As[28]=258,Es[258]=28,Ts=t(Cs,0))[0],Ls=Ts[1],Is=new _s(32768),Os=0;Os<32768;++Os){var Us=(43690&Os)>>>1|(21845&Os)<<1;Is[Os]=((65280&(Us=(61680&(Us=(52428&Us)>>>2|(13107&Us)<<2))>>>4|(3855&Us)<<4))>>>8|(255&Us)<<8)>>>1}var ks=function(e,t,r){for(var s=e.length,i=0,n=new _s(t);i<s;++i)++n[e[i]-1];var a=new _s(t);for(i=0;i<t;++i)a[i]=a[i-1]+n[i-1]<<1;if(r){var o=new _s(1<<t),l=15-t;for(i=0;i<s;++i)if(e[i])for(var h=i<<4|e[i],c=t-e[i],u=a[e[i]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)o[Is[u]>>>l]=h}else for(o=new _s(s),i=0;i<s;++i)e[i]&&(o[i]=Is[a[e[i]-1]++]>>>15-e[i]);return o},Bs=new Ms(288);for(Os=0;Os<144;++Os)Bs[Os]=8;for(Os=144;Os<256;++Os)Bs[Os]=9;for(Os=256;Os<280;++Os)Bs[Os]=7;for(Os=280;Os<288;++Os)Bs[Os]=8;var Ns=new Ms(32);for(Os=0;Os<32;++Os)Ns[Os]=5;function Fs(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 zs(e,t,r,s,i){var n,a=gi(e,s,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(n)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,n=r],[e.buffer])},t.terminate=function(){a.terminate()}}function js(e,t){return Ci(e,t)+4294967296*Ci(e,t+4)}var Vs=ks(Bs,9,0),Hs=ks(Bs,9,1),Gs=ks(Ns,5,0),Ws=ks(Ns,5,1),Xs=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Ys=function(e,t,r){var s=t/8|0;return(e[s]|e[1+s]<<8)>>(7&t)&r},Zs=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},Qs=function(e){return(e/8|0)+(7&e&&1)},qs=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var s=new(e instanceof _s?_s:e instanceof Ss?Ss:Ms)(r-(t=null==t||t<0?0:t));return s.set(e.subarray(t,r)),s},Ks=function(e,t,r){var s=e.length;if(!s||r&&!r.l&&s<5)return t||new Ms(0);function i(e){var r=t.length;r<e&&((r=new Ms(Math.max(2*r,e))).set(t),t=r)}var n=!t||r,a=!r||r.i,o=(r=r||{},t=t||new Ms(3*s),r.f||0),l=r.p||0,h=r.b||0,c=r.l,u=r.d,d=r.m,p=r.n,m=8*s;do{if(!c){r.f=o=Ys(e,l,1);var f=Ys(e,l+1,3);if(l+=3,!f){var g=e[(S=Qs(l)+4)-4]|e[S-3]<<8;if(s<(T=S+g)){if(a)throw"unexpected EOF";break}n&&i(h+g),t.set(e.subarray(S,T),h),r.b=h+=g,r.p=l=8*T;continue}if(1==f)c=Hs,u=Ws,d=9,p=5;else{if(2!=f)throw"invalid block type";g=Ys(e,l,31)+257;for(var v=Ys(e,l+10,15)+4,y=g+Ys(e,l+5,31)+1,x=(l+=14,new Ms(y)),w=new Ms(19),b=0;b<v;++b)w[Rs[b]]=Ys(e,l+3*b,7);l+=3*v;var T,M=(1<<(T=Xs(w)))-1,_=ks(w,T,1);for(b=0;b<y;){var S,P=_[Ys(e,l,M)];if(l+=15&P,(S=P>>>4)<16)x[b++]=S;else{var C=0,R=0;for(16==S?(R=3+Ys(e,l,3),l+=2,C=x[b-1]):17==S?(R=3+Ys(e,l,7),l+=3):18==S&&(R=11+Ys(e,l,127),l+=7);R--;)x[b++]=C}}f=x.subarray(0,g);var A=x.subarray(g);d=Xs(f),p=Xs(A),c=ks(f,d,1),u=ks(A,p,1)}if(m<l){if(a)throw"unexpected EOF";break}}n&&i(h+131072);for(var E=(1<<d)-1,D=(1<<p)-1,L=l;;L=l){var I=(C=c[Zs(e,l)&E])>>>4;if(m<(l+=15&C)){if(a)throw"unexpected EOF";break}if(!C)throw"invalid length/literal";if(I<256)t[h++]=I;else{if(256==I){L=l,c=null;break}var O,U=I-254,k=(264<I&&(O=Ps[b=I-257],U=Ys(e,l,(1<<O)-1)+As[b],l+=O),(I=u[Zs(e,l)&D])>>>4);if(!I)throw"invalid distance";if(l+=15&I,A=Ds[k],3<k&&(O=Cs[k],A+=Zs(e,l)&(1<<O)-1,l+=O),m<l){if(a)throw"unexpected EOF";break}n&&i(h+131072);for(var B=h+U;h<B;h+=4)t[h]=t[h-A],t[h+1]=t[h+1-A],t[h+2]=t[h+2-A],t[h+3]=t[h+3-A];h=B}}r.l=c,r.p=L,r.b=h,c&&(o=1,r.m=d,r.d=u,r.n=p)}while(!o);return h==t.length?t:qs(t,0,h)},Js=function(e,t,r){var s=t/8|0;e[s]|=r<<=7&t,e[1+s]|=r>>>8},$s=function(e,t,r){var s=t/8|0;e[s]|=r<<=7&t,e[1+s]|=r>>>8,e[2+s]|=r>>>16},ei=function(e,t){for(var r=[],s=0;s<e.length;++s)e[s]&&r.push({s,f:e[s]});var i=r.length,n=r.slice();if(!i)return[oi,0];if(1==i)return(f=new Ms(r[0].s+1))[r[0].s]=1,[f,1];r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var a=r[0],o=r[1],l=0,h=1,c=2;for(r[0]={s:-1,f:a.f+o.f,l:a,r:o};h!=i-1;)a=r[r[l].f<r[c].f?l++:c++],o=r[l!=h&&r[l].f<r[c].f?l++:c++],r[h++]={s:-1,f:a.f+o.f,l:a,r:o};var u=n[0].s;for(s=1;s<i;++s)n[s].s>u&&(u=n[s].s);var d=new _s(u+1),p=ti(r[h-1],d,0);if(t<p){s=0;var m=0,f=p-t,g=1<<f;for(n.sort((function(e,t){return d[t.s]-d[e.s]||e.f-t.f}));s<i;++s){var v=n[s].s;if(!(d[v]>t))break;m+=g-(1<<p-d[v]),d[v]=t}for(m>>>=f;0<m;){var y=n[s].s;d[y]<t?m-=1<<t-d[y]++-1:++s}for(;0<=s&&m;--s){var x=n[s].s;d[x]==t&&(--d[x],++m)}p=t}return[new Ms(d),p]},ti=function(e,t,r){return-1==e.s?Math.max(ti(e.l,t,r+1),ti(e.r,t,r+1)):t[e.s]=r},ri=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new _s(++t),s=0,i=e[0],n=1,a=function(e){r[s++]=e},o=1;o<=t;++o)if(e[o]==i&&o!=t)++n;else{if(!i&&2<n){for(;138<n;n-=138)a(32754);2<n&&(a(10<n?n-11<<5|28690:n-3<<5|12305),n=0)}else if(3<n){for(a(i),--n;6<n;n-=6)a(8304);2<n&&(a(n-3<<5|8208),n=0)}for(;n--;)a(i);n=1,i=e[o]}return[r.subarray(0,s),t]},si=function(e,t){for(var r=0,s=0;s<t.length;++s)r+=e[s]*t[s];return r},ii=function(e,t,r){var s=r.length,i=Qs(t+2);e[i]=255&s,e[i+1]=s>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var n=0;n<s;++n)e[i+n+4]=r[n];return 8*(i+4+s)},ni=function(e,t,r,s,i,n,a,o,l,h,c){Js(t,c++,r),++i[256];for(var u=(r=ei(i,15))[0],d=(r=r[1],(p=ei(n,15))[0]),p=p[1],m=(f=ri(u))[0],f=f[1],g=(v=ri(d))[0],v=v[1],y=new _s(19),x=0;x<m.length;++x)y[31&m[x]]++;for(x=0;x<g.length;++x)y[31&g[x]]++;for(var w=(b=ei(y,7))[0],b=b[1],T=19;4<T&&!w[Rs[T-1]];--T);var M,_=h+5<<3,S=si(i,Bs)+si(n,Ns)+a;if(i=si(i,u)+si(n,d)+a+14+3*T+si(y,w)+(2*y[16]+3*y[17]+7*y[18]),_<=S&&_<=i)return ii(t,c,e.subarray(l,l+h));if(Js(t,c,1+(i<S)),c+=2,i<S){var P=ks(u,r,0),C=u,R=ks(d,p,0),A=d,E=ks(w,b,0);for(Js(t,c,f-257),Js(t,c+5,v-1),Js(t,c+10,T-4),c+=14,x=0;x<T;++x)Js(t,c+3*x,w[Rs[x]]);c+=3*T;for(var D=[m,g],L=0;L<2;++L){var I=D[L];for(x=0;x<I.length;++x){var O=31&I[x];Js(t,c,E[O]),c+=w[O],15<O&&(Js(t,c,I[x]>>>5&127),c+=I[x]>>>12)}}}else P=Vs,C=Bs,R=Gs,A=Ns;for(x=0;x<o;++x)255<s[x]?(O=s[x]>>>18&31,$s(t,c,P[O+257]),c+=C[O+257],7<O&&(Js(t,c,s[x]>>>23&31),c+=Ps[O]),M=31&s[x],$s(t,c,R[M]),c+=A[M],3<M&&($s(t,c,s[x]>>>5&8191),c+=Cs[M])):($s(t,c,P[s[x]]),c+=C[s[x]]);return $s(t,c,P[256]),c+C[256]},ai=new Ss([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),oi=new Ms(0),li=function(e,t,r,s,i,n){var a=e.length,o=new Ms(s+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(s,o.length-i),h=0;if(!t||a<8)for(var c=0;c<=a;c+=65535){var u=c+65535;h=u<a?ii(l,h,e.subarray(c,u)):(l[c]=n,ii(l,h,e.subarray(c,a)))}else{for(var d=(t=ai[t-1])>>>13,p=8191&t,m=(1<<r)-1,f=new _s(32768),g=new _s(1+m),v=Math.ceil(r/3),y=2*v,x=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&m},w=new Ss(25e3),b=new _s(288),T=new _s(32),M=0,_=0,S=(c=0,0),P=0,C=0;c<a;++c){var R=x(c),A=32767&c,E=g[R];if(f[A]=E,g[R]=A,P<=c){var D=a-c;if((7e3<M||24576<S)&&423<D){h=ni(e,l,0,w,b,T,_,S,C,c-C,h),S=M=_=0,C=c;for(var L=0;L<286;++L)b[L]=0;for(L=0;L<30;++L)T[L]=0}var I=2,O=0,U=p,k=A-E&32767;if(2<D&&R==x(c-k))for(var B=Math.min(d,D)-1,N=Math.min(32767,c),F=Math.min(258,D);k<=N&&--U&&A!=E;){if(e[c+I]==e[c+I-k]){for(var z=0;z<F&&e[c+z]==e[c+z-k];++z);if(I<z){if(O=k,B<(I=z))break;var j=Math.min(k,z-2),V=0;for(L=0;L<j;++L){var H=c-k+L+32768&32767,G=H-f[H]+32768&32767;V<G&&(V=G,E=H)}}}k+=(A=E)-(E=f[A])+32768&32767}O?(w[S++]=268435456|Es[I]<<18|Ls[O],R=31&Es[I],D=31&Ls[O],_+=Ps[R]+Cs[D],++b[257+R],++T[D],P=c+I,++M):(w[S++]=e[c],++b[e[c]])}}h=ni(e,l,n,w,b,T,_,S,C,c-C,h),!n&&7&h&&(h=ii(l,h+1,oi))}return qs(o,0,s+Qs(h)+i)},hi=function(){for(var e=new Ss(256),t=0;t<256;++t){for(var r=t,s=9;--s;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),ci=function(){var e=-1;return{p:function(t){for(var r=e,s=0;s<t.length;++s)r=hi[255&r^t[s]]^r>>>8;e=r},d:function(){return~e}}},ui=function(){var e=1,t=0;return{p:function(r){for(var s=e,i=t,n=r.length,a=0;a!=n;){for(var o=Math.min(a+2655,n);a<o;++a)i+=s+=r[a];s=(65535&s)+15*(s>>16),i=(65535&i)+15*(i>>16)}e=s,t=i},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},di=function(e,t,r,s,i){return li(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,s,!i)},pi=function(e,t){var r,s={};for(r in e)s[r]=e[r];for(r in t)s[r]=t[r];return s},mi=function(e,t,r){for(var s=e(),i=(e=e.toString()).slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/ /g,"").split(","),n=0;n<s.length;++n){var a=s[n],o=i[n];if("function"==typeof a){t+=";"+o+"=";var l=a.toString();if(a.prototype)if(-1!=l.indexOf("[native code]")){var h=l.indexOf(" ",8)+1;t+=l.slice(h,l.indexOf("(",h))}else for(var c in t+=l,a.prototype)t+=";"+o+".prototype."+c+"="+a.prototype[c].toString();else t+=l}else r[o]=a}return[t,r]},fi=[],gi=function(e,t,r,s){var i;if(!fi[r]){for(var n="",a={},o=e.length-1,l=0;l<o;++l)n=(i=mi(e[l],n,a))[0],a=i[1];fi[r]=mi(e[o],n,a)}var h=pi({},fi[r][1]);return function(e,t,r,s,i){return(t=bs(xs[t]||(xs[t]=ws(e)))).onerror=function(e){return i(e.error,null)},t.onmessage=function(e){return i(null,e.data)},t.postMessage(r,s),t}(fi[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,h,function(e){var t,r=[];for(t in e)(e[t]instanceof Ms||e[t]instanceof _s||e[t]instanceof Ss)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(h),s)},vi=function(){return[Ms,_s,Ss,Ps,Cs,Rs,As,Ds,Hs,Ws,Is,ks,Xs,Ys,Zs,Qs,qs,Ks,Hi,Mi,_i]},yi=function(){return[Ms,_s,Ss,Ps,Cs,Rs,Es,Ls,Vs,Bs,Gs,Ns,Is,ai,oi,ks,Js,$s,ei,ti,ri,si,ii,ni,Qs,qs,li,di,Fi,Mi]},xi=function(){return[Ai,Li,Ri,ci,hi]},wi=function(){return[Ei,Di]},bi=function(){return[Ii,Ri,ui]},Ti=function(){return[Oi]},Mi=function(e){return postMessage(e,[e.buffer])},_i=function(e){return e&&e.size&&new Ms(e.size)},Si=function(e,t,r,s,i,n){var a=gi(r,s,i,(function(e,t){a.terminate(),n(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},Pi=function(e,t){return e[t]|e[t+1]<<8},Ci=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ri=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},Ai=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&&Ri(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var s=0;s<=r.length;++s)e[s+10]=r.charCodeAt(s)}},Ei=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 s=(t>>3&1)+(t>>4&1);0<s;s-=!e[r++]);return r+(2&t)},Di=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Li=function(e){return 10+(e.filename&&e.filename.length+1||0)},Ii=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)},Oi=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 Ui(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var ki=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(di(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}(),Bi=function(e,t){zs([yi,function(){return[Fs,ki]}],this,Ui.call(this,e,t),(function(e){e=new ki(e.data),onmessage=Fs(e)}),6)};function Ni(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[yi],(function(e){return Mi(Fi(e.data[0],e.data[1]))}),0,r)}function Fi(e,t){return di(e,t||{},0,0)}var zi=function(){function e(e){this.s={},this.p=new Ms(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 Ms(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=Ks(this.p,this.o,this.s);this.ondata(qs(t,e,this.s.b),this.d),this.o=qs(t,this.s.b-32768),this.s.b=this.o.length,this.p=qs(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ji=function(e){this.ondata=e,zs([vi,function(){return[Fs,zi]}],this,0,(function(){var e=new zi;onmessage=Fs(e)}),7)};function Vi(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[vi],(function(e){return Mi(Hi(e.data[0],_i(e.data[1])))}),1,r)}function Hi(e,t){return Ks(e,t)}var Gi=function(){function e(e,t){this.c=ci(),this.l=0,this.v=1,ki.call(this,e,t)}return e.prototype.push=function(e,t){ki.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=di(e,this.o,this.v&&Li(this.o),t&&8,!t),this.v&&(Ai(e,this.o),this.v=0),t&&(Ri(e,e.length-8,this.c.d()),Ri(e,e.length-4,this.l)),this.ondata(e,t)},e}(),Wi=function(e,t){zs([yi,xi,function(){return[Fs,ki,Gi]}],this,Ui.call(this,e,t),(function(e){e=new Gi(e.data),onmessage=Fs(e)}),8)};function Xi(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[yi,xi,function(){return[Yi]}],(function(e){return Mi(Yi(e.data[0],e.data[1]))}),2,r)}function Yi(e,t){t=t||{};var r=ci(),s=e.length,i=(r.p(e),e=di(e,t,Li(t),8)).length;return Ai(e,t),Ri(e,i-8,r.d()),Ri(e,i-4,s),e}var Zi=function(){function e(e){this.v=1,zi.call(this,e)}return e.prototype.push=function(e,t){if(zi.prototype.e.call(this,e),this.v){if((e=3<this.p.length?Ei(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)}zi.prototype.c.call(this,t)},e}(),Qi=function(e){this.ondata=e,zs([vi,wi,function(){return[Fs,zi,Zi]}],this,0,(function(){var e=new Zi;onmessage=Fs(e)}),9)};function qi(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[vi,wi,function(){return[Ki]}],(function(e){return Mi(Ki(e.data[0]))}),3,r)}function Ki(e,t){return Ks(e.subarray(Ei(e),-8),t||new Ms(Di(e)))}var Ji=function(){function e(e,t){this.c=ui(),this.v=1,ki.call(this,e,t)}return e.prototype.push=function(e,t){ki.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=di(e,this.o,this.v&&2,t&&4,!t),this.v&&(Ii(e,this.o),this.v=0),t&&Ri(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),$i=function(e,t){zs([yi,bi,function(){return[Fs,ki,Ji]}],this,Ui.call(this,e,t),(function(e){e=new Ji(e.data),onmessage=Fs(e)}),10)};function en(e,t){t=t||{};var r=ui();return r.p(e),e=di(e,t,2,4),Ii(e,t),Ri(e,e.length-4,r.d()),e}var tn=function(){function e(e){this.v=1,zi.call(this,e)}return e.prototype.push=function(e,t){if(zi.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)}zi.prototype.c.call(this,t)},e}(),rn=function(e){this.ondata=e,zs([vi,Ti,function(){return[Fs,zi,tn]}],this,0,(function(){var e=new tn;onmessage=Fs(e)}),11)};function sn(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return Si(e,t,[vi,Ti,function(){return[nn]}],(function(e){return Mi(nn(e.data[0],_i(e.data[1])))}),5,r)}function nn(e,t){return Ks((Oi(e),e.subarray(2,-4)),t)}var an=function(){function e(e){this.G=Zi,this.I=zi,this.Z=tn,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";var r,s;this.s?this.s.push(e,t):(this.p&&this.p.length?((r=new Ms(this.p.length+e.length)).set(this.p),r.set(e,this.p.length)):this.p=e,2<this.p.length&&((s=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(){s.ondata.apply(s,arguments)})),this.s.push(this.p,t),this.p=null))},e}(),on=function(){function e(e){this.G=Qi,this.I=ji,this.Z=rn,this.ondata=e}return e.prototype.push=function(e,t){an.prototype.push.call(this,e,t)},e}(),ln=function(e,t,r,s){for(var i in e){var n=e[i];i=t+i,n instanceof Ms?r[i]=[n,s]:Array.isArray(n)?r[i]=[n[0],pi(s,n[1])]:ln(n,i+"/",r,s)}},hn="undefined"!=typeof TextEncoder&&new TextEncoder,cn="undefined"!=typeof TextDecoder&&new TextDecoder,un=0;try{cn.decode(oi,{stream:!0}),un=1}catch(Os){}var dn=function(e){for(var t="",r=0;;){var s=e[r++],i=(127<s)+(223<s)+(239<s);if(r+i>e.length)return[t,qs(e,r-1)];i?3==i?(s=((15&s)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|s>>10,56320|1023&s)):t+=1&i?String.fromCharCode((31&s)<<6|63&e[r++]):String.fromCharCode((15&s)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(s)}},pn=function(){function e(e){this.ondata=e,un?this.t=new TextDecoder:this.p=oi}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 Ms(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=dn(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}(),mn=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(fn(e),this.d=t||!1)},e}();function fn(e,t){if(t){for(var r=new Ms(e.length),s=0;s<e.length;++s)r[s]=e.charCodeAt(s);return r}if(hn)return hn.encode(e);var i=e.length,n=new Ms(e.length+(e.length>>1)),a=0,o=function(e){n[a++]=e};for(s=0;s<i;++s){a+5>n.length&&((l=new Ms(a+8+(i-s<<1))).set(n),n=l);var l=e.charCodeAt(s);l<128||t?o(l):(l<2048?o(192|l>>6):(55295<l&&l<57344?(o(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++s))>>18),o(128|l>>12&63)):o(224|l>>12),o(128|l>>6&63)),o(128|63&l))}return qs(n,0,a)}function gn(e,t){if(t){for(var r="",s=0;s<e.length;s+=16384)r+=String.fromCharCode.apply(null,e.subarray(s,s+16384));return r}if(cn)return cn.decode(e);var i=(t=dn(e))[0];if(t[1].length)throw"invalid utf-8 data";return i}function vn(e){return 1==e?3:e<6?2:9==e?1:0}var yn=function(e,t){return t+30+Pi(e,t+26)+Pi(e,t+28)},xn=function(e,t,r){var s=Pi(e,t+28),i=gn(e.subarray(t+46,t+46+s),!(2048&Pi(e,t+8))),n=(s=t+46+s,Ci(e,t+20)),a=(n=(r=r&&4294967295==n?wn(e,s):[n,Ci(e,t+24),Ci(e,t+42)])[0],r[1]);return r=r[2],[Pi(e,t+10),n,a,i,s+Pi(e,t+30)+Pi(e,t+32),r]},wn=function(e,t){for(;1!=Pi(e,t);t+=4+Pi(e,t+2));return[js(e,t+12),js(e,t+4),js(e,t+20)]},bn=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},Tn=function(e,t,r,s,i,n,a,o){var l=s.length,h=r.extra,c=o&&o.length,u=bn(h),d=(Ri(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==n&&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(d<0||119<d)throw"date not in range 1980-2099";if(Ri(e,t,d<<25|i.getMonth()+1<<21|i.getDate()<<16|i.getHours()<<11|i.getMinutes()<<5|i.getSeconds()>>>1),t+=4,null!=n&&(Ri(e,t,r.crc),Ri(e,t+4,n),Ri(e,t+8,r.size)),Ri(e,t+12,l),Ri(e,t+14,u),t+=16,null!=a&&(Ri(e,t,c),Ri(e,t+6,r.attrs),Ri(e,t+10,a),t+=14),e.set(s,t),t+=l,u)for(var p in h){var m=h[p],f=m.length;Ri(e,t,+p),Ri(e,t+2,f),e.set(m,t+4),t+=4+f}return c&&(e.set(o,t),t+=c),t},Mn=function(e,t,r,s,i){Ri(e,t,101010256),Ri(e,t+8,r),Ri(e,t+10,r),Ri(e,t+12,s),Ri(e,t+16,i)},_n=function(){function e(e){this.filename=e,this.c=ci(),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}(),Sn=function(){function e(e,t){var r=this;t=t||{},_n.call(this,e),this.d=new ki(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=vn(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){_n.prototype.push.call(this,e,t)},e}(),Pn=function(){function e(e,t){var r=this;t=t||{},_n.call(this,e),this.d=new Bi(t,(function(e,t,s){r.ondata(e,t,s)})),this.compression=8,this.flag=vn(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){_n.prototype.push.call(this,e,t)},e}(),Cn=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=fn(e.filename),s=r.length,i=(n=e.comment)&&fn(n),n=s!=e.filename.length||i&&n.length!=i.length,a=s+bn(e.extra)+30;if(65535<s)throw"filename too long";function o(){for(var e=0,r=l;e<r.length;e++){var s=r[e];t.ondata(null,s,!1)}l=[]}s=new Ms(a);var l=(Tn(s,0,e,r,n),[s]),h=this.d,c=(this.d=0,this.u.length),u=pi(e,{f:r,u:n,o:i,t:function(){e.terminate&&e.terminate()},r:function(){var e;o(),h&&((e=t.u[c+1])?e.r():t.d=1),h=1}}),d=0;e.ondata=function(r,s,i){r?(t.ondata(r,s,i),t.terminate()):(d+=s.length,l.push(s),i?(r=new Ms(16),Ri(r,0,134695760),Ri(r,4,e.crc),Ri(r,8,d),Ri(r,12,e.size),l.push(r),u.c=d,u.b=a+d+16,u.crc=e.crc,u.size=e.size,h&&u.r(),h=1):h&&o())},this.u.push(u)},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,s=0,i=this.u;s<i.length;s++)r+=46+(l=i[s]).f.length+bn(l.extra)+(l.o?l.o.length:0);for(var n=new Ms(r+22),a=0,o=this.u;a<o.length;a++){var l=o[a];Tn(n,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+bn(l.extra)+(l.o?l.o.length:0),t+=l.b}Mn(n,e,this.u.length,r,t),this.ondata(null,n,!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}(),Rn=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),An=function(){function e(){var e=this;this.i=new zi((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}(),En=function(){function e(e,t){var r=this;t<32e4?this.i=new zi((function(e,t){r.ondata(null,e,t)})):(this.i=new ji((function(e,t,s){r.ondata(e,t,s)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=qs(e,0)),this.i.push(e,t)},e.compression=8,e}(),Dn=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Rn},this.p=oi}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 s=Math.min(this.c,e.length),i=e.subarray(0,s);if(this.c-=s,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(s)).length)return this.push(e,t)}else{for(var n=0,a=0,o=void 0,l=void 0,h=(this.p.length?e.length?((l=new Ms(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e,l.length),c=this.c,u=(i=c&&this.d,this);a<h-4&&"break"!==function(){var e,t,s,i,d,p,m,f,g,v,y,x=Ci(l,a);return 67324752==x?(n=1,o=a,u.d=null,u.c=0,s=Pi(l,a+6),e=Pi(l,a+8),t=2048&s,s&=8,i=Pi(l,a+26),d=Pi(l,a+28),a+30+i+d<h&&(u.k.unshift(p=[]),n=2,m=Ci(l,a+18),f=Ci(l,a+22),g=gn(l.subarray(a+30,a+=30+i),!t),4294967295==m?(i=s?[-2]:wn(l,a),m=i[0],f=i[1]):s&&(m=-1),a+=d,u.c=m,y={name:g,compression:e,start:function(){if(!y.ondata)throw"no callback";if(m){var t=r.o[e];if(!t)throw"unknown compression type "+e;(v=m<0?new t(g):new t(g,m,f)).ondata=function(e,t,r){y.ondata(e,t,r)};for(var s=0,i=p;s<i.length;s++)v.push(i[s],!1);r.k[0]==p&&r.c?r.d=v:v.push(oi,!0)}else y.ondata(null,oi,!0)},terminate:function(){v&&v.terminate&&v.terminate()}},0<=m&&(y.size=m,y.originalSize=f),u.onfile(y)),"break"):c?134695760==x?(o=a+=12+(-2==c&&8),n=3,u.c=0,"break"):33639248==x?(o=a-=4,n=3,u.c=0,"break"):void 0:void 0}();++a);if(this.p=oi,c<0&&(s=n?l.subarray(0,o-12-(-2==c&&8)-(134695760==Ci(l,o-16)&&4)):l.subarray(0,a),i?i.push(s,!!n):this.k[+(2==n)].push(s)),2&n)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 Ln(e,t,r){var s=r.length-e-1;if(t>=r[s])return s-1;if(t<=r[e])return e;let i=e,n=s,a=Math.floor((i+n)/2);for(;t<r[a]||t>=r[a+1];)t<r[a]?n=a:i=a,a=Math.floor((i+n)/2);return a}class In extends s.Curve{constructor(e,t,r,i,n){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=n||this.knots.length-1;for(let e=0;e<r.length;++e){var a=r[e];this.controlPoints[e]=new s.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t=new s.Vector3){const r=t;t=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]);const i=function(e,t,r,i){var n=Ln(e,i,t),a=function(e,t,r,s){const i=[],n=[],a=[];for(let c=i[0]=1;c<=r;++c){n[c]=t-s[e+1-c],a[c]=s[e+c]-t;let r=0;for(let e=0;e<c;++e){var o=a[e+1],l=n[c-e],h=i[e]/(o+l);i[e]=r+o*h,r=l*h}i[c]=r}return i}(n,i,e,t);const o=new s.Vector4(0,0,0,0);for(let t=0;t<=e;++t){var l=r[n-e+t],h=a[t],c=l.w*h;o.x+=l.x*c,o.y+=l.y*c,o.z+=l.z*c,o.w+=l.w*h}return o}(this.degree,this.knots,this.controlPoints,t);return 1!==i.w&&i.divideScalar(i.w),r.set(i.x,i.y,i.z)}getTangent(e,t=new s.Vector3){const r=t;return t=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),e=function(e){var t=e.length;const r=[],i=[];for(let a=0;a<t;++a){var n=e[a];r[a]=new s.Vector3(n.x,n.y,n.z),i[a]=n.w}const a=[];for(let e=0;e<t;++e){const t=r[e].clone();for(let r=1;r<=e;++r)t.sub(a[e-r].clone().multiplyScalar(function(e,t){let r=1;for(let t=2;t<=e;++t)r*=t;let s=1;for(let e=2;e<=t;++e)s*=e;for(let r=2;r<=e-t;++r)s*=r;return r/s}(e,r)*i[r]));a[e]=t.divideScalar(i[0])}return a}(function(e,t,r,i,n){var a=1<e?1:e;const o=[];var l=Ln(e,i,t),h=function(e,t,r,s,i){const n=[];for(let e=0;e<=r;++e)n[e]=0;const a=[];for(let e=0;e<=s;++e)a[e]=n.slice(0);const o=[];for(let e=0;e<=r;++e)o[e]=n.slice(0);o[0][0]=1;const l=n.slice(0),h=n.slice(0);for(let s=1;s<=r;++s){l[s]=t-i[e+1-s],h[s]=i[e+s]-t;let r=0;for(let e=0;e<s;++e){var c=h[e+1],u=l[s-e],d=(o[s][e]=c+u,o[e][s-1]/o[s][e]);o[e][s]=r+c*d,r=u*d}o[s][s]=r}for(let e=0;e<=r;++e)a[0][e]=o[e][r];for(let e=0;e<=r;++e){let t=0,i=1;const l=[];for(let e=0;e<=r;++e)l[e]=n.slice(0);for(let n=l[0][0]=1;n<=s;++n){let s=0;var p=e-n,m=r-n,f=(e>=n&&(l[i][0]=l[t][0]/o[1+m][p],s=l[i][0]*o[p][m]),-1<=p?1:-p),g=e-1<=m?n-1:r-e;for(let e=f;e<=g;++e)l[i][e]=(l[t][e]-l[t][e-1])/o[1+m][p+e],s+=l[i][e]*o[p+e][m];e<=m&&(l[i][n]=-l[t][n-1]/o[1+m][e],s+=l[i][n]*o[e][m]),a[n][e]=s,f=t,t=i,i=f}}let v=r;for(let e=1;e<=s;++e){for(let t=0;t<=r;++t)a[e][t]*=v;v*=r-e}return a}(l,i,e,a,t);const c=[];for(let e=0;e<r.length;++e){const t=r[e].clone();var u=t.w;t.x*=u,t.y*=u,t.z*=u,c[e]=t}for(let t=0;t<=a;++t){const r=c[l-e].clone().multiplyScalar(h[t][0]);for(let s=1;s<=e;++s)r.add(c[l-e+s].clone().multiplyScalar(h[t][s]));o[t]=r}for(let e=a+1;e<=2;++e)o[e]=new s.Vector4(0,0,0);return o}(e=this.degree,this.knots,this.controlPoints,t)),r.copy(e[1]).normalize(),r}}let On,Un,kn;class Bn extends s.Loader{constructor(e){super(e)}load(e,t,r,i){const n=this,a=""===n.path?s.LoaderUtils.extractUrlBase(e):n.path,o=new s.FileLoader(this.manager);o.setPath(n.path),o.setResponseType("arraybuffer"),o.setRequestHeader(n.requestHeader),o.setWithCredentials(n.withCredentials),o.load(e,(function(r){try{t(n.parse(r,a))}catch(r){i?i(r):console.error(r),n.manager.itemError(e)}}),r,i)}parse(e,t){if(i="Kaydara FBX Binary \0",(r=e).byteLength>=i.length&&i===ea(r,0,i.length))On=(new Vn).parse(e);else{if(!function(e){var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let r=0;for(let s=0;s<t.length;++s)if(function(t){var s=e[0];return e=e.slice(r+1),r++,s}()===t[s])return;return 1}(r=ea(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(Wn(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Wn(r));On=(new jn).parse(r)}var r,i=new s.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Nn(i,this.manager).parse(On)}}class Nn{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Un=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new Fn).parse(t);return this.parseScene(t,r,e),kn}parseConnections(){const e=new Map;return"Connections"in On&&On.Connections.connections.forEach((function(t){var r=t[0],s=t[1],i=(t=t[2],e.has(r)||e.set(r,{parents:[],children:[]}),{ID:s,relationship:t});e.get(r).parents.push(i),e.has(s)||e.set(s,{parents:[],children:[]}),i={ID:r,relationship:t},e.get(s).children.push(i)})),e}parseImages(){const e={},t={};if("Video"in On.Objects){var r=On.Objects.Video;for(const a in r){var s,i=r[a],n=parseInt(a);e[n]=i.RelativeFilename||i.Filename,"Content"in i&&(n=i.Content instanceof ArrayBuffer&&0<i.Content.byteLength,s="string"==typeof i.Content&&""!==i.Content,(n||s)&&(n=this.parseImage(r[a]),t[i.RelativeFilename||i.Filename]=n))}}for(const r in e){var a=e[r];void 0!==t[a]?e[r]=t[a]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){var t=e.Content;const r=e.RelativeFilename||e.Filename;var s=r.slice(r.lastIndexOf(".")+1).toLowerCase();let i;switch(s){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",r),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+s+'" is not supported.')}return"string"==typeof t?"data:"+i+";base64,"+t:(e=new Uint8Array(t),window.URL.createObjectURL(new Blob([e],{type:i})))}parseTextures(e){const t=new Map;if("Texture"in On.Objects){var r=On.Objects.Texture;for(const i in r){var s=this.parseTexture(r[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName,t=e.WrapModeU;var i=e.WrapModeV;return t=void 0!==t?t.value:0,i=void 0!==i?i.value:0,r.wrapS=0===t?s.RepeatWrapping:s.ClampToEdgeWrapping,r.wrapT=0===i?s.RepeatWrapping:s.ClampToEdgeWrapping,"Scaling"in e&&(t=e.Scaling.value,r.repeat.x=t[0],r.repeat.y=t[1]),"Translation"in e&&(i=e.Translation.value,r.offset.x=i[0],r.offset.y=i[1]),r}loadTexture(e,t){let r;var i=this.textureLoader.path,n=Un.get(e.id).children;let a;if(void 0!==n&&0<n.length&&void 0!==t[n[0].ID]&&(0!==(r=t[n[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0)),"tga"===(t=e.FileName.slice(-3).toLowerCase())){const t=this.manager.getHandler(".tga");a=null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),new s.Texture):(t.setPath(this.textureLoader.path),t.load(r))}else a="psd"===t?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),new s.Texture):this.textureLoader.load(r);return this.textureLoader.setPath(i),a}parseMaterials(e){const t=new Map;if("Material"in On.Objects){var r=On.Objects.Material;for(const i in r){var s=this.parseMaterial(r[i],e);null!==s&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){var r=e.id,i=e.attrName;let n,a=e.ShadingModel;if("object"==typeof a&&(a=a.value),!Un.has(r))return null;switch(e=this.parseParameters(e,t,r),a.toLowerCase()){case"phong":n=new s.MeshPhongMaterial;break;case"lambert":n=new s.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),n=new s.MeshPhongMaterial}return n.setValues(e),n.name=i,n}parseParameters(e,t,r){const i={},n=(e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new s.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new s.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new s.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new s.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new s.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new s.Color).fromArray(e.SpecularColor.value)),this);return Un.get(r).children.forEach((function(e){var r=e.relationship;switch(r){case"Bump":i.bumpMap=n.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=n.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=n.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=s.sRGBEncoding);break;case"DisplacementColor":i.displacementMap=n.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=n.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=s.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=n.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=n.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=s.EquirectangularReflectionMapping,i.envMap.encoding=s.sRGBEncoding);break;case"SpecularColor":i.specularMap=n.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=s.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=n.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}})),i}getTexture(e,t){return"LayeredTexture"in On.Objects&&t in On.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Un.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in On.Objects){var r=On.Objects.Deformer;for(const n in r){var s=r[n],i=Un.get(parseInt(n));if("Skin"===s.attrType){const t=this.parseSkeleton(i,r);t.ID=n,1<i.parents.length&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=i.parents[0].ID,e[n]=t}else if("BlendShape"===s.attrType){const e={id:n};e.rawTargets=this.parseMorphTargets(i,r),e.id=n,1<i.parents.length&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach((function(e){var i=t[e.ID];if("Cluster"===i.attrType){const t={ID:e.ID,indices:[],weights:[],transformLink:(new s.Matrix4).fromArray(i.TransformLink.a)};"Indexes"in i&&(t.indices=i.Indexes.a,t.weights=i.Weights.a),r.push(t)}})),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let n=0;n<e.children.length;n++){var s=e.children[n],i=t[s.ID];const a={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if("BlendShapeChannel"!==i.attrType)return;a.geoID=Un.get(parseInt(s.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,r.push(a)}return r}parseScene(e,t,r){kn=new s.Group;const i=this.parseModels(e.skeletons,t,r),n=On.Objects.Model,a=this;i.forEach((function(e){var t=n[e.ID];a.setLookAtProperties(e,t),Un.get(e.ID).parents.forEach((function(t){const r=i.get(t.ID);void 0!==r&&r.add(e)})),null===e.parent&&kn.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),kn.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=Kn(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new zn).parse(),1===kn.children.length&&kn.children[0].isGroup&&(kn.children[0].animations=r,kn=kn.children[0]),kn.animations=r}parseModels(e,t,r){const i=new Map;var n=On.Objects.Model;for(const h in n){var a=parseInt(h),o=n[h],l=Un.get(a);let c=this.buildSkeleton(l,e,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,r);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new s.Bone;break;default:c=new s.Group}c.name=o.attrName?s.PropertyBinding.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),i.set(a,c)}return i}buildSkeleton(e,t,r,i){let n=null;return e.parents.forEach((function(e){for(const a in t){const o=t[a];o.rawBones.forEach((function(t,a){var l;t.ID===e.ID&&(l=n,(n=new s.Bone).matrixWorld.copy(t.transformLink),n.name=i?s.PropertyBinding.sanitizeNodeName(i):"",n.ID=r,o.bones[a]=n,null!==l&&n.add(l))}))}})),n}createCamera(e){let t,r;if(e.children.forEach((function(e){void 0!==(e=On.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new s.Object3D;else{let e=0,a=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(e=1),1),o=(void 0!==r.NearPlane&&(a=r.NearPlane.value/1e3),1e3),l=(void 0!==r.FarPlane&&(o=r.FarPlane.value/1e3),window.innerWidth),h=window.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(l=r.AspectWidth.value,h=r.AspectHeight.value);var i=l/h;let c=45;void 0!==r.FieldOfView&&(c=r.FieldOfView.value);var n=r.FocalLength?r.FocalLength.value:null;switch(e){case 0:t=new s.PerspectiveCamera(c,i,a,o),null!==n&&t.setFocalLength(n);break;case 1:t=new s.OrthographicCamera(-l/2,l/2,h/2,-h/2,a,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new s.Object3D}}return t}createLight(e){let t,r;if(e.children.forEach((function(e){void 0!==(e=On.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new s.Object3D;else{let e,i=(e=void 0===r.LightType?0:r.LightType.value,16777215),n=(void 0!==r.Color&&(i=(new s.Color).fromArray(r.Color.value)),void 0===r.Intensity?1:r.Intensity.value/100),a=(void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(n=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 s.PointLight(i,n,a,1);break;case 1:t=new s.DirectionalLight(i,n);break;case 2:let e=Math.PI/3,o=(void 0!==r.InnerAngle&&(e=s.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(o=s.MathUtils.degToRad(r.OuterAngle.value),o=Math.max(o,1)),t=new s.SpotLight(i,n,a,e,o,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new s.PointLight(i,n)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,r){let i,n=null,a=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(n=t.get(e.ID)),r.has(e.ID)&&o.push(r.get(e.ID))})),1<o.length?a=o:0<o.length?a=o[0]:(a=new s.MeshPhongMaterial({color:13421772}),o.push(a)),"color"in n.attributes&&o.forEach((function(e){e.vertexColors=!0})),n.FBX_Deformer?(i=new s.SkinnedMesh(n,a)).normalizeSkinWeights():i=new s.Mesh(n,a),i}createCurve(e,t){e=e.children.reduce((function(e,r){return t.has(r.ID)?t.get(r.ID):e}),null);var r=new s.LineBasicMaterial({color:3342591,linewidth:1});return new s.Line(e,r)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?Jn(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}setLookAtProperties(e,t){"LookAtProperty"in t&&Un.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=On.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),kn.add(e.target)):e.lookAt((new s.Vector3).fromArray(t)))}))}bindSkeleton(e,t,r){const i=this.parsePoseNodes();for(const n in e){const a=e[n];Un.get(parseInt(a.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,Un.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new s.Skeleton(a.bones),i[e.ID])})))}))}}parsePoseNodes(){const e={};if("Pose"in On.Objects){var t=On.Objects.Pose;for(const r in t)if("BindPose"===t[r].attrType&&0<t[r].NbPoseNodes){const i=t[r].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new s.Matrix4).fromArray(t.Matrix.a)})):e[i.Node]=(new s.Matrix4).fromArray(i.Matrix.a)}}return e}createAmbientLight(){var e,t,r;"GlobalSettings"in On&&"AmbientColor"in On.GlobalSettings&&(r=(t=On.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new s.Color(r,e,t),kn.add(new s.AmbientLight(r,1))))}}class Fn{parse(e){const t=new Map;if("Geometry"in On.Objects){var r=On.Objects.Geometry;for(const i in r){var s=Un.get(parseInt(i));s=this.parseGeometry(s,r[i],e),t.set(parseInt(i),s)}}return t}parseGeometry(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const s=r.skeletons,i=[];var n=e.parents.map((function(e){return On.Objects.Model[e.ID]}));if(0!==n.length){var a=e.children.reduce((function(e,t){return void 0!==s[t.ID]?s[t.ID]:e}),null);const o={};return"RotationOrder"in(e.children.forEach((function(e){void 0!==r.morphTargets[e.ID]&&i.push(r.morphTargets[e.ID])})),e=n[0])&&(o.eulerOrder=Jn(e.RotationOrder.value)),"InheritType"in e&&(o.inheritType=parseInt(e.InheritType.value)),"GeometricTranslation"in e&&(o.translation=e.GeometricTranslation.value),"GeometricRotation"in e&&(o.rotation=e.GeometricRotation.value),"GeometricScaling"in e&&(o.scale=e.GeometricScaling.value),n=Kn(o),this.genGeometry(t,a,i,n)}}genGeometry(e,t,r,i){const n=new s.BufferGeometry;e.attrName&&(n.name=e.attrName);var a=this.parseGeoNode(e,t);const o=this.genBuffers(a),l=new s.Float32BufferAttribute(o.vertex,3);if(l.applyMatrix4(i),n.setAttribute("position",l),0<o.colors.length&&n.setAttribute("color",new s.Float32BufferAttribute(o.colors,3)),t&&(n.setAttribute("skinIndex",new s.Uint16BufferAttribute(o.weightsIndices,4)),n.setAttribute("skinWeight",new s.Float32BufferAttribute(o.vertexWeights,4)),n.FBX_Deformer=t),0<o.normal.length){t=(new s.Matrix3).getNormalMatrix(i);const e=new s.Float32BufferAttribute(o.normal,3);e.applyNormalMatrix(t),n.setAttribute("normal",e)}if(o.uvs.forEach((function(e,t){let r="uv"+(t+1).toString();0===t&&(r="uv"),n.setAttribute(r,new s.Float32BufferAttribute(o.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=o.materialIndex[0],r=0;o.materialIndex.forEach((function(t,s){t!==e&&(n.addGroup(r,s-r,e),e=t,r=s)})),0<n.groups.length&&(a=(t=n.groups[n.groups.length-1]).start+t.count)!==o.materialIndex.length&&n.addGroup(a,o.materialIndex.length-a,e),0===n.groups.length&&n.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(n,e,r,i),n}parseGeoNode(e,t){const 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=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return r.weightTable={},null!==t&&(r.skeleton=t).rawBones.forEach((function(e,t){e.indices.forEach((function(s,i){void 0===r.weightTable[s]&&(r.weightTable[s]=[]),r.weightTable[s].push({id:t,weight:e.weights[i]})}))})),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,s=0,i=!1,n=[],a=[],o=[],l=[],h=[],c=[];const u=this;return e.vertexIndices.forEach((function(d,p){let m,f=!1,g=(d<0&&(d^=-1,f=!0),[]),v=[];var y;if(n.push(3*d,3*d+1,3*d+2),e.color&&(y=Zn(p,r,d,e.color),o.push(y[0],y[1],y[2])),e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),4<v.length){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(r,s){let i=r,n=g[s];t.forEach((function(t,r,s){i>t&&(s[r]=i,i=t,s=e[r],e[r]=n,n=s)}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}e.normal&&(y=Zn(p,r,d,e.normal),a.push(y[0],y[1],y[2])),e.material&&"AllSame"!==e.material.mappingType&&(m=Zn(p,r,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=Zn(p,r,d,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),s++,f&&(u.genFace(t,e,n,m,a,o,l,h,c,s),r++,s=0,n=[],a=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,r,s,i,n,a,o,l,h){for(let c=2;c<h;c++)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*(c-1)]]),e.vertex.push(t.vertexPositions[r[3*(c-1)+1]]),e.vertex.push(t.vertexPositions[r[3*(c-1)+2]]),e.vertex.push(t.vertexPositions[r[3*c]]),e.vertex.push(t.vertexPositions[r[3*c+1]]),e.vertex.push(t.vertexPositions[r[3*c+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(c-1)]),e.vertexWeights.push(o[4*(c-1)+1]),e.vertexWeights.push(o[4*(c-1)+2]),e.vertexWeights.push(o[4*(c-1)+3]),e.vertexWeights.push(o[4*c]),e.vertexWeights.push(o[4*c+1]),e.vertexWeights.push(o[4*c+2]),e.vertexWeights.push(o[4*c+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*(c-1)]),e.weightsIndices.push(l[4*(c-1)+1]),e.weightsIndices.push(l[4*(c-1)+2]),e.weightsIndices.push(l[4*(c-1)+3]),e.weightsIndices.push(l[4*c]),e.weightsIndices.push(l[4*c+1]),e.weightsIndices.push(l[4*c+2]),e.weightsIndices.push(l[4*c+3])),t.color&&(e.colors.push(n[0]),e.colors.push(n[1]),e.colors.push(n[2]),e.colors.push(n[3*(c-1)]),e.colors.push(n[3*(c-1)+1]),e.colors.push(n[3*(c-1)+2]),e.colors.push(n[3*c]),e.colors.push(n[3*c+1]),e.colors.push(n[3*c+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(c-1)]),e.normal.push(i[3*(c-1)+1]),e.normal.push(i[3*(c-1)+2]),e.normal.push(i[3*c]),e.normal.push(i[3*c+1]),e.normal.push(i[3*c+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*(c-1)]),e.uvs[r].push(a[r][2*(c-1)+1]),e.uvs[r].push(a[r][2*c]),e.uvs[r].push(a[r][2*c+1])}))}addMorphTargets(e,t,r,s){if(0!==r.length){e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;r.forEach((function(r){r.rawTargets.forEach((function(r){var n=On.Objects.Geometry[r.geoID];void 0!==n&&i.genMorphGeometry(e,t,n,s,r.name)}))}))}}genMorphGeometry(e,t,r,i,n){t=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[];var a=void 0!==r.Vertices?r.Vertices.a:[],o=void 0!==r.Indexes?r.Indexes.a:[],l=3*e.attributes.position.count;const h=new Float32Array(l);for(let e=0;e<o.length;e++){var c=3*o[e];h[c]=a[3*e],h[1+c]=a[3*e+1],h[2+c]=a[3*e+2]}l={vertexIndices:t,vertexPositions:h},t=this.genBuffers(l);const u=new s.Float32BufferAttribute(t.vertex,3);u.name=n||r.attrName,u.applyMatrix4(i),e.morphAttributes.position.push(u)}parseNormals(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,s=e.Normals.a;let i=[];return"IndexToDirect"===r&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:i,mappingType:t,referenceType:r}}parseUVs(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;let s=[];return{dataSize:2,buffer:e.UV.a,indices:s="IndexToDirect"===r?e.UVIndex.a:s,mappingType:t,referenceType:r}}parseVertexColors(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;let s=[];return{dataSize:4,buffer:e.Colors.a,indices:s="IndexToDirect"===r?e.ColorIndex.a:s,mappingType:t,referenceType:r}}parseMaterialIndices(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};var s=e.Materials.a;const i=[];for(let e=0;e<s.length;++e)i.push(e);return{dataSize:1,buffer:s,indices:i,mappingType:t,referenceType:r}}parseNurbsGeometry(e){if(void 0===In)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 s.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 s.BufferGeometry;var r=t-1;t=e.KnotVector.a;const i=[];var n=e.Points.a;for(let e=0,t=n.length;e<t;e+=4)i.push((new s.Vector4).fromArray(n,e));let a,o;if("Closed"===e.Form)i.push(i[0]);else if("Periodic"===e.Form){a=r,o=t.length-1-a;for(let e=0;e<r;++e)i.push(i[e])}return e=new In(r,t,i,a,o).getPoints(12*i.length),(new s.BufferGeometry).setFromPoints(e)}}class zn{parse(){const e=[];var t=this.parseClips();if(void 0!==t)for(const s in t){var r=t[s];r=this.addClip(r),e.push(r)}return e}parseClips(){var e;if(void 0!==On.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}parseAnimationCurveNodes(){var e,t=On.Objects.AnimationCurveNode;const r=new Map;for(const s in t){const i=t[s];null!==i.attrName.match(/S|R|T|DeformPercent/)&&(e={id:i.id,attr:i.attrName,curves:{}},r.set(e.id,e))}return r}parseAnimationCurves(e){const t=On.Objects.AnimationCurve;for(const n in t){var r={id:t[n].id,times:t[n].KeyTime.a.map(Xn),values:t[n].KeyValueFloat.a},s=Un.get(r.id);if(void 0!==s){var i=s.parents[0].ID;const t=s.parents[0].relationship;t.match(/X/)?e.get(i).curves.x=r:t.match(/Y/)?e.get(i).curves.y=r:t.match(/Z/)?e.get(i).curves.z=r:t.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=r)}}}parseAnimationLayers(e){var t=On.Objects.AnimationLayer;const r=new Map;for(const n in t){const t=[];var i=Un.get(parseInt(n));void 0!==i&&(i.children.forEach((function(r,i){if(e.has(r.ID)){var n,a=e.get(r.ID);if(void 0!==a.curves.x||void 0!==a.curves.y||void 0!==a.curves.z){if(void 0===t[i]){const e=Un.get(r.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const n=On.Objects.Model[e.toString()];if(void 0===n)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",r);const a={modelName:n.attrName?s.PropertyBinding.sanitizeNodeName(n.attrName):"",ID:n.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};kn.traverse((function(e){e.ID===n.id&&(a.transform=e.matrix,e.userData.transformData&&(a.eulerOrder=e.userData.transformData.eulerOrder))})),a.transform||(a.transform=new s.Matrix4),"PreRotation"in n&&(a.preRotation=n.PreRotation.value),"PostRotation"in n&&(a.postRotation=n.PostRotation.value),t[i]=a}}t[i]&&(t[i][a.attr]=a)}else void 0!==a.curves.morph&&(void 0===t[i]&&(r=Un.get(r.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,n=Un.get(r).parents[0].ID,n=Un.get(n).parents[0].ID,n=Un.get(n).parents[0].ID,n={modelName:(n=On.Objects.Model[n]).attrName?s.PropertyBinding.sanitizeNodeName(n.attrName):"",morphName:On.Objects.Deformer[r].attrName},t[i]=n),t[i][a.attr]=a)}})),r.set(parseInt(n),t))}return r}parseAnimStacks(e){var t=On.Objects.AnimationStack;const r={};for(const i in t){var s=Un.get(parseInt(i)).children;1<s.length&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers."),s=e.get(s[0].ID),r[i]={name:t[i].attrName,layer:s}}return r}addClip(e){let t=[];const r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new s.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let r=new s.Vector3,i=new s.Quaternion,n=new s.Vector3;var a;return e.transform&&e.transform.decompose(r,i,n),r=r.toArray(),i=(new s.Euler).setFromQuaternion(i,e.eulerOrder).toArray(),n=n.toArray(),void 0!==e.T&&0<Object.keys(e.T.curves).length&&void 0!==(a=this.generateVectorTrack(e.modelName,e.T.curves,r,"position"))&&t.push(a),void 0!==e.R&&0<Object.keys(e.R.curves).length&&void 0!==(a=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder))&&t.push(a),void 0!==e.S&&0<Object.keys(e.S.curves).length&&void 0!==(a=this.generateVectorTrack(e.modelName,e.S.curves,n,"scale"))&&t.push(a),void 0!==e.DeformPercent&&void 0!==(a=this.generateMorphTrack(e))&&t.push(a),t}generateVectorTrack(e,t,r,i){var n=this.getTimesForAllAxes(t);return t=this.getKeyframeTrackValues(n,t,r),new s.VectorKeyframeTrack(e+"."+i,n,t)}generateRotationTrack(e,t,r,i,n,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(s.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(s.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(s.MathUtils.degToRad));var o=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(o,t,r);void 0!==i&&((i=i.map(s.MathUtils.degToRad)).push(a),i=(new s.Euler).fromArray(i),i=(new s.Quaternion).setFromEuler(i)),void 0!==n&&((n=n.map(s.MathUtils.degToRad)).push(a),n=(new s.Euler).fromArray(n),n=(new s.Quaternion).setFromEuler(n).invert());const h=new s.Quaternion,c=new s.Euler;var u=[];for(let e=0;e<l.length;e+=3)c.set(l[e],l[e+1],l[e+2],a),h.setFromEuler(c),void 0!==i&&h.premultiply(i),void 0!==n&&h.multiply(n),h.toArray(u,e/3*4);return new s.QuaternionKeyframeTrack(e+".quaternion",o,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph;var r=t.values.map((function(e){return e/100})),i=kn.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new s.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+i+"]",t.times,r)}getTimesForAllAxes(e){let 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){let e=1,s=t[0];for(let i=1;i<t.length;i++){var r=t[i];r!==s&&(t[e]=r,s=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,r){const s=r,i=[];let n=-1,a=-1,o=-1;return e.forEach((function(e){t.x&&(n=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(o=t.z.times.indexOf(e)),-1!==n?(e=t.x.values[n],i.push(e),s[0]=e):i.push(s[0]),-1!==a?(e=t.y.values[a],i.push(e),s[1]=e):i.push(s[1]),-1!==o?(e=t.z.values[o],i.push(e),s[2]=e):i.push(s[2])})),i}interpolateRotations(e){for(let a=1;a<e.values.length;a++){var t=e.values[a-1],r=e.values[a]-t;if(180<=(s=Math.abs(r))){var s,i=r/(s/=180);let o=t+i;r=e.times[a-1];var n=(e.times[a]-r)/s;let l=r+n;const h=[],c=[];for(;l<e.times[a];)h.push(l),l+=n,c.push(o),o+=i;e.times=ta(e.times,a,h),e.values=ta(e.values,a,c)}}}}class jn{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),--this.currentIndent}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Gn,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,r=e.split(/[\r\n]+/);return r.forEach((function(e,s){var i,n=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);n||a||(n=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),i=e.match("^\\t{"+(t.currentIndent-1)+"}}"),n?t.parseNodeBegin(e,n):a?t.parseNodeProperty(e,a,r[++s]):i?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e))})),this.allNodes}parseNodeBegin(e,t){var r=t[1].trim().replace(/^"/,"").replace(/"$/,"");t=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}));const s={name:r};t=this.parseNodeAttr(t);const i=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(r,s):r in i?("PoseNode"===r?i.PoseNode.push(s):void 0!==i[r].id&&(i[r]={},i[r][i[r].id]=i[r]),""!==t.id&&(i[r][t.id]=s)):"number"==typeof t.id?(i[r]={},i[r][t.id]=s):"Properties70"!==r&&(i[r]="PoseNode"===r?[s]:s),"number"==typeof t.id&&(s.id=t.id),""!==t.name&&(s.attrName=t.name),""!==t.type&&(s.attrType=t.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0],r=(""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0])),""),s="";return 1<e.length&&(r=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:r,type:s}}parseNodeProperty(e,t,r){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===s&&","===i&&(i=r.replace(/"/g,"").replace(/,$/,"").trim());const n=this.getCurrentNode();if("Properties70"===n.name)this.parseNodeSpecialProperty(e,s,i);else{if("C"===s){t=i.split(",").slice(1),r=parseInt(t[0]),e=parseInt(t[1]);let l=i.split(",").slice(3);l=l.map((function(e){return e.trim().replace(/^"/,"")})),s="connections";var a=i=[r,e],o=l;for(let e=0,t=a.length,r=o.length;e<r;e++,t++)a[t]=o[e];void 0===n[s]&&(n[s]=[])}"Node"===s&&(n.id=i),s in n&&Array.isArray(n[s])?n[s].push(i):"a"!==s?n[s]=i:n.a=i,this.setCurrentProp(n,s),"a"===s&&","!==i.slice(-1)&&(n.a=$n(i))}}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=$n(t.a))}parseNodeSpecialProperty(e,t,r){r=r.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}));var s=r[0],i=r[1],n=r[2],a=r[3];let o=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":o=parseFloat(o);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":o=$n(o)}this.getPrevNode()[s]={type:i,type2:n,flag:a,value:o},this.setCurrentProp(this.getPrevNode(),s)}}class Vn{parse(e){const t=new Hn(e);t.skip(23);var r=t.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const s=new Gn;for(;!this.endOfContent(t);){var i=this.parseNode(t,r);null!==i&&s.add(i.name,i)}return s}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const r={};var s=7500<=t?e.getUint64():e.getUint32(),i=7500<=t?e.getUint64():e.getUint32(),n=(7500<=t?e.getUint64():e.getUint32(),e.getUint8()),a=e.getString(n);if(0===s)return null;const o=[];for(let t=0;t<i;t++)o.push(this.parseProperty(e));n=0<o.length?o[0]:"";var l=1<o.length?o[1]:"",h=2<o.length?o[2]:"";for(r.singleProperty=1===i&&e.getOffset()===s;s>e.getOffset();){var c=this.parseNode(e,t);null!==c&&this.parseSubNode(a,r,c)}return r.propertyList=o,"number"==typeof n&&(r.id=n),""!==l&&(r.attrName=l),""!==h&&(r.attrType=h),""!==a&&(r.name=a),r}parseSubNode(e,t,r){if(!0===r.singleProperty){var s=r.propertyList[0];Array.isArray(s)?(t[r.name]=r).a=s:t[r.name]=s}else if("Connections"===e&&"C"===r.name){const e=[];r.propertyList.forEach((function(t,r){0!==r&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===r.name)Object.keys(r).forEach((function(e){t[e]=r[e]}));else if("Properties70"===e&&"P"===r.name){let i,n=r.propertyList[0],a=r.propertyList[1];s=r.propertyList[2],e=r.propertyList[3],0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),0===a.indexOf("Lcl ")&&(a=a.replace("Lcl ","Lcl_")),i="Color"===a||"ColorRGB"===a||"Vector"===a||"Vector3D"===a||0===a.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[n]={type:a,type2:s,flag:e,value:i}}else 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)}parseProperty(t){var r=t.getString(1);let s;switch(r){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return s=t.getUint32(),t.getArrayBuffer(s);case"S":return s=t.getUint32(),t.getString(s);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var i=t.getUint32(),n=t.getUint32(),a=t.getUint32();if(0===n)switch(r){case"b":case"c":return t.getBooleanArray(i);case"d":return t.getFloat64Array(i);case"f":return t.getFloat32Array(i);case"i":return t.getInt32Array(i);case"l":return t.getInt64Array(i)}void 0===e&&console.error("THREE.FBXLoader: External library fflate.min.js required."),n=nn(new Uint8Array(t.getArrayBuffer(a)));const o=new Hn(n.buffer);switch(r){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+r)}}}class Hn{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let r=0;r<e;r++)t.push(this.getBoolean());return t}getUint8(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getInt32());return t}getUint32(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,4294967295==(e=4294967295&~e)&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getFloat32());return t}getFloat64(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getFloat64());return t}getArrayBuffer(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let r=0;r<e;r++)t[r]=this.getUint8();var r=t.indexOf(0);return 0<=r&&(t=t.slice(0,r)),s.LoaderUtils.decodeText(new Uint8Array(t))}}class Gn{add(e,t){this[e]=t}}function Wn(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 Xn(e){return e/46186158e3}const Yn=[];function Zn(e,t,r,s){let i;switch(s.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=r;break;case"AllSame":i=s.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+s.mappingType)}var n=(i="IndexToDirect"===s.referenceType?s.indices[i]:i)*s.dataSize,a=n+s.dataSize,o=Yn,l=s.buffer,h=a;for(let e=n,t=0;e<h;e++,t++)o[t]=l[e];return o}const Qn=new s.Euler,qn=new s.Vector3;function Kn(e){const t=new s.Matrix4,r=new s.Matrix4,i=new s.Matrix4,n=new s.Matrix4,a=new s.Matrix4,o=new s.Matrix4,l=new s.Matrix4,h=new s.Matrix4,c=new s.Matrix4,u=new s.Matrix4,d=new s.Matrix4,p=new s.Matrix4;var m=e.inheritType||0;if(e.translation&&t.setPosition(qn.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(s.MathUtils.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(Qn.fromArray(t))}if(e.rotation){const t=e.rotation.map(s.MathUtils.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(Qn.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(s.MathUtils.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(Qn.fromArray(t)),n.invert()}e.scale&&a.scale(qn.fromArray(e.scale)),e.scalingOffset&&l.setPosition(qn.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(qn.fromArray(e.scalingPivot)),e.rotationOffset&&h.setPosition(qn.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(qn.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(d.copy(e.parentMatrix),u.copy(e.parentMatrixWorld)),e=r.clone().multiply(i).multiply(n);const f=new s.Matrix4,g=(f.extractRotation(u),new s.Matrix4);g.copyPosition(u);var v=g.clone().invert().multiply(u);const y=f.clone().invert().multiply(v);v=a;const x=new s.Matrix4;0===m?x.copy(f).multiply(e).multiply(y).multiply(v):1===m?x.copy(f).multiply(y).multiply(e).multiply(v):(m=(new s.Matrix4).scale((new s.Vector3).setFromMatrixScale(d)).clone().invert(),m=y.clone().multiply(m),x.copy(f).multiply(e).multiply(m).multiply(v)),e=c.clone().invert(),m=o.clone().invert();let w=t.clone().multiply(h).multiply(c).multiply(r).multiply(i).multiply(n).multiply(e).multiply(l).multiply(o).multiply(a).multiply(m);return v=(new s.Matrix4).copyPosition(w),e=u.clone().multiply(v),p.copyPosition(e),(w=p.clone().multiply(x)).premultiply(u.invert()),w}function Jn(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 $n(e){return e.split(",").map((function(e){return parseFloat(e)}))}function ea(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),s.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function ta(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}const ra=/^[og]\s*(.+)?/,sa=/^mtllib /,ia=/^usemtl /,na=/^usemap /,aa=new s.Vector3,oa=new s.Vector3,la=new s.Vector3,ha=new s.Vector3,ca=new s.Vector3,ua=new s.Color;function da(){const 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);const r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(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){const t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}},this.materials.push(e),e},currentMaterial:function(){if(0<this.materials.length)return this.materials[this.materials.length-1]},_finalize:function(e){const 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(let e=this.materials.length-1;0<=e;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){const e=r.clone(0);e.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 s=this.vertices;const i=this.object.geometry.vertices;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[r+0],s[r+1],s[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 s=this.normals;const i=this.object.geometry.normals;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[r+0],s[r+1],s[r+2])},addFaceNormal:function(e,t,r){var s=this.vertices;const i=this.object.geometry.normals;aa.fromArray(s,e),oa.fromArray(s,t),la.fromArray(s,r),ca.subVectors(la,oa),ha.subVectors(aa,oa),ca.cross(ha),ca.normalize(),i.push(ca.x,ca.y,ca.z),i.push(ca.x,ca.y,ca.z),i.push(ca.x,ca.y,ca.z)},addColor:function(e,t,r){var s=this.colors;const i=this.object.geometry.colors;void 0!==s[e]&&i.push(s[e+0],s[e+1],s[e+2]),void 0!==s[t]&&i.push(s[t+0],s[t+1],s[t+2]),void 0!==s[r]&&i.push(s[r+0],s[r+1],s[r+2])},addUV:function(e,t,r){var s=this.uvs;const i=this.object.geometry.uvs;i.push(s[e+0],s[e+1]),i.push(s[t+0],s[t+1]),i.push(s[r+0],s[r+1])},addDefaultUV:function(){const 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,s,i,n,a,o,l){var h=this.vertices.length;let c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(r,h);this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==a&&""!==a?(e=this.normals.length,c=this.parseNormalIndex(a,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)):this.addFaceNormal(c,u,d),void 0!==s&&""!==s?(t=this.uvs.length,c=this.parseUVIndex(s,t),u=this.parseUVIndex(i,t),d=this.parseUVIndex(n,t),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0):this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";var t=this.vertices.length;for(let s=0,i=e.length;s<i;s++){var r=this.parseVertexIndex(e[s],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";var r=this.vertices.length,s=this.uvs.length;for(let t=0,s=e.length;t<s;t++)this.addVertexLine(this.parseVertexIndex(e[t],r));for(let e=0,r=t.length;e<r;e++)this.addUVLine(this.parseUVIndex(t[e],s))}};return e.startObject("",!1),e}class pa extends s.Loader{constructor(e){super(e),this.materials=null}load(e,t,r,i){const n=this,a=new s.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(r){try{t(n.parse(r))}catch(r){i?i(r):console.error(r),n.manager.itemError(e)}}),r,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new da;var r=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n");let i,n="",a=[];var o,l="function"==typeof"".trimLeft;for(let e=0,s=r.length;e<s;e++)if(n=r[e],0!==(n=l?n.trimLeft():n.trim()).length&&"#"!==(i=n.charAt(0)))if("v"===i){var h=n.split(/\s+/);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),7<=h.length?(ua.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(ua.r,ua.g,ua.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]))}}else if("f"===i){var c,u=n.slice(1).trim().split(/\s+/);const e=[];for(let t=0,r=u.length;t<r;t++){const r=u[t];0<r.length&&(c=r.split("/"),e.push(c))}var d=e[0];for(let r=1,s=e.length-1;r<s;r++){var p=e[r],m=e[r+1];t.addFace(d[0],p[0],m[0],d[1],p[1],m[1],d[2],p[2],m[2])}}else if("l"===i){const e=n.substring(1).trim().split(" ");let r=[];const s=[];if(-1===n.indexOf("/"))r=e;else for(let t=0,i=e.length;t<i;t++){var f=e[t].split("/");""!==f[0]&&r.push(f[0]),""!==f[1]&&s.push(f[1])}t.addLineGeometry(r,s)}else if("p"===i){var g=n.slice(1).trim().split(" ");t.addPointGeometry(g)}else if(null!==(a=ra.exec(n)))g=(" "+a[0].slice(1).trim()).slice(1),t.startObject(g);else if(ia.test(n))t.object.startMaterial(n.substring(7).trim(),t.materialLibraries);else if(sa.test(n))t.materialLibraries.push(n.substring(7).trim());else if(na.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===i){1<(a=n.split(" ")).length?(o=a[1].trim().toLowerCase(),t.object.smooth="0"!==o&&"off"!==o):t.object.smooth=!0;const e=t.object.currentMaterial();e&&(e.smooth=t.object.smooth)}else"\0"!==n&&console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"');t.finalize();const v=new s.Group;if(v.materialLibraries=[].concat(t.materialLibraries),1==!(1===t.objects.length&&0===t.objects[0].geometry.vertices.length))for(let e=0,r=t.objects.length;e<r;e++){var y=t.objects[e],x=y.geometry,w=y.materials,b="Line"===x.type,T="Points"===x.type;let r=!1;if(0!==x.vertices.length){const e=new s.BufferGeometry,i=(e.setAttribute("position",new s.Float32BufferAttribute(x.vertices,3)),0<x.normals.length&&e.setAttribute("normal",new s.Float32BufferAttribute(x.normals,3)),0<x.colors.length&&(r=!0,e.setAttribute("color",new s.Float32BufferAttribute(x.colors,3))),!0===x.hasUVIndices&&e.setAttribute("uv",new s.Float32BufferAttribute(x.uvs,2)),[]);for(let e=0,n=w.length;e<n;e++){var M=w[e],_=M.name+"_"+M.smooth+"_"+r;let n=t.materials[_];if(null!==this.materials)if(n=this.materials.create(M.name),!b||!n||n instanceof s.LineBasicMaterial){if(T&&n&&!(n instanceof s.PointsMaterial)){const e=new s.PointsMaterial({size:10,sizeAttenuation:!1});s.Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,n=e}}else{const e=new s.LineBasicMaterial;s.Material.prototype.copy.call(e,n),e.color.copy(n.color),n=e}void 0===n&&((n=b?new s.LineBasicMaterial:T?new s.PointsMaterial({size:1,sizeAttenuation:!1}):new s.MeshPhongMaterial).name=M.name,n.flatShading=!M.smooth,n.vertexColors=r,t.materials[_]=n),i.push(n)}let n;if(1<i.length){for(let t=0,r=w.length;t<r;t++){var S=w[t];e.addGroup(S.groupStart,S.groupCount,t)}n=new(b?s.LineSegments:T?s.Points:s.Mesh)(e,i)}else n=new(b?s.LineSegments:T?s.Points:s.Mesh)(e,i[0]);n.name=y.name,v.add(n)}}else if(0<t.vertices.length){const r=new s.PointsMaterial({size:1,sizeAttenuation:!1}),i=new s.BufferGeometry;i.setAttribute("position",new s.Float32BufferAttribute(t.vertices,3)),0<t.colors.length&&void 0!==t.colors[0]&&(i.setAttribute("color",new s.Float32BufferAttribute(t.colors,3)),r.vertexColors=!0),e=new s.Points(i,r),v.add(e)}return v}}var ma=function(e,t,r,s){return new(r=r||Promise)((function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(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,o)}l((s=s.apply(e,t||[])).next())}))};const fa=new s.Raycaster,ga=new s.Vector3,va=new s.Vector3,ya=new s.Quaternion,xa={X:new s.Vector3(1,0,0),Y:new s.Vector3(0,1,0),Z:new s.Vector3(0,0,1)},wa={type:"change"},ba={type:"mouseDown"},Ta={type:"mouseUp",mode:null},Ma={type:"objectChange"};class _a extends s.Object3D{constructor(e,t){super(),void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const r=new za,i=(this._gizmo=r,this.add(r),new ja),n=(this._plane=i,this.add(i),this);function a(e,t){let s=t;Object.defineProperty(n,e,{get:function(){return void 0!==s?s:t},set:function(t){s!==t&&(s=t,i[e]=t,r[e]=t,n.dispatchEvent({type:e+"-changed",value:t}),n.dispatchEvent(wa))}}),n[e]=t,i[e]=t,r[e]=t}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),t=new s.Vector3,e=new s.Vector3;var o=new s.Quaternion,l=new s.Quaternion,h=new s.Vector3,c=new s.Quaternion,u=new s.Vector3,d=new s.Vector3,p=new s.Vector3,m=new s.Vector3;a("worldPosition",t),a("worldPositionStart",e),a("worldQuaternion",o),a("worldQuaternionStart",l),a("cameraPosition",h),a("cameraQuaternion",c),a("pointStart",u),a("pointEnd",d),a("rotationAxis",p),a("rotationAngle",0),a("eye",m),this._offset=new s.Vector3,this._startNorm=new s.Vector3,this._endNorm=new s.Vector3,this._cameraScale=new s.Vector3,this._parentPosition=new s.Vector3,this._parentQuaternion=new s.Quaternion,this._parentQuaternionInv=new s.Quaternion,this._parentScale=new s.Vector3,this._worldScaleStart=new s.Vector3,this._worldQuaternionInv=new s.Quaternion,this._worldScale=new s.Vector3,this._positionStart=new s.Vector3,this._quaternionStart=new s.Quaternion,this._scaleStart=new s.Vector3,this._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(this),this._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(this),this._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(this),this._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(this),this._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){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(),super.updateMatrixWorld(this)}pointerHover(e){void 0!==this.object&&!0!==this.dragging&&(fa.setFromCamera(e,this.camera),e=Sa(this._gizmo.picker[this.mode],fa),this.axis=e?e.object.name:null)}pointerDown(e){void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis&&(fa.setFromCamera(e,this.camera),(e=Sa(this._plane,fa,!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,ba.mode=this.mode,this.dispatchEvent(ba))}pointerMove(e){const t=this.axis;var r=this.mode;const s=this.object;let i=this.space;if("scale"===r?i="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(i="world"),void 0!==s&&null!==t&&!1!==this.dragging&&-1===e.button&&(fa.setFromCamera(e,this.camera),e=Sa(this._plane,fa,!0))){if(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),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===i&&(s.position.applyQuaternion(ya.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),"world"===i&&(s.parent&&s.position.add(ga.setFromMatrixPosition(s.parent.matrixWorld)),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(ga.setFromMatrixPosition(s.parent.matrixWorld))));else if("scale"===r){if(-1!==t.search("XYZ")){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),va.set(e,e,e)}else ga.copy(this.pointStart),va.copy(this.pointEnd),ga.applyQuaternion(this._worldQuaternionInv),va.applyQuaternion(this._worldQuaternionInv),va.divide(ga),-1===t.search("X")&&(va.x=1),-1===t.search("Y")&&(va.y=1),-1===t.search("Z")&&(va.z=1);s.scale.copy(this._scaleStart).multiply(va),this.scaleSnap&&(-1!==t.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else"rotate"===r&&(this._offset.copy(this.pointEnd).sub(this.pointStart),e=20/this.worldPosition.distanceTo(ga.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(ga.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(xa[t]),ga.copy(xa[t]),"local"===i&&ga.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(ga.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===i&&"E"!==t&&"XYZE"!==t?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(ya.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(ya.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize()));this.dispatchEvent(wa),this.dispatchEvent(Ma)}}pointerUp(e){0===e.button&&(this.dragging&&null!==this.axis&&(Ta.mode=this.mode,this.dispatchEvent(Ta)),this.dragging=!1,this.axis=null)}dispose(){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()}))}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(wa),this.dispatchEvent(Ma),this.pointStart.copy(this.pointEnd))}getRaycaster(){return fa}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}update(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}function Sa(e,t,r){var s=t.intersectObject(e,!0);for(let e=0;e<s.length;e++)if(s[e].object.visible||r)return s[e];return!1}_a.prototype.isTransformControls=!0;const Pa=new s.Euler,Ca=new s.Vector3(0,1,0),Ra=new s.Vector3(0,0,0),Aa=new s.Matrix4,Ea=new s.Quaternion,Da=new s.Quaternion,La=new s.Vector3,Ia=new s.Matrix4,Oa=new s.Vector3(1,0,0),Ua=new s.Vector3(0,1,0),ka=new s.Vector3(0,0,1),Ba=new s.Vector3,Na=new s.Vector3,Fa=new s.Vector3;class za extends s.Object3D{constructor(){super(),this.type="TransformControlsGizmo";const e=new s.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new s.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),r=e.clone(),i=(r.opacity=.15,t.clone()),n=(i.opacity=.5,e.clone()),a=(n.color.setHex(16711680),e.clone()),o=(a.color.setHex(65280),e.clone()),l=(o.color.setHex(255),e.clone()),h=(l.color.setHex(16711680),l.opacity=.5,e.clone()),c=(h.color.setHex(65280),h.opacity=.5,e.clone()),u=(c.color.setHex(255),c.opacity=.5,e.clone()),d=(u.opacity=.25,e.clone()),p=((d.color.setHex(16776960),d.opacity=.25,e.clone()).color.setHex(16776960),e.clone()),m=(p.color.setHex(7895160),new s.CylinderGeometry(0,.04,.1,12)),f=(m.translate(0,.05,0),new s.BoxGeometry(.08,.08,.08)),g=(f.translate(0,.04,0),new s.BufferGeometry),v=(g.setAttribute("position",new s.Float32BufferAttribute([0,0,0,1,0,0],3)),new s.CylinderGeometry(.0075,.0075,.5,3));function y(e,t){const r=new s.TorusGeometry(e,.0075,3,64,t*Math.PI*2);return r.rotateY(Math.PI/2),r.rotateX(Math.PI/2),r}v.translate(0,.25,0);var x={X:[[new s.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new s.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new s.Mesh(v,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new s.Mesh(m,a),[0,.5,0]],[new s.Mesh(m,a),[0,-.5,0],[Math.PI,0,0]],[new s.Mesh(v,a)]],Z:[[new s.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new s.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new s.Mesh(v,o),null,[Math.PI/2,0,0]]],XYZ:[[new s.Mesh(new s.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},w={X:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,.3,0]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new s.Mesh(new s.OctahedronGeometry(.2,0),r)]],XY:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new s.Mesh(new s.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new s.Mesh(new s.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new s.Line(function(){const e=new s.BufferGeometry;return e.setAttribute("position",new s.Float32BufferAttribute([0,0,0,1,1,1],3)),e}(),i),null,null,null,"helper"]],X:[[new s.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new s.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new s.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},T={XYZE:[[new s.Mesh(y(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new s.Mesh(y(.5,.5),n)]],Y:[[new s.Mesh(y(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new s.Mesh(y(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new s.Mesh(y(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new s.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},_={XYZE:[[new s.Mesh(new s.SphereGeometry(.25,10,8),r)]],X:[[new s.Mesh(new s.TorusGeometry(.5,.1,4,24),r),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new s.Mesh(new s.TorusGeometry(.5,.1,4,24),r),[0,0,0],[Math.PI/2,0,0]]],Z:[[new s.Mesh(new s.TorusGeometry(.5,.1,4,24),r),[0,0,0],[0,0,-Math.PI/2]]],E:[[new s.Mesh(new s.TorusGeometry(.75,.1,2,24),r)]]},S={X:[[new s.Mesh(f,n),[.5,0,0],[0,0,-Math.PI/2]],[new s.Mesh(v,n),[0,0,0],[0,0,-Math.PI/2]],[new s.Mesh(f,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new s.Mesh(f,a),[0,.5,0]],[new s.Mesh(v,a)],[new s.Mesh(f,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new s.Mesh(f,o),[0,0,.5],[Math.PI/2,0,0]],[new s.Mesh(v,o),[0,0,0],[Math.PI/2,0,0]],[new s.Mesh(f,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new s.Mesh(new s.BoxGeometry(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new s.Mesh(new s.BoxGeometry(.1,.1,.1),u.clone())]]},P={X:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,.3,0]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new s.Mesh(new s.CylinderGeometry(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new s.Mesh(new s.BoxGeometry(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new s.Mesh(new s.BoxGeometry(.2,.2,.2),r),[0,0,0]]]},C={X:[[new s.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new s.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new s.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function R(e){const t=new s.Object3D;for(const s in e)for(let o=e[s].length;o--;){const l=e[s][o][0].clone();var r=e[s][o][1],i=e[s][o][2],n=e[s][o][3],a=e[s][o][4];l.name=s,l.tag=a,r&&l.position.set(r[0],r[1],r[2]),i&&l.rotation.set(i[0],i[1],i[2]),n&&l.scale.set(n[0],n[1],n[2]),l.updateMatrix();const h=l.geometry.clone();h.applyMatrix4(l.matrix),l.geometry=h,l.renderOrder=1/0,l.position.set(0,0,0),l.rotation.set(0,0,0),l.scale.set(1,1,1),t.add(l)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=R(x)),this.add(this.gizmo.rotate=R(T)),this.add(this.gizmo.scale=R(S)),this.add(this.picker.translate=R(w)),this.add(this.picker.rotate=R(_)),this.add(this.picker.scale=R(P)),this.add(this.helper.translate=R(b)),this.add(this.helper.rotate=R(M)),this.add(this.helper.scale=R(C)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){var t="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Da;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;let r=[];r=(r=(r=r.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(let e=0;e<r.length;e++){const s=r[e];let i;s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition),i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(i*this.size/4),"helper"===s.tag?(s.visible=!1,"AXIS"===s.name?(s.position.copy(this.worldPositionStart),s.visible=!!this.axis,"X"===this.axis&&(ya.setFromEuler(Pa.set(0,0,0)),s.quaternion.copy(t).multiply(ya),.9<Math.abs(Ca.copy(Oa).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"Y"===this.axis&&(ya.setFromEuler(Pa.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(ya),.9<Math.abs(Ca.copy(Ua).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"Z"===this.axis&&(ya.setFromEuler(Pa.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(ya),.9<Math.abs(Ca.copy(ka).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"XYZE"===this.axis&&(ya.setFromEuler(Pa.set(0,Math.PI/2,0)),Ca.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(Aa.lookAt(Ra,Ca,Ua)),s.quaternion.multiply(ya),s.visible=this.dragging),"E"===this.axis&&(s.visible=!1)):"START"===s.name?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):"END"===s.name?(s.position.copy(this.worldPosition),s.visible=this.dragging):"DELTA"===s.name?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),ga.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ga.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(ga),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=-1!==this.axis.search(s.name)))):(s.quaternion.copy(t),"translate"===this.mode||"scale"===this.mode?("X"===s.name&&.99<Math.abs(Ca.copy(Oa).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Y"===s.name&&.99<Math.abs(Ca.copy(Ua).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Z"===s.name&&.99<Math.abs(Ca.copy(ka).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XY"===s.name&&Math.abs(Ca.copy(ka).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"YZ"===s.name&&Math.abs(Ca.copy(Oa).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XZ"===s.name&&Math.abs(Ca.copy(Ua).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):"rotate"===this.mode&&(Ea.copy(t),Ca.copy(this.eye).applyQuaternion(ya.copy(t).invert()),-1!==s.name.search("E")&&s.quaternion.setFromRotationMatrix(Aa.lookAt(this.eye,Ra,Ua)),"X"===s.name&&(ya.setFromAxisAngle(Oa,Math.atan2(-Ca.y,Ca.z)),ya.multiplyQuaternions(Ea,ya),s.quaternion.copy(ya)),"Y"===s.name&&(ya.setFromAxisAngle(Ua,Math.atan2(Ca.x,Ca.z)),ya.multiplyQuaternions(Ea,ya),s.quaternion.copy(ya)),"Z"===s.name&&(ya.setFromAxisAngle(ka,Math.atan2(Ca.y,Ca.x)),ya.multiplyQuaternions(Ea,ya),s.quaternion.copy(ya))),s.visible=s.visible&&(-1===s.name.indexOf("X")||this.showX),s.visible=s.visible&&(-1===s.name.indexOf("Y")||this.showY),s.visible=s.visible&&(-1===s.name.indexOf("Z")||this.showZ),s.visible=s.visible&&(-1===s.name.indexOf("E")||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some((function(e){return s.name===e})))&&(s.material.color.setHex(16776960),s.material.opacity=1))}super.updateMatrixWorld(e)}}za.prototype.isTransformControlsGizmo=!0;class ja extends s.Mesh{constructor(){super(new s.PlaneGeometry(1e5,1e5,2,2),new s.MeshBasicMaterial({visible:!1,wireframe:!0,side:s.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Ba.copy(Oa).applyQuaternion("local"===t?this.worldQuaternion:Da),Na.copy(Ua).applyQuaternion("local"===t?this.worldQuaternion:Da),Fa.copy(ka).applyQuaternion("local"===t?this.worldQuaternion:Da),Ca.copy(Na),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ca.copy(this.eye).cross(Ba),La.copy(Ba).cross(Ca);break;case"Y":Ca.copy(this.eye).cross(Na),La.copy(Na).cross(Ca);break;case"Z":Ca.copy(this.eye).cross(Fa),La.copy(Fa).cross(Ca);break;case"XY":La.copy(Fa);break;case"YZ":La.copy(Ba);break;case"XZ":Ca.copy(Fa),La.copy(Na);break;case"XYZ":case"E":La.set(0,0,0)}break;default:La.set(0,0,0)}0===La.length()?this.quaternion.copy(this.cameraQuaternion):(Ia.lookAt(ga.set(0,0,0),La,Ca),this.quaternion.setFromRotationMatrix(Ia)),super.updateMatrixWorld(e)}}ja.prototype.isTransformControlsPlane=!0;class Va extends _a{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new s.Vector3,this.beginScale=new s.Vector3,this.posStart=new s.Vector2,this.posEnd=new s.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)}}}const Ha=new WeakMap;class Ga extends s.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,i){const n=new s.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,(e=>{var r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(i)}),r,i)}decodeDracoFile(e,t,r,s){s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r},this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){var r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}var s=JSON.stringify(t);if(Ha.has(e)){var i=Ha.get(e);if(i.key===s)return i.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const a=this.workerNextTaskID++;i=e.byteLength;const o=this._getWorker(a,i).then((r=>(n=r,new Promise(((r,s)=>{n._callbacks[a]={resolve:r,reject:s},n.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{n&&a&&this._releaseTask(n,a)})),Ha.set(e,{key:s,promise:o}),o}_createGeometry(e){const t=new s.BufferGeometry;e.index&&t.setIndex(new s.BufferAttribute(e.index.array,1));for(let a=0;a<e.attributes.length;a++){var r=e.attributes[a],i=r.name,n=r.array;r=r.itemSize,t.setAttribute(i,new s.BufferAttribute(n,r))}return t}_loadLibrary(e,t){const r=new s.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise(((t,s)=>{r.load(e,t,void 0,s)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const r=t[0],s=(e||(this.decoderConfig.wasmBinary=t[1]),function(){let e,t;onmessage=function(r){const s=r.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=s.buffer,i=s.taskConfig;t.then((e=>{const t=e.draco;e=new t.Decoder;const n=new t.DecoderBuffer;n.Init(new Int8Array(r),r.byteLength);try{const r=function(e,t,r,s){var i=s.attributeIDs,n=s.attributeTypes;let a,o;var l,h,c,u,d,p,m,f,g,v,y,x,w,b,T=t.GetEncodedGeometryType(r);if(T===e.TRIANGULAR_MESH)a=new e.Mesh,o=t.DecodeBufferToMesh(r,a);else{if(T!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,o=t.DecodeBufferToPointCloud(r,a)}if(!o.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+o.error_msg());const M={index:null,attributes:[]};for(const r in i){var _=self[n[r]];let o,y;if(s.useUniqueIDs)y=i[r],o=t.GetAttributeByUniqueId(a,y);else{if(-1===(y=t.GetAttributeId(a,e[i[r]])))continue;o=t.GetAttribute(a,y)}M.attributes.push((l=e,h=t,c=a,u=r,d=o,m=void 0,p=d.num_components(),m=c.num_points(),f=(m*=p)*_.BYTES_PER_ELEMENT,g=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}}(l,_),v=l._malloc(f),h.GetAttributeDataArrayForAllPoints(c,d,g,f,v),h=new _(l.HEAPF32.buffer,v,m).slice(),l._free(v),{name:u,array:h,itemSize:p}))}return T===e.TRIANGULAR_MESH&&(M.index=(r=e,T=t,x=(y=a).num_faces(),w=4*(x*=3),b=r._malloc(w),T.GetTrianglesUInt32Array(y,w,b),T=new Uint32Array(r.HEAPF32.buffer,b,x).slice(),r._free(b),{array:T,itemSize:1})),e.destroy(a),M}(t,e,n,i),a=r.attributes.map((e=>e.array.buffer));r.index&&a.push(r.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:r},a)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(n),t.destroy(e)}}))}}}.toString());t=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n"),this.workerSourceURL=URL.createObjectURL(new Blob([t]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){var r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}const Wa={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={}}},Xa=new class{constructor(e,t,r){const s=this;let i,n=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){o++,!1===n&&void 0!==s.onStart&&s.onStart(e,a,o),n=!0},this.itemEnd=function(e){a++,void 0!==s.onProgress&&s.onProgress(e,a,o),a===o&&(n=!1,void 0!==s.onLoad&&s.onLoad())},this.itemError=function(e){void 0!==s.onError&&s.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){return-1!==(e=l.indexOf(e))&&l.splice(e,2),this},this.getHandler=function(e){for(let r=0,s=l.length;r<s;r+=2){const s=l[r];var t=l[r+1];if(s.global&&(s.lastIndex=0),s.test(e))return t}return null}}};class Ya extends class{constructor(e){this.manager=void 0!==e?e:Xa,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise((function(s,i){r.load(e,s,t,i)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,n=Wa.get(e);if(void 0!==n)return i.manager.itemStart(e),setTimeout((function(){t&&t(n),i.manager.itemEnd(e)}),0),n;const 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",resizeQuality:"pixelated"})),Promise.resolve(e)])})).then((function(r){var[r,s]=r;Wa.add(e,r),t&&t(r,s),i.manager.itemEnd(e)})).catch((function(t){s&&s(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}Ya.prototype.isImageBitmapLoader=!0;class Za extends s.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new $a(e)})),this.register((function(e){return new no(e)})),this.register((function(e){return new ao(e)})),this.register((function(e){return new eo(e)})),this.register((function(e){return new to(e)})),this.register((function(e){return new ro(e)})),this.register((function(e){return new so(e)})),this.register((function(e){return new io(e)})),this.register((function(e){return new Ka(e)})),this.register((function(e){return new oo(e)}))}load(e,t,r,i){const n=this;let a;function o(t){i?i(t):console.error(t),n.manager.itemError(e),n.manager.itemEnd(e)}a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:s.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const l=new s.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(r){try{n.parse(r,a,(function(r){t(r),n.manager.itemEnd(e)}),o)}catch(r){o(r)}}),r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,i,n){let a;const o={},l={};if("string"==typeof e)a=e;else if(s.LoaderUtils.decodeText(new Uint8Array(e,0,4))===lo){try{o[qa.KHR_BINARY_GLTF]=new ho(e)}catch(e){return void(i&&i(e))}a=o[qa.KHR_BINARY_GLTF].content}else a=s.LoaderUtils.decodeText(new Uint8Array(e));var h=JSON.parse(a);if(void 0===h.asset||h.asset.version[0]<2)i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{n.helper.beforeLoader(h);const e=new Eo(h,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:n});e.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){var c=this.pluginCallbacks[t](e);l[c.name]=c,o[c.name]=!0}if(h.extensionsUsed)for(let e=0;e<h.extensionsUsed.length;++e){var u=h.extensionsUsed[e];const t=h.extensionsRequired||[];switch(u){case qa.KHR_MATERIALS_UNLIT:o[u]=new Ja;break;case qa.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[u]=new mo;break;case qa.KHR_DRACO_MESH_COMPRESSION:o[u]=new co(h,this.dracoLoader);break;case qa.KHR_TEXTURE_TRANSFORM:o[u]=new uo;break;case qa.KHR_MESH_QUANTIZATION:o[u]=new fo;break;default:0<=t.indexOf(u)&&void 0===l[u]&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}e.setExtensions(o),e.setPlugins(l),e.parse(r,i)}}parseAsync(e,t){const r=this;return new Promise((function(s,i){r.parse(e,t,s,i)}))}}function Qa(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const qa={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Ka{constructor(e){this.parser=e,this.name=qa.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser;var t=this.parser.json.nodes||[];for(let s=0,i=t.length;s<i;s++){var r=t[s];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser;var r="light:"+e;let i=t.cache.get(r);if(i)return i;var n=t.json;const a=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let o;const l=new s.Color(16777215);void 0!==a.color&&l.fromArray(a.color);var h=void 0!==a.range?a.range:0;switch(a.type){case"directional":(o=new s.DirectionalLight(l)).target.position.set(0,0,-1),o.add(o.target);break;case"point":(o=new s.PointLight(l)).distance=h;break;case"spot":(o=new s.SpotLight(l)).distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),o.decay=2,void 0!==a.intensity&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(o),t.cache.add(r,i),i}createNodeAttachment(e){const t=this,r=this.parser,s=((e=r.json.nodes[e]).extensions&&e.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then((function(e){return r._getNodeRef(t.cache,s,e)}))}}class Ja{constructor(){this.name=qa.KHR_MATERIALS_UNLIT}getMaterialType(){return s.MeshBasicMaterial}extendParams(e,t,r){const i=[];var n;return e.color=new s.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)}}class $a{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const i=[];return void 0!==(e=e.extensions[this.name]).clearcoatFactor&&(t.clearcoat=e.clearcoatFactor),void 0!==e.clearcoatTexture&&i.push(r.assignTexture(t,"clearcoatMap",e.clearcoatTexture)),void 0!==e.clearcoatRoughnessFactor&&(t.clearcoatRoughness=e.clearcoatRoughnessFactor),void 0!==e.clearcoatRoughnessTexture&&i.push(r.assignTexture(t,"clearcoatRoughnessMap",e.clearcoatRoughnessTexture)),void 0!==e.clearcoatNormalTexture&&(i.push(r.assignTexture(t,"clearcoatNormalMap",e.clearcoatNormalTexture)),void 0!==e.clearcoatNormalTexture.scale&&(e=e.clearcoatNormalTexture.scale,t.clearcoatNormalScale=new s.Vector2(e,e))),Promise.all(i)}}class eo{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_SHEEN}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const i=[];return t.sheenColor=new s.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,void 0!==(e=e.extensions[this.name]).sheenColorFactor&&t.sheenColor.fromArray(e.sheenColorFactor),void 0!==e.sheenRoughnessFactor&&(t.sheenRoughness=e.sheenRoughnessFactor),void 0!==e.sheenColorTexture&&i.push(r.assignTexture(t,"sheenColorMap",e.sheenColorTexture)),void 0!==e.sheenRoughnessTexture&&i.push(r.assignTexture(t,"sheenRoughnessMap",e.sheenRoughnessTexture)),Promise.all(i)}}class to{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];return void 0!==(e=e.extensions[this.name]).transmissionFactor&&(t.transmission=e.transmissionFactor),void 0!==e.transmissionTexture&&s.push(r.assignTexture(t,"transmissionMap",e.transmissionTexture)),Promise.all(s)}}class ro{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_VOLUME}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const i=[];return e=e.extensions[this.name],t.thickness=void 0!==e.thicknessFactor?e.thicknessFactor:0,void 0!==e.thicknessTexture&&i.push(r.assignTexture(t,"thicknessMap",e.thicknessTexture)),t.attenuationDistance=e.attenuationDistance||0,e=e.attenuationColor||[1,1,1],t.attenuationColor=new s.Color(e[0],e[1],e[2]),Promise.all(i)}}class so{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_IOR}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(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()}}class io{constructor(e){this.parser=e,this.name=qa.KHR_MATERIALS_SPECULAR}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?s.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const i=[];e=e.extensions[this.name];var n=(t.specularIntensity=void 0!==e.specularFactor?e.specularFactor:1,void 0!==e.specularTexture&&i.push(r.assignTexture(t,"specularIntensityMap",e.specularTexture)),e.specularColorFactor||[1,1,1]);return t.specularColor=new s.Color(n[0],n[1],n[2]),void 0!==e.specularColorTexture&&i.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=s.sRGBEncoding}))),Promise.all(i)}}class no{constructor(e){this.parser=e,this.name=qa.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json;if(!(s=r.textures[e]).extensions||!s.extensions[this.name])return null;var s=s.extensions[this.name],i=t.options.ktx2Loader;if(i)return t.loadTextureImage(e,s.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}}class ao{constructor(e){this.parser=e,this.name=qa.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json;if(!(i=s.textures[e]).extensions||!i.extensions[t])return null;var i=i.extensions[t];const n=s.images[i.source];let a=r.textureLoader;return n.uri&&null!==(i=r.options.manager.getHandler(n.uri))&&(a=i),this.detectSupport().then((function(i){if(i)return r.loadTextureImage(e,n,a);if(s.extensionsRequired&&0<=s.extensionsRequired.indexOf(t))throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class oo{constructor(e){this.name=qa.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json;if((e=t.bufferViews[e]).extensions&&e.extensions[this.name]){const r=e.extensions[this.name];e=this.parser.getDependency("buffer",r.buffer);const s=this.parser.options.meshoptDecoder;if(s&&s.supported)return Promise.all([e,s.ready]).then((function(e){var t=r.byteOffset||0,i=r.byteLength||0,n=r.count,a=r.byteStride,o=new ArrayBuffer(n*a);return e=new Uint8Array(e[0],t,i),s.decodeGltfBuffer(new Uint8Array(o),n,a,e,r.mode,r.filter),o}));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}}const lo="glTF";class ho{constructor(e){this.name=qa.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:s.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==lo)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");var r=this.header.length-12;const i=new DataView(e,12);let n=0;for(;n<r;){var a,o=i.getUint32(n,!0),l=(n+=4,i.getUint32(n,!0));n+=4,1313821514===l?(a=new Uint8Array(e,12+n,o),this.content=s.LoaderUtils.decodeText(a)):5130562===l&&(a=12+n,this.body=e.slice(a,a+o)),n+=o}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class co{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=qa.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){var r=this.json;const s=this.dracoLoader;var i=e.extensions[this.name].bufferView,n=e.extensions[this.name].attributes;const a={},o={},l={};for(const e in n){var h=Mo[e]||e.toLowerCase();a[h]=n[e]}for(const t in e.attributes){var c,u,d=Mo[t]||t.toLowerCase();void 0!==n[t]&&(c=r.accessors[e.attributes[t]],u=xo[c.componentType],l[d]=u,o[d]=!0===c.normalized)}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const s=e.attributes[t];var r=o[t];void 0!==r&&(s.normalized=r)}t(e)}),a,l)}))}))}}class uo{constructor(){this.name=qa.KHR_TEXTURE_TRANSFORM}extendTexture(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}}class po extends s.MeshStandardMaterial{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),r=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["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"),n=["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"),a=["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"),o={specular:{value:(new s.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",r).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",n).replace("#include <lights_physical_fragment>",a)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){(o.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){(o.glossinessMap.value=e)?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(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}}class mo{constructor(){this.name=qa.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return po}extendParams(e,t,r){var i;t=t.extensions[this.name],e.color=new s.Color(1,1,1),e.opacity=1;const n=[];return Array.isArray(t.diffuseFactor)&&(i=t.diffuseFactor,e.color.fromArray(i),e.opacity=i[3]),void 0!==t.diffuseTexture&&n.push(r.assignTexture(e,"map",t.diffuseTexture)),e.emissive=new s.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new s.Color(1,1,1),Array.isArray(t.specularFactor)&&e.specular.fromArray(t.specularFactor),void 0!==t.specularGlossinessTexture&&(i=t.specularGlossinessTexture,n.push(r.assignTexture(e,"glossinessMap",i)),n.push(r.assignTexture(e,"specularMap",i))),Promise.all(n)}createMaterial(e){const t=new po(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=s.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}}class fo{constructor(){this.name=qa.KHR_MESH_QUANTIZATION}}class go extends s.Interpolant{constructor(e,t,r,s){super(e,t,r,s)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let e=0;e!==s;e++)t[e]=r[i+e];return t}}go.prototype.beforeStart_=go.prototype.copySampleValue_,go.prototype.afterEnd_=go.prototype.copySampleValue_,go.prototype.interpolate_=function(e,t,r,s){const i=this.resultBuffer;var n=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=s-t,c=e*l,u=c-l,d=-2*(t=(r=(s=(r-t)/h)*s)*s)+3*r,p=t-r,m=1-d,f=p-r+s;for(let e=0;e!==a;e++){var g=n[u+e+a],v=n[u+e+o]*h,y=n[c+e+a],x=n[c+e]*h;i[e]=m*g+f*v+d*y+p*x}return i};const vo=new s.Quaternion;class yo extends go{interpolate_(e,t,r,s){return e=super.interpolate_(e,t,r,s),vo.fromArray(e).normalize().toArray(e),e}}const xo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},wo={9728:s.NearestFilter,9729:s.LinearFilter,9984:s.NearestMipmapNearestFilter,9985:s.LinearMipmapNearestFilter,9986:s.NearestMipmapLinearFilter,9987:s.LinearMipmapLinearFilter},bo={33071:s.ClampToEdgeWrapping,33648:s.MirroredRepeatWrapping,10497:s.RepeatWrapping},To={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Mo={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_o={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},So={CUBICSPLINE:void 0,LINEAR:s.InterpolateLinear,STEP:s.InterpolateDiscrete};function Po(e,t,r){for(const s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function Co(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Ro(e){let t="";var r=Object.keys(e).sort();for(let s=0,i=r.length;s<i;s++)t+=r[s]+":"+e[r[s]]+";";return t}function Ao(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.")}}class Eo{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Qa,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 Ya(this.options.manager):this.textureLoader=new s.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new s.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,s=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.options.myOptions.helper.processInput(s,this),...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){const n={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};Po(i,n,s),Co(n,s),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(n)}))).then((function(){r.options.myOptions.helper.done(n),e(n)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[];var t=this.json.skins||[];const r=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){var s=t[r].joints;for(let t=0,r=s.length;t<r;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){var i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(r[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const s=r.clone(),i=(e,t)=>{var r,s,n=this.associations.get(e);for([r,s]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(s,t.children[r])};return i(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){var r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins),r=(t.unshift(this),[]);for(let i=0;i<t.length;i++){var s=e(t[i]);s&&r.push(s)}return r}getDependency(e,t){var r=e+":"+t;let s=this.cache.get(r);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this.loadNode(t);break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this.loadAnimation(t);break;case"camera":s=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const 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[qa.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,n){r.load(s.LoaderUtils.resolveURL(t.uri,i.path),e,void 0,(function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))}loadAccessor(e){const t=this,r=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const n=[];return void 0!==i.bufferView?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),void 0!==i.sparse&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then((function(e){var n=e[0],a=To[i.type];const o=xo[i.componentType];var l=o.BYTES_PER_ELEMENT,h=l*a,c=i.byteOffset||0,u=void 0!==i.bufferView?r.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let p,m;if(u&&u!==h){h=Math.floor(c/u);var f="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+h+":"+i.count;let e=t.cache.get(f);e||(p=new o(n,h*u,i.count*u/l),e=new s.InterleavedBuffer(p,u/l),t.cache.add(f,e)),m=new s.InterleavedBufferAttribute(e,a,c%u/l,d)}else p=null===n?new o(i.count*a):new o(n,c,i.count*a),m=new s.BufferAttribute(p,a,d);if(void 0!==i.sparse){h=To.SCALAR;const t=xo[i.sparse.indices.componentType];f=i.sparse.indices.byteOffset||0,u=i.sparse.values.byteOffset||0;var g=new t(e[1],f,i.sparse.count*h),v=new o(e[2],u,i.sparse.count*a);null!==n&&(m=new s.BufferAttribute(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=g.length;e<t;e++){var y=g[e];if(m.setX(y,v[e*a]),2<=a&&m.setY(y,v[e*a+1]),3<=a&&m.setZ(y,v[e*a+2]),4<=a&&m.setW(y,v[e*a+3]),5<=a)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){var t=this.json;const r=this.options;var s=t.textures[e].source;t=t.images[s];let i=this.textureLoader;return t.uri&&null!==(t=r.manager.getHandler(t.uri))&&(i=t),this.loadTextureImage(e,s,i)}loadTextureImage(e,t,r){const i=this,n=this.json,a=n.textures[e];var o=((o=n.images[t]).uri||o.bufferView)+":"+a.sampler;return this.textureCache[o]?this.textureCache[o]:(t=this.loadImageSource(t,r).then((function(t){t.flipY=!1,a.name&&(t.name=a.name);var r=(n.samplers||{})[a.sampler]||{};return t.magFilter=wo[r.magFilter]||s.LinearFilter,t.minFilter=wo[r.minFilter]||s.LinearMipmapLinearFilter,t.wrapS=bo[r.wrapS]||s.RepeatWrapping,t.wrapT=bo[r.wrapT]||s.RepeatWrapping,i.associations.set(t,{textures:e}),i.options.myOptions.helper.material.processTexture({texture:t,textureDef:a}),t})).catch((function(){return null})),this.textureCache[o]=t)}loadImageSource(e,t){var r=this.json;const i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((function(e){return e.clone()})).catch((function(e){throw e}));const n=r.images[e],a=self.URL||self.webkitURL;let o=n.uri||"";if(void 0!==n.bufferView)o=this.getDependency("bufferView",n.bufferView).then((function(e){return e=new Blob([e],{type:n.mimeType}),o=a.createObjectURL(e)}));else if(void 0===n.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return r=Promise.resolve(o).then((function(e){return new Promise((function(r,n){let a=r;!0===t.isImageBitmapLoader&&(a=function(e,t){const i=new s.Texture(e);i.needsUpdate=!0,r({texture:i,blob:t})}),t.load(s.LoaderUtils.resolveURL(e,i.path),a,void 0,n)}))})).then((function(e){const{texture:t,blob:r}=e;return t.userData.url=o,t.userData.blob=r,t.url=o,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e})),this.sourceCache[e]=r}assignTexture(e,t,r){const s=this;return this.getDependency("texture",r.index).then((function(i){var n,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."),s.extensions[qa.KHR_TEXTURE_TRANSFORM]&&(n=void 0!==r.extensions?r.extensions[qa.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=s.associations.get(i),i=s.extensions[qa.KHR_TEXTURE_TRANSFORM].extendTexture(i,n),s.associations.set(i,a)),e[t]=i}))}assignFinalMaterial(e){const t=e.geometry;let r=e.material;var i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){var o="PointsMaterial:"+r.uuid;let e=this.cache.get(o);e||(e=new s.PointsMaterial,s.Material.prototype.copy.call(e,r),e.color.copy(r.color),e.map=r.map,e.sizeAttenuation=!1,this.cache.add(o,e)),r=e}else if(e.isLine){o="LineBasicMaterial:"+r.uuid;let e=this.cache.get(o);e||(e=new s.LineBasicMaterial,s.Material.prototype.copy.call(e,r),e.color.copy(r.color),this.cache.add(o,e)),r=e}if(i||n||a){let e="ClonedMaterial:"+r.uuid+":",t=(r.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),a&&(e+="flat-shading:"),this.cache.get(e));t||(t=r.clone(),n&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}r.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),this.options.myOptions.helper.material.process({material:r,materialDef:r.userData,model:e}),e.material=r}getMaterialType(){return s.MeshStandardMaterial}loadMaterial(e){const t=this;var r=this.json;const i=this.extensions,n=r.materials[e];let a;const o={},l=[];if((r=n.extensions||{})[qa.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[qa.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];a=e.getMaterialType(),l.push(e.extendParams(o,n,t))}else if(r[qa.KHR_MATERIALS_UNLIT]){const e=i[qa.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(o,n,t))}else r=n.pbrMetallicRoughness||{},o.color=new s.Color(1,1,1),o.opacity=1,Array.isArray(r.baseColorFactor)&&(h=r.baseColorFactor,o.color.fromArray(h),o.opacity=h[3]),void 0!==r.baseColorTexture&&l.push(t.assignTexture(o,"map",r.baseColorTexture)),o.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,o.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",r.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",r.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))));!0===n.doubleSided&&(o.side=s.DoubleSide);var h=n.alphaMode||"OPAQUE";return"BLEND"===h?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===h&&(o.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&a!==s.MeshBasicMaterial&&(l.push(t.assignTexture(o,"normalMap",n.normalTexture)),o.normalScale=new s.Vector2(1,1),void 0!==n.normalTexture.scale&&(r=n.normalTexture.scale,o.normalScale.set(r,r))),void 0!==n.occlusionTexture&&a!==s.MeshBasicMaterial&&(l.push(t.assignTexture(o,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(o.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&a!==s.MeshBasicMaterial&&(o.emissive=(new s.Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&a!==s.MeshBasicMaterial&&l.push(t.assignTexture(o,"emissiveMap",n.emissiveTexture)),Promise.all(l).then((function(){let r;return r=a===po?i[qa.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new a(o),n.name&&(r.name=n.name),r.map&&(r.map.encoding=s.sRGBEncoding),r.emissiveMap&&(r.emissiveMap.encoding=s.sRGBEncoding),Co(r,n),t.associations.set(r,{materials:e}),n.extensions&&Po(i,r,n),r}))}createUniqueName(e){var t=s.PropertyBinding.sanitizeNodeName(e||"");let r=t;for(let e=1;this.nodeNamesUsed[r];++e)r=t+"_"+e;return this.nodeNamesUsed[r]=!0,r}loadGeometries(e){const t=this,r=this.extensions,i=this.primitiveCache,n=[];for(let h=0,c=e.length;h<c;h++){var a=e[h],o=function(e){var t=e.extensions&&e.extensions[qa.KHR_DRACO_MESH_COMPRESSION];return t?"draco:"+t.bufferView+":"+t.indices+":"+Ro(t.attributes):e.indices+":"+Ro(e.attributes)+":"+e.mode}(a),l=i[o];if(l)n.push(l.promise);else{let e;e=a.extensions&&a.extensions[qa.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[qa.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return Do(r,e,t)}))}(a):Do(new s.BufferGeometry,a,t),i[o]={primitive:a,promise:e},n.push(e)}}return Promise.all(n)}loadMesh(e){const t=this;var r,i=this.json;const n=this.extensions,a=i.meshes[e],o=a.primitives,l=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(r=this.cache).DefaultMaterial&&(r.DefaultMaterial=new s.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:s.FrontSide})),r.DefaultMaterial):this.getDependency("material",o[e].material);t.then((e=>{})),l.push(t)}return l.push(t.loadGeometries(o)),Promise.all(l).then((function(r){var i=r.slice(0,r.length-1),l=r[r.length-1];const h=[];for(let r=0,g=l.length;r<g;r++){var c=l[r],u=o[r];let g;var d=i[r];if(4===u.mode||5===u.mode||6===u.mode||void 0===u.mode)!0!==(g=new(!0===a.isSkinnedMesh?s.SkinnedMesh:s.Mesh)(c,d)).isSkinnedMesh||g.geometry.attributes.skinWeight.normalized||g.normalizeSkinWeights(),5===u.mode?g.geometry=Lo(g.geometry,s.TriangleStripDrawMode):6===u.mode&&(g.geometry=Lo(g.geometry,s.TriangleFanDrawMode));else if(1===u.mode)g=new s.LineSegments(c,d);else if(3===u.mode)g=new s.Line(c,d);else if(2===u.mode)g=new s.LineLoop(c,d);else{if(0!==u.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);g=new s.Points(c,d)}if(0<Object.keys(g.geometry.morphAttributes).length){f=p=void 0;var p=g,m=a;if(p.updateMorphTargets(),void 0!==m.weights)for(let e=0,t=m.weights.length;e<t;e++)p.morphTargetInfluences[e]=m.weights[e];if(m.extras&&Array.isArray(m.extras.targetNames)){var f=m.extras.targetNames;if(p.morphTargetInfluences.length===f.length){p.morphTargetDictionary={};for(let e=0,t=f.length;e<t;e++)p.morphTargetDictionary[f[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}g.name=t.createUniqueName(a.name||"mesh_"+e),Co(g,a),u.extensions&&Po(n,g,u),t.assignFinalMaterial(g),h.push(g)}for(let r=0,s=h.length;r<s;r++)t.associations.set(h[r],{meshes:e,primitives:r});if(1===h.length)return h[0];const g=new s.Group;t.associations.set(g,{meshes:e});for(let e=0,t=h.length;e<t;e++)g.add(h[e]);return g}))}loadCamera(e){let t;var r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new s.PerspectiveCamera(s.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new s.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),Co(t,e),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const 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}))}loadAnimation(e){const t=this.json.animations[e],r=[],i=[],n=[],a=[],o=[];for(let e=0,s=t.channels.length;e<s;e++){var l=t.channels[e],h=t.samplers[l.sampler],c=void 0!==(l=l.target).node?l.node:l.id,u=void 0!==t.parameters?t.parameters[h.input]:h.input,d=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",c)),i.push(this.getDependency("accessor",u)),n.push(this.getDependency("accessor",d)),a.push(h),o.push(l)}return Promise.all([Promise.all(r),Promise.all(i),Promise.all(n),Promise.all(a),Promise.all(o)]).then((function(r){var i=r[0],n=r[1],a=r[2],o=r[3],l=r[4];const h=[];for(let e=0,t=i.length;e<t;e++){const t=i[e];var c=n[e],u=a[e],d=o[e],p=l[e];if(void 0!==t){let e;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,_o[p.path]){case _o.weights:e=s.NumberKeyframeTrack;break;case _o.rotation:e=s.QuaternionKeyframeTrack;break;default:e=s.VectorKeyframeTrack}var m=t.name||t.uuid,f=void 0!==d.interpolation?So[d.interpolation]:s.InterpolateLinear;const r=[];_o[p.path]===_o.weights?t.traverse((function(e){e.morphTargetInfluences&&r.push(e.name||e.uuid)})):r.push(m);let i=u.array;if(u.normalized){var g=Ao(i.constructor);const e=new Float32Array(i.length);for(let t=0,r=i.length;t<r;t++)e[t]=i[t]*g;i=e}for(let t=0,n=r.length;t<n;t++){const n=new e(r[t]+"."+_o[p.path],c.array,i,f);"CUBICSPLINE"===d.interpolation&&(n.createInterpolant=function(e){return new(this instanceof s.QuaternionKeyframeTrack?yo:go)(this.times,this.values,this.getValueSize()/3,e)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),h.push(n)}}}return r=t.name||"animation_"+e,new s.AnimationClip(r,void 0,h)}))}createNodeMesh(e){var t=this.json;const r=this,s=t.nodes[e];return void 0===s.mesh?null:r.getDependency("mesh",s.mesh).then((function(e){const t=r._getNodeRef(r.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,r=s.weights.length;t<r;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){var t=this.json;const r=this.extensions,i=this,n=t.nodes[e],a=n.name?i.createUniqueName(n.name):"";return function(){const t=[];var r=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return r&&t.push(r),void 0!==n.camera&&t.push(i.getDependency("camera",n.camera).then((function(e){return i._getNodeRef(i.cameraCache,n.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if((o=!0===n.isBone?new s.Bone:1<t.length?new s.Group:1===t.length?t[0]:new s.Object3D)!==t[0])for(let e=0,r=t.length;e<r;e++)o.add(t[e]);if(n.name&&(o.userData.name=n.name,o.name=a),Co(o,n),n.extensions&&Po(r,o,n),void 0!==n.matrix){const e=new s.Matrix4;e.fromArray(n.matrix),o.applyMatrix4(e)}else void 0!==n.translation&&o.position.fromArray(n.translation),void 0!==n.rotation&&o.quaternion.fromArray(n.rotation),void 0!==n.scale&&o.scale.fromArray(n.scale);return i.associations.has(o)||i.associations.set(o,{}),i.associations.get(o).nodes=e,i.options.myOptions.helper.processNode({node:o,nodeDef:n})||o}))}loadScene(e){var t=this.json,r=this.extensions;e=this.json.scenes[e];const i=this;i.options.myOptions;const n=new s.Group;e.name&&(n.name=i.createUniqueName(e.name)),Co(n,e),e.extensions&&Po(r,n,e);var a=e.nodes||[];const o=[];for(let e=0,r=a.length;e<r;e++)o.push(function e(t,r,i,n){const a=i.nodes[t];return n.getDependency("node",t).then((function(e){if(void 0===a.skin)return e;let t;return n.getDependency("skin",a.skin).then((function(e){t=e;const r=[];for(let e=0,s=t.joints.length;e<s;e++)r.push(n.getDependency("node",t.joints[e]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){const i=[],n=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){i.push(a);const r=new s.Matrix4;void 0!==t.inverseBindMatrices&&r.fromArray(t.inverseBindMatrices.array,16*e),n.push(r)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new s.Skeleton(i,n),e.matrixWorld)}})),e}))})).then((function(t){r.add(t);const s=[];if(a.children){const r=a.children;for(let a=0,o=r.length;a<o;a++){const o=r[a];s.push(e(o,t,i,n))}}return Promise.all(s)}))}(a[e],n,t,i));return Promise.all(o).then((function(){return console.log(n,n.children,"scene"),i.options.myOptions?.models.push(n),i.associations=(e=>{const t=new Map;for(var[r,n]of i.associations)(r instanceof s.Material||r instanceof s.Texture)&&t.set(r,n);return e.traverse((e=>{var r=i.associations.get(e);null!=r&&t.set(e,r)})),t})(n),n}))}}function Do(e,t,r){var i=t.attributes;const n=[];for(const t in i){var a=Mo[t]||t.toLowerCase();a in e.attributes||n.push(function(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}(i[t],a))}void 0===t.indices||e.index||(o=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),n.push(o)),Co(e,t);{var o=e,l=t,h=r,c=l.attributes;const i=new s.Box3;if(void 0!==c.POSITION){var u=(c=h.json.accessors[c.POSITION]).min,d=c.max;if(void 0===u||void 0===d)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{i.set(new s.Vector3(u[0],u[1],u[2]),new s.Vector3(d[0],d[1],d[2])),c.normalized&&(u=Ao(xo[c.componentType]),i.min.multiplyScalar(u),i.max.multiplyScalar(u));var p=l.targets;if(void 0!==p){const e=new s.Vector3,t=new s.Vector3;for(let r=0,s=p.length;r<s;r++){var m,f,g=p[r];void 0!==g.POSITION&&(f=(g=h.json.accessors[g.POSITION]).min,m=g.max,void 0!==f&&void 0!==m?(t.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),t.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),t.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),g.normalized&&(f=Ao(xo[g.componentType]),t.multiplyScalar(f)),e.max(t)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}i.expandByVector(e)}o.boundingBox=i;const e=new s.Sphere;i.getCenter(e.center),e.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=e}}}return Promise.all(n).then((function(){if(void 0===t.targets)return e;{var s=e,i=t.targets,n=r;let h=!1,c=!1,u=!1;for(let e=0,t=i.length;e<t;e++){var a=i[e];if(void 0!==a.POSITION&&(h=!0),void 0!==a.NORMAL&&(c=!0),void 0!==a.COLOR_0&&(u=!0),h&&c&&u)break}if(!h&&!c&&!u)return Promise.resolve(s);const d=[],p=[],m=[];for(let e=0,t=i.length;e<t;e++){var o,l=i[e];h&&(o=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):s.attributes.position,d.push(o)),c&&(o=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):s.attributes.normal,p.push(o)),u&&(l=void 0!==l.COLOR_0?n.getDependency("accessor",l.COLOR_0):s.attributes.color,m.push(l))}return Promise.all([Promise.all(d),Promise.all(p),Promise.all(m)]).then((function(e){var t=e[0],r=e[1];return e=e[2],h&&(s.morphAttributes.position=t),c&&(s.morphAttributes.normal=r),u&&(s.morphAttributes.color=e),s.morphTargetsRelative=!0,s}))}}))}function Lo(e,t){let r=e.getIndex();if(null===r){const t=[];var i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}var n=r.count-2;const a=[];if(t===s.TriangleFanDrawMode)for(let e=1;e<=n;e++)a.push(r.getX(0)),a.push(r.getX(e)),a.push(r.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(a.push(r.getX(e)),a.push(r.getX(e+1)),a.push(r.getX(e+2))):(a.push(r.getX(e+2)),a.push(r.getX(e+1)),a.push(r.getX(e)));a.length/3!=n&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(a),o}class Io{constructor(){this.materialMap={},this.textureMap={},this.materialIns={},this.textureIns={},this.parser=null}processInput(e,t){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){this.parser=t}))}processTexture(e){const{textureDef:t,texture:r}=e;r.userData.md5=t.md5,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||{})}processTextureMap(e){(0,D.js)(e,((e,t)=>{var{format:t,center:r,rotation:s,offset:i,repeat:n}=t;const a=this.textureIns[e];a&&(a.format=t,void 0!==n&&(({x:e,y:t}="object"==typeof n?n:{x:n,y:n}),a.repeat.x=e,a.repeat.y=t),void 0!==r&&(({x:n,y:e}="object"==typeof r?r:{x:r,y:r}),a.center.x=n,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),s&&(a.rotation=s),gl.bindData(a))}))}processMaterialMap(e){(0,D.js)(e,((e,t)=>{const{material:r,models:s}=this.materialIns[e];if(r){var{normal:e,textures:i}=t;if(e.type){const t=(0,D.js)(i,((e,t)=>({type:e,texture:this.textureIns[t]}))),n=Ml.getDataByType(e.type,{normal:e,textures:t,models:s,material:r});if(Ml.parseNromals(e,n),!n)return;s.map((e=>e.material=n))}else(0,D.js)(i,((e,t)=>{(t=this.textureIns[t])&&(gl.bindData(t),pl.texture.addMaterial(t,{material:r,type:e}),r[e]=t)})),Ml.parseNromals(e,r),s.map((e=>e.material=r));r.needsUpdate=!0}}))}}class Oo{done(e){var t,r,s,i;e.asset.ex&&(({camera:e,lights:t,sceneEx:r,options:s,controls:i}=e.asset.ex),this.camera(e),this.controls(i),this.lights(t),this.ex(r),this.options(s))}controls(e){var t,r;e&&(({x:e,y:t,z:r}=e),yl.controls.target.set(e,t,r),yl.controls.update())}camera(e){var{position:e,far:t,near:r,fov:s,name:i,userData:n}=Cl.object.parse(e);const a=yl.get().camera;a.position.copy(e),a.far=t,a.near=r,a.fov=s,a.name=i,a.updateProjectionMatrix(),a.userData.id=n.id,pl.model.add(a),yl.get().controls.update()}lights(e){e.map((e=>{var t=e.type;(t=k[t].parseJSON(e)).target&&Pl.setSelectByModel(t.target),Al.setNull(t)}))}ex(e){var t,r;e=e.fog;const i=Sl.get();e&&(({color:e,near:t,far:r}=e),i.fog=new s.Fog(e,t,r),ml.cb.setScene.cb({scene:i,type:"fog"}))}options(e){e.map((e=>{var{type:e,data:t}=e;const r=B.getParse(e);null!=r&&r.parse(t)}))}}class Uo{constructor(){this.material=new Io,this.scene=new Oo,this.parser=null,this.helperModels=[],this.nodeType={MySpriteMaterial:Jr}}processInput(e,t){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.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){Cl.gltf.beforeParse(null==(e=null==(e=e.asset)?void 0:e.ex)?void 0:e.type)}processNode(e){let{node:t,nodeDef:r}=e;if((0,D.js)(Pl.defNodeMap,((e,s)=>{t[e]=r[e]})),r.extras){var{layers:e,normal:s}=r.extras;if(e&&(t.layers.enable(1),ml.cb.model.setLayers.cb({model:t,val:1})),r.extras.isHelper&&this.helperModels.push(t),s){const r=this.nodeType[null==s?void 0:s.type].modelTools.parseData(t,s);if(s=null==(s=null==(e=null==t?void 0:t.material)?void 0:e.userData)?void 0:s.id){const e=this.material.materialIns[s];if(e){const s=[];e.models.map((e=>{e===t?s.push(r):s.push(e)})),e.models=s}}t=r}}return r.wireframe&&(t.material.wireframe=!0),t}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()}sceneEx(e){const t=Sl.get();var r=this.material.materialIns,{materialId:e,backgroundMapping:i,backgroundColor:n,fog:a}=e.asset.ex.sceneEx;if(e&&(e=null==(r=r[e])?void 0:r.material)){const{map:r,envMap:s}=e;r&&(r.mapping=i||300,r.needsUpdate=!0,Sl.setBackground(r,!1),r.userData.isBackgroud=!0),s&&(t.environment=gl.toThree(s))}n&&(t.background=new s.Color("#"+n)),a&&(({color:r,far:e,near:i}=a),t.fog=new s.Fog("#"+r,i,e),t.fog.open="true"),ml.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 ko{constructor(){var e;this.dracoPath="./draco/",this._gltf=new Za;const t=new Ga;t.setDecoderPath((null==(e=null==ml?void 0:ml.options)?void 0:e.decodePath)||this.dracoPath),this._gltf.dracoLoader=t}parse(e){return new Promise((t=>{try{e instanceof ArrayBuffer&&this._gltf.parse(e,"",(e=>{t(e),this.afterParse(e.parser.options.myOptions,e)}),(()=>{}),{rootModel:yl.get().scene,models:[],helper:new Uo})}catch(e){console.log(e,"e")}}))}beforeParse(e){"scene"===e&&Sl.clean()}afterParse(e,t){e=e.models[0].children.filter((e=>{if(!Pl.isUnless(e))return e.userData.id=(0,S.getId)(),e})),Pl.add(e,void 0,!1,!1,!1),"scene"===t.asset.ex.type&&El.parseSavedGroupMap(t.asset.ex.timeLine||{}),Pl.selectNull(),Tl.unfocus()}}class Bo{static create(){return new s.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],i=e[t];if(r instanceof s.Color){if(r.getHexString()!==i.getHexString())return!1}else if("object"==typeof r){if(i.x!==r.x)return!1}else if(i!==r)return!1}for(const t of Fr)if(e[t])return!1;return!0}}function No(e){if("object"!=typeof e)return e;if(null===e)return null;if(e){var t,r,s=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=No(e[t]),s[t]=r);return s}}Bo.defVal={color:new s.Color(16777215),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new s.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class Fo{static create(){const e=new s.ShaderMaterial({uniforms:No(zo.uniforms),vertexShader:zo.vertexShader,fragmentShader:zo.fragmentShader});return e.userData.tools=Fo.tools,e}static undo(e){var{material:e,list:t,val:r}=e;fl.addUndo(new I({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}Fo.e=null,Fo.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"],Fo.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,i=new s.ShaderMaterial({uniforms:No(zo.uniforms),vertexShader:zo.vertexShader,fragmentShader:zo.fragmentShader});return t.forEach((e=>{"ceilingTex"===e.type?i.uniforms.ceilingTex.value=e.texture||null:"floorTex"===e.type?i.uniforms.floorTex.value=e.texture||null:"sideWallTex"===e.type?i.uniforms.sideWallTex.value=e.texture||null:"backWallTex"===e.type&&(i.uniforms.backWallTex.value=e.texture||null)})),Object.keys(r.uniforms).filter((e=>!Fo.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];i.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new s.Vector4(t.x,t.y,t.z,t.w):t})),i.userData.tools=Fo.tools,i},toNormal:e=>{const t=Ml.create(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Fo.tools.type,uniforms:{}},textures:Fo.tools.getTextures(e)}),{}),i=e.uniforms,n=zo.uniforms;return Object.keys(i).filter((e=>!Fo.TextureNames.includes(e))).map((e=>{var t,a,o,l,h,c,u=i[e].value,d=n[e].value;u instanceof s.Vector4?(({x:t,y:a,z:o}=u),({x:l,y:h,z:c}=d),t===l&&a===h&&o===c||(r[e]=u)):(console.log(u,d,"val,defVal"),u!==d&&(r[e]=u))})),console.log(r,"uniforms"),t.userData.normal.uniforms=r,console.log(t,"newMaterial"),t},clone:function(e,t){return e}};const zo={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new s.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 s.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new s.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 "},jo={uniforms:{tDiffuse:new s.Uniform(null),h:new s.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}"},Vo={uniforms:{tDiffuse:new s.Uniform(null),v:new s.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 s.Uniform(null),new s.Uniform(null),new s.Uniform(0),new s.Uniform(0),new s.Uniform(0),new s.Uniform(new s.Vector2),new s.Uniform(.1),new s.Uniform(1e3);class Ho{static create(e){const t=new Go(void 0,void 0),r=(t.insertReflectorShader(),t.userData.tools=Ho.tools,e||Pl.select);return r&&(t.name=r.name),ml.cb.render.add("Reflector-"+t.name+"-"+(0,S.getId)(),(()=>{t.update(r)})),t}static undo(e){var{material:e,list:t,val:r}=e;fl.addUndo(new I({target:e,typeList:[...t],newVal:r}).execute())}}Ho.e=null,Ho.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"],Ho.tools={type:"Reflector",getTextures:e=>Ml.getAllTextures(e),parseData:e=>{const{textures:t,normal:r,models:s,material:i}=e,n=Ml.merge(i,new Go);return n.name=i.name,t.forEach((e=>{n[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!Ho.TextureNames.includes(e))).map((e=>{n[e]=r.uniforms[e]})),n.setRTSize(n.resolution),n.setBlurPass(n.blurSize),n.insertReflectorShader(),n.userData.tools=Ho.tools,ml.cb.render.add("Reflector-"+n.name+"-"+(0,S.getId)(),(()=>{n.update(s[0])})),n},toNormal:e=>{const t=Ml.merge(e,Ml.create()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Ho.tools.type,uniforms:{}},textures:Ho.tools.getTextures(e)}),t.name=e.name,{}),s=Wo.uniforms;return Object.keys(s).filter((e=>!Ho.TextureNames.includes(e))).map((t=>{var i=e[t],n=s[t].value;"mirror"===t||"mixBlur"===t||"mixStrength"===t||"mixContrast"===t?i.value!==n&&(r[t]=i):i!==n&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>Ho.create(t)};class Go extends s.MeshStandardMaterial{constructor(e,t){e?super(e):(super(),this.opacity=Wo.uniforms.opacity.value,this.transparent=Wo.uniforms.transparent.value,this.roughness=Wo.uniforms.roughness.value,this.metalness=Wo.uniforms.metalness.value),t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new s.Uniform(t.mirror),this.mixBlur=new s.Uniform(t.mixBlur),this.mixStrength=new s.Uniform(t.mixStrength),this.mixContrast=new s.Uniform(t.mixContrast)):(this.resolution=Wo.uniforms.resolution.value,this.blurSize=Wo.uniforms.blurSize.value,this.mirror=new s.Uniform(Wo.uniforms.mirror.value),this.mixBlur=new s.Uniform(Wo.uniforms.mixBlur.value),this.mixStrength=new s.Uniform(Wo.uniforms.mixStrength.value),this.mixContrast=new s.Uniform(Wo.uniforms.mixContrast.value)),this.textureMatrix=new s.Uniform(new s.Matrix4),this.reflectorWorldPosition=new s.Vector3,this.cameraWorldPosition=new s.Vector3,this.rotationMatrix=new s.Matrix4,this.normal=new s.Vector3,this.view=new s.Vector3,this.lookAtPosition=new s.Vector3,this.target=new s.Vector3,this.tempQuaternion=new s.Vector4,this.virtualCamera=new s.PerspectiveCamera,this.reflectorPlane=new s.Plane,this.clipPlane=new s.Vector4,e={minFilter:s.LinearFilter,magFilter:s.LinearFilter,type:s.HalfFloatType,encoding:yl.get().renderer.outputEncoding},this.glRT1=new s.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new s.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new s.Uniform(this.glRT1.texture),this.tDiffuseBlur=new s.Uniform(this.glRT2.texture),this.hBlurPass=new u(jo),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 u(Vo),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=Wo.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",Wo.vertexShader),e.fragmentShader=Wo.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",Wo.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(yl.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(yl.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=yl.get().camera.far,this.virtualCamera.updateMatrixWorld(),this.virtualCamera.projectionMatrix.copy(yl.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,yl.get().renderer.setRenderTarget(this.glRT1),yl.get().renderer.clear(),yl.get().renderer.render(yl.get().scene,this.virtualCamera),this.hBlurPass&&this.hBlurPass.enabled&&(this.hBlurPass.render(yl.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),this.vBlurPass&&this.vBlurPass.enabled&&(this.vBlurPass.render(yl.get().renderer,this.glRT2,this.glRT1,0,!1),this.swapBuffers()),e.visible=!0,yl.get().renderer.setRenderTarget(null))}}const Wo={uniforms:{opacity:new s.Uniform(1),transparent:new s.Uniform(!1),roughness:new s.Uniform(1),metalness:new s.Uniform(.6),resolution:new s.Uniform(1024),blurSize:new s.Uniform(1024),mirror:new s.Uniform(0),mixBlur:new s.Uniform(10),mixStrength:new s.Uniform(2),mixContrast:new s.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 Xo{static create(e){console.log("Fresnel Create");const t=new Yo;return t.insertFresnelShader(),t.userData.tools=Xo.tools,(e=e||Pl.select)&&(t.name=e.name),t}static undo(e){var{material:e,list:t,val:r}=e;fl.addUndo(new I({target:e,typeList:[...t],newVal:r}).execute())}}Xo.TextureNames=["envMap"],Xo.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:s}=e,i=Ml.merge(s,new Yo);return i.name=s.name,t.forEach((e=>{i[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!Xo.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.insertReflectorShader(),i.userData.tools=Xo.tools,i},toNormal(e){const t=Ml.merge(e,Ml.create()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:Xo.tools.type,uniforms:{}},textures:Xo.tools.getTextures(e)}),t.name=e.name,{}),s=Zo.uniforms;return Object.keys(s).filter((e=>!Xo.TextureNames.includes(e))).map((t=>{var i=e[t],n=s[t].value;"fresnelBias"===t||"fresnelScale"===t||"fresnelPower"===t?i.value!==n&&(r[t]=i):i!==n&&(r[t]=i)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>Xo.create(t)};class Yo extends s.MeshPhysicalMaterial{constructor(e,t){if(e?super(e):(super(),this.emissive=new s.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),t?(this.fresnelBias=new s.Uniform(t.fresnelBias),this.fresnelScale=new s.Uniform(t.fresnelScale),this.fresnelPower=new s.Uniform(t.fresnelPower)):(this.fresnelBias=new s.Uniform(Zo.uniforms.fresnelBias.value),this.fresnelScale=new s.Uniform(Zo.uniforms.fresnelScale.value),this.fresnelPower=new s.Uniform(Zo.uniforms.fresnelPower.value)),!Yo.cubeCamera){const e=new s.WebGLCubeRenderTarget(2048);e.texture.mapping=s.CubeRefractionMapping,Yo.cubeCamera=new s.CubeCamera(.1,1e5,e),yl.scene.add(Yo.cubeCamera),console.log("cubeCamera"),ml.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,Zo.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,Zo.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,Zo.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,Zo.fragmentShaderEmissive)}}update(){Yo.cubeCamera&&(Yo.cubeCamera.position.copy(yl.camera.position),Yo.cubeCamera.update(yl.renderer,yl.scene))}}const Zo={uniforms:{fresnelBias:new s.Uniform(0),fresnelScale:new s.Uniform(1),fresnelPower:new s.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 "},Qo={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},qo=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];t=a(356);var Ko=a.n(t);const Jo=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"],$o=class extends L{constructor(e){super(),this.type="修改父元素",this.oldParent=e.oldParent,this.newParent=e.newParent,this.target=e.target}execute(){return this.redo(),this}_execute(e){e.attach(this.target),ml.cb.model.setParent.cb({model:this.target,parent:e})}undo(){this._execute(this.oldParent)}redo(){this._execute(this.newParent)}},el=class extends L{constructor(e){super(),this.type="三维矩阵修改";var{target:e,info:t,newV3:r,oldV3:s}=e;this.target=e,this.info=t,this.newV3=r,this.oldV3=s,this.target.uuid===(null==(e=Pl.select)?void 0:e.uuid)&&(ml.cb.model.setSelect.cb(null),ml.cb.model.setSelect.cb(this.target))}_execute(e){console.log(e,"data"),this.target[this.info].copy(e),this.target.uuid===(null==(e=Pl.select)?void 0:e.uuid)&&Tl.focus(this.target)}execute(){return this.redo(),this}undo(){this._execute(this.oldV3)}redo(){console.log(1,"1"),this._execute(this.newV3)}};var tl=a(639);class rl{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 sl{constructor(){this.resize=new rl,this.setSelectMaterial=new rl,this.setScene=new rl,this.reset=new rl,this.render=new rl,this.baseLog=new rl,this.inited=new rl,this.texture={add:new rl,remove:new rl},this.model={setSelect:new rl,add:new rl,remove:new rl,multipDrop:new rl,focus:new rl,unFocus:new rl,changeName:new rl,setOpen:new rl,setMainStatue:new rl,setVisible:new rl,setParent:new rl,setLayers:new rl,clone:new rl},this.material={add:new rl,dispose:new rl,setName:new rl},this.unique={material:{add:new rl}},this.undo={addUndos:new rl,removeUndos:new rl,undoByIndex:new rl,reset:new rl},this.scene={save:new rl,saveNet:new rl},this.timeLine={setProgress:new rl,playGroup:new rl,setGroupMap:new rl,reset:new rl,closeGroup:new rl},this.events={key:{g:new rl}},this.bloom={glow:{setData:new rl}}}}function il(){var e=0,t=document.createElement("div");function r(e){return t.appendChild(e.dom),e}function s(r){for(var s=0;s<t.children.length;s++)t.children[s].style.display=s===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(),s(++e%t.children.length)}),!1);var i,n=(performance||Date).now(),a=n,o=0,l=r(new il.Panel("FPS","#0ff","#002")),h=r(new il.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=r(new il.Panel("MB","#f08","#201"))),s(0),{REVISION:16,dom:t,addPanel:r,showPanel:s,begin:function(){n=(performance||Date).now()},end:function(){o++;var e,t=(performance||Date).now();return h.update(t-n,200),a+1e3<=t&&(l.update(1e3*o/(t-a),100),a=t,o=0,i&&(e=performance.memory,i.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){n=this.end()},domElement:t,setMode:s}}il.Panel=function(e,t,r){var s=1/0,i=0,n=Math.round,a=n(window.devicePixelRatio||1),o=80*a,l=48*a,h=3*a,c=2*a,u=3*a,d=15*a,p=74*a,m=30*a,f=document.createElement("canvas"),g=(f.width=o,f.height=l,f.style.cssText="width:80px;height:48px",f.getContext("2d"));return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=r,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(u,d,p,m),{dom:f,update:function(l,v){s=Math.min(s,l),i=Math.max(i,l),g.fillStyle=r,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(n(l)+" "+e+" ("+n(s)+"-"+n(i)+")",h,c),g.drawImage(f,u+a,d,p-a,m,u,d,p-a,m),g.fillRect(u+p-a,d,a,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(u+p-a,d,a,n((1-l/v)*m))}}};const nl=il;class al{constructor(e){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,s)=>{const i={},n={};if(e=al.isNotNow(e)?this.getAllData():e,(0,D.js)(s,((r,s)=>{void 0!==e[r]&&("number"===(s=s.type)?(i[r]=t[r],n[r]=e[r]):"color"===s&&(0,D.js)(e[r],((e,s)=>{var a=r+e;i[a]=t[r][e],n[a]=s})))})),!(0,D.CV)(i))return{begin:i,end:n}};return(t,r,s,i=!1,n)=>{let a=i?s.time:0;const o=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var l=(0,E.lastArrayEle)(o),h=i?"0.00":String(s.time);return l!==h&&(t[h]=Object.assign({},l),o.push(h)),o.map((o=>{var l=t[String(o)],h=.001*((h=i?a-o:o-a)<=0?.001:h)*s.speed;a=o;{var c=r,u=l,d=h,p=n;const t={color(e){const{animaData:t,defType:r}=e,s={};(0,D.js)(t,(e=>{var i;-1!==e.indexOf(r)&&(i=e.substring(r.length),["r","g","b"].includes(i)&&(s[i]=t[e]))}));var{r:e,g:i,b:n}=s;if((0,tl.isTrue)(e)&&(0,tl.isTrue)(i)&&(0,tl.isTrue)(n))return s}};return()=>{let r;return{promise:new Promise((s=>{var i=e(u,c,0,p);if(console.log(i,"leftAndRight"),!i)return s(0);var{begin:i,end:n}=i;return r=Hr(i,n,d,(e=>{(0,D.js)(p,((r,s)=>{s=s.type;var i,n=e[r];"number"===s?c[r]=n:"color"===s&&(n=t.color({animaData:e,defType:r}))&&(({r:s,g:n,b:i}=n),c[r].setRGB(s,n,i))}))}),s)})),anima:r}}}}))}})(),this.target=e,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 s={};return(0,D.js)(e,(i=>{s[i]=r?"notNow":al.getValByType(t,i,e)})),s}static getValByType(e,t,r){var s,i;return r=r[t].type,e=e[t],"number"===r?e:"color"===r?(({r:t,g:s,b:i}=e),{r:t,g:s,b:i}):"V3"===r?Ko().model.v3ToMap(e):""}static SetTargetByData(e){const{baseType:t,data:r,defType:s,target:i}=e;var n,a;"number"===t?i[s]=r:"color"===t&&(({r:e,g:n,b:a}=r),i[s].setRGB(e,n,a))}getAllData(e=!1){return al.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return al.getValByType(this.target,e,this.defOptions)}static getTarget(e){}getAnima(e,t){return this.getAnimaByModelData(this.data,this.target,e,t,this.defOptions)}setTargetByBetween(e,t,r){al.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const s=new(0,ll[r])(e);return s.data=t,s}reset(){(0,D.js)(this.defOptions,((e,t)=>{al.SetTargetByData({baseType:t.type,data:al.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}}al.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,s,i,n)=>{(0,D.js)(i,((i,a)=>{var o,l,h,c,u,d;a=a.type,void 0!==t[i]&&void 0!==r[i]&&al.SetTargetByData({baseType:a,data:(o=t[i],l=r[i],h=s,"number"===a?e(o,l,h):"color"===a?(({r:a,g:o,b:c}=o),({r:l,g:u,b:d}=l),{r:e(a,l,h),g:e(o,u,h),b:e(c,d,h)}):void 0),defType:i,target:n})}))}})();const ol=al,ll={model:class extends ol{constructor(e){super(e),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:s,z:i}=e,{x:t,y:n,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:s!==n?(n-s)*r+s:s,z:i!==a?(a-i)*r+i:i}};return(t,r,s)=>{var i,{position:t,scale:n,rotation:a}=t,{position:r,scale:o,rotation:l}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,s)),this.target.position.set(t,r,i)),n&&o&&(({x:t,y:r,z:i}=e(n,o,s)),this.target.scale.set(t,r,i)),a&&l&&(({x:n,y:o,z:t}=e(a,l,s)),this.target.rotation.set(n,o,t))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:s,rotation:i}=t,{position:e,scale:n,rotation:a}=ol.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},n?{sx:s.x,sy:s.y,sz:s.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}:{},n?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{})}};return(t,r,s,i=!1)=>{let n=i?s.time:0;const a=Object.keys(t).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var o=(0,E.lastArrayEle)(a),l=i?"0.00":String(s.time)+".00";return o!==l&&(console.log(o,"last"),t[l]={position:"notNow",rotation:"notNow",scale:"notNow"},a.push(l)),a.map((a=>{var o,l,h,c,u=t[String(a)],d=.001*((d=i?n-a:a-n)<=0?.001:d)*s.speed;return n=a,o=r,l=u,h=d,c=s,()=>{let t;return{promise:new Promise((r=>{var{begin:s,end:i}=e(l,o,c);return t=Hr(s,i,h,(e=>{var{px:e,py:t,pz:r,sx:s,sy:i,sz:n,rx:a,ry:h,rz:c}=e;l.position&&o.position.set(e,t,r),l.scale&&o.scale.set(s,i,n),l.rotation&&o.rotation.set(a,h,c)}),r)})),anima:t}}}))}})(),this.beginData=this.getAllData()}static getTarget(e){return pl.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 pl.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 ol{constructor(e){super(e),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:s,z:i}=e,{x:t,y:n,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:s!==n?(n-s)*r+s:s,z:i!==a?(a-i)*r+i:i}};return(t,r,s)=>{var i,{position:t,scale:n,rotation:a,target:o}=t,{position:r,scale:l,rotation:h,target:c}=r;t&&r&&(({x:t,y:r,z:i}=e(t,r,s)),this.target.position.set(t,r,i)),n&&l&&(({x:t,y:r,z:i}=e(n,l,s)),this.target.scale.set(t,r,i)),a&&h&&(({x:n,y:l,z:t}=e(a,h,s)),this.target.rotation.set(n,l,t)),o&&c&&(({x:r,y:i,z:a}=e(o,c,s)),this.controls.target.set(r,i,a))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:s,rotation:i}=t,{position:e,scale:n,rotation:a,target:o}=ol.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},n?{sx:s.x,sy:s.y,sz:s.z}:{},a?{rx:i.x,ry:i.y,rz:i.z}:{},o?{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}:{},n?{sx:n.x,sy:n.y,sz:n.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{},o?{tx:o.x,ty:o.y,tz:o.z}:{})}},t=(t,r,s,i)=>()=>{let n;return{promise:new Promise((a=>{var{begin:o,end:l}=e(r,t,i);return n=Hr(o,l,s,(e=>{var{px:e,py:s,pz:i,sx:n,sy:a,sz:o,rx:l,ry:h,rz:c,tx:u,ty:d,tz:p}=e;r.position&&t.position.set(e,s,i),r.scale&&t.scale.set(n,a,o),r.rotation&&t.rotation.set(l,h,c),r.target&&this.controls.target.set(u,d,p)}),a)})),anima:Hr}};return(e,r,s,i=!1)=>{let n=i?s.time:0;const a=Object.keys(e).sort(((e,t)=>i?Number(t)-Number(e):Number(e)-Number(t)));var o=(0,E.lastArrayEle)(a),l=i?"0.00":String(s.time);return o!==l&&(e[l]=Object.assign({},o),a.push(l)),a.map((a=>{var o=e[String(a)],l=.001*((l=i?n-a:a-n)<=0?.001:l)*s.speed;return n=a,t(r,o,l,s)}))}})(),this.controls=yl.get().controls,this.beginData=this.getAllData()}static getTarget(e){return pl.model.get(e)}getBeginData(e){return this.getAllData()}isRemoved(){return!this.target}getAllData(e=!1){var{position:t,scale:r,rotation:s}=this.target;return{position:e?"notNow":Ko().model.v3ToMap(t),scale:e?"notNow":Ko().model.v3ToMap(r),rotation:e?"notNow":Ko().model.v3ToMap(s),target:e?"notNow":Ko().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:s}=this.target;let i;if("position"===e)i=Ko().model.v3ToMap(t);else if("scale"===e)i=Ko().model.v3ToMap(r);else if("rotation"===e)i=Ko().model.v3ToMap(s);else{if("target"!==e)throw TypeError("输入值不存在");i=Ko().model.v3ToMap(this.controls.target)}return i}getAnima(e,t=!1){return this.getAnimaByModelData(this.data,this.target,e,t)}getId(){return pl.getId(this.target)}reset(){var{position:e,scale:t,rotation:r,target:s}=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(s.x,s.y,s.z)}},material:class extends ol{constructor(e){super(e),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){return pl.material.get(e)}isRemoved(){return!0}getId(){return pl.getId(this.target)}}};class hl{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){let s=e.userData.id;s||(s=(0,S.getId)(),e.userData.id=s),this.map[s]||(this.map[s]={material:e,models:new Set},ml.cb.unique.material.add.cb(e),t&&this.addModel(t,e,r))}addModel(e,t,r){t&&(t=t.userData.id,null!=(t=this.map[t])&&t.models.add(e)),r&&null!=(t=this.map[r.userData.id])&&t.models.delete(e)}get(e){return null==(e=this.map[e])?void 0:e.material}remove(e){delete this.map[e]}addRemoved(e){this.map[e.uuid]&&(this.removes.push(e.uuid),console.log("添加材质到移除列表",e,"material"))}dispose(){(0,D.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var cl=a(1);class ul 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,S.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),cl.type.isNumber(e)?Number.parseInt(e):-1)},t=(r,s)=>{var i=(t=>{if(-1===e(t))return t;var r=t.lastIndexOf("_");return-1===r?t:t.slice(0,r)})(r)+"_"+s++;return this.nameMap[i]?t(r,s):i},r=["PerspectiveCamera"];return s=>{if(r.includes(s.type))return s.name=s.type;let i=s.name;if(cl.valid.isTrue(i)||(i=s.type),this.nameMap[i]){var n=this.nameMap[i];if(this.unique.model.get(n)!==s)return n=-1===(n=e(i))?0:n,n=t(i,n),this.nameMap[n]=this.unique.getId(s),s.name=n}else this.nameMap[i]=this.unique.getId(s)}})()}add(e,t){var{reset:r,hasReset:s}=t||{};if(e instanceof Array)return e.map((e=>this.add(e,t)));if(e){let i=e.userData.id;if(i&&!r||(i=(0,S.getId)(),e.userData.id=i),this.map[i]){if(!s)return;i=(0,S.getId)(),e.userData.id=i}return this.map[i]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):i}}get(e){return this.map[e]}getByName(e){return this.nameMap[e]}remove(e){if(e instanceof Array)return e.map((e=>this.remove(e)));e.traverse((e=>{delete this.nameMap[e.name]})),delete this.map[e.userData.id]}dispose(){this.map={},this.nameMap={}}}class dl{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,S.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 s=e.userData.id;this.map[s]||this.add(e),t&&(({material:e,type:t}=t),this.map[s].materialMap[e.userData.id]||(this.map[s].materialMap[e.userData.id]=new Set),this.map[s].materialMap[e.userData.id].add(t)),r&&(({material:e,type:t}=r),this.map[s].materialMap[e.userData.id]&&this.map[s].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,D.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}const pl=new class{constructor(){this.model=new ul(this),this.material=new hl(this),this.texture=new dl(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}};new class{constructor(){this.parses={fbx:new Bn,obj:new pa}}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 ma(this,void 0,void 0,(function*(){var t=yield(0,W.toResult)(e,"arrayBuffer");return Cl.gltf.parse(t)}))}fbx(e){return ma(this,void 0,void 0,(function*(){var t=yield(0,W.toResult)(e,"arrayBuffer");const r=this.parses.fbx.parse(t,"");r.traverse((e=>{e.material&&(e.material=Ml.create())})),Pl.add(Sl.cleanUnlessLevel(r))}))}obj(e){return ma(this,void 0,void 0,(function*(){var t=yield(0,W.toResult)(e,"text");const r=this.parses.obj.parse(t);r.traverse((e=>{e.material&&(e.material=Ml.create())})),Pl.add(Sl.cleanUnlessLevel(r))}))}};const ml=new class{constructor(){this.options={msg:{show:!0,level:"base"},run:!0,decodePath:"./draco/",showFps:!1,loadInterval:2e3},this.exporterOptions={compressTexture:!1,notMaterial:!1},this.setLoadInterval=(()=>{let e=null;return t=>{const{inputInterval:r,cb:s}=t;e&&clearTimeout(e),e=setTimeout((()=>{s(),e=null,clearTimeout(e)}),r)}})(),this.cb=new sl}init(e){this.options=Object.assign(this.options,e),this.options.showFps&&(this.addFps(),ml.cb.render.add("optionx-ex-render",this.render.bind(this)))}addFps(){this.stats=nl(),this.stats.showPanel(0),yl.engineDom.appendChild(this.stats.dom)}render(){var e;null!=(e=this.stats)&&e.update()}log(e,t="detail",r="succees"){var s;null!=(s=null==(s=this.options)?void 0:s.msg)&&s.show&&("base"===this.options.msg.level&&"base"===t&&ml.cb.baseLog.cb(e,r),console.log(e))}},fl=new class{constructor(){this.undos=[],this.redos=[],this.dataMap={history:[],index:0}}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,ml.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,ml.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,ml.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,ml.cb.undo.reset.cb(""),console.log(this,"this")}},gl=new class{constructor(){this.allTextures=new Set}loadImagBit(e){return createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"})}load(e){return jr(this,void 0,void 0,(function*(){var t=new s.CanvasTexture(yield this.loadImagBit(yield Wr(e)));return this.afterLoad(e,t)}))}clone(e){const t=new s.Texture(e.image);return t.userData=Object.assign({},e.userData),this._afterLoad(t)}getDef(e){return e=new s.Texture(e),this._afterLoad(e)}toThree(e){return e.mapping=C.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 s=this.getSameTexture(t,e);return s?(e.dispose(),s):(e.userData.url=URL.createObjectURL(r),e.userData.md5=t,e.format=-1!==r.type.indexOf("png")?1023:1022,e.needsUpdate=!0,e.flipY=!1,this.addToAllTextures(e),e)}afterLoad(e,t){return jr(this,void 0,void 0,(function*(){const r=yield Wr(e);t.userData.blob=r;var s=Xr(yield r.arrayBuffer());return t.userData.url=URL.createObjectURL(r),t.userData.md5=s,this._afterLoad(t)}))}getSameTexture(e,t){for(const s in pl.texture.map){var r=pl.texture.get(s);if(r.userData.md5===e&&r.mapping===t.mapping)return r}}bindData(e){return jr(this,void 0,void 0,(function*(){if(this.setTexture(e),this.addToAllTextures(e),!e.userData.blob){const t=yield this.getBlob(e);return e.userData.md5=Xr(yield t.arrayBuffer()),e.userData.blob=t,e.userData.url=URL.createObjectURL(t),e}}))}setTexture(e){return e.magFilter=1003,e.wrapS=C.RepeatWrapping,e.wrapT=C.RepeatWrapping,e.encoding=3e3,e.needsUpdate=!0,e.version=3,e}addToAllTextures(e){var t=pl.texture.getLength();pl.texture.add(e),pl.texture.getLength()!==t&&(this.setTexture(e),ml.cb.texture.add.cb(e))}parse(e){return jr(this,void 0,void 0,(function*(){var t=yield(e=>Vr(void 0,void 0,void 0,(function*(){{let t=(yield(0,W.toResult)(e,"base64")).split(","),r=t[0].match(/:(.*?);/)[1],s=atob(t[1]),i=s.length,n=new Uint8Array(i);for(;i--;)n[i]=s.charCodeAt(i);return new Blob([n],{type:r})}})))(e);return this.afterLoad(URL.createObjectURL(t),new s.Texture(yield this.loadImagBit(t)))}))}getBlob(e){return e.userData.blob||(e=>Vr(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)}))}))})))(e.image)}getUrl(e){return console.log(e,"texture"),e.userData.url}getBlobAndBase64(e){return e.userData.blob?e.userData:(e=>Vr(void 0,void 0,void 0,(function*(){var t=e.image;const r=document.createElement("canvas"),s=(r.width=t.width,r.height=t.height,r.getContext("2d")),i=1023===e.format?"image/png":"image/jpeg";return s.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(i)})}),i)}))})))(e)}dispose(e){e.dispose()}reverseY(e){return createImageBitmap(e,{imageOrientation:"flipY"})}coverByImage(e,t){return jr(this,void 0,void 0,(function*(){let r;r=t instanceof s.Texture?t:t?yield this.parse(t):null;var i=pl.texture.getMaterials(pl.getId(e));if(i){const t=[];(0,D.js)(i,((s,i)=>{const n=pl.material.get(s);n&&i.forEach((s=>{t.push(new zr({target:n,info:s,newVal:r,oldVal:e}).execute())}))})),fl.addUndo(t)}}))}removeTexture(e){ml.cb.texture.remove.cb(e),pl.texture.remove(e)}},vl=new class{create(e,t){return new V(e,t)}},yl=new class{constructor(){this.scene=null,this.camera=null,this.controls=null,this.renderer=null,this.engineDom=null}init(e){var t=Sl.create(),r=_l.create(),s=wl.create(),i=vl.create(r,s.domElement);return this.camera=r,{scene:this.scene=t,camera:r,render:this.renderer=s,controls:this.controls=i,engineDom:this.engineDom=e}}get(){var{scene:e,camera:t,renderer:r,controls:s,engineDom:i}=this;return{scene:e,camera:t,renderer:r,controls:s,engineDom:i}}},xl={glow:N.getInstance()},wl=new class{constructor(){this.setSize=(e,t)=>{var{w:r,h:s}=this.getDomSize(),r=(e=e||r,t||s);const{camera:i,renderer:n}=yl.get();i.aspect=e/r,i.updateProjectionMatrix(),n.setSize(e,r),xl.glow.setSize(e,r)}}create(){let e=new s.WebGLRenderer({antialias:!0,alpha:!0,powerPreference:"high-performance"});return e.domElement.style.position="absolute",e.setPixelRatio(window.devicePixelRatio),e.shadowMap.enabled=!0,e.shadowMap.type=s.PCFSoftShadowMap,e.physicallyCorrectLights=!0,e.localClippingEnabled=!0,e}getDomSize(){return{w:yl.get().engineDom.clientWidth,h:document.body.getBoundingClientRect().height-44-45}}},bl=new class{constructor(){this.selectors={},this.boxHelperMap={},Qr.mouse.bindEvent({type:"up",local:"local",name:"MultipSelector",fn:e=>{Qr.key.ctrl||bl.setEmpty()}})}add(e,t=!1){if("array"===(0,tl.getType)(e))return e.map((e=>this.add(e)));var r=Pl.select;if(r&&(Pl.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,ml.cb.model.focus.cb({model:e,status:!0,domActive:!0}),Tl.focus(e)}}setInfo(e,t,r,s,i,n){"position"!==t&&(i=s,n=r);const a=this.getSelectedList("value");var{x:i,y:o,z:l}=i;const h=i-n.x,c=o-n.y,u=l-n.z,d=[new el({target:e,info:t,oldV3:Pl.cloneV3(r),newV3:s}).execute()];a.map((r=>{if(r!==e){var{x:s,y:i,z:n}=r[t],s=s+=h,i=i+=c,n=n+=u;let e=r[t].clone();e.x=s,e.y=i,e.z=n,s=new el({target:r,info:t,oldV3:Pl.cloneV3(r[t]),newV3:e}).execute(),d.push(s),this.boxHelperMap[r.uuid].setFromObject(r)}})),fl.addUndo(d)}getLast(){var e=this.getSelectedList("value");return e[e.length-1]}addBoxHelper(e){var t=Tl.getBoxHelper(e);this.boxHelperMap[e.uuid]=t}removeBoxHelper(e){yl.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)));ml.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(),Tl.unfocus()}setBoxHelperEmpty(){var e=Object.values(this.boxHelperMap);yl.get().scene.remove(...e),this.boxHelperMap={}}setEmpty(){this.getSelectedList("value").map((e=>{ml.cb.model.unFocus.cb(e)})),this.setBoxHelperEmpty(),this.selectors={}}createGroup(){Tl.unfocus(),Pl.selectNull();var e=new s.Group;const t=new s.Group;Pl.add(e,void 0,!1),Pl.add(t);var r=[...this.getSelectedList("value")],i=(ml.cb.model.multipDrop.cb(this.getSelectedList("value"),e),Ko().group.getCenter(e));t.position.copy(i),ml.cb.model.multipDrop.cb(r,t),Pl.remove(e,!1),Pl.select=t}getSelectorGroup(){const e=this.getSelectedList("value"),t=new s.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}},Tl=new class{constructor(){this.boxHelper=null,this.deepIsHelper=e=>"Scene"===e.type||!this.isHelper(e)&&!!e.parent&&this.deepIsHelper(e.parent),this.getBoxHelper=e=>(e=new s.BoxHelper(e),this.setHelper(e),yl.get().scene.add(this.grid),e),this.transContro=new class{constructor(){this.tansControls=null,this.controlsMode="position",this.isDraggingChange=!1,this.modelNewVal=new C.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new C.Vector3,this.draggingChanged=e=>{const t=yl.get().controls;var r=this.controlsMode;let s=Pl.select;if(e.value){if(!bl.isEmpty()){t.enabled=!1;const e=bl.getLast();this.multipSelectLast=e,this.worldOldVal=Gr(e,Sl.get())}}else if(!t.enabled&&!bl.isEmpty()&&this.multipSelectLast){const e=this.multipSelectLast;this.multipObj=e,Qr.mouse.enableUp=!1,Tl.boxHelper.setFromObject(yl.get().scene);var i=Gr(e,Sl.get());bl.setInfo(e,r,this.modelNewVal,e[r],i,this.worldOldVal),Pl.selectNull(),this.multipSelectLast=void 0}if(bl.isEmpty()?Qr.mouse.enableUp=!0:Qr.mouse.enableUp=!1,!s){if(bl.isEmpty())return;s=bl.getLast()}t.enabled?(this.modelNewVal=Pl.cloneV3(s[r]),this.isDraggingChange=!0,this.worldOldVal=Gr(s,Sl.get())):(bl.isEmpty()?Pl.setV3({model:s,info:r,newV3:Pl.cloneV3(s[r]),oldV3:this.modelNewVal},!0,!1):(this.multipObj=s,Qr.mouse.enableUp=!1,Tl.boxHelper.setFromObject(yl.get().scene),i=Gr(s,Sl.get()),bl.setInfo(s,r,this.modelNewVal,s[r],i,this.worldOldVal)),this.isDraggingChange=!1),yl.get().controls.enabled=!e.value}}init(){const{camera:e,renderer:t,scene:r}=yl;this.tansControls=new Va(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=Pl.select;t&&(Al.update(t),Tl.boxHelper.setFromObject(t))}close(){this.tansControls.enabled=!1}open(){this.tansControls.enabled=!0}reset(){this.tansControls&&(this.tansControls.removeEventListener("dragging-changed",this.draggingChanged),this.tansControls.removeEventListener("change",this.transChangeFn))}},this.grid=this.createGrid()}init(){this.transContro.init(),yl.get().scene.add(this.grid)}createGrid(){const e=new C.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof s.Material&&(e.material.opacity=.75,e.material.transparent=!0),e}dispose(){}reset(){}isHelper(e){return"GridHelper"===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){this.boxHelper||(this.boxHelper=this.getBoxHelper(e)),this.transContro.addObject(e),this.boxHelper.setFromObject(e)}unfocus(){var e;this.transContro.removeFocus(),null!=(e=this.boxHelper)&&e.setFromObject(yl.get().scene)}},Ml=new class{constructor(){this.defMaterialMap={BaseMaterial:Bo,SpriteMaterial:Jr,FakeInterior:Fo,Reflector:Ho,Fresnel:Xo},this.addCb=e=>{ml.cb.material.add.cb(e)},ml.cb.unique.material.add.add("engine-material-add",(e=>{"SpriteMaterial"!==e.type&&this.addCb(e)}))}add(e,t,r){pl.material.add(e,t,r)}create(){var e=new s.MeshStandardMaterial;return this.add(e),e}createNotHis(){const e=new s.MeshStandardMaterial;return e.userData.id=(0,S.getId)(),e}clone(e){const t=e.clone();return t.userData.id=(0,S.getId)(),t}setNormal(e,t=!0){return e=new zr(e).execute(),t&&fl.addUndo(e),e}setTexture(e,t=!0){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{info:r,newVal:s}=e,s=(s instanceof File&&(e.newVal=yield gl.parse(s)),"envMap"===r&&gl.toThree(e.newVal),new zr(e).execute());return t&&fl.addUndo(s),e.newVal}))}createDef(){}resetMaterial(e,t,r=!0){var s;e&&t&&e.material&&(s=new O({target:e,info:"material",newVal:t,oldVal:e.material}).execute(),Pl.select===e&&ml.cb.setSelectMaterial.cb(t),r&&fl.addUndo(s))}getBase(e){const t=this.defMaterialMap[e];if(("SpriteMaterial"!==e||"Sprite"===(null==(e=Pl.select)?void 0:e.type))&&t)return t.create()}getAllTextures(e){var t=e.userData.textures||Fr.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t}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){ml.cb.setSelectMaterial.cb(e)}getDataByType(e,t){return this.defMaterialMap[e].tools.parseData(t)}dispose(){ml.cb.material.dispose.cb("")}remove(e){}getDefNromals(e){const t={};return(0,D.js)(Qo,((r,s)=>{const i=e[r];if("object"==typeof i)for(const e in i)if(i[e]!==s[e])return void(t[r]=i.clone());i!==s&&(t[r]=i)})),t}parseNromals(e,t){(0,D.js)(e,((e,r)=>{var s,i,n;void 0!==Qo[e]&&("object"==typeof r?(({x:s,y:i,z:n}=r),t[e].set(s,i,n)):t[e]=r)}))}merge(e,t){return qo.map((r=>{const s=e[r];"object"==typeof s&&(t[r]=s.clone()),t[r]=s})),t}isBaseMaterial(e){return"MeshStandardMaterial"===e.type&&Bo.isDefval(e)}},_l=new class{create(){return new s.PerspectiveCamera}reset(e){e.position.set(0,20,20);const t=yl.get().controls;t.target.set(0,0,0),t.update()}get(){return yl.get().camera}},Sl=new class{constructor(){this.oldFog=null,this.removeMap={light:{valid:e=>Al.isLight(e),remove:e=>Al.remove(e)}}}each(e){return yl.get().scene.traverseAncestors(e)}get(){return new Proxy(yl.get().scene,{set:(e,t,r)=>(e[t]=r,!0)})}getNromal(){return this.get().children.filter((e=>!Tl.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:s,remove:i}=this.removeMap[r];if(s(e))return t.push(...(0,E.multiArrToArr)(i(e)))}t.push(new U({model:e,parent:e.parent}).execute())})),fl.addUndo(t),t}for(const t in this.removeMap){const{valid:r,remove:s}=this.removeMap[t];if(r(e))return s(e)}Pl.remove(e),null!=(t=Tl.boxHelper)&&t.setFromObject(this.get())}}cleanUnlessLevel(e){return Pl.isUnlessLevel(e)&&!Tl.isHelper(e)&&0!==e.children.length&&1===e.children.length?this.cleanUnlessLevel(e.children[0]):e}getClearModels(){return this.get().children.filter((e=>!Tl.isHelper(e)&&!Al.isLight(e)))}getClear(){const e=this.get(),t=new s.Group;return e.children.filter((e=>!Tl.isHelper(e)&&!Al.isLight(e))).map((e=>t.add(e.clone()))),Tl.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 s.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),i=new O({target:r,info:"background",newVal:e,oldVal:r.background,cb:e=>{xl.glow.setBackground(e.background)}}).execute();return t&&fl.addUndo(i),ml.cb.setScene.cb({scene:r,type:"background"}),xl.glow.setBackground(e),e}isBackground(e){return e.userData.isBackgroud}clean(){Tl.unfocus(),ml.cb.reset.cb(this.get()),Pl.selectNull(),this.cleanSceneInfo(this.get()),_l.reset(yl.get().camera),yl.get().controls.update(),this.cleanNormal(),pl.dispose(),Ml.dispose(),fl.reset(),El.reset(),xl.glow.reset()}render(){}create(){return new s.Scene}setEnv(e,t){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){let r;return t instanceof File&&(r=gl.toThree(yield gl.parse(t))),null!=t&&t.isTexture&&(r=gl.toThree(gl.clone(t))),this.setNormal({model:e,info:"environment",val:r}),ml.cb.setScene.cb({scene:e,type:"environment"}),r}))}setNormal(e,t=!0){var{model:e,info:r,val:s}=e;e=new O({target:e,info:r,oldVal:e[r],newVal:s}).execute(),t&&fl.addUndo(e)}setFogShow(e){var{show:e,color:t,scene:r}=e;e?this.setNormal({model:r,info:"fog",val:this.oldFog||new s.Fog(t)}):(this.oldFog=r.fog,this.setNormal({model:r,info:"fog",val:null})),ml.cb.setScene.cb({scene:r,type:"fog"})}setFog(e){var{scene:e,type:t,val:r}=e;e=new I({target:e,typeList:["fog",t],newVal:r}).execute(),fl.addUndo(e)}getFogJson(e){const{color:t,far:r,near:s}=e;return{color:t.getHexString(),far:r,near:s}}},Pl=new class{constructor(){this._selectModel=void 0,this.defNodeMap={castShadow:!1,receiveShadow:!1,renderOrder:0},this.deepIsVisible=e=>"Scene"===e.type||!!e.visible&&!!e.parent&&this.deepIsVisible(e.parent),this.defMap={}}get select(){return this._selectModel}set select(e){this.setSelectByModel(e)}add(e,t,r=!0,s=!1,i=!0){if(e instanceof Array)return e.map((e=>this.add(e,t,r,s,i)));s&&(pl.model.add(e,{hasReset:!0}),ml.cb.model.clone.cb(e));var n=new A({model:e,parent:t||Sl.get(),isClone:s}).execute();!0===r&&fl.addUndo(n),i&&this.setSelectByModel(e,{isDomTreeActive:!1,isClone:s})}setSelectByModel(e,t){var r,{isDomTreeActive:t,isClone:s}=t||{};if(Qr.key.shift&&this._selectModel)return(r=this.getBeTweenChildByTwoModel(this._selectModel,e))?void bl.add([...r,e],!0):void 0;Qr.key.ctrl&&!s?bl.add(e):(bl.isEmpty()||bl.setEmpty(),this._selectModel&&(Al.setNull(this._selectModel),ml.cb.model.unFocus.cb(this._selectModel)),e&&(e.isCamera||(Tl.focus(e),Al.setSelect(e)),ml.cb.model.focus.cb({model:e,status:!0,domActive:!t}),Ml.setSelect(e.material),ml.cb.model.setSelect.cb(e),this._selectModel=e))}setSelectById(e){(e=pl.model.get(e))&&this.setSelectByModel(e)}remove(e,t=!0){if(e instanceof Array)return e.map((e=>this.remove(e)));e=new U({model:e,parent:e.parent||Sl.get()}).execute(),t&&fl.addUndo(e)}isNavieV3(e,t=0){var{x:e,y:r,z:s}=e;return e+r+s===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 Ko().model.getModelByType("Box")}clone(e){var t,r,s;if(!Al.isLight(e))return t=e.clone(),null!=(s=null==(r=null==e?void 0:e.material)?void 0:r.userData)&&s.tools&&(s=null==(s=r.userData.tools)?void 0:s.clone(r,t))&&s.uuid!==r.uuid&&(Ml.resetMaterial(t,s,!0),Ml.add(s,e,r)),pl.model.add(t,{reset:!0}),t;Al.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&&(ml.cb.model.unFocus.cb(e),Ml.setSelect(null),Al.setNull(e)),this._selectModel=void 0,ml.cb.model.setSelect.cb(null),Tl.unfocus()}cloneV3(e){return e.clone()}setParent(e,t,r=!0){if(t=new $o({oldParent:e.parent,newParent:t,target:e}).execute(),!r)return t;fl.addUndo(t)}setV3(e,t=!0,r=!0){var{model:e,info:s,newV3:i,oldV3:n}=e;const a=new el({target:e,info:s,oldV3:n,newV3:i});r&&a.execute(),t&&fl.addUndo(a)}setNormal(e,t=!0){var{model:e,info:r,val:s}=e;e=new O({target:e,info:r,oldVal:e[r],newVal:s}).execute(),t&&fl.addUndo(e)}setMaterial(e,t,r=!0){var s=new O({target:e,info:"material",oldVal:e.material,newVal:t}).execute();this.select===e&&ml.cb.setSelectMaterial.cb(t),e.material.needsUpdate=!0,r&&fl.addUndo(s)}createDef(e){if(Jo.includes(e)){const t=Ko().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=Jr.tools),t}throw this.defMap[e],TypeError("")}addDef(e){this.add(this.createDef(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new s.MeshBasicMaterial,t=new s.SphereGeometry(.7,150,150);return new s.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 s=Math.max(r,t),i=r===s?t:r;return e.parent.children.map(((e,t)=>t>i&&t<s&&e)).filter((e=>e))}}}setMultip(e){var{model:e,typeList:t,newVal:r}=e;fl.addUndo(new I({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const i=t||new s.Group,n=[];n.push(new A({model:i,parent:r||yl.get().scene}).execute()),e instanceof Array?n.push(...e.map((e=>new $o({target:e,oldParent:e.parent,newParent:i}).execute()))):n.push(new $o({target:e,oldParent:e.parent,newParent:i}).execute()),r&&ml.cb.model.setOpen.cb({isOpen:!0,model:r}),ml.cb.model.setOpen.cb({isOpen:!0,model:i}),ml.cb.model.setMainStatue.cb({status:!0,model:i}),fl.addUndo(n),this.setSelectByModel(i)}cleanGroup(e,t=!0){if(e instanceof Array){const t=(0,E.multiArrToArr)(e.map((e=>(ml.cb.model.unFocus.cb(e),this.cleanGroup(e,!1)))).filter((e=>e)));return fl.addUndo(t),t}if(ml.cb.model.unFocus.cb(e),0!==e.children.length){const r=[],s=e.children.map((e=>{if(e.parent.parent)return new $o({target:e,oldParent:e.parent,newParent:e.parent.parent})})).filter((e=>e));return r.push(...s.map((e=>e.execute()))),r.push(new U({model:e,parent:e.parent}).execute()),t&&fl.addUndo(r),r}}hideOther(e){const t=e.uuid,r=0<e.children.length,s=Sl.getClearModels(),i=[];s.map((s=>{s.traverse((s=>{r?!1===Ko().model.deepFindParentByUuid(s,t)&&s.uuid!==e.uuid&&i.push(s):s.uuid!==e.uuid&&i.push(s)}))}));var n=i.map((e=>new O({target:e,info:"visible",newVal:!1,oldVal:e.visible}).execute()));fl.addUndo(n),Ko().model.setParentVisible(e,!0)}showAll(){const e=Sl.getClearModels(),t=[];e.map((e=>{e.traverse((e=>{"materialHelper"!==e.name&&!1===e.visible&&t.push(e)}))}));var r=t.map((e=>new O({target:e,info:"visible",newVal:!0,oldVal:e.visible}).execute()));fl.addUndo(r)}removeHide(){const e=Sl.getClearModels(),t=new Set,r=[];e.map((e=>{e.traverse((e=>{e.visible||t.add(e)}))})),t.forEach((e=>{r.push(new U({model:e,parent:e.parent}).execute())})),fl.addUndo(r)}},Cl=new class{constructor(){this.imgBitMap=new s.ImageBitmapLoader,this.object=new s.ObjectLoader,this.gltf=new ko}},Rl=new class{constructor(){this.gltf=new ys}},Al=new class{constructor(){this.shadowList=["DirectionalLight","PointLight","SpotLight"],this.helperList=["DirectionalLight","PointLight","SpotLight","RectAreaLight","HemisphereLight"],this.lightDom=void 0,this.helperUpdateList=["DirectionalLight","PointLight","SpotLight","HemisphereLight"]}getLightsByScene(e=Sl.get()){return e.children.filter((e=>e.isLight))}get(e,t){var{isClone:t,id:r,addUndo:s}=t||{};let i=new C[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:Sl.get(),addTree:!0}),r=t.map((e=>new A(e).execute())),void 0!==s&&s&&fl.addUndo(r),null!=(e=i.lightHelper)&&e.update()}else Pl.add(i,void 0,s);return Pl.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 Tl.unfocus(),r="DirectionalLight"===e.type||"SpotLight"===e.type?[e,e.cameraHelper,e.helper].map((t=>new U({addTree:t===e,model:t,parent:t.parent||Sl.get()}).execute())):[e,e.helper].map((t=>{if(t)return new U({addTree:t===e,model:t,parent:t.parent||Sl.get()}).execute()})).filter((e=>e)),t&&r&&fl.addUndo(r),r}getLightHelper(e,t){pl.model.add(t);const r=pl.getId(t);let s,i=[];switch(e){case"RectAreaLight":s=new P(t,16773120);break;case"DirectionalLight":if(s=new C.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new C.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 C.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,Tl.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:Sl.get(),addTree:!1});break;case"PointLight":s=new C.PointLightHelper(t,1,16711935);break;case"SpotLight":s=new C.SpotLightHelper(t);let n=new C.Object3D;(t.target=n).name="helperModel",n.userData.isLightTarget=!0,n.userData.light=t,n.position.y=-10,t.shadow.autoUpdate=!0,t.add(n);const a=new C.CameraHelper(t.shadow.camera);t.shadow.camera.matrixWorldNeedsUpdate=!0,Tl.setHelper(a,!0,(e=>{e.userData.id=r})),a.userData.id=r,t.cameraHelper=a,i.push({model:a,parent:Sl.get(),addTree:!1});break;case"HemisphereLight":s=new C.HemisphereLightHelper(t,1,16773135)}return s.name="helperModel",Tl.setHelper(s,!0,(e=>{e.userData.id=r})),s.userData.id=r,(s.light=t).helper=s,i.push({model:s,parent:Sl.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:s,cb:i}=e;return new O({target:e,info:r,oldVal:e[r],newVal:s,cb:i}).execute()}setMultip(e,t,r=!0,s=!0){if(e instanceof Array)return i=e.map((e=>{var{model:e,typeList:s,newVal:i}=e;const n=new I({target:e,typeList:s,newVal:i,cb:t});return r?n.execute():n})),s&&fl.addUndo(i),i;{var{model:i,typeList:e,newVal:n}=e;const a=new I({target:i,typeList:e,newVal:n,cb:t});return s&&fl.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 Pl.selectNull(),this.get(e.type,{isClone:!0,id:(0,S.getId)()})}},El=new class{constructor(){this.timerMap={},this.animaMap={},this.groupMap={},this.setModelLocal=(e,t)=>{Object.values(e.data).map((e=>{var r,s,i=((e,t)=>{let r=-1,s=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<s&&(s=e,r=i)})),-1!==r)){var n=i[r],a=i[r+1],o=e[n];if(e=e[a],o&&e){var l=Object.values(o)[0],h=Object.values(e)[0];if("notNow"!==l&&"notNow"!==h)return{left:o,right:e,progress:(t-Number(n))/(Number(a)-Number(n))}}}})(e.data,t);i&&(({left:i,right:r,progress:s}=i),e.setTargetByBetween(i,r,s))}))}}reset(){this.timerMap={},this.animaMap={},this.groupMap={},ml.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,ml.cb.timeLine.closeGroup.cb(e);const s=this.animaMap[e];s&&s.length&&s.map((e=>{e.controls.clean=!0}))}resetGroup(e){var t=this.groupMap[e];t&&(this.closeGroup(e),ml.cb.timeLine.setProgress.cb(0),Object.values(t.data).map((e=>e.reset())))}getSavedData(){return(0,D.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],s={};(0,D.js)(r.data,((e,t)=>{var{type:t,data:r}=t;const i=ll[t];if(t=i.getTarget(e)){const n=new i(t);n.data=r,s[e]=n}})),r.data=s,this.groupMap[t]=r,ml.cb.timeLine.setGroupMap.cb({group:r,groupName:t})}))}playGroup(e){Tl.unfocus();const t=this.groupMap[e];if(t&&!t.run){t.run=!0;const s=Object.keys(t.data).map((e=>{const r=t.data[e],s=(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),s.push(...e)),s})),i=(this.animaMap[e]||(this.animaMap[e]=[]),this.animaMap[e]=s.map((e=>(0,E.eachTriggerArrGetControls)(e))),t.time*t.speed*(t.reverse?2:1)),n=(new Date).valueOf(),a=i;var r=setInterval((()=>{var t=((new Date).valueOf()-n)/a;ml.cb.timeLine.playGroup.cb({groupName:e,progress:t})}),16.6);let o;const l=new Promise((e=>o=setTimeout(e,i)));return this.timerMap[e]={setProgressTime:r,awaitRuned:o},l.then((()=>{if(clearInterval(this.timerMap[e].setProgressTime),t.run)return t.run=!1,t.loop?this.playGroup(e):void 0}))}}},Dl=class{constructor(e){var{rootDom:t,options:r}=e;if(!t)throw TypeError("根节点或路径不可为空");(t=(r||{}).loadInterval)&&0<t?ml.setLoadInterval({inputInterval:t,cb:this.load.bind(this,e)}):this.load(e)}load(e){const{path:t,rootDom:r,options:s}=e,{camera:i,renderer:n,controls:a}=(Qr.init(r),yl.init(r),Tl.init(),yl.get());ml.init(s||{}),r.appendChild(n.domElement),n.setAnimationLoop(this.render.bind(this)),_l.reset(i),pl.model.add(i),wl.setSize(),a.update(),window.engine=this,xl.glow.init(yl.get()),ml.cb.inited.cb(""),this.loadScene(t)}loadScene(e){return function(e,t,r,s){return new(r=r||Promise)((function(t,i){function n(e){try{o(s.next(e))}catch(e){i(e)}}function a(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(n,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){if(e){ml.log("正在拉取场景","base","info");var t=yield r().get(e,{responseType:"arraybuffer"}).then((e=>e.data));if(t)return ml.log("拉取场景成功、正在解析","base","success"),Cl.gltf.parse(t)}}))}render(){var e;null!=(e=ml.options)&&e.run&&(ml.cb.render.cb(""),xl.glow.update())}}})(),h.default;function a(e){var t=l[e];return void 0!==t||(t=l[e]={exports:{}},o[e].call(t.exports,t,t.exports,a)),t.exports}var o,l,h}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("uuid1"),require("js-funcs")):"function"==typeof define&&define.amd?define(["axios","three","@allex/md5","js-funcs-three","uuid1","js-funcs"],t):"object"==typeof exports?exports.RunScene=t(require("axios"),require("three"),require("@allex/md5"),require("js-funcs-three"),require("uuid1"),require("js-funcs")):e.RunScene=t(e.axios,e.three,e["@allex/md5"],e["js-funcs-three"],e.uuid1,e["js-funcs"])}(self,((e,t,r,s,n,i)=>{return o={685:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};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;const n=s(r(300));t.base64ToFile=(e,t)=>{let r=e.split(","),s=r[0].match(/:(.*?);/)[1],n=atob(r[1]),i=n.length,a=new Uint8Array(i);for(;i--;)a[i]=n.charCodeAt(i);return new File([a],t,{type:s})},t.bufferToArrayBuffer=e=>{for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),s=0;s<e.length;++s)r[s]=e[s];return t},t.blobToDataUrl=e=>n.default.get(e,{baseURL:"",responseType:"blob",timeout:5e3}).then((e=>(0,t.toResult)(e.data))).catch((e=>!1)),t.toUrl=(e,t="any.json")=>{let r;return r=e instanceof File?e:(e=JSON.stringify(e),new File([e],t)),window.URL.createObjectURL(r)},t.strToArrayBuffer=e=>{let t="";for(let 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=e=>new Promise((t=>{var r=new Blob([e]),s=new FileReader;s.readAsText(r,"utf-8"),s.onload=function(){t(s.result)}})),t.bToMB=(e,t=!1)=>{const r=e/1024/1024;return t?r:r.toFixed(2)+"MB"},t.getBackWord=e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),t.getPrefixWord=e=>e.substr(0,e.lastIndexOf(".")),t.toResult=(e,t="text")=>{var r=new FileReader;return"text"===t?r.readAsText(e):"arrayBuffer"===t?r.readAsArrayBuffer(e):"base64"===t&&r.readAsDataURL(e),new Promise((e=>{r.onload=t=>e(t.target.result)}))},t.urlToBase64=e=>n.default.get(e,{responseType:"arraybuffer"}).then((e=>`data:${e.headers["content-type"]};base64,`+new Buffer(e.data,"binary").toString("base64"))),t.getFileName=e=>e.substring(e.lastIndexOf("-")+1),t.downloadFile=(e,t="any.text")=>{let 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";var s=this&&this.__awaiter||function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deepArrByMaps=t.map=t.multiArrToArr=t.eachTriggerArray=t.eachTriggerArrGetControls=t.emptyArray=t.delArrEle=t.lastArrayEle=void 0;const n=r(185);t.lastArrayEle=e=>e.slice(-1)[0],t.delArrEle=(e,t)=>{var r=e.slice(0,t);return e=e.slice(t+1),[...r,...e]},t.emptyArray=e=>0===e.length,t.eachTriggerArrGetControls=e=>{const r=new Proxy({run:!0,clean:!1,target:e,index:0,runningAnima:null,eachCb:(e,t)=>{e.anima&&(r.runningAnima=e.anima),r.index=t}},{set:(e,t,s)=>("clean"===t&&!0===s&&!1===e[t]&&(r.run=!1,r.target.splice(0)),"run"===t&&!1===s&&!0===e[t]&&(console.log(r,"controls"),r.runningAnima&&r.runningAnima.pause()),"run"===t&&!0===s&&!1===e[t]&&r.runningAnima&&r.runningAnima.resume(),e[t]=s,!0)});return e=(0,t.eachTriggerArray)(e,r),{controls:r,promise:e}},t.eachTriggerArray=(()=>{const e=(t,r,n,i)=>s(void 0,void 0,void 0,(function*(){const s=t[r++];if(!s)return n();var a,o=s();o instanceof Promise?(a=yield o,null!=i&&i.eachCb(a,r)):o.promise&&o.promise instanceof Promise?(null!=i&&i.eachCb(o,r),yield o.promise):null!=i&&i.eachCb(o,r),e(t,r,n,i)}));return(t,r)=>new Promise((s=>e(t,0,s,r)))})(),t.multiArrToArr=(()=>{const e=(t,r)=>{t.map((t=>{if("array"===(0,n.getType)(t))return e(t,r);r.push(t)}))};return t=>{var r=[];return e(t,r),r}})(),t.map=(e,t)=>e.map(((r,s)=>t(r,s,e))).filter((e=>e)),t.deepArrByMaps=e=>{const{arr:r,typeList:s,findType:n,mapType:i}=e;if(!r||!s||!n)return r;const a=[...s];return(e=r.find((e=>e[n]===s[0])))?1!==s.length&&e[i]instanceof Array?(a.shift(),(0,t.deepArrByMaps)({arr:e[i],typeList:a,findType:n,mapType:i})):e:r}},594:(e,t,r)=>{"use strict";t.qR=t.js=t.CV=void 0,r(185),t.CV=e=>0===Object.values(e).length,t.js=(e,t)=>Object.keys(e).map(((r,s)=>{var n=e[r];return t(r,n,s)})),t.qR=(e,t)=>{let r=-1,s=e=>(r++,t.length===r+1?e:s(e[t[r]]));return s(e)}},251:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getId=t.getMacro=t.getUuid=void 0;const n=s(r(937)),i=s(r(181));t.getUuid=()=>n.default.UUID1(),t.getMacro=(e,t=0)=>{let r=setTimeout((()=>(clearTimeout(r),r=null,e())),t)},t.getId=()=>(0,i.default)()},185:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTrue=t.getType=void 0,t.getType=e=>{if(void 0!==e){if(null===e)return null;let 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=e=>!(null==e||!1===e)},326:e=>{e.exports=function(e,t,r){for(var s=(2<<Math.log(t.length-1)/Math.LN2)-1,n=-~(1.6*s*r/t.length),i="";;)for(var a=e(n),o=n;o--;)if((i+=t[a[o]&s]||"").length===+r)return i}},181:(e,t,r)=>{"use strict";e.exports=r(882)},488:(e,t,r)=>{"use strict";var s,n,i,a=r(87),o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function l(){i=!1}function h(e){if(e){if(e!==s){if(e.length!==o.length)throw new Error("Custom alphabet for shortid must be "+o.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 "+o.length+" unique characters. These characters were not unique: "+t.join(", "));s=e,l()}}else s!==o&&(s=o,l())}function c(){return i=i||function(){s||h(o);var e,t=s.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 s||o},characters:function(e){return h(e),s},seed:function(e){a.seed(e),n!==e&&(l(),n=e)},lookup:function(e){return c()[e]},shuffled:c}},239:(e,t,r)=>{"use strict";var s,n,i=r(253);r(488),e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===n?s++:(s=0,n=r),t=(t+=i(7))+i(e),0<s&&(t+=i(s)),t+i(r)}},253:(e,t,r)=>{"use strict";var s=r(488),n=r(19),i=r(326);e.exports=function(e){for(var t,r=0,a="";!t;)a+=i(n,s.get(),1),t=e<Math.pow(16,r+1),r++;return a}},882:(e,t,r)=>{"use strict";var s=r(488),n=r(239),i=r(40),a=r(595)||0;function o(){return n(a)}e.exports=o,e.exports.generate=o,e.exports.seed=function(t){return s.seed(t),e.exports},e.exports.worker=function(t){return a=t,e.exports},e.exports.characters=function(e){return void 0!==e&&s.characters(e),s.shuffled()},e.exports.isValid=i},40:(e,t,r)=>{"use strict";var s=r(488);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+s.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},19:e=>{"use strict";var t="object"==typeof window&&(window.crypto||window.msCrypto),r=t&&t.getRandomValues?function(e){return t.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=r},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=r},300:t=>{"use strict";t.exports=e},1:e=>{"use strict";e.exports=i},356:e=>{"use strict";e.exports=s},881:e=>{"use strict";e.exports=t},937:e=>{"use strict";e.exports=n}},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})},h={},(()=>{"use strict";a.d(h,{default:()=>Gl});var e={},t=(a.r(e),a.d(e,{AsyncCompress:()=>Mi,AsyncDecompress:()=>Ni,AsyncDeflate:()=>gi,AsyncGunzip:()=>Ci,AsyncGzip:()=>Mi,AsyncInflate:()=>wi,AsyncUnzipInflate:()=>la,AsyncUnzlib:()=>Ui,AsyncZipDeflate:()=>na,AsyncZlib:()=>Li,Compress:()=>Ti,DecodeUTF8:()=>Wi,Decompress:()=>Fi,Deflate:()=>fi,EncodeUTF8:()=>Xi,Gunzip:()=>Pi,Gzip:()=>Ti,Inflate:()=>yi,Unzip:()=>ha,UnzipInflate:()=>oa,UnzipPassThrough:()=>aa,Unzlib:()=>Oi,Zip:()=>ia,ZipDeflate:()=>sa,ZipPassThrough:()=>ra,Zlib:()=>Ai,compress:()=>_i,compressSync:()=>Ei,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]?Ri:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?bi:ki)(e,t,r)},decompressSync:()=>function(e,t){return(31==e[0]&&139==e[1]&&8==e[2]?Di:8!=(15&e[0])||7<e[0]>>4||(e[0]<<8|e[1])%31?Si:Bi)(e,t)},deflate:()=>vi,deflateSync:()=>xi,gunzip:()=>Ri,gunzipSync:()=>Di,gzip:()=>_i,gzipSync:()=>Ei,inflate:()=>bi,inflateSync:()=>Si,strFromU8:()=>Yi,strToU8:()=>qi,unzip:()=>function(e,t){if("function"!=typeof t)throw"no callback";for(var r=[],s=function(){for(var e=0;e<r.length;++e)r[e]()},n={},i=e.length-22;101010256!=ai(e,i);--i)if(!i||65558<e.length-i)return void t("invalid zip file",null);var a=ii(e,i+8);a||t(null,{});var o=a,l=ai(e,i+16),h=4294967295==l;if(h){if(i=ai(e,i-12),101075792!=ai(e,i))return void t("invalid zip file",null);o=a=ai(e,i+32),l=ai(e,i+48)}for(var c=function(i){function o(e,r){e?(s(),t(e,null)):(n[p]=r,--a||t(null,n))}var c=(f=Ki(e,l,h))[0],u=f[1],d=f[2],p=f[3],m=f[4],f=f[5];if(f=Qi(e,f),l=m,c)if(8==c)if(m=e.subarray(f,f+u),u<32e4)try{o(null,Si(m,new tn(d)))}catch(i){o(i,null)}else r.push(bi(m,{size:d},o));else o("unknown compression type "+c,null);else o(null,Rn(e,f,f+u))},u=0;u<o;++u)c();return s},unzipSync:()=>function(e){for(var t={},r=e.length-22;101010256!=ai(e,r);--r)if(!r||65558<e.length-r)throw"invalid zip file";var s=ii(e,r+8);if(!s)return{};var n=ai(e,r+16),i=4294967295==n;if(i){if(r=ai(e,r-12),101075792!=ai(e,r))throw"invalid zip file";s=ai(e,r+32),n=ai(e,r+48)}for(var a=0;a<s;++a){var o=(d=Ki(e,n,i))[0],l=d[1],h=d[2],c=d[3],u=d[4],d=d[5];if(d=Qi(e,d),n=u,o){if(8!=o)throw"unknown compression type "+o;t[c]=Si(e.subarray(d,d+l),new tn(h))}else t[c]=Rn(e,d,d+l)}return t},unzlib:()=>ki,unzlibSync:()=>Bi,zip:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";function s(){for(var e=0;e<d.length;++e)d[e]()}function n(){for(var e=new tn(h+22),t=l,s=h-l,n=h=0;n<c;++n){var i=u[n];try{var a=i.c.length,o=(ea(e,h,i,i.f,i.u,a),30+i.f.length+$i(i.extra)),d=h+o;e.set(i.c,d),ea(e,l,i,i.f,i.u,a,h,i.m),l+=16+o+(i.m?i.m.length:0),h=d+a}catch(e){return r(e,null)}}ta(e,l,u.length,s,t),r(null,e)}var i={},a=(zi(e,"",i,t),Object.keys(i)),o=a.length,l=0,h=0,c=o,u=new Array(o),d=[];o||n();for(var p=function(e){function t(t,i){t?(s(),r(t,null)):(t=i.length,u[e]=Xn(f,{size:v,crc:g.d(),c:i,f:x,m:b,u:y!=c.length||b&&w.length!=S,compression:M}),l+=30+y+T+t,h+=76+2*(y+T)+(S||0)+t,--o||n())}var c=a[e],p=i[c],m=p[0],f=p[1],g=Hn(),v=m.length,x=(g.p(m),qi(c)),y=x.length,w=f.comment,b=w&&qi(w),S=b&&b.length,T=$i(f.extra),M=0==f.level?0:8;if(65535<y&&t("filename too long",null),M)if(v<16e4)try{t(null,xi(m,f))}catch(p){t(p,null)}else d.push(vi(m,f,t));else t(null,m)},m=0;m<c;++m)p(m);return s},zipSync:()=>function(e,t){var r,s={},n=[],i=(zi(e,"",s,t=t||{}),0),a=0;for(r in s){var o,l=(o=s[r])[0],h=0==(o=o[1]).level?0:8,c=(w=qi(r)).length,u=o.comment,d=u&&qi(u),p=d&&d.length,m=$i(o.extra);if(65535<c)throw"filename too long";var f=h?xi(l,o):l,g=f.length,v=Hn();v.p(l),n.push(Xn(o,{size:l.length,crc:v.d(),c:f,f:w,m:d,u:c!=r.length||d&&u.length!=p,o:i,compression:h})),i+=30+c+m+g,a+=76+2*(c+m)+(p||0)+g}for(var x=new tn(a+22),y=(e=i,t=a-i,0);y<n.length;++y){var w=n[y],b=(ea(x,w.o,w,w.f,w.u,w.c.length),30+w.f.length+$i(w.extra));x.set(w.c,w.o+b),ea(x,i,w,w.f,w.u,w.c.length,w.o,w.m),i+=16+b+(w.m?w.m.length:0)}return ta(x,i,n.length,t,e),x},zlib:()=>function(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Kn,ei,function(){return[Ii]}],(function(e){return ri(Ii(e.data[0],e.data[1]))}),4,r)},zlibSync:()=>Ii}),a(300)),r=a.n(t);class s{constructor(e){this.scene=null,this.camera=null,this.controls=null,this.renderer=null,this.engineDom=null,this.runScene=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)}init(e){var t=this.runScene.sceneEx.create(),r=this.runScene.cameraEx.create();const s=this.runScene.renderEx.create(e);var n=this.runScene.controlsEx.create(r,s.domElement);return this.camera=r,this.scene=t,this.renderer=s,this.controls=n,this.engineDom=e,this.runScene.renderEx.setSize(),s.setAnimationLoop(this.runScene.render.bind(this.runScene)),{scene:t,camera:r,render:s,controls:n,engineDom:e}}get(){var{scene:e,camera:t,renderer:r,controls:s,engineDom:n}=this;return{scene:e,camera:t,renderer:r,controls:s,engineDom:n}}}var n=a(881);const i={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}"};class o{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const l=new n.OrthographicCamera(-1,1,1,-1,0,1),c=new n.BufferGeometry;c.setAttribute("position",new n.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new n.Float32BufferAttribute([0,2,0,0,2,0],2));class u{constructor(e){this._mesh=new n.Mesh(c,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,l)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class d extends o{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof n.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=n.UniformsUtils.clone(e.uniforms),this.material=new n.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new u(this.material)}render(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)}}const p={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new n.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}"};class m extends o{constructor(e,t,r,s){super(),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=s,this.resolution=void 0!==e?new n.Vector2(e.x,e.y):new n.Vector2(256,256),this.clearColor=new n.Color(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new n.WebGLRenderTarget(a,o),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){const t=new n.WebGLRenderTarget(a,o),r=(t.texture.name="UnrealBloomPass.h"+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t),new n.WebGLRenderTarget(a,o));r.texture.name="UnrealBloomPass.v"+e,r.texture.generateMipmaps=!1,this.renderTargetsVertical.push(r),a=Math.round(a/2),o=Math.round(o/2)}r=p;var l=(this.highPassUniforms=n.UniformsUtils.clone(r.uniforms),this.highPassUniforms.luminosityThreshold.value=s,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new n.ShaderMaterial({uniforms:this.highPassUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,defines:{}}),this.separableBlurMaterials=[],[3,5,7,9,11]);a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[e])),this.separableBlurMaterials[e].uniforms.texSize.value=new n.Vector2(a,o),a=Math.round(a/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0,this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e=i,this.copyUniforms=n.UniformsUtils.clone(e.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new n.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:n.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new n.Color,this.oldClearAlpha=1,this.basic=new n.MeshBasicMaterial,this.fsQuad=new u(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()}setSize(e,t){let r=Math.round(e/2),s=Math.round(t/2);this.renderTargetBright.setSize(r,s);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(r,s),this.renderTargetsVertical[e].setSize(r,s),this.separableBlurMaterials[e].uniforms.texSize.value=new n.Vector2(r,s),r=Math.round(r/2),s=Math.round(s/2)}render(e,t,r,s,n){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();var i=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),n&&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);let a=this.renderTargetBright;for(let t=0;t<this.nMips;t++)this.fsQuad.material=this.separableBlurMaterials[t],this.separableBlurMaterials[t].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[t].uniforms.direction.value=m.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[t]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[t].uniforms.colorTexture.value=this.renderTargetsHorizontal[t].texture,this.separableBlurMaterials[t].uniforms.direction.value=m.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[t]),e.clear(),this.fsQuad.render(e),a=this.renderTargetsVertical[t];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,n&&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=i}getSeperableBlurMaterial(e){return new n.ShaderMaterial({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new n.Vector2(.5,.5)},direction:{value:new n.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}"})}getCompositeMaterial(e){return new n.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}"})}}m.BlurDirectionX=new n.Vector2(1,0),m.BlurDirectionY=new n.Vector2(0,1);class f extends o{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){var s=e.getContext();const n=e.state;let i,a;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0),a=this.inverse?(i=0,1):(i=1,0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),n.buffers.stencil.setFunc(s.ALWAYS,i,4294967295),n.buffers.stencil.setClear(a),n.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),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(s.EQUAL,1,4294967295),n.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),n.buffers.stencil.setLocked(!0)}}class g extends o{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class v{constructor(e,t){var r;this.renderer=e,void 0===t?(r=e.getSize(new n.Vector2),this._pixelRatio=e.getPixelRatio(),this._width=r.width,this._height=r.height,(t=new n.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio)).texture.name="EffectComposer.rt1"):(this._pixelRatio=1,this._width=t.width,this._height=t.height),this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===d&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new d(i),this.clock=new n.Clock}swapBuffers(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){-1!==(e=this.passes.indexOf(e))&&this.passes.splice(e,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){void 0===e&&(e=this.clock.getDelta());var t=this.renderer.getRenderTarget();let r=!1;for(let t=0,n=this.passes.length;t<n;t++){const n=this.passes[t];if(!1!==n.enabled){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),n.render(this.renderer,this.writeBuffer,this.readBuffer,e,r),n.needsSwap){if(r){var s=this.renderer.getContext();const t=this.renderer.state.buffers.stencil;t.setFunc(s.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),t.setFunc(s.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==f&&(n instanceof f?r=!0:n instanceof g&&(r=!1))}}this.renderer.setRenderTarget(t)}reset(e){var t;void 0===e&&(t=this.renderer.getSize(new n.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}setSize(e,t){this._width=e,this._height=t;var r=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(r,s),this.renderTarget2.setSize(r,s);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}}new n.OrthographicCamera(-1,1,1,-1,0,1);const x=new n.BufferGeometry;x.setAttribute("position",new n.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),x.setAttribute("uv",new n.Float32BufferAttribute([0,2,0,0,2,0],2));class y extends o{constructor(e,t,r,s){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==r?r:0,this.clearAlpha=void 0!==s?s:0,this._oldClearColor=new n.Color,e=i,this.copyUniforms=n.UniformsUtils.clone(e.uniforms),this.copyMaterial=new n.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:n.AdditiveBlending,depthTest:!1,depthWrite:!1}),this.fsQuad=new u(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}setSize(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}render(e,t,r){this.sampleRenderTarget||(this.sampleRenderTarget=new n.WebGLRenderTarget(r.width,r.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var s=w[Math.max(0,Math.min(this.sampleLevel,5))],i=e.autoClear,a=(e.autoClear=!1,e.getClearColor(this._oldClearColor),e.getClearAlpha()),o=1/s.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(let r=0;r<s.length;r++){var h=s[r];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*h[0],l.offsetY+.0625*h[1],l.width,l.height);let n=o;this.unbiased&&(h=(r+.5)/s.length-.5,n+=1/32*h),this.copyUniforms.opacity.value=n,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===r&&(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)}}const w=[[[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 b extends y{constructor(e,t,r,s){super(e,t,r,s),this.sampleLevel=0,this.accumulate=!1}render(e,t,r,s){if(!1===this.accumulate)return super.render(e,t,r,s),void(this.accumulateIndex=-1);var i=S[5],a=(void 0===this.sampleRenderTarget&&(this.sampleRenderTarget=new n.WebGLRenderTarget(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),void 0===this.holdRenderTarget&&(this.holdRenderTarget=new n.WebGLRenderTarget(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),-1===this.accumulateIndex&&(super.render(e,this.holdRenderTarget,r,s),this.accumulateIndex=0),s=e.autoClear,e.autoClear=!1,1/i.length);if(0<=this.accumulateIndex&&this.accumulateIndex<i.length){this.copyUniforms.opacity.value=a,this.copyUniforms.tDiffuse.value=t.texture;var o=Math.pow(2,this.sampleLevel);for(let s=0;s<o;s++){var l=i[this.accumulateIndex];if(this.camera.setViewOffset&&this.camera.setViewOffset(r.width,r.height,.0625*l[0],.0625*l[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>=i.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}0<(a=this.accumulateIndex*a)&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),a<1&&(this.copyUniforms.opacity.value=1-a,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.setRenderTarget(t),0==a&&e.clear(),this.fsQuad.render(e)),e.autoClear=s}}const S=[[[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 T extends o{constructor(e,t,r){super(),this.baseTextureID=void 0!==t?t:"tDiffuse",this.effectTextureID=void 0!==r?r:"tDiffuse",e instanceof n.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=n.UniformsUtils.clone(e.uniforms),this.material=new n.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new u(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 M extends o{constructor(e,t,r,s,i){super(),this.scene=e,this.camera=t,this.layerIndex=0,this.overrideMaterial=r,this.clearColor=s,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.oldClearColor=new n.Color,this.oldCameraLayer=t.layers.mask}render(e,t,r){var s=e.autoClear;let n,i;e.autoClear=!1,void 0!==this.overrideMaterial&&(i=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this.oldClearColor),n=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,n),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=i),this.scene.background=this.sceneBg,e.autoClear=s}}const _={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 E{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 E.instance||(E.instance=new E(e)),E.instance}set rendererTone(e){this.renderer&&(this.renderer.toneMapping=e?n.ACESFilmicToneMapping:n.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 n.Vector2),this.rtSize={width:t.width,height:t.height},this.postProcessing())}setData(e){e=e.bloomParams;var{bloomRadius:e,bloomStrength:t,bloomThreshold:r,isBloom:s}=e;this.bloomParams.isBloom=s,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 n.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 n.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.effectRT.texture.name="EffectComposer.pass",this.effectRT.texture.type=n.FloatType,this.effectRT.texture.format=n.RGBAFormat,this.effectRT.texture.encoding=n.sRGBEncoding,this.effectRT.texture.minFilter=n.LinearFilter,this.effectRT.texture.magFilter=n.LinearFilter),this.effectRT.depthTexture=new n.DepthTexture(this.rtSize.width,this.rtSize.height),this.effectRT.depthTexture.format=n.DepthFormat,this.effectRT.depthTexture.type=n.UnsignedIntType,this.taaRenderPass?(this.taaRenderPass.scene=this.mainScene,this.taaRenderPass.camera=this.mainCamera):(this.taaRenderPass=new b(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 n.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.sampleRT.texture.name="TAARenderPass.sample",this.sampleRT.texture.type=n.FloatType,this.sampleRT.texture.format=n.RGBAFormat,this.sampleRT.texture.encoding=n.sRGBEncoding,this.sampleRT.texture.minFilter=n.LinearFilter,this.sampleRT.texture.magFilter=n.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 n.WebGLRenderTarget(this.rtSize.width,this.rtSize.height),this.holdRT.texture.name="TAARenderPass.hold",this.holdRT.texture.type=n.FloatType,this.holdRT.texture.format=n.RGBAFormat,this.holdRT.texture.encoding=n.sRGBEncoding,this.holdRT.texture.minFilter=n.LinearFilter,this.holdRT.texture.magFilter=n.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 M(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 m(new n.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 T(_,"baseTexture","bloomTexture"),this.mixingPass.renderToScreen=!1),this.effectCopy||(this.effectCopy=new d(i),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 v(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 P{constructor(e){this.runScene=e}create(){return new n.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}}const C={type:"change"},R={type:"start"},D={type:"end"};class A extends n.EventDispatcher{constructor(e,t){super(),void 0===t&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new n.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:n.MOUSE.ROTATE,MIDDLE:n.MOUSE.DOLLY,RIGHT:n.MOUSE.PAN},this.touches={ONE:n.TOUCH.ROTATE,TWO:n.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",q),this._domElementKeyEvents=e},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(C),r.update(),i=s.NONE},this.update=function(){const t=new n.Vector3,d=(new n.Quaternion).setFromUnitVectors(e.up,new n.Vector3(0,1,0)),p=d.clone().invert(),m=new n.Vector3,f=new n.Quaternion,g=2*Math.PI;return function(){const e=r.object.position;t.copy(e).sub(r.target),t.applyQuaternion(d),o.setFromVector3(t),r.autoRotate&&i===s.NONE&&M(2*Math.PI/60/60*r.autoRotateSpeed),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let n=r.minAzimuthAngle,v=r.maxAzimuthAngle;return isFinite(n)&&isFinite(v)&&(n<-Math.PI?n+=g:n>Math.PI&&(n-=g),v<-Math.PI?v+=g:v>Math.PI&&(v-=g),o.theta=n<=v?Math.max(n,Math.min(v,o.theta)):o.theta>(n+v)/2?Math.max(n,o.theta):Math.min(v,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=h,o.radius=Math.max(r.minDistance,Math.min(r.maxDistance,o.radius)),!0===r.enableDamping?r.target.addScaledVector(c,r.dampingFactor):r.target.add(c),t.setFromSpherical(o),t.applyQuaternion(p),e.copy(r.target).add(t),r.object.lookAt(r.target),!0===r.enableDamping?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,c.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),c.set(0,0,0)),h=1,!(!(u||m.distanceToSquared(r.object.position)>a||8*(1-f.dot(r.object.quaternion))>a)||(r.dispatchEvent(C),m.copy(r.object.position),f.copy(r.object.quaternion),u=!1))}}(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",Y),r.domElement.removeEventListener("pointerdown",V),r.domElement.removeEventListener("pointercancel",W),r.domElement.removeEventListener("wheel",X),r.domElement.removeEventListener("pointermove",H),r.domElement.removeEventListener("pointerup",G),null!==r._domElementKeyEvents&&r._domElementKeyEvents.removeEventListener("keydown",q)};const r=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=s.NONE;const a=1e-6,o=new n.Spherical,l=new n.Spherical;let h=1;const c=new n.Vector3;let u=!1;const d=new n.Vector2,p=new n.Vector2,m=new n.Vector2,f=new n.Vector2,g=new n.Vector2,v=new n.Vector2,x=new n.Vector2,y=new n.Vector2,w=new n.Vector2,b=[],S={};function T(){return Math.pow(.95,r.zoomSpeed)}function M(e){l.theta-=e}function _(e){l.phi-=e}const E=function(){const e=new n.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),c.add(e)}}(),P=function(){const e=new n.Vector3;return function(t,s){!0===r.screenSpacePanning?e.setFromMatrixColumn(s,1):(e.setFromMatrixColumn(s,0),e.crossVectors(r.object.up,e)),e.multiplyScalar(t),c.add(e)}}(),A=function(){const e=new n.Vector3;return function(t,s){var n,i=r.domElement;r.object.isPerspectiveCamera?(n=r.object.position,e.copy(n).sub(r.target),n=e.length(),n*=Math.tan(r.object.fov/2*Math.PI/180),E(2*t*n/i.clientHeight,r.object.matrix),P(2*s*n/i.clientHeight,r.object.matrix)):r.object.isOrthographicCamera?(E(t*(r.object.right-r.object.left)/r.object.zoom/i.clientWidth,r.object.matrix),P(s*(r.object.top-r.object.bottom)/r.object.zoom/i.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}}();function L(e){r.object.isPerspectiveCamera?h/=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*e)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function I(e){r.object.isPerspectiveCamera?h*=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/e)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function O(e){d.set(e.clientX,e.clientY)}function U(e){f.set(e.clientX,e.clientY)}function k(){var e,t;1===b.length?d.set(b[0].pageX,b[0].pageY):(e=.5*(b[0].pageX+b[1].pageX),t=.5*(b[0].pageY+b[1].pageY),d.set(e,t))}function B(){var e,t;1===b.length?f.set(b[0].pageX,b[0].pageY):(e=.5*(b[0].pageX+b[1].pageX),t=.5*(b[0].pageY+b[1].pageY),f.set(e,t))}function F(){var e=b[0].pageX-b[1].pageX,t=b[0].pageY-b[1].pageY;e=Math.sqrt(e*e+t*t),x.set(0,e)}function N(e){1==b.length?p.set(e.pageX,e.pageY):(s=K(e),t=.5*(e.pageX+s.x),e=.5*(e.pageY+s.y),p.set(t,e)),m.subVectors(p,d).multiplyScalar(r.rotateSpeed);var t,s=r.domElement;M(2*Math.PI*m.x/s.clientHeight),_(2*Math.PI*m.y/s.clientHeight),d.copy(p)}function z(e){var t,s;1===b.length?g.set(e.pageX,e.pageY):(t=K(e),s=.5*(e.pageX+t.x),e=.5*(e.pageY+t.y),g.set(s,e)),v.subVectors(g,f).multiplyScalar(r.panSpeed),A(v.x,v.y),f.copy(g)}function j(e){var t=K(e),s=e.pageX-t.x;e=e.pageY-t.y,t=Math.sqrt(s*s+e*e),y.set(0,t),w.set(0,Math.pow(y.y/x.y,r.zoomSpeed)),L(w.y),x.copy(y)}function V(e){var t;if(!1!==r.enabled)if(0===b.length&&(r.domElement.setPointerCapture(e.pointerId),r.domElement.addEventListener("pointermove",H),r.domElement.addEventListener("pointerup",G)),t=e,b.push(t),"touch"!==e.pointerType){var a=e;let t;switch(a.button){case 0:t=r.mouseButtons.LEFT;break;case 1:t=r.mouseButtons.MIDDLE;break;case 2:t=r.mouseButtons.RIGHT;break;default:t=-1}switch(t){case n.MOUSE.DOLLY:if(!1===r.enableZoom)return;!function(e){x.set(e.clientX,e.clientY)}(a),i=s.DOLLY;break;case n.MOUSE.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(!1===r.enablePan)return;U(a),i=s.PAN}else{if(!1===r.enableRotate)return;O(a),i=s.ROTATE}break;case n.MOUSE.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(!1===r.enableRotate)return;O(a),i=s.ROTATE}else{if(!1===r.enablePan)return;U(a),i=s.PAN}break;default:i=s.NONE}i!==s.NONE&&r.dispatchEvent(R)}else{switch(Q(e),b.length){case 1:switch(r.touches.ONE){case n.TOUCH.ROTATE:if(!1===r.enableRotate)return;k(),i=s.TOUCH_ROTATE;break;case n.TOUCH.PAN:if(!1===r.enablePan)return;B(),i=s.TOUCH_PAN;break;default:i=s.NONE}break;case 2:switch(r.touches.TWO){case n.TOUCH.DOLLY_PAN:if(!1===r.enableZoom&&!1===r.enablePan)return;r.enableZoom&&F(),r.enablePan&&B(),i=s.TOUCH_DOLLY_PAN;break;case n.TOUCH.DOLLY_ROTATE:if(!1===r.enableZoom&&!1===r.enableRotate)return;r.enableZoom&&F(),r.enableRotate&&k(),i=s.TOUCH_DOLLY_ROTATE;break;default:i=s.NONE}break;default:i=s.NONE}i!==s.NONE&&r.dispatchEvent(R)}}function H(e){if(!1!==r.enabled)if("touch"===e.pointerType){var t=e;switch(Q(t),i){case s.TOUCH_ROTATE:if(!1===r.enableRotate)return;N(t),r.update();break;case s.TOUCH_PAN:if(!1===r.enablePan)return;z(t),r.update();break;case s.TOUCH_DOLLY_PAN:if(!1===r.enableZoom&&!1===r.enablePan)return;!function(e){r.enableZoom&&j(e),r.enablePan&&z(e)}(t),r.update();break;case s.TOUCH_DOLLY_ROTATE:if(!1===r.enableZoom&&!1===r.enableRotate)return;!function(e){r.enableZoom&&j(e),r.enableRotate&&N(e)}(t),r.update();break;default:i=s.NONE}}else{var n=e;if(!1!==r.enabled)switch(i){case s.ROTATE:if(!1===r.enableRotate)return;!function(e){p.set(e.clientX,e.clientY),m.subVectors(p,d).multiplyScalar(r.rotateSpeed),e=r.domElement,M(2*Math.PI*m.x/e.clientHeight),_(2*Math.PI*m.y/e.clientHeight),d.copy(p),r.update()}(n);break;case s.DOLLY:if(!1===r.enableZoom)return;!function(e){y.set(e.clientX,e.clientY),w.subVectors(y,x),0<w.y?L(T()):w.y<0&&I(T()),x.copy(y),r.update()}(n);break;case s.PAN:if(!1===r.enablePan)return;!function(e){g.set(e.clientX,e.clientY),v.subVectors(g,f).multiplyScalar(r.panSpeed),A(v.x,v.y),f.copy(g),r.update()}(n)}}}function G(e){Z(e),0===b.length&&(r.domElement.releasePointerCapture(e.pointerId),r.domElement.removeEventListener("pointermove",H),r.domElement.removeEventListener("pointerup",G)),r.dispatchEvent(D),i=s.NONE}function W(e){Z(e)}function X(e){!1!==r.enabled&&!1!==r.enableZoom&&i===s.NONE&&(e.preventDefault(),r.dispatchEvent(R),e.deltaY<0?I(T()):0<e.deltaY&&L(T()),r.update(),r.dispatchEvent(D))}function q(e){if(!1!==r.enabled&&!1!==r.enablePan){let t=!1;switch(e.code){case r.keys.UP:A(0,r.keyPanSpeed),t=!0;break;case r.keys.BOTTOM:A(0,-r.keyPanSpeed),t=!0;break;case r.keys.LEFT:A(r.keyPanSpeed,0),t=!0;break;case r.keys.RIGHT:A(-r.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),r.update())}}function Y(e){!1!==r.enabled&&e.preventDefault()}function Z(e){delete S[e.pointerId];for(let t=0;t<b.length;t++)if(b[t].pointerId==e.pointerId)return void b.splice(t,1)}function Q(e){let t=S[e.pointerId];void 0===t&&(t=new n.Vector2,S[e.pointerId]=t),t.set(e.pageX,e.pageY)}function K(e){return e=e.pointerId===b[0].pointerId?b[1]:b[0],S[e.pointerId]}r.domElement.addEventListener("contextmenu",Y),r.domElement.addEventListener("pointerdown",V),r.domElement.addEventListener("pointercancel",W),r.domElement.addEventListener("wheel",X,{passive:!1}),this.update()}}class L{create(e,t){return new A(e,t)}}class I{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 O=a(594),U=a(129),k=a(685);let B,F,N,z,j,V,H,G,W,X={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},q={duration:.5,overwrite:!1,delay:0},Y=1e8,Z=1/Y,Q=2*Math.PI,K=Q/4,J=0,$=Math.sqrt,ee=Math.cos,te=Math.sin,re=e=>"string"==typeof e,se=e=>"function"==typeof e,ne=e=>"number"==typeof e,ie=e=>void 0===e,ae=e=>"object"==typeof e,oe=e=>!1!==e,le=()=>"undefined"!=typeof window,he=e=>se(e)||re(e),ce="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},ue=Array.isArray,de=/(?:-?\.?\d|\.)+/gi,pe=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,me=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,fe=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,ge=/[+-]=-?[.\d]+/,ve=/[^,'"\[\]\s]+/gi,xe=/[\d.+\-=]+(?:e[-+]\d*)*/i,ye={},we={},be=e=>(we=Ge(e,ye))&&Cr,Se=(e,t)=>console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()"),Te=(e,t)=>!t&&console.warn(e),Me=(e,t)=>e&&(ye[e]=t)&&we&&(we[e]=t)||ye,_e=()=>0,Ee={},Pe=[],Ce={},Re={},De={},Ae=30,Le=[],Ie="",Oe=e=>{let t,r,s=e[0];if(ae(s)||se(s)||(e=[e]),!(t=(s._gsap||{}).harness)){for(r=Le.length;r--&&!Le[r].targetTest(s););t=Le[r]}for(r=e.length;r--;)e[r]&&(e[r]._gsap||(e[r]._gsap=new er(e[r],t)))||e.splice(r,1);return e},Ue=e=>e._gsap||Oe(yt(e))[0]._gsap,ke=(e,t,r)=>(r=e[t])&&se(r)?e[t]():ie(r)&&e.getAttribute&&e.getAttribute(t)||r,Be=(e,t)=>(e=e.split(",")).forEach(t)||e,Fe=e=>Math.round(1e7*e)/1e7||0,Ne=()=>{let e,t,r=Pe.length,s=Pe.slice(0);for(Ce={},Pe.length=0,e=0;e<r;e++)(t=s[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},ze=(e,t,r,s)=>{Pe.length&&Ne(),e.render(t,r,s),Pe.length&&Ne()},je=e=>{var t=parseFloat(e);return(t||0===t)&&(e+"").match(ve).length<2?t:re(e)?e.trim():e},Ve=e=>e,He=(e,t)=>{for(var r in t)r in e||(e[r]=t[r]);return e},Ge=(e,t)=>{for(var r in t)e[r]=t[r];return e},We=(e,t)=>{for(var r in t)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(e[r]=ae(t[r])?We(e[r]||(e[r]={}),t[r]):t[r]);return e},Xe=(e,t)=>{let r,s={};for(r in e)r in t||(s[r]=e[r]);return s},qe=e=>{let t=e.parent||F,r=e.keyframes?(s=ue(e.keyframes),(e,t)=>{for(var r in t)r in e||"duration"===r&&s||"ease"===r||(e[r]=t[r])}):He;var s;if(oe(e.inherit))for(;t;)r(e,t.vars.defaults),t=t.parent||t._dp;return e},Ye=(e,t,r="_first",s="_last")=>{let n=t._prev,i=t._next;n?n._next=i:e[r]===t&&(e[r]=i),i?i._prev=n:e[s]===t&&(e[s]=n),t._next=t._prev=t.parent=null},Ze=(e,t)=>{!e.parent||t&&!e.parent.autoRemoveChildren||e.parent.remove(e),e._act=0},Qe=(e,t)=>{if(e&&(!t||t._end>e._dur||t._start<0)){let t=e;for(;t;)t._dirty=1,t=t.parent}return e},Ke=e=>!e||e._ts&&Ke(e.parent),Je=e=>e._repeat?$e(e._tTime,e=e.duration()+e._rDelay)*e:0,$e=(e,t)=>(t=Math.floor(e/=t),e&&t===e?t-1:t),et=(e,t)=>(e-t._start)*t._ts+(0<=t._ts?0:t._dirty?t.totalDuration():t._tDur),tt=e=>e._end=Fe(e._start+(e._tDur/Math.abs(e._ts||e._rts||Z)||0)),rt=(e,t)=>{var r=e._dp;return r&&r.smoothChildTiming&&e._ts&&(e._start=Fe(r._time-(0<e._ts?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),tt(e),r._dirty||Qe(r,e)),e},st=(e,t)=>{let r;if((t._time||t._initted&&!t._dur)&&(r=et(e.rawTime(),t),(!t._dur||ft(0,t.totalDuration(),r)-t._tTime>Z)&&t.render(r,!0)),Qe(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=-Z}},nt=(e,t,r,s)=>{t.parent&&Ze(t),t._start=Fe((ne(r)?r:r||e!==F?dt(e,r,t):e._time)+t._delay),t._end=Fe(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0));{var n=t,i="_first",a="_last",o=(r=e)._sort?"_start":0;let s,l=r[a];if(o)for(s=n[o];l&&l[o]>s;)l=l._prev;l?(n._next=l._next,l._next=n):(n._next=r[i],r[i]=n),n._next?n._next._prev=n:r[a]=n,n._prev=l,n.parent=n._dp=r}return lt(t)||(e._recent=t),s||st(e,t),e},it=(e,t)=>(ye.ScrollTrigger||Se("scrollTrigger",t))&&ye.ScrollTrigger.create(t,e),at=(e,t,r,s)=>(or(e,t),e._initted?!r&&e._pt&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&H!==jt.frame?(Pe.push(e),e._lazy=[t,s],1):void 0:1),ot=({parent:e})=>e&&e._ts&&e._initted&&!e._lock&&(e.rawTime()<0||ot(e)),lt=({data:e})=>"isFromStart"===e||"isStart"===e,ht=(e,t,r,s)=>{var n=e._repeat,i=Fe(t)||0;return(t=e._tTime/e._tDur)&&!s&&(e._time*=i/e._dur),e._dur=i,e._tDur=n?n<0?1e10:Fe(i*(n+1)+e._rDelay*n):i,0<t&&!s?rt(e,e._tTime=e._tDur*t):e.parent&&tt(e),r||Qe(e.parent,e),e},ct=e=>e instanceof rr?Qe(e):ht(e,e._dur),ut={_start:0,endTime:_e,totalDuration:_e},dt=(e,t,r)=>{let s,n,i,a=e.labels,o=e._recent||ut,l=e.duration()>=Y?o.endTime(!1):e._dur;return re(t)&&(isNaN(t)||t in a)?(n=t.charAt(0),i="%"===t.substr(-1),s=t.indexOf("="),"<"===n||">"===n?(0<=s&&(t=t.replace(/=/,"")),("<"===n?o._start:o.endTime(0<=o._repeat))+(parseFloat(t.substr(1))||0)*(i?(s<0?o:r).totalDuration()/100:1)):s<0?(t in a||(a[t]=l),a[t]):(n=parseFloat(t.charAt(s-1)+t.substr(s+1)),i&&r&&(n=n/100*(ue(r)?r[0]:r).totalDuration()),1<s?dt(e,t.substr(0,s-1),r)+n:l+n)):null==t?l:+t},pt=(e,t,r)=>{let s,n,i=ne(t[1]),a=(i?2:1)+(e<2?0:1),o=t[a];if(i&&(o.duration=t[1]),o.parent=r,e){for(s=o,n=r;n&&!("immediateRender"in s);)s=n.vars.defaults||{},n=oe(n.vars.inherit)&&n.parent;o.immediateRender=oe(s.immediateRender),e<2?o.runBackwards=1:o.startAt=t[a-1]}return new ur(t[0],o,t[1+a])},mt=(e,t)=>e||0===e?t(e):t,ft=(e,t,r)=>r<e?e:t<r?t:r,gt=(e,t)=>re(e)&&(t=xe.exec(e))?e.substr(t.index+t[0].length):"",vt=[].slice,xt=(e,t)=>e&&ae(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&ae(e[0]))&&!e.nodeType&&e!==N,yt=(e,t,r)=>!re(e)||r||!z&&Vt()?ue(e)?((e,t,r=[])=>e.forEach((e=>re(e)&&!t||xt(e,1)?r.push(...yt(e)):r.push(e)))||r)(e,r):xt(e)?vt.call(e,0):e?[e]:[]:vt.call((t||j).querySelectorAll(e),0),wt=e=>e.sort((()=>.5-Math.random())),bt=e=>{if(se(e))return e;let t=ae(e)?e:{each:e},r=Yt(t.ease),s=t.from||0,n=parseFloat(t.base)||0,i={},a=0<s&&s<1,o=isNaN(s)||a,l=t.axis,h=s,c=s;return re(s)?h=c={center:.5,edges:.5,end:1}[s]||0:!a&&o&&(h=s[0],c=s[1]),(e,a,u)=>{let d,p,m,f,g,v,x,y,w,b=(u||t).length,S=i[b];if(!S){if(!(w="auto"===t.grid?0:(t.grid||[1,Y])[1])){for(x=-Y;x<(x=u[w++].getBoundingClientRect().left)&&w<b;);w--}for(S=i[b]=[],d=o?Math.min(w,b)*h-.5:s%w,p=w===Y?0:o?b*c/w-.5:s/w|0,x=0,y=Y,v=0;v<b;v++)m=v%w-d,f=p-(v/w|0),S[v]=g=l?Math.abs("y"===l?f:m):$(m*m+f*f),g>x&&(x=g),g<y&&(y=g);"random"===s&&wt(S),S.max=x-y,S.min=y,S.v=b=(parseFloat(t.amount)||parseFloat(t.each)*(w>b?b-1:l?"y"===l?b/w:w:Math.max(w,b/w))||0)*("edges"===s?-1:1),S.b=b<0?n-b:n,S.u=gt(t.amount||t.each)||0,r=r&&b<0?Xt(r):r}return b=(S[e]-S.min)/S.max||0,Fe(S.b+(r?r(b):b)*S.v)+S.u}},St=e=>{let t=Math.pow(10,((e+"").split(".")[1]||"").length);return r=>{var s=Math.round(parseFloat(r)/e)*e*t;return(s-s%1)/t+(ne(r)?0:gt(r))}},Tt=(e,t)=>{let r,s,n=ue(e);return!n&&ae(e)&&(r=n=e.radius||Y,e.values?(e=yt(e.values),(s=!ne(e[0]))&&(r*=r)):e=St(e.increment)),mt(t,n?se(e)?t=>(s=e(t),Math.abs(s-t)<=r?s:t):t=>{let n,i,a=parseFloat(s?t.x:t),o=parseFloat(s?t.y:0),l=Y,h=0,c=e.length;for(;c--;)(n=s?(n=e[c].x-a,i=e[c].y-o,n*n+i*i):Math.abs(e[c]-a))<l&&(l=n,h=c);return h=!r||l<=r?e[h]:t,s||h===t||ne(t)?h:h+gt(t)}:St(e))},Mt=(e,t,r,s)=>mt(ue(e)?!t:!0===r?!!(r=0):!s,(()=>ue(e)?e[~~(Math.random()*e.length)]:(r=r||1e-5)&&(s=r<1?10**((r+"").length-2):1)&&Math.floor(Math.round((e-r/2+Math.random()*(t-e+.99*r))/r)*r*s)/s)),_t=(e,t,r)=>mt(r,(r=>e[~~t(r)])),Et=(e,t,r)=>{let s=t-e,n=2*s;return ue(e)?_t(e,Et(0,e.length-1),t):mt(r,(t=>e+((t=(n+(t-e)%n)%n||0)>s?n-t:t)))},Pt=e=>{let t,r,s,n,i=0,a="";for(;~(t=e.indexOf("random(",i));)s=e.indexOf(")",t),n="["===e.charAt(t+7),r=e.substr(t+7,s-t-7).match(n?ve:de),a+=e.substr(i,t-i)+Mt(n?r:+r[0],n?0:+r[1],+r[2]||1e-5),i=s+1;return a+e.substr(i,e.length-i)},Ct=(e,t,r,s,n)=>{let i=t-e,a=s-r;return mt(n,(t=>r+((t-e)/i*a||0)))},Rt=(e,t,r,s)=>{let n=isNaN(e+t)?0:r=>(1-r)*e+r*t;if(!n){let i,a,o,l,h,c=re(e),u={};if(!0===r&&(s=1)&&(r=null),c)e={p:e},t={p:t};else if(ue(e)&&!ue(t)){for(o=[],l=e.length,h=l-2,a=1;a<l;a++)o.push(Rt(e[a-1],e[a]));l--,n=e=>{e*=l;var t=Math.min(h,~~e);return o[t](e-t)},r=t}else s||(e=Ge(ue(e)?[]:{},e));if(!o){for(i in t)ir.call(u,e,i,"get",t[i]);n=t=>(pr(t,u),c?e.p:e)}}return mt(r,n)},Dt=(e,t,r)=>{let s,n,i,a=e.labels,o=Y;for(s in a)n=a[s]-t,n<0==!!r&&n&&o>(n=Math.abs(n))&&(i=s,o=n);return i},At=(e,t,r)=>{let s,n,i=e.vars,a=i[t];if(a)return s=i[t+"Params"],n=i.callbackScope||e,r&&Pe.length&&Ne(),s?a.apply(n,s):a.call(n)},Lt=e=>(Ze(e),e.scrollTrigger&&e.scrollTrigger.kill(!1),e.progress()<1&&At(e,"onInterrupt"),e),It=255,Ot={aqua:[0,It,It],lime:[0,It,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,It],navy:[0,0,128],white:[It,It,It],olive:[128,128,0],yellow:[It,It,0],orange:[It,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[It,0,0],pink:[It,192,203],cyan:[0,It,It],transparent:[It,It,It,0]},Ut=(e,t,r)=>(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)*It+.5|0,kt=(e,t,r)=>{let s,n,i,a,o,l,h,c,u,d,p=e?ne(e)?[e>>16,e>>8&It,e&It]:0:Ot.black;if(!p){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),Ot[e])p=Ot[e];else if("#"===e.charAt(0)){if(e.length<6&&(s=e.charAt(1),n=e.charAt(2),i=e.charAt(3),e="#"+s+s+n+n+i+i+(5===e.length?e.charAt(4)+e.charAt(4):"")),9===e.length)return[(p=parseInt(e.substr(1,6),16))>>16,p>>8&It,p&It,parseInt(e.substr(7),16)/255];p=[(e=parseInt(e.substr(1),16))>>16,e>>8&It,e&It]}else if("hsl"===e.substr(0,3))if(p=d=e.match(de),t){if(~e.indexOf("="))return p=e.match(pe),r&&p.length<4&&(p[3]=1),p}else a=+p[0]%360/360,o=+p[1]/100,l=+p[2]/100,n=l<=.5?l*(o+1):l+o-l*o,s=2*l-n,3<p.length&&(p[3]*=1),p[0]=Ut(a+1/3,s,n),p[1]=Ut(a,s,n),p[2]=Ut(a-1/3,s,n);else p=e.match(de)||Ot.transparent;p=p.map(Number)}return t&&!d&&(s=p[0]/It,n=p[1]/It,i=p[2]/It,h=Math.max(s,n,i),c=Math.min(s,n,i),l=(h+c)/2,h===c?a=o=0:(u=h-c,o=.5<l?u/(2-h-c):u/(h+c),a=h===s?(n-i)/u+(n<i?6:0):h===n?(i-s)/u+2:(s-n)/u+4,a*=60),p[0]=~~(a+.5),p[1]=~~(100*o+.5),p[2]=~~(100*l+.5)),r&&p.length<4&&(p[3]=1),p},Bt=e=>{let t=[],r=[],s=-1;return e.split(Nt).forEach((e=>{e=e.match(me)||[],t.push(...e),r.push(s+=e.length+1)})),t.c=r,t},Ft=(e,t,r)=>{let s,n,i,a,o="",l=(e+o).match(Nt),h=t?"hsla(":"rgba(",c=0;if(!l)return e;if(l=l.map((e=>(e=kt(e,t,1))&&h+(t?e[0]+","+e[1]+"%,"+e[2]+"%,"+e[3]:e.join(","))+")")),r&&(i=Bt(e),(s=r.c).join(o)!==i.c.join(o)))for(n=e.replace(Nt,"1").split(me),a=n.length-1;c<a;c++)o+=n[c]+(~s.indexOf(c)?l.shift()||h+"0,0,0,0)":(i.length?i:l.length?l:r).shift());if(!n)for(n=e.split(Nt),a=n.length-1;c<a;c++)o+=n[c]+l[c];return o+n[a]},Nt=function(){let e,t="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b";for(e in Ot)t+="|"+e+"\\b";return new RegExp(t+")","gi")}(),zt=/hsl[a]?\(/,jt=function(){let e,t,r,s,n,i,a=Date.now,o=500,l=33,h=a(),c=h,u=1e3/240,d=u,p=[],m=r=>{let f,g,v,x,y=a()-c,w=!0===r;if(y>o&&(h+=y-l),c+=y,(0<(f=(v=c-h)-d)||w)&&(x=++s.frame,n=v-1e3*s.time,s.time=v/=1e3,d+=f+(f>=u?4:u-f),g=1),w||(e=t(m)),g)for(i=0;i<p.length;i++)p[i](v,n,x,r)};return s={time:0,frame:0,tick(){m(!0)},deltaRatio:e=>n/(1e3/(e||60)),wake(){V&&(!z&&le()&&(N=z=window,j=N.document||{},ye.gsap=Cr,(N.gsapVersions||(N.gsapVersions=[])).push(Cr.version),be(we||N.GreenSockGlobals||!N.gsap&&N||{}),r=N.requestAnimationFrame),e&&s.sleep(),t=r||(e=>setTimeout(e,d-1e3*s.time+1|0)),W=1,m(2))},sleep(){(r?N.cancelAnimationFrame:clearTimeout)(e),W=0,t=_e},lagSmoothing(e,t){o=e||1/Z,l=Math.min(t,o,0)},fps(e){u=1e3/(e||240),d=1e3*s.time+u},add(e){p.indexOf(e)<0&&p.push(e),Vt()},remove(e,t){~(t=p.indexOf(e))&&p.splice(t,1)&&i>=t&&i--},_listeners:p}}(),Vt=()=>!W&&jt.wake(),Ht={},Gt=/^[\d.\-M][\d.\-,\s]/,Wt=/["']/g,Xt=e=>t=>1-e(1-t),qt=(e,t)=>{let r,s=e._first;for(;s;)s instanceof rr?qt(s,t):!s.vars.yoyoEase||s._yoyo&&s._repeat||s._yoyo===t||(s.timeline?qt(s.timeline,t):(r=s._ease,s._ease=s._yEase,s._yEase=r,s._yoyo=t)),s=s._next},Yt=(e,t)=>e&&(se(e)?e:Ht[e]||(e=>{let t=(e+"").split("("),r=Ht[t[0]];return r&&1<t.length&&r.config?r.config.apply(null,~e.indexOf("{")?[(e=>{let t,r,s,n={},i=e.substr(1,e.length-3).split(":"),a=i[0],o=1,l=i.length;for(;o<l;o++)r=i[o],t=o!==l-1?r.lastIndexOf(","):r.length,s=r.substr(0,t),n[a]=isNaN(s)?s.replace(Wt,"").trim():+s,a=r.substr(t+1).trim();return n})(t[1])]:(n=(s=e).indexOf("(")+1,i=s.indexOf(")"),a=s.indexOf("(",n),s.substring(n,~a&&a<i?s.indexOf(")",i+1):i).split(",").map(je))):Ht._CE&&Gt.test(e)?Ht._CE("",e):r;var s,n,i,a})(e))||t,Zt=(e,t,r=(e=>1-t(1-e)),s=(e=>e<.5?t(2*e)/2:1-t(2*(1-e))/2))=>{let n,i={easeIn:t,easeOut:r,easeInOut:s};return Be(e,(e=>{for(var t in Ht[e]=ye[e]=i,Ht[n=e.toLowerCase()]=r,i)Ht[n+("easeIn"===t?".in":"easeOut"===t?".out":".inOut")]=Ht[e+"."+t]=i[t]})),i},Qt=e=>t=>t<.5?(1-e(1-2*t))/2:.5+e(2*(t-.5))/2,Kt=(e,t,r)=>{let s=1<=t?t:1,n=(r||(e?.3:.45))/(t<1?t:1),i=n/Q*(Math.asin(1/s)||0),a=e=>1===e?1:s*2**(-10*e)*te((e-i)*n)+1,o="out"===e?a:"in"===e?e=>1-a(1-e):Qt(a);return n=Q/n,o.config=(t,r)=>Kt(e,t,r),o},Jt=(e,t=1.70158)=>{let r=e=>e?--e*e*((t+1)*e+t)+1:0,s="out"===e?r:"in"===e?e=>1-r(1-e):Qt(r);return s.config=t=>Jt(e,t),s};Be("Linear,Quad,Cubic,Quart,Quint,Strong",((e,t)=>{let r=t<5?t+1:t;Zt(e+",Power"+(r-1),t?e=>e**r:e=>e,(e=>1-(1-e)**r),(e=>e<.5?(2*e)**r/2:1-(2*(1-e))**r/2))})),Ht.Linear.easeNone=Ht.none=Ht.Linear.easeIn,Zt("Elastic",Kt("in"),Kt("out"),Kt());{var $t=7.5625;let e=1/2.75,t=t=>t<e?$t*t*t:t<.7272727272727273?$t*(t-1.5/2.75)**2+.75:t<.9090909090909092?$t*(t-=2.25/2.75)*t+.9375:$t*(t-2.625/2.75)**2+.984375;Zt("Bounce",(e=>1-t(1-e)),t)}Zt("Expo",(e=>e?2**(10*(e-1)):0)),Zt("Circ",(e=>-($(1-e*e)-1))),Zt("Sine",(e=>1===e?1:1-ee(e*K))),Zt("Back",Jt("in"),Jt("out"),Jt()),Ht.SteppedEase=Ht.steps=ye.SteppedEase={config(e=1,t){let r=1/e,s=e+(t?0:1),n=t?1:0;return e=>((s*ft(0,.99999999,e)|0)+n)*r}},q.ease=Ht["quad.out"],Be("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",(e=>Ie+=e+","+e+"Params,"));class er{constructor(e,t){this.id=J++,(e._gsap=this).target=e,this.harness=t,this.get=t?t.get:ke,this.set=t?t.getSetter:yr}}class tr{constructor(e){this.vars=e,this._delay=+e.delay||0,(this._repeat=e.repeat===1/0?-2:e.repeat||0)&&(this._rDelay=e.repeatDelay||0,this._yoyo=!!e.yoyo||!!e.yoyoEase),this._ts=1,ht(this,+e.duration,1,1),this.data=e.data,W||jt.wake()}delay(e){return e||0===e?(this.parent&&this.parent.smoothChildTiming&&this.startTime(this._start+e-this._delay),this._delay=e,this):this._delay}duration(e){return arguments.length?this.totalDuration(0<this._repeat?e+(e+this._rDelay)*this._repeat:e):this.totalDuration()&&this._dur}totalDuration(e){return arguments.length?(this._dirty=0,ht(this,this._repeat<0?e:(e-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur}totalTime(e,t){if(Vt(),!arguments.length)return this._tTime;let r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(rt(this,e),r._dp&&!r.parent&&st(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)&&nt(this._dp,this,this._start-this._delay)}return(this._tTime!==e||!this._dur&&!t||this._initted&&Math.abs(this._zTime)===Z||!e&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=e),ze(this,e,t)),this}time(e,t){return arguments.length?this.totalTime(Math.min(this.totalDuration(),e+Je(this))%(this._dur+this._rDelay)||(e?this._dur:0),t):this._time}totalProgress(e,t){return arguments.length?this.totalTime(this.totalDuration()*e,t):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.ratio}progress(e,t){return arguments.length?this.totalTime(this.duration()*(!this._yoyo||1&this.iteration()?e:1-e)+Je(this),t):this.duration()?Math.min(1,this._time/this._dur):this.ratio}iteration(e,t){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(e-1)*r,t):this._repeat?$e(this._tTime,r)+1:1}timeScale(e){if(!arguments.length)return this._rts===-Z?0:this._rts;if(this._rts===e)return this;var t=this.parent&&this._ts?et(this.parent._time,this):this._tTime;this._rts=+e||0,this._ts=this._ps||e===-Z?0:this._rts;{let r=(e=this.totalTime(ft(-this._delay,this._tDur,t),!0)).parent;for(;r&&r.parent;)r._dirty=1,r.totalDuration(),r=r.parent}return tt(this),this}paused(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):(Vt(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,1===this.progress()&&Math.abs(this._zTime)!==Z&&(this._tTime-=Z)))),this):this._ps}startTime(e){var t;return arguments.length?(this._start=e,!(t=this.parent||this._dp)||!t._sort&&this.parent||nt(t,this,e-this._delay),this):this._start}endTime(e){return this._start+(oe(e)?this.totalDuration():this.duration())/Math.abs(this._ts||1)}rawTime(e){let 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?et(t.rawTime(e),this):this._tTime:this._tTime}globalTime(e){let t=this,r=arguments.length?e:t.rawTime();for(;t;)r=t._start+r/(t._ts||1),t=t._dp;return r}repeat(e){return arguments.length?(this._repeat=e===1/0?-2:e,ct(this)):-2===this._repeat?1/0:this._repeat}repeatDelay(e){var t;return arguments.length?(t=this._time,this._rDelay=e,ct(this),t?this.time(t):this):this._rDelay}yoyo(e){return arguments.length?(this._yoyo=e,this):this._yoyo}seek(e,t){return this.totalTime(dt(this,e),oe(t))}restart(e,t){return this.play().totalTime(e?-this._delay:0,oe(t))}play(e,t){return null!=e&&this.seek(e,t),this.reversed(!1).paused(!1)}reverse(e,t){return null!=e&&this.seek(e||this.totalDuration(),t),this.reversed(!0).paused(!1)}pause(e,t){return null!=e&&this.seek(e,t),this.paused(!0)}resume(){return this.paused(!1)}reversed(e){return arguments.length?(!!e!==this.reversed()&&this.timeScale(-this._rts||(e?-Z:0)),this):this._rts<0}invalidate(){return this._initted=this._act=0,this._zTime=-Z,this}isActive(){let e,t=this.parent||this._dp,r=this._start;return!(t&&!(this._ts&&this._initted&&t.isActive()&&(e=t.rawTime(!0))>=r&&e<this.endTime(!0)-Z))}eventCallback(e,t,r){let s=this.vars;return 1<arguments.length?(t?(s[e]=t,r&&(s[e+"Params"]=r),"onUpdate"===e&&(this._onUpdate=t)):delete s[e],this):s[e]}then(e){let t=this;return new Promise((r=>{let s=se(e)?e:Ve,n=()=>{var e=t.then;t.then=null,se(s)&&(s=s(t))&&(s.then||s===t)&&(t.then=e),r(s),t.then=e};t._initted&&1===t.totalProgress()&&0<=t._ts||!t._tTime&&t._ts<0?n():t._prom=n}))}kill(){Lt(this)}}He(tr.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:-Z,_prom:0,_ps:!1,_rts:1});class rr extends tr{constructor(e={},t){super(e),this.labels={},this.smoothChildTiming=!!e.smoothChildTiming,this.autoRemoveChildren=!!e.autoRemoveChildren,this._sort=oe(e.sortChildren),F&&nt(e.parent||F,this,t),e.reversed&&this.reverse(),e.paused&&this.paused(!0),e.scrollTrigger&&it(this,e.scrollTrigger)}to(e,t,r){return pt(0,arguments,this),this}from(e,t,r){return pt(1,arguments,this),this}fromTo(e,t,r,s){return pt(2,arguments,this),this}set(e,t,r){return t.duration=0,t.parent=this,qe(t).repeatDelay||(t.repeat=0),t.immediateRender=!!t.immediateRender,new ur(e,t,dt(this,r),1),this}call(e,t,r){return nt(this,ur.delayedCall(0,e,t),r)}staggerTo(e,t,r,s,n,i,a){return r.duration=t,r.stagger=r.stagger||s,r.onComplete=i,r.onCompleteParams=a,r.parent=this,new ur(e,r,dt(this,n)),this}staggerFrom(e,t,r,s,n,i,a){return r.runBackwards=1,qe(r).immediateRender=oe(r.immediateRender),this.staggerTo(e,t,r,s,n,i,a)}staggerFromTo(e,t,r,s,n,i,a,o){return s.startAt=r,qe(s).immediateRender=oe(s.immediateRender),this.staggerTo(e,t,s,n,i,a,o)}render(e,t,r){let s,n,i,a,o,l,h,c,u,d,p,m,f=this._time,g=this._dirty?this.totalDuration():this._tDur,v=this._dur,x=e<=0?0:Fe(e),y=this._zTime<0!=e<0&&(this._initted||!v);if((x=this!==F&&x>g&&0<=e?g:x)!==this._tTime||r||y){if(f!==this._time&&v&&(x+=this._time-f,e+=this._time-f),s=x,u=this._start,l=!(c=this._ts),y&&(v||(f=this._zTime),!e&&t||(this._zTime=e)),this._repeat){if(p=this._yoyo,o=v+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*o+e,t,r);if(s=Fe(x%o),x===g?(a=this._repeat,s=v):((a=~~(x/o))&&a===x/o&&(s=v,a--),s>v&&(s=v)),d=$e(this._tTime,o),!f&&this._tTime&&d!==a&&(d=a),p&&1&a&&(s=v-s,m=1),a!==d&&!this._lock){let e=p&&1&d,r=e===(p&&1&a);if(a<d&&(e=!e),f=e?0:v,this._lock=1,this.render(f||(m?0:Fe(a*o)),t,!v)._lock=0,this._tTime=x,!t&&this.parent&&At(this,"onRepeat"),this.vars.repeatRefresh&&!m&&(this.invalidate()._lock=1),f&&f!==this._time||l!=!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(v=this._dur,g=this._tDur,r&&(this._lock=2,f=e?v:-1e-4,this.render(f,!0),this.vars.repeatRefresh&&!m&&this.invalidate()),this._lock=0,!this._ts&&!l)return this;qt(this,m)}}if(this._hasPause&&!this._forcing&&this._lock<2&&(h=((e,t,r)=>{let s;if(t<r)for(s=e._first;s&&s._start<=r;){if("isPause"===s.data&&s._start>t)return s;s=s._next}else for(s=e._last;s&&s._start>=r;){if("isPause"===s.data&&s._start<t)return s;s=s._prev}})(this,Fe(f),Fe(s)))&&(x-=s-(s=h._start)),this._tTime=x,this._time=s,this._act=!c,this._initted||(this._onUpdate=this.vars.onUpdate,this._initted=1,this._zTime=e,f=0),!f&&s&&!t&&(At(this,"onStart"),this._tTime!==x))return this;if(s>=f&&0<=e)for(n=this._first;n;){if(i=n._next,(n._act||s>=n._start)&&n._ts&&h!==n){if(n.parent!==this)return this.render(e,t,r);if(n.render(0<n._ts?(s-n._start)*n._ts:(n._dirty?n.totalDuration():n._tDur)+(s-n._start)*n._ts,t,r),s!==this._time||!this._ts&&!l){h=0,i&&(x+=this._zTime=-Z);break}}n=i}else{n=this._last;for(var w=e<0?e:s;n;){if(i=n._prev,(n._act||w<=n._end)&&n._ts&&h!==n){if(n.parent!==this)return this.render(e,t,r);if(n.render(0<n._ts?(w-n._start)*n._ts:(n._dirty?n.totalDuration():n._tDur)+(w-n._start)*n._ts,t,r),s!==this._time||!this._ts&&!l){h=0,i&&(x+=this._zTime=w?-Z:Z);break}}n=i}}if(h&&!t&&(this.pause(),h.render(s>=f?0:-Z)._zTime=s>=f?1:-1,this._ts))return this._start=u,tt(this),this.render(e,t,r);this._onUpdate&&!t&&At(this,"onUpdate",!0),!(x===g&&g>=this.totalDuration()||!x&&f)||u!==this._start&&Math.abs(c)===Math.abs(this._ts)||this._lock||(!e&&v||!(x===g&&0<this._ts||!x&&this._ts<0)||Ze(this,1),t||e<0&&!f||!x&&!f&&g||(At(this,x===g&&0<=e?"onComplete":"onReverseComplete",!0),!this._prom||x<g&&0<this.timeScale()||this._prom()))}return this}add(e,t){if(ne(t)||(t=dt(this,t,e)),!(e instanceof tr)){if(ue(e))return e.forEach((e=>this.add(e,t))),this;if(re(e))return this.addLabel(e,t);if(!se(e))return this;e=ur.delayedCall(0,e)}return this!==e?nt(this,e,t):this}getChildren(e=!0,t=!0,r=!0,s=-Y){let n=[],i=this._first;for(;i;)i._start>=s&&(i instanceof ur?t&&n.push(i):(r&&n.push(i),e&&n.push(...i.getChildren(!0,t,r)))),i=i._next;return n}getById(e){let t=this.getChildren(1,1,1),r=t.length;for(;r--;)if(t[r].vars.id===e)return t[r]}remove(e){return re(e)?this.removeLabel(e):se(e)?this.killTweensOf(e):(Ye(this,e),e===this._recent&&(this._recent=this._last),Qe(this))}totalTime(e,t){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=Fe(jt.time-(0<this._ts?e/this._ts:(this.totalDuration()-e)/-this._ts))),super.totalTime(e,t),this._forcing=0,this):this._tTime}addLabel(e,t){return this.labels[e]=dt(this,t),this}removeLabel(e){return delete this.labels[e],this}addPause(e,t,r){let s=ur.delayedCall(0,t||_e,r);return s.data="isPause",this._hasPause=1,nt(this,s,dt(this,e))}removePause(e){let t=this._first;for(e=dt(this,e);t;)t._start===e&&"isPause"===t.data&&Ze(t),t=t._next}killTweensOf(e,t,r){let s=this.getTweensOf(e,r),n=s.length;for(;n--;)sr!==s[n]&&s[n].kill(e,t);return this}getTweensOf(e,t){let r,s=[],n=yt(e),i=this._first,a=ne(t);for(;i;)i instanceof ur?((e,t)=>{let r=t.length,s=0;for(;e.indexOf(t[s])<0&&++s<r;);return s<r})(i._targets,n)&&(a?(!sr||i._initted&&i._ts)&&i.globalTime(0)<=t&&i.globalTime(i.totalDuration())>t:!t||i.isActive())&&s.push(i):(r=i.getTweensOf(n,t)).length&&s.push(...r),i=i._next;return s}tweenTo(e,t){t=t||{};let r,s=this,n=dt(s,e),{startAt:i,onStart:a,onStartParams:o,immediateRender:l}=t,h=ur.to(s,He({ease:t.ease||"none",lazy:!1,immediateRender:!1,time:n,overwrite:"auto",duration:t.duration||Math.abs((n-(i&&"time"in i?i.time:s._time))/s.timeScale())||Z,onStart:()=>{var e;s.pause(),r||(e=t.duration||Math.abs((n-(i&&"time"in i?i.time:s._time))/s.timeScale()),h._dur!==e&&ht(h,e,0,1).render(h._time,!0,!0),r=1),a&&a.apply(h,o||[])}},t));return l?h.render(0):h}tweenFromTo(e,t,r){return this.tweenTo(t,He({startAt:{time:dt(this,e)}},r))}recent(){return this._recent}nextLabel(e=this._time){return Dt(this,dt(this,e))}previousLabel(e=this._time){return Dt(this,dt(this,e),1)}currentLabel(e){return arguments.length?this.seek(e,!0):this.previousLabel(this._time+Z)}shiftChildren(e,t,r=0){let s,n=this._first,i=this.labels;for(;n;)n._start>=r&&(n._start+=e,n._end+=e),n=n._next;if(t)for(s in i)i[s]>=r&&(i[s]+=e);return Qe(this)}invalidate(){let e=this._first;for(this._lock=0;e;)e.invalidate(),e=e._next;return super.invalidate()}clear(e=!0){let t,r=this._first;for(;r;)t=r._next,this.remove(r),r=t;return this._dp&&(this._time=this._tTime=this._pTime=0),e&&(this.labels={}),Qe(this)}totalDuration(e){let t,r,s,n=0,i=this,a=i._last,o=Y;if(arguments.length)return i.timeScale((i._repeat<0?i.duration():i.totalDuration())/(i.reversed()?-e:e));if(i._dirty){for(s=i.parent;a;)t=a._prev,a._dirty&&a.totalDuration(),(r=a._start)>o&&i._sort&&a._ts&&!i._lock?(i._lock=1,nt(i,a,r-a._delay,1)._lock=0):o=r,r<0&&a._ts&&(n-=r,(!s&&!i._dp||s&&s.smoothChildTiming)&&(i._start+=r/i._ts,i._time-=r,i._tTime-=r),i.shiftChildren(-r,!1,-1/0),o=0),a._end>n&&a._ts&&(n=a._end),a=t;ht(i,i===F&&i._time>n?i._time:n,1,1),i._dirty=0}return i._tDur}static updateRoot(e){if(F._ts&&(ze(F,et(e,F)),H=jt.frame),jt.frame>=Ae){Ae+=X.autoSleep||120;let e=F._first;if((!e||!e._ts)&&X.autoSleep&&jt._listeners.length<2){for(;e&&!e._ts;)e=e._next;e||jt.sleep()}}}}He(rr.prototype,{_lock:0,_hasPause:0,_forcing:0});let sr,nr=function(e,t,r,s,n,i,a){let o,l,h,c,u,d,p,m,f=new Mr(this._pt,e,t,0,1,dr,null,n),g=0,v=0;for(f.b=r,f.e=s,r+="",(p=~(s+="").indexOf("random("))&&(s=Pt(s)),i&&(i(m=[r,s],e,t),r=m[0],s=m[1]),l=r.match(fe)||[];o=fe.exec(s);)c=o[0],u=s.substring(g,o.index),h?h=(h+1)%5:"rgba("===u.substr(-5)&&(h=1),c!==l[v++]&&(d=parseFloat(l[v-1])||0,f._pt={_next:f._pt,p:u||1===v?u:",",s:d,c:"="===c.charAt(1)?parseFloat(c.substr(2))*("-"===c.charAt(0)?-1:1):parseFloat(c)-d,m:h&&h<4?Math.round:0},g=fe.lastIndex);return f.c=g<s.length?s.substring(g,s.length):"",f.fp=a,(ge.test(s)||p)&&(f.e=0),this._pt=f},ir=function(e,t,r,s,n,i,a,o,l){se(s)&&(s=s(n||0,e,i));let h,c=e[t],u="get"!==r?r:se(c)?l?e[t.indexOf("set")||!se(e["get"+t.substr(3)])?t:"get"+t.substr(3)](l):e[t]():c,d=se(c)?l?xr:vr:gr;if(re(s)&&"="===(s=~s.indexOf("random(")?Pt(s):s).charAt(1)&&(!(h=parseFloat(u)+parseFloat(s.substr(2))*("-"===s.charAt(0)?-1:1)+(gt(u)||0))&&0!==h||(s=h)),u!==s)return isNaN(u*s)||""===s?(c||t in e||Se(t,s),nr.call(this,e,t,u,s,d,o||X.stringFilter,l)):(h=new Mr(this._pt,e,t,+u||0,s-(u||0),"boolean"==typeof c?br:wr,0,d),l&&(h.fp=l),a&&h.modifier(a,this,e),this._pt=h)},ar=(e,t,r,s,n,i)=>{let a,o,l,h;if(Re[e]&&!1!==(a=new Re[e]).init(n,a.rawVars?t[e]:((e,t,r,s,n)=>{if(se(e)&&(e=lr(e,n,t,r,s)),!ae(e)||e.style&&e.nodeType||ue(e)||ce(e))return re(e)?lr(e,n,t,r,s):e;let i,a={};for(i in e)a[i]=lr(e[i],n,t,r,s);return a})(t[e],s,n,i,r),r,s,i)&&(r._pt=o=new Mr(r._pt,n,e,0,1,a.render,a,0,a.priority),r!==G))for(l=r._ptLookup[r._targets.indexOf(n)],h=a._props.length;h--;)l[a._props[h]]=o;return a},or=(e,t)=>{let r,s,n,i,a,o,l,h,c,u,d,p,m,f=e.vars,{ease:g,startAt:v,immediateRender:x,lazy:y,onUpdate:w,onUpdateParams:b,callbackScope:S,runBackwards:T,yoyoEase:M,keyframes:_,autoRevert:E}=f,P=e._dur,C=e._startAt,R=e._targets,D=e.parent,A=D&&"nested"===D.data?D.parent._targets:R,L="auto"===e._overwrite&&!B,I=e.timeline;if(!I||_&&g||(g="none"),e._ease=Yt(g,q.ease),e._yEase=M?Xt(Yt(!0===M?g:M,q.ease)):0,M&&e._yoyo&&!e._repeat&&(M=e._yEase,e._yEase=e._ease,e._ease=M),e._from=!I&&!!f.runBackwards,!I||_&&!f.stagger){if(p=(h=R[0]?Ue(R[0]).harness:0)&&f[h.prop],r=Xe(f,Ee),C&&Ze(C.render(-1,!0)),v)if(Ze(e._startAt=ur.set(R,He({data:"isStart",overwrite:!1,parent:D,immediateRender:!0,lazy:oe(y),startAt:null,delay:0,onUpdate:w,onUpdateParams:b,callbackScope:S,stagger:0},v))),t<0&&!x&&!E&&e._startAt.render(-1,!0),x){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(C)E||(e._startAt=0);else if(t&&(x=!1),n=He({overwrite:!1,data:"isFromStart",lazy:x&&oe(y),immediateRender:x,stagger:0,parent:D},r),p&&(n[h.prop]=p),Ze(e._startAt=ur.set(R,n)),t<0&&e._startAt.render(-1,!0),e._zTime=t,x){if(!t)return}else or(e._startAt,Z);for(e._pt=0,y=P&&oe(y)||y&&!P,s=0;s<R.length;s++){if(l=(a=R[s])._gsap||Oe(R)[s]._gsap,e._ptLookup[s]=u={},Ce[l.id]&&Pe.length&&Ne(),d=A===R?s:A.indexOf(a),h&&!1!==(c=new h).init(a,p||r,e,d,A)&&(e._pt=i=new Mr(e._pt,a,c.name,0,1,c.render,c,0,c.priority),c._props.forEach((e=>{u[e]=i})),c.priority&&(o=1)),!h||p)for(n in r)Re[n]&&(c=ar(n,r,e,d,a,A))?c.priority&&(o=1):u[n]=i=ir.call(e,a,n,"get",r[n],d,A,0,f.stringFilter);e._op&&e._op[s]&&e.kill(a,e._op[s]),L&&e._pt&&(sr=e,F.killTweensOf(a,u,e.globalTime(t)),m=!e.parent,sr=0),e._pt&&y&&(Ce[l.id]=1)}o&&Tr(e),e._onInit&&e._onInit(e)}e._onUpdate=w,e._initted=(!e._op||e._pt)&&!m,_&&t<=0&&I.render(Y,!0,!0)},lr=(e,t,r,s,n)=>se(e)?e.call(t,r,s,n):re(e)&&~e.indexOf("random(")?Pt(e):e,hr=Ie+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",cr={};Be(hr+",id,stagger,delay,duration,paused,scrollTrigger",(e=>cr[e]=1));class ur extends tr{constructor(e,t,r,s){"number"==typeof t&&(r.duration=t,t=r,r=null),super(s?t:qe(t));let n,i,a,o,l,h,c,u,{duration:d,delay:p,immediateRender:m,stagger:f,overwrite:g,keyframes:v,defaults:x,scrollTrigger:y,yoyoEase:w}=this.vars,b=t.parent||F,S=(ue(e)||ce(e)?ne(e[0]):"length"in t)?[e]:yt(e);if(this._targets=S.length?Oe(S):Te("GSAP target "+e+" not found. https://greensock.com",!X.nullTargetWarn)||[],this._ptLookup=[],this._overwrite=g,v||f||he(d)||he(p)){if(t=this.vars,(n=this.timeline=new rr({data:"nested",defaults:x||{}})).kill(),n.parent=n._dp=this,n._start=0,f||he(d)||he(p)){if(o=S.length,c=f&&bt(f),ae(f))for(l in f)~hr.indexOf(l)&&(u=u||{},u[l]=f[l]);for(i=0;i<o;i++)(a=Xe(t,cr)).stagger=0,w&&(a.yoyoEase=w),u&&Ge(a,u),h=S[i],a.duration=+lr(d,this,i,h,S),a.delay=(+lr(p,this,i,h,S)||0)-this._delay,!f&&1===o&&a.delay&&(this._delay=p=a.delay,this._start+=p,a.delay=0),n.to(h,a,c?c(i,h,S):0),n._ease=Ht.none;n.duration()?d=p=0:this.timeline=0}else if(v){qe(He(n.vars.defaults,{ease:"none"})),n._ease=Yt(v.ease||t.ease||"none");let e,r,s,o=0;if(ue(v))v.forEach((e=>n.to(S,e,">")));else{for(l in a={},v)"ease"!==l&&"easeEach"!==l&&((e,t,r,s)=>{let n,i,a=t.ease||s||"power1.inOut";if(ue(t))i=r[e]||(r[e]=[]),t.forEach(((e,r)=>i.push({t:r/(t.length-1)*100,v:e,e:a})));else for(n in t)i=r[n]||(r[n]=[]),"ease"!==n&&i.push({t:parseFloat(e),v:t[n],e:a})})(l,v[l],a,v.easeEach);for(l in a)for(e=a[l].sort(((e,t)=>e.t-t.t)),o=0,i=0;i<e.length;i++)r=e[i],s={ease:r.e,duration:(r.t-(i?e[i-1].t:0))/100*d},s[l]=r.v,n.to(S,s,o),o+=s.duration;n.duration()<d&&n.to({},{duration:d-n.duration()})}}d||this.duration(d=n.duration())}else this.timeline=0;!0!==g||B||(sr=this,F.killTweensOf(S),sr=0),nt(b,this,r),t.reversed&&this.reverse(),t.paused&&this.paused(!0),(m||!d&&!v&&this._start===Fe(b._time)&&oe(m)&&Ke(this)&&"nested"!==b.data)&&(this._tTime=-Z,this.render(Math.max(0,-p))),y&&it(this,y)}render(e,t,r){let s,n,i,a,o,l,h,c,u,d=this._time,p=this._tDur,m=this._dur,f=e>p-Z&&0<=e?p:e<Z?0:e;if(m){if(f!==this._tTime||!e||r||!this._initted&&this._tTime||this._startAt&&this._zTime<0!=e<0){if(s=f,c=this.timeline,this._repeat){if(a=m+this._rDelay,this._repeat<-1&&e<0)return this.totalTime(100*a+e,t,r);if(s=Fe(f%a),f===p?(i=this._repeat,s=m):((i=~~(f/a))&&i===f/a&&(s=m,i--),s>m&&(s=m)),(l=this._yoyo&&1&i)&&(u=this._yEase,s=m-s),o=$e(this._tTime,a),s===d&&!r&&this._initted)return this;i!==o&&(c&&this._yEase&&qt(c,l),!this.vars.repeatRefresh||l||this._lock||(this._lock=r=1,this.render(Fe(a*i),!0).invalidate()._lock=0))}if(!this._initted){if(at(this,e<0?e:s,r,t))return this._tTime=0,this;if(m!==this._dur)return this.render(e,t,r)}if(this._tTime=f,this._time=s,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=h=(u||this._ease)(s/m),this._from&&(this.ratio=h=1-h),s&&!d&&!t&&(At(this,"onStart"),this._tTime!==f))return this;for(n=this._pt;n;)n.r(h,n.d),n=n._next;c&&c.render(e<0?e:!s&&l?-Z:c._dur*c._ease(s/this._dur),t,r)||this._startAt&&(this._zTime=e),this._onUpdate&&!t&&(e<0&&this._startAt&&this._startAt.render(e,!0,r),At(this,"onUpdate")),this._repeat&&i!==o&&this.vars.onRepeat&&!t&&this.parent&&At(this,"onRepeat"),f!==this._tDur&&f||this._tTime!==f||(e<0&&this._startAt&&!this._onUpdate&&this._startAt.render(e,!0,!0),!e&&m||!(f===this._tDur&&0<this._ts||!f&&this._ts<0)||Ze(this,1),t||e<0&&!d||!f&&!d||(At(this,f===p?"onComplete":"onReverseComplete",!0),!this._prom||f<p&&0<this.timeScale()||this._prom()))}}else{var g=this;let s,n,i,a=g.ratio,o=e<0||!e&&(!g._start&&ot(g)&&(g._initted||!lt(g))||(g._ts<0||g._dp._ts<0)&&!lt(g))?0:1,l=g._rDelay,h=0;if(l&&g._repeat&&(h=ft(0,g._tDur,e),n=$e(h,l),g._yoyo&&1&n&&(o=1-o),n!==$e(g._tTime,l)&&(a=1-o,g.vars.repeatRefresh&&g._initted&&g.invalidate())),o!==a||r||g._zTime===Z||!e&&g._zTime){if(g._initted||!at(g,e,r,t)){for(i=g._zTime,g._zTime=e||(t?Z:0),t=t||e&&!i,g.ratio=o,g._from&&(o=1-o),g._time=0,g._tTime=h,s=g._pt;s;)s.r(o,s.d),s=s._next;g._startAt&&e<0&&g._startAt.render(e,!0,!0),g._onUpdate&&!t&&At(g,"onUpdate"),h&&g._repeat&&!t&&g.parent&&At(g,"onRepeat"),(e>=g._tDur||e<0)&&g.ratio===o&&(o&&Ze(g,1),t||(At(g,o?"onComplete":"onReverseComplete",!0),g._prom&&g._prom()))}}else g._zTime||(g._zTime=e)}return this}targets(){return this._targets}invalidate(){return this._pt=this._op=this._startAt=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(),super.invalidate()}kill(e,t="all"){if(!(e||t&&"all"!==t))return this._lazy=this._pt=0,this.parent?Lt(this):this;var r;if(this.timeline)return r=this.timeline.totalDuration(),this.timeline.killTweensOf(e,t,sr&&!0!==sr.vars.overwrite)._first||Lt(this),this.parent&&r!==this.timeline.totalDuration()&&ht(this,this._dur*this.timeline._tDur/r,0,1),this;let s,n,i,a,o,l,h,c=this._targets,u=e?yt(e):c,d=this._ptLookup,p=this._pt;if((!t||"all"===t)&&((e,t)=>{let r=e.length,s=r===t.length;for(;s&&r--&&e[r]===t[r];);return r<0})(c,u))return"all"===t&&(this._pt=0),Lt(this);for((s=this._op=this._op||[],"all"!==t&&(re(t)&&(o={},Be(t,(e=>o[e]=1)),t=o),t=((e,t)=>{let r,s,n,i,a=e[0]?Ue(e[0]).harness:0,o=a&&a.aliases;if(!o)return t;for(s in r=Ge({},t),o)if(s in r)for(i=o[s].split(","),n=i.length;n--;)r[i[n]]=r[s];return r})(c,t)),h=c.length);h--;)if(~u.indexOf(c[h]))for(o in n=d[h],"all"===t?(s[h]=t,a=n,i={}):(i=s[h]=s[h]||{},a=t),a)l=n&&n[o],l&&("kill"in l.d&&!0!==l.d.kill(o)||Ye(this,l,"_pt"),delete n[o]),"all"!==i&&(i[o]=1);return this._initted&&!this._pt&&p&&Lt(this),this}static to(e,t){return new ur(e,t,arguments[2])}static from(e,t){return pt(1,arguments)}static delayedCall(e,t,r,s){return new ur(t,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:e,onComplete:t,onReverseComplete:t,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:s})}static fromTo(e,t,r){return pt(2,arguments)}static set(e,t){return t.duration=0,t.repeatDelay||(t.repeat=0),new ur(e,t)}static killTweensOf(e,t,r){return F.killTweensOf(e,t,r)}}function dr(e,t){let r=t._pt,s="";if(!e&&t.b)s=t.b;else if(1===e&&t.e)s=t.e;else{for(;r;)s=r.p+(r.m?r.m(r.s+r.c*e):Math.round(1e4*(r.s+r.c*e))/1e4)+s,r=r._next;s+=t.c}t.set(t.t,t.p,s,t)}function pr(e,t){let r=t._pt;for(;r;)r.r(e,r.d),r=r._next}function mr(e,t,r,s){let n,i=this._pt;for(;i;)n=i._next,i.p===s&&i.modifier(e,t,r),i=n}function fr(e){let t,r,s=this._pt;for(;s;)r=s._next,s.p===e&&!s.op||s.op===e?Ye(this,s,"_pt"):s.dep||(t=1),s=r;return!t}He(ur.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),Be("staggerTo,staggerFrom,staggerFromTo",(e=>{ur[e]=function(){let t=new rr,r=vt.call(arguments,0);return r.splice("staggerFromTo"===e?5:4,0,0),t[e].apply(t,r)}}));let gr=(e,t,r)=>e[t]=r,vr=(e,t,r)=>e[t](r),xr=(e,t,r,s)=>e[t](s.fp,r),yr=(e,t)=>se(e[t])?vr:ie(e[t])&&e.setAttribute?(e,t,r)=>e.setAttribute(t,r):gr,wr=(e,t)=>t.set(t.t,t.p,Math.round(1e6*(t.s+t.c*e))/1e6,t),br=(e,t)=>t.set(t.t,t.p,!!(t.s+t.c*e),t),Sr=(e,t,r,s)=>{s.mSet(e,t,s.m.call(s.tween,r,s.mt),s)},Tr=e=>{let t,r,s,n,i=e._pt;for(;i;){for(t=i._next,r=s;r&&r.pr>i.pr;)r=r._next;(i._prev=r?r._prev:n)?i._prev._next=i:s=i,(i._next=r)?r._prev=i:n=i,i=t}e._pt=s};class Mr{constructor(e,t,r,s,n,i,a,o,l){this.t=t,this.s=s,this.c=n,this.p=r,this.r=i||wr,this.d=a||this,this.set=o||gr,this.pr=l||0,(this._next=e)&&(e._prev=this)}modifier(e,t,r){this.mSet=this.mSet||this.set,this.set=Sr,this.m=e,this.mt=r,this.tween=t}}Be(Ie+"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",(e=>Ee[e]=1)),ye.TweenMax=ye.TweenLite=ur,ye.TimelineLite=ye.TimelineMax=rr,F=new rr({sortChildren:!1,defaults:q,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),X.stringFilter=e=>{var t=e.join(" ");if(Nt.lastIndex=0,Nt.test(t))return t=zt.test(t),e[1]=Ft(e[1],t),e[0]=Ft(e[0],t,Bt(e[1])),!0};const _r={registerPlugin(...e){e.forEach((e=>{{let t=(e=!e.name&&e.default||e).name,r=se(e),s=t&&!r&&e.init?function(){this._props=[]}:e,n={init:_e,render:pr,add:ir,kill:fr,modifier:mr,rawVars:0},i={targetTest:0,get:0,getSetter:yr,aliases:{},register:0};if(Vt(),e!==s){if(Re[t])return;He(s,He(Xe(e,n),i)),Ge(s.prototype,Ge(n,Xe(e,i))),Re[s.prop=t]=s,e.targetTest&&(Le.push(s),Ee[t]=1),t=("css"===t?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}return Me(t,s),void(e.register&&e.register(Cr,s,Mr))}}))},timeline:e=>new rr(e),getTweensOf:(e,t)=>F.getTweensOf(e,t),getProperty(e,t,r,s){re(e)&&(e=yt(e)[0]);let n=Ue(e||{}).get,i=r?Ve:je;return"native"===r&&(r=""),e&&(t?i((Re[t]&&Re[t].get||n)(e,t,r,s)):(t,r,s)=>i((Re[t]&&Re[t].get||n)(e,t,r,s)))},quickSetter(e,t,r){if(1<(e=yt(e)).length){let s=e.map((e=>Cr.quickSetter(e,t,r))),n=s.length;return e=>{let t=n;for(;t--;)s[t](e)}}e=e[0]||{};let s=Re[t],n=Ue(e),i=n.harness&&(n.harness.aliases||{})[t]||t,a=s?t=>{let n=new s;G._pt=0,n.init(e,r?t+r:t,G,0,[e]),n.render(1,n),G._pt&&pr(1,G)}:n.set(e,i);return s?a:t=>a(e,i,r?t+r:t,n,1)},isTweening:e=>0<F.getTweensOf(e,!0).length,defaults:e=>(e&&e.ease&&(e.ease=Yt(e.ease,q.ease)),We(q,e||{})),config:e=>We(X,e||{}),registerEffect({name:e,effect:t,plugins:r,defaults:s,extendTimeline:n}){(r||"").split(",").forEach((t=>t&&!Re[t]&&!ye[t]&&Te(e+" effect requires "+t+" plugin."))),De[e]=(e,r,n)=>t(yt(e),He(r||{},s),n),n&&(rr.prototype[e]=function(t,r,s){return this.add(De[e](t,ae(r)?r:(s=r)&&{},this),s)})},registerEase(e,t){Ht[e]=Yt(t)},parseEase(e,t){return arguments.length?Yt(e,t):Ht},getById:e=>F.getById(e),exportRoot(e={},t){let r,s,n=new rr(e);for(n.smoothChildTiming=oe(e.smoothChildTiming),F.remove(n),n._dp=0,n._time=n._tTime=F._time,r=F._first;r;)s=r._next,!t&&!r._dur&&r instanceof ur&&r.vars.onComplete===r._targets[0]||nt(n,r,r._start-r._delay),r=s;return nt(F,n,0),n},utils:{wrap:function e(t,r,s){let n=r-t;return ue(t)?_t(t,e(0,t.length),r):mt(s,(e=>(n+(e-t)%n)%n+t))},wrapYoyo:Et,distribute:bt,random:Mt,snap:Tt,normalize:(e,t,r)=>Ct(e,t,0,1,r),getUnit:gt,clamp:(e,t,r)=>mt(r,(r=>ft(e,t,r))),splitColor:kt,toArray:yt,selector:e=>(e=yt(e)[0]||Te("Invalid scope")||{},t=>{var r=e.current||e.nativeElement||e;return yt(t,r.querySelectorAll?r:r===e?Te("Invalid scope")||j.createElement("div"):e)}),mapRange:Ct,pipe:(...e)=>t=>e.reduce(((e,t)=>t(e)),t),unitize:(e,t)=>r=>e(parseFloat(r))+(t||gt(r)),interpolate:Rt,shuffle:wt},install:be,effects:De,ticker:jt,updateRoot:rr.updateRoot,plugins:Re,globalTimeline:F,core:{PropTween:Mr,globals:Me,Tween:ur,Timeline:rr,Animation:tr,getCache:Ue,_removeLinkedListItem:Ye,suppressOverwrites:e=>B=e}};Be("to,from,fromTo,delayedCall,set,killTweensOf",(e=>_r[e]=ur[e])),jt.add(rr.updateRoot),G=_r.to({},{duration:0});let Er=(e,t)=>{let r=e._pt;for(;r&&r.p!==t&&r.op!==t&&r.fp!==t;)r=r._next;return r},Pr=(e,t)=>({name:e,rawVars:1,init(e,r,s){s._onInit=e=>{let s,n;if(re(r)&&(s={},Be(r,(e=>s[e]=1)),r=s),t){for(n in s={},r)s[n]=t(r[n]);r=s}{var i=e,a=r;let t,s,n,o=i._targets;for(t in a)for(s=o.length;s--;)n=i._ptLookup[s][t],(n=n&&n.d)&&(n._pt&&(n=Er(n,t)),n&&n.modifier&&n.modifier(a[t],i,o[s],t));return}}}});const Cr=_r.registerPlugin({name:"attr",init(e,t,r,s,n){let i,a;for(i in t)a=this.add(e,"setAttribute",(e.getAttribute(i)||0)+"",t[i],s,n,0,0,i),a&&(a.op=i),this._props.push(i)}},{name:"endArray",init(e,t){let r=t.length;for(;r--;)this.add(e,r,e[r]||0,t[r])}},Pr("roundProps",St),Pr("modifiers"),Pr("snap",Tt))||_r;ur.version=rr.version=Cr.version="3.9.1",V=1,le()&&Vt();var{}=Ht;const Rr=n,Dr=["map","normalMap","aoMap"],Ar=["map","metalnessMap","roughnessMap","normalMap","aoMap","emissiveMap","alphaMap","lightMap","envMap","displacementMap"];class Lr{}const Ir=class extends Lr{constructor(e){super(),this.type="修改材质";var{target:e,info:t,newVal:r,oldVal:s,runScene:n}=e;this.runScene=n,this.target=e,this.info=t,this.newVal=r,this.oldVal=s}_execute(e,t){console.log(this,e,"this,data"),this.target[this.info]=e,this.target.needsUpdate=!0,Ar.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 Or=function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};class Ur{constructor(e){this.allTextures=new Set,this.runScene=e}loadImagBit(e){return createImageBitmap(e,{imageOrientation:"flipY",resizeQuality:"pixelated"})}load(e){return Or(this,void 0,void 0,(function*(){var t=yield this.loadImagBit(yield Vr(e));return t=new n.Texture(t),this.afterLoad(e,t)}))}clone(e){const t=new n.Texture(e.image);return t.userData=Object.assign({},e.userData),this._afterLoad(t)}getDef(e){return e=new n.Texture(e),this._afterLoad(e)}toThree(e){return e.mapping=Rr.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 s=this.getSameTexture(t,e);return s?(e.dispose(),s):(e.userData.url=URL.createObjectURL(r),e.userData.md5=t,e.userData.gm=kr(e),e.format=-1!==r.type.indexOf("png")?1023:1022,e.needsUpdate=!0,e.flipY=!1,e.minFilter=Rr.LinearMipmapLinearFilter,this.addToAllTextures(e),e)}afterLoad(e,t){return Or(this,void 0,void 0,(function*(){const r=yield Vr(e);t.userData.blob=r;var s=Gr(yield r.arrayBuffer());return t.userData.url=URL.createObjectURL(r),t.userData.md5=s,this._afterLoad(t)}))}getSameTexture(e,t){for(const s in this.runScene.uniqueEx.texture.map){var r=this.runScene.uniqueEx.texture.get(s);if(r.userData.md5===e&&r.mapping===t.mapping)return r}}bindData(e){return Or(this,void 0,void 0,(function*(){if(this.setTexture(e),this.addToAllTextures(e),e.userData.gm=kr(e),!e.userData.blob){const t=yield this.getBlob(e);return e.userData.md5=Gr(yield t.arrayBuffer()),e.userData.blob=t,e.userData.url=URL.createObjectURL(t),e}}))}setTexture(e){return e.magFilter=1003,e.wrapS=Rr.RepeatWrapping,e.wrapT=Rr.RepeatWrapping,e.encoding=3e3,e.needsUpdate=!0,e.version=3,e.minFilter=Rr.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 Or(this,void 0,void 0,(function*(){var t=yield Hr(e);return this.afterLoad(URL.createObjectURL(t),new n.Texture(yield this.loadImagBit(t)))}))}getBlob(e){return e.userData.blob||zr(e.image)}getUrl(e){return console.log(e,"texture"),e.userData.url}getBlobAndBase64(e){return e.userData.blob?e.userData:jr(e)}dispose(e){e.dispose()}reverseY(e){return createImageBitmap(e,{imageOrientation:"flipY"})}coverByImage(e,t){return Or(this,void 0,void 0,(function*(){let r;r=t instanceof n.Texture?t:t?yield this.parse(t):null;var s=this.runScene.uniqueEx.texture.getMaterials(this.runScene.uniqueEx.getId(e));if(s){const t=[];(0,O.js)(s,((s,n)=>{const i=this.runScene.uniqueEx.material.get(s);i&&n.forEach((s=>{t.push(new Ir({target:i,info:s,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 kr=e=>{var{width:e,height:t}=e.image;return e*t*4*1.33};var Br=function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};const Fr=(e,t,r,s,n)=>{let i=Object.assign({},e),a=new ur(i,r,t).eventCallback("onUpdate",(e=>s&&s(i))).eventCallback("onComplete",(e=>{n&&n(),ur.killTweensOf(a)}));return a},Nr=(e,t)=>(t.updateMatrixWorld(!0),t=new Rr.Vector3,e.getWorldPosition(t),t),zr=e=>Br(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)}))}))})),jr=e=>Br(void 0,void 0,void 0,(function*(){var t=e.image;const r=document.createElement("canvas"),s=(r.width=t.width,r.height=t.height,r.getContext("2d")),n=1023===e.format?"image/png":"image/jpeg";return s.drawImage(t,0,0,r.width,r.height),new Promise((e=>{r.toBlob((t=>{e({blob:t,base64:r.toDataURL(n)})}),n)}))})),Vr=e=>Br(void 0,void 0,void 0,(function*(){return(yield r().get(e,{responseType:"blob"})).data})),Hr=e=>Br(void 0,void 0,void 0,(function*(){{let t=(yield(0,k.toResult)(e,"base64")).split(","),r=t[0].match(/:(.*?);/)[1],s=atob(t[1]),n=s.length,i=new Uint8Array(n);for(;n--;)i[n]=s.charCodeAt(n);return new Blob([i],{type:r})}})),Gr=e=>(0,U.md5)(e);class Wr{constructor(e){this.alt=!1,this.ctrl=!1,this.shift=!1,this.eventsMap={down:{},up:{}},this.allFn={s_saveScene:()=>function(e,t,r,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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:s,renderer:i,controls:a}=this.events.runScene.assetsEx.get(),o=new n.Vector3,l=new n.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 n.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 h=new n.Vector3;h.subVectors(s.position,l),h.projectOnPlane(new n.Vector3(0,1,0)),h.normalize(),1<r&&(r=1/r),t=2*Math.tan(.5*s.fov*Math.PI/180),t=a.length()/r/t,o.addVectors(l,h.multiplyScalar(t))}else{r.updateMatrixWorld(!0),t=new n.Vector3,e.getWorldPosition(t),l.set(t.x,t.y,t.z);let i=new n.Vector3;i.subVectors(s.position,l),i.projectOnPlane(new n.Vector3(0,1,0)),i.normalize(),o.addVectors(l,i.multiplyScalar(3))}Fr({positionX:s.position.x,positionY:s.position.y,positionZ:s.position.z,targetX:a.target.x,targetY:a.target.y,targetZ:a.target.z},{positionX:o.x,positionY:o.y,positionZ:o.z,targetX:l.x,targetY:l.y,targetZ:l.z},.5,(e=>{s.position.set(e.positionX,e.positionY,e.positionZ),s.lookAt(e.targetX,e.targetY,e.targetZ),a.target.set(e.targetX,e.targetY,e.targetZ),a.update(),s.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,O.js)(this.eventsMap.down,((r,s)=>{s(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 s=this.events.runScene.modelEx.clone(r);if(!s)return;this.events.runScene.modelEx.add(s,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(),s=this.events.runScene.multipSelector.getSelectedList("value"),this.events.runScene.sceneEx.remove(this.events.runScene.modelEx.select||s),s&&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,O.js)(this.eventsMap.up,((r,s)=>{s(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 Xr{constructor(e){this.downPosition={x:0,y:0},this.enableUp=!0,this.fnMap={global:{down:{},up:{}},local:{down:{},up:{}}},this.down=e=>{(0,O.js)(this.fnMap.local.down,((t,r)=>{r(e)})),this.downPosition={x:e.offsetX,y:e.offsetY}},this.up=e=>{var t,r,s,n;2===e.button||null!=(t=this.events.runScene.helperEx.transContro)&&t.isDraggingChange||((0,O.js)(this.fnMap.local.up,((t,r)=>{r(e)})),t=e.offsetX,r=e.offsetY,({x:s,y:n}=this.downPosition),t===s&&r===n&&this.trigger(e))},this.events=e}bindEvent(e){var{type:e,name:t,fn:r,local:s}=e;this.fnMap[s][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 n.Raycaster,r=new n.Vector2,{engineDom:s,camera:i,scene:a}=this.events.runScene.assetsEx.get();return r.x=e.offsetX/s.clientWidth*2-1,r.y=-e.offsetY/s.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)}}t=a(356);var qr=a.n(t),Yr=a(298);const Zr=["Group","Box","Circle","Cylinder","Dodecahedron","Icosahedron","Lathe","Octahedron","Plane","Ring","Sphere","Sprite","Tetrahedron","Torus","TorusKnot","Tube","Reflector"];var Qr=a(251);class Kr{static create(){return new n.MeshStandardMaterial}static isDefval(e){for(const t in this.defVal){const r=this.defVal[t],s=e[t];if(r instanceof n.Color){if(r.getHexString()!==s.getHexString())return!1}else if("object"==typeof r){if(s.x!==r.x)return!1}else if(s!==r)return!1}for(const t of Ar)if(e[t])return!1;return!0}}Kr.defVal={color:new n.Color(16777215),emissive:new n.Color(0),roughness:1,metalness:0,lightMapIntensity:1,aoMapIntensity:1,emissiveIntensity:1,bumpScale:1,normalScale:new n.Vector2(1,1),displacementScale:1,envMapIntensity:1,wireframe:!1,transparent:!1,opacity:1};class Jr{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 $r(e){if("object"!=typeof e)return e;if(null===e)return null;if(e){var t,r,s=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(r=$r(e[t]),s[t]=r);return s}}const es=class extends Lr{constructor(e){super(),this.type="多层级修改",this.target=e.target,this.typeList=e.typeList,this.new=e.newVal,this.cb=e.cb,this.old=(0,O.qR)(e.target,this.typeList)[(0,Yr.lastArrayEle)(e.typeList)]}execute(){return this.redo(),this}_execute(e){const t=(0,O.qR)(this.target,this.typeList);t[(0,Yr.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 ts{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,s=new n.ShaderMaterial({uniforms:$r(rs.uniforms),vertexShader:rs.vertexShader,fragmentShader:rs.fragmentShader});return t.forEach((e=>{"ceilingTex"===e.type?s.uniforms.ceilingTex.value=e.texture||null:"floorTex"===e.type?s.uniforms.floorTex.value=e.texture||null:"sideWallTex"===e.type?s.uniforms.sideWallTex.value=e.texture||null:"backWallTex"===e.type&&(s.uniforms.backWallTex.value=e.texture||null)})),Object.keys(r.uniforms).filter((e=>!ts.TextureNames.includes(e))).map((e=>{var t=r.uniforms[e];s.uniforms[e].value="roomsXYZPropsW"===e||"positionOffsetRoomsXYZPropsW"===e||"roomColorTint"===e?new n.Vector4(t.x,t.y,t.z,t.w):t})),s.userData.tools=this.tools,s},toNormal:e=>{const t=fs(),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),{}),s=e.uniforms,i=rs.uniforms;return Object.keys(s).filter((e=>!ts.TextureNames.includes(e))).map((e=>{var t,a,o,l,h,c,u=s[e].value,d=i[e].value;u instanceof n.Vector4?(({x:t,y:a,z:o}=u),({x:l,y:h,z:c}=d),t===l&&a===h&&o===c||(r[e]=u)):(console.log(u,d,"val,defVal"),u!==d&&(r[e]=u))})),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 n.ShaderMaterial({uniforms:$r(rs.uniforms),vertexShader:rs.vertexShader,fragmentShader:rs.fragmentShader});return e.userData.tools=this.tools,e}undo(e){var{material:e,list:t,val:r}=e;this.runScene.undoEx.addUndo(new es({target:e,typeList:["uniforms",...t],newVal:r}).execute())}}ts.TextureNames=["sideWallTex","backWallTex","floorTex","ceilingTex"];const rs={uniforms:{roomIntensity:{value:1},roomColorTint:{value:new n.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 n.Vector4(.35,.65,.1,1)},positionOffsetRoomsXYZPropsW:{value:new n.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 "},ss={uniforms:{tDiffuse:new n.Uniform(null),h:new n.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}"},ns={uniforms:{tDiffuse:new n.Uniform(null),v:new n.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 n.Uniform(null),new n.Uniform(null),new n.Uniform(0),new n.Uniform(0),new n.Uniform(0),new n.Uniform(new n.Vector2),new n.Uniform(.1),new n.Uniform(1e3);class is{constructor(e){this.materials={},this.render=()=>{(0,O.js)(this.materials,((e,t)=>{const{model:r,material:s}=t;s.update(r)}))},this.tools={type:"Reflector",getTextures:e=>vs(e),parseData:e=>{const{textures:t,normal:r,models:s,material:n}=e,i=gs(n,new as(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=>!is.TextureNames.includes(e))).map((e=>{i[e]=r.uniforms[e]})),i.setRTSize(i.resolution),i.setBlurPass(i.blurSize),i.insertReflectorShader(),i.userData.tools=this.tools,this.bindData({model:s[0],material:i}),i},toNormal:e=>{const t=gs(e,fs()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),s=os.uniforms;return Object.keys(s).filter((e=>!is.TextureNames.includes(e))).map((t=>{var n=e[t],i=s[t].value;"mirror"===t||"mixBlur"===t||"mixStrength"===t||"mixContrast"===t?n.value!==i&&(r[t]=n):n!==i&&(r[t]=n)})),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,Qr.getId)();t.userData.id=r,this.materials[r]=e}create(e){const t=new as(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 es({target:e,typeList:[...t],newVal:r}).execute())}dispose(){this.materials={}}}is.TextureNames=["map","normalMap","roughnessMap","metalnessMap","tDiffuse","tDiffuseBlur"];class as extends n.MeshStandardMaterial{constructor(e,t,r){e?super(e):(super(),this.opacity=os.uniforms.opacity.value,this.transparent=os.uniforms.transparent.value,this.roughness=os.uniforms.roughness.value,this.metalness=os.uniforms.metalness.value),this.runScene=r,t?(this.resolution=t.resolution,this.blurSize=t.blurSize,this.mirror=new n.Uniform(t.mirror),this.mixBlur=new n.Uniform(t.mixBlur),this.mixStrength=new n.Uniform(t.mixStrength),this.mixContrast=new n.Uniform(t.mixContrast)):(this.resolution=os.uniforms.resolution.value,this.blurSize=os.uniforms.blurSize.value,this.mirror=new n.Uniform(os.uniforms.mirror.value),this.mixBlur=new n.Uniform(os.uniforms.mixBlur.value),this.mixStrength=new n.Uniform(os.uniforms.mixStrength.value),this.mixContrast=new n.Uniform(os.uniforms.mixContrast.value)),this.textureMatrix=new n.Uniform(new n.Matrix4),this.reflectorWorldPosition=new n.Vector3,this.cameraWorldPosition=new n.Vector3,this.rotationMatrix=new n.Matrix4,this.normal=new n.Vector3,this.view=new n.Vector3,this.lookAtPosition=new n.Vector3,this.target=new n.Vector3,this.tempQuaternion=new n.Vector4,this.virtualCamera=new n.PerspectiveCamera,this.reflectorPlane=new n.Plane,this.clipPlane=new n.Vector4,e={minFilter:n.LinearFilter,magFilter:n.LinearFilter,type:n.HalfFloatType,encoding:this.runScene.assetsEx.get().renderer.outputEncoding},this.glRT1=new n.WebGLRenderTarget(this.resolution,this.resolution,e),this.glRT2=new n.WebGLRenderTarget(this.resolution,this.resolution,e),this.tDiffuse=new n.Uniform(this.glRT1.texture),this.tDiffuseBlur=new n.Uniform(this.glRT2.texture),this.hBlurPass=new d(ss),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 d(ns),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=os.vertexParas+""+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <project_vertex>",os.vertexShader),e.fragmentShader=os.fragmentParas+""+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>",os.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 os={uniforms:{opacity:new n.Uniform(1),transparent:new n.Uniform(!1),roughness:new n.Uniform(1),metalness:new n.Uniform(.6),resolution:new n.Uniform(1024),blurSize:new n.Uniform(1024),mirror:new n.Uniform(0),mixBlur:new n.Uniform(10),mixStrength:new n.Uniform(2),mixContrast:new n.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 ls{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:s}=e,n=gs(s,new hs(void 0,void 0,this.runScene));return n.name=s.name,t.forEach((e=>{n[e.type]=e.texture})),Object.keys(r.uniforms).filter((e=>!ls.TextureNames.includes(e))).map((e=>{n[e]=r.uniforms[e]})),n.insertFresnelShader(),n.userData.tools=this.tools,n},toNormal:e=>{const t=gs(e,fs()),r=(t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:this.tools.type,uniforms:{}},textures:this.tools.getTextures(e)}),t.name=e.name,{}),s=cs.uniforms;return Object.keys(s).filter((e=>!ls.TextureNames.includes(e))).map((t=>{var n=e[t],i=s[t].value;"fresnelBias"===t||"fresnelScale"===t||"fresnelPower"===t?n.value!==i&&(r[t]=n):n!==i&&(r[t]=n)})),t.userData.normal.uniforms=r,t},clone:(e,t)=>this.create(t)},this.runScene=e}create(e){console.log("Fresnel Create");const t=new hs(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 es({target:e,typeList:[...t],newVal:r}).execute())}}ls.TextureNames=["envMap"];class hs extends n.MeshPhysicalMaterial{constructor(e,t,r){if(e?super(e):(super(),this.emissive=new n.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 n.Uniform(t.fresnelBias),this.fresnelScale=new n.Uniform(t.fresnelScale),this.fresnelPower=new n.Uniform(t.fresnelPower)):(this.fresnelBias=new n.Uniform(cs.uniforms.fresnelBias.value),this.fresnelScale=new n.Uniform(cs.uniforms.fresnelScale.value),this.fresnelPower=new n.Uniform(cs.uniforms.fresnelPower.value)),!this.cubeCamera){const e=new n.WebGLCubeRenderTarget(2048);e.texture.mapping=n.CubeRefractionMapping,this.cubeCamera=new n.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,cs.vertexParas),e.vertexShader=e.vertexShader.replace(/vWorldPosition = worldPosition.xyz;/g,cs.vertexShader),e.fragmentShader=e.fragmentShader.replace(/#include <transmission_pars_fragment>/g,cs.fragmentParas),e.fragmentShader=e.fragmentShader.replace(/vec3 totalEmissiveRadiance = emissive;/g,cs.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 cs={uniforms:{fresnelBias:new n.Uniform(0),fresnelScale:new n.Uniform(1),fresnelPower:new n.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 "},us=class extends Lr{constructor(e){super(),this.type="修改属性",this.cb=e=>{};var{target:e,info:t,oldVal:r,newVal:s,runScene:n,cb:i,executeCb:a}=e;this.runScene=n,this.target=e,this.info=t,this.newVal=s,this.oldVal=r,i&&(this.cb=i),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)}},ds={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},ps=["color","emissive","roughness","metalness","normalScale","aoMapIntensity","displacementScale","transparent","lightMapIntensity","envMapIntensity","opacity","alphaTest"];class ms{constructor(e){this.defMaterialMap={BaseMaterial:Kr,SpriteMaterial:xs,FakeInterior:ts,Reflector:is,Fresnel:ls},this.defMaterial=fs(),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:Kr,SpriteMaterial:xs,FakeInterior:new ts(e),Reflector:new is(e),Fresnel:new ls(e)}}add(e,t,r){this.runScene.uniqueEx.material.add(e,t,r)}create(){var e=new n.MeshStandardMaterial;return this.add(e),e}clone(e){const t=e.clone();return t.userData.id=(0,Qr.getId)(),t}setNormal(e,t=!0){return e=new Ir(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,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){var{info:r,newVal:s}=e,s=(s instanceof File&&(e.newVal=yield this.runScene.textureEx.parse(s)),"envMap"===r&&this.runScene.textureEx.toThree(e.newVal),new Ir(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute());return t&&this.runScene.undoEx.addUndo(s),e.newVal}))}resetMaterial(e,t,r=!0){var s;e&&t&&e.material&&(s=new us({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(s))}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,O.js)(ds,((t,s)=>{const n=e[t];if("object"==typeof n)for(const e in n)if(n[e]!==s[e])return void(r[t]=n.clone());n!==s&&(r[t]=n)})),r}parseNromals(e,t){(0,O.js)(e,((e,r)=>{var s,n,i,a,o;void 0!==ds[e]&&("object"==typeof r?(({x:i,y:a,z:o}=r),null!=(n=null==(s=t[e])?void 0:s.set)&&n.call(s,i,a,o)):t[e]=r)}))}isBaseMaterial(e){return"MeshStandardMaterial"===e.type&&!e.userData.isTimeLineUsed&&Kr.isDefval(e)}}const fs=()=>{const e=new n.MeshStandardMaterial;return e.userData.id=(0,Qr.getId)(),e},gs=(e,t)=>(ps.map((r=>{const s=e[r];"object"==typeof s&&(t[r]=s.clone()),t[r]=s})),t),vs=e=>{var t=e.userData.textures||Ar.map((t=>({type:t,texture:e[t]}))).filter((e=>e.texture));return delete e.userData.textures,t};class xs{static create(){const e=new n.SpriteMaterial;return e.userData.tools=this.tools,e}}xs.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=_s("Box");return t.userData.normal={type:"MySpriteMaterial"},xs.modelTools.merge(e,t),t},parseData:(e,t)=>{const r=_s("Sprite");return xs.modelTools.merge(e,r),r.material=e.material,r}},xs.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,s=gs(r,xs.create());return t.map((e=>{var{type:e,texture:t}=e;s[e]=t})),s},toNormal:e=>{const t=gs(e,fs());return t.userData=Object.assign(Object.assign({},t.userData),{normal:{type:xs.tools.type},textures:xs.tools.getTextures(e)}),t},clone:function(e,t){return e}};class ys{constructor(e){this.addTree=!0,this.isClone=!1,this.cb=(e,t)=>{};var{model:e,parent:t,cb:r,addTree:s,isClone:n,runScene:i}=e;this.runScene=i,this.model=e,this.parent=t,!1===s&&(this.addTree=s),!0===n&&(this.isClone=n),r&&(this.cb=r)}remove(e){const{model:t,parent:r,addTree:s,runScene:n}=e;n.modelEx.select===t&&n.modelEx.selectNull(),r.remove(t),s&&n.uniqueEx.model.remove(t),s&&n.optionsEx.cb.model.remove.cb({model:t,parent:r}),this.cb(t,"remove"),n.uniqueEx.material.addModel(t,void 0,t.material)}add(e){const{model:t,parent:r,addTree:s,isClone:n,runScene:i}=e;r.add(t),s&&i.uniqueEx.model.add(t),s&&i.optionsEx.cb.model.add.cb({model:t,parent:r,isClone:n}),this.cb(t,"add"),i.uniqueEx.material.addModel(t,t.material)}}class ws extends ys{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 bs=class extends Lr{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 Ss extends ys{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 Ts=class extends Lr{constructor(e){super(),this.type="三维矩阵修改";var{target:e,info:t,newV3:r,oldV3:s,runScene:n}=e;this.target=e,this.info=t,this.runScene=n,this.newV3=r,this.oldV3=s,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 Ms{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,s=!1,n=!0){if(e instanceof Array)return e.map((e=>this.add(e,t,r,s,n)));s&&(this.runScene.uniqueEx.model.add(e,{hasReset:!0}),this.runScene.optionsEx.cb.model.clone.cb(e));var i=new ws({model:e,parent:t||this.runScene.sceneEx.get(),isClone:s,runScene:this.runScene}).execute();!0===r&&this.runScene.undoEx.addUndo(i),n&&this.setSelectByModel(e,{isDomTreeActive:!1,isClone:s})}setSelectByModel(e,t){var r,{isDomTreeActive:t,isClone:s}=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&&!s)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 Ss({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:s}=e;return e+r+s===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 qr().model.getModelByType("Box")}clone(e){if(!this.runScene.lightEx.isLight(e)){let s=e.clone();s.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,s))&&t.uuid!==r.uuid&&(this.runScene.materialEx.resetMaterial(s,t,!0),this.runScene.materialEx.add(t,e,r)),this.runScene.uniqueEx.model.add(s,{reset:!0}),s}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 bs({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:s,newV3:n,oldV3:i}=e;const a=new Ts({target:e,info:s,oldV3:i,newV3:n,runScene:this.runScene});r&&a.execute(),t&&this.runScene.undoEx.addUndo(a)}setNormal(e,t=!0){var{model:e,info:r,val:s}=e;e=new us({target:e,info:r,runScene:this.runScene,oldVal:e[r],newVal:s}).execute(),t&&this.runScene.undoEx.addUndo(e)}setMaterial(e,t,r=!0){var s=new us({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(s)}addDef(e){this.add(_s(e))}isModel(e){return!(e.isLight||e.isCamera)}getSphere(){var e=new n.MeshBasicMaterial,t=new n.SphereGeometry(.7,150,150);return new n.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 s=Math.max(r,t),n=r===s?t:r;return e.parent.children.map(((e,t)=>t>n&&t<s&&e)).filter((e=>e))}}}setMultip(e){var{model:e,typeList:t,newVal:r}=e;this.runScene.undoEx.addUndo(new es({target:e,typeList:t,newVal:r}).execute())}createGroup(e,t,r){const s=t||new n.Group,i=[];i.push(new ws({model:s,runScene:this.runScene,parent:r||this.runScene.assetsEx.get().scene}).execute()),e instanceof Array?i.push(...e.map((e=>new bs({target:e,oldParent:e.parent,newParent:s,runScene:this.runScene}).execute()))):i.push(new bs({target:e,oldParent:e.parent,newParent:s,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:s}),this.runScene.optionsEx.cb.model.setMainStatue.cb({status:!0,model:s}),this.runScene.undoEx.addUndo(i),this.setSelectByModel(s)}cleanGroup(e,t=!0){if(e instanceof Array){const t=(0,Yr.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=[],s=e.children.map((e=>{if(e.parent.parent)return new bs({target:e,oldParent:e.parent,newParent:e.parent.parent,runScene:this.runScene})})).filter((e=>e));return r.push(...s.map((e=>e.execute()))),r.push(new Ss({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,s=this.runScene.sceneEx.getClearModels(),n=[];s.map((s=>{s.traverse((s=>{r?!1===qr().model.deepFindParentByUuid(s,t)&&s.uuid!==e.uuid&&n.push(s):s.uuid!==e.uuid&&n.push(s)}))}));var i=n.map((e=>new us({target:e,info:"visible",newVal:!1,runScene:this.runScene,oldVal:e.visible}).execute()));this.runScene.undoEx.addUndo(i),qr().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 us({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 Ss({runScene:this.runScene,model:e,parent:e.parent}).execute())})),this.runScene.undoEx.addUndo(r)}}const _s=e=>{if(Zr.includes(e)){const t=qr().model.getModelByType(e);return"Sprite"===t.type&&(t.material.userData.tools=xs.tools),t}throw TypeError("")};class Es{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:s}=t;return{type:s,data:r(e)}}))}}class Ps{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:s}=e;s[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,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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 Cs{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 n.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 Rs{constructor(e,t){this.helperModels=[],this.runScene=t,this.type=e,this.material=new Ps(t),this.scene=new Cs(t)}init(){this.scene.init()}parseNode(e){const{object:t,nodeDef:r}=e;(0,O.js)(this.runScene.modelEx.defNodeMap,((e,s)=>{t[e]!==s&&(r[e]=t[e])})),t.material&&t.material.wireframe&&(t.material.wireframe=!1,r.wireframe=!0)}parseSprite(){}done(e){return function(e,t,r,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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 Ds=function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};class As{constructor(e,t){this.materialMap={},this.textureMap={},this.json={materialMap:{},textureMap:{}},this.modelType={Sprite:xs},this.type=e,this.runScene=t}parse(e){return Ds(this,void 0,void 0,(function*(){const t=new n.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 n.Texture||t.environment instanceof n.Texture){this.runScene.bloom.glow.setUpdate(!1),t.userData.ex={};var{background:r,environment:s}=t;this.runScene.bloom.glow.setUpdate(!0);const i=this.runScene.modelEx.create(),a=fs();i.material=a,e.add(i),e=(0,Qr.getId)(),t.userData.ex.materialId=e,a.userData.id=e,this.materialMap[e]={material:a},r instanceof n.Texture&&303===(a.map=r).mapping&&(t.userData.ex.backgroundMapping=303),s instanceof n.Texture&&(a.envMap=s)}}_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:s}=e.position;0===t&&0===r&&0===s||(e.position.set(0,0,0),e.userData.local=t+","+r+","+s)}_processModel(e,t){const r=this.modelType[e.type];if(!r)return e;const s=r.modelTools.toNormal(e);return t&&(s.material=t),e.parent.add(s),e.parent.remove(e),s}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,O.js)(this.materialMap,((e,t)=>Ds(this,void 0,void 0,(function*(){var e=t.material,r=vs(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 n in this.textureMap){var{md5:r,texture:s}=this.textureMap[n];if(t.md5===r&&e.mapping===s.mapping)return{isSame:!0,texture:s}}return this.textureMap[e.userData.id]=Object.assign(Object.assign({},t),{texture:e}),{isSame:!1,texture:e}}mergeAndRemoveTexture(e,t){return Ds(this,void 0,void 0,(function*(){return e.map((e=>{const{type:r,texture:s}=e;this.runScene.uniqueEx.texture.add(s),t[r]=null;var{isSame:e,texture:n}=this.mergeSame(s);if(e)this.runScene.textureEx.dispose(s);else if(!this.json.textureMap[s.userData.id]){var i,{format:a,repeat:o,center:l,rotation:h,offset:c}=s;const e={format:a};this.runScene.modelEx.isNavieV2(o,1)||(({x:a,y:i}=o),e.repeat=a===i?a:o),this.runScene.modelEx.isNavieV2(l,0)||(({x:i,y:a}=l),e.center=i===a?i:l),this.runScene.modelEx.isNavieV2(c,0)||(({x:o,y:a}=c),e.offset=o===a?o:c),0!==h&&(e.rotation=h),this.json.textureMap[s.userData.id]=e}"normalMap"!==r||s.userData.isNormalMap||(s.userData.isNormalMap=!0),this.json.materialMap[t.userData.id].textures[r]=n.userData.id}))}))}setMultipMaterial(e,t){const r=this.runScene.modelEx.create(),s=fs();r.material=s,e.add(r);for(const e of Dr){if(!t.length)return;var n=t.pop();if(!n)return;s[e]=this.textureMap[n].texture}t.length&&this.setMultipMaterial(e,t)}}class Ls{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Vs(e)})),this.register((function(e){return new Hs(e)})),this.register((function(e){return new Gs(e)})),this.register((function(e){return new Xs(e)})),this.register((function(e){return new qs(e)})),this.register((function(e){return new Ws(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){"object"==typeof r&&(console.warn("THREE.GLTFExporter: parse() expects options as the fourth argument now."),s=r);const n=new js,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](n));n.setPlugins(i),n.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise((function(s,n){r.parse(e,s,n,t)}))}}const Is=5121,Os=5123,Us={},ks=(Us[n.NearestFilter]=9728,Us[n.NearestMipmapNearestFilter]=9984,Us[n.NearestMipmapLinearFilter]=9986,Us[n.LinearFilter]=9729,Us[n.LinearMipmapNearestFilter]=9985,Us[n.LinearMipmapLinearFilter]=9987,Us[n.ClampToEdgeWrapping]=33071,Us[n.RepeatWrapping]=10497,Us[n.MirroredRepeatWrapping]=33648,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function Bs(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Fs(e){return 4*Math.ceil(e/4)}function Ns(e,t=0){var r=Fs(e.byteLength);if(r===e.byteLength)return e;{const s=new Uint8Array(r);if(s.set(new Uint8Array(e)),0!==t)for(let n=e.byteLength;n<r;n++)s[n]=t;return s.buffer}}let zs=null;class js{constructor(){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}}setPlugins(e){this.plugins=e}async write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);var s=(e=this).buffers;const n=e.json;if(r=e.options,await e.options.myOptions.helper.done(n),e=e.extensionsUsed,s=new Blob(s,{type:"application/octet-stream"}),0<(e=Object.keys(e)).length&&(n.extensionsUsed=e),n.buffers&&0<n.buffers.length&&(n.buffers[0].byteLength=s.size),!0===r.binary){const e=new window.FileReader;e.readAsArrayBuffer(s),e.onloadend=function(){var r=Ns(e.result);const s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);var i=Ns(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;const t=new Uint8Array(new ArrayBuffer(e.length));for(let s=0,n=e.length;s<n;s++){var r=e.charCodeAt(s);t[s]=255<r?32:r}return t.buffer}(JSON.stringify(n)),32);const a=new DataView(new ArrayBuffer(8));a.setUint32(0,i.byteLength,!0),a.setUint32(4,1313821514,!0);var o=new ArrayBuffer(12);const l=new DataView(o);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0);var h=12+a.byteLength+i.byteLength+s.byteLength+r.byteLength;l.setUint32(8,h,!0),h=new Blob([o,a,i,s,r],{type:"application/octet-stream"});const c=new window.FileReader;c.readAsArrayBuffer(h),c.onloadend=function(){t(c.result)}}}else if(n.buffers&&0<n.buffers.length){const e=new window.FileReader;e.readAsDataURL(s),e.onloadend=function(){var r=e.result;n.buffers[0].uri=r,t(n)}}else t(n)}serializeUserData(e,t){if(0!==Object.keys(e.userData).length){var r=this.options;const s=this.extensionsUsed;try{const n=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&n.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in n.gltfExtensions)t.extensions[e]=n.gltfExtensions[e],s[e]=!0;delete n.gltfExtensions}0<Object.keys(n).length&&(t.extras=n)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new n.Vector3;for(let r=0,s=e.count;r<s;r++)if(5e-4<Math.abs(t.fromBufferAttribute(e,r).length()-1))return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),s=new n.Vector3;for(let e=0,t=r.count;e<t;e++)s.fromBufferAttribute(r,e),0===s.x&&0===s.y&&0===s.z?s.setX(1):s.normalize(),r.setXYZ(e,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};0===t.offset.x&&0===t.offset.y||(s.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(s.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(s.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildORMTexture(e){var t=e.aoMap?.image,r=e.roughnessMap?.image,s=e.metalnessMap?.image;if(t===r&&r===s)return e.aoMap;if(t||r||s){e=Math.max(t?.width||0,r?.width||0,s?.width||0);var i=Math.max(t?.height||0,r?.height||0,s?.height||0);const h=document.createElement("canvas"),c=(h.width=e,h.height=i,h.getContext("2d")),u=(c.fillStyle="#ffffff",c.fillRect(0,0,e,i),c.getImageData(0,0,e,i));if(t){c.drawImage(t,0,0,e,i);var a=c.getImageData(0,0,e,i).data;for(let e=0;e<a.length;e+=4)u.data[e]=a[e]}if(r){c.drawImage(r,0,0,e,i);var o=c.getImageData(0,0,e,i).data;for(let e=1;e<o.length;e+=4)u.data[e]=o[e]}if(s){c.drawImage(s,0,0,e,i);var l=c.getImageData(0,0,e,i).data;for(let e=2;e<l.length;e+=4)u.data[e]=l[e]}return c.putImageData(u,0,0),new n.Texture(h)}}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,n){const i=this.json;let a;i.bufferViews||(i.bufferViews=[]),a=t===Is?1:t===Os?2:4;var o=Fs(s*e.itemSize*a);const l=new DataView(new ArrayBuffer(o));let h=0;for(let n=r;n<r+s;n++)for(let r=0;r<e.itemSize;r++){let s;4<e.itemSize?s=e.array[n*e.itemSize+r]:0===r?s=e.getX(n):1===r?s=e.getY(n):2===r?s=e.getZ(n):3===r&&(s=e.getW(n)),5126===t?l.setFloat32(h,s,!0):5125===t?l.setUint32(h,s,!0):t===Os?l.setUint16(h,s,!0):t===Is&&l.setUint8(h,s),h+=a}const c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==n&&(c.target=n),34962===n&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,i.bufferViews.push(c),{id:i.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(s,n){const i=new window.FileReader;if(!(e instanceof Blob))return n();i.readAsArrayBuffer(e),i.onloadend=function(){var e=Ns(i.result),n={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,s(r.bufferViews.push(n)-1)}}))}processAccessor(e,t,r,s){var n=this.options;const i=this.json;let a,o;if(e.array.constructor===Float32Array)a=5126;else if(e.array.constructor===Uint32Array)a=5125;else if(e.array.constructor===Uint16Array)a=Os;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");a=Is}if(void 0===r&&(r=0),void 0===s&&(s=e.count),n.truncateDrawRange&&void 0!==t&&null===t.index&&(n=r+s,l=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count,r=Math.max(r,t.drawRange.start),(s=Math.min(n,l)-r)<0&&(s=0)),0===s)return null;n=function(e,t,r){const s={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=t;n<t+r;n++)for(let t=0;t<e.itemSize;t++){let r;4<e.itemSize?r=e.array[n*e.itemSize+t]:0===t?r=e.getX(n):1===t?r=e.getY(n):2===t?r=e.getZ(n):3===t&&(r=e.getW(n)),s.min[t]=Math.min(s.min[t],r),s.max[t]=Math.max(s.max[t],r)}return s}(e,r,s),void 0!==t&&(o=e===t.index?34963:34962);var l=this.processBufferView(e,a,r,s,o);const h={bufferView:l.id,byteOffset:l.byteOffset,componentType:a,count:s,max:n.max,min:n.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(h)-1}processImage(e,t,r,s){const i=this,a=i.cache,o=i.json;var l=i.options;const h=i.pending,c=(a.images.has(e)||a.images.set(e,{}),a.images.get(e));let u=s.userData?.blob;var d=s.userData.isNormalMap,p=i.options.myOptions.optionsEx.exporterOptions.compressTexture;const m=p?"image/webp":"image/png";if(p&&(u=!!d),void 0!==c[p=m+":flipY/"+r.toString()])return c[p];o.images||(o.images=[]);const f={mimeType:m};if(!0===l.binary&&u)h.push(new Promise((e=>{i.processBufferViewImage(s.userData.blob).then((function(t){f.bufferView=t,e()}))})));else if(l.embedImages){const r=zs=zs||document.createElement("canvas"),s=(r.width=Math.min(e.width,l.maxTextureSize),r.height=Math.min(e.height,l.maxTextureSize),r.getContext("2d"));if(s.translate(0,r.height),s.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)s.drawImage(e,0,0,r.width,r.height);else{t!==n.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const r=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<r.length;t+=4)r[t+0]=e.data[t+0],r[t+1]=e.data[t+1],r[t+2]=e.data[t+2],r[t+3]=e.data[t+3];s.putImageData(new ImageData(r,e.width,e.height),0,0)}!0===l.binary?h.push(new Promise((function(e){r.toBlob((function(t){i.processBufferViewImage(t).then((function(t){f.bufferView=t,e()}))}),m)}))):f.uri=r.toDataURL(m)}else f.uri=e.src;return d=o.images.push(f)-1,c[p]=d}processSampler(e){const t=this.json;return t.samplers||(t.samplers=[]),e={magFilter:Us[e.magFilter],minFilter:Us[e.minFilter],wrapS:Us[e.wrapS],wrapT:Us[e.wrapT]},t.samplers.push(e)-1}processTexture(e){const t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);const s={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,e)};e.name&&(s.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,s)}));var n=r.textures.push(s)-1;return t.textures.set(e,n),this.options.myOptions.helper.material.processTexture({texture:e,textureDef:s}),n}processMaterial(e){const 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=[]);const s={pbrMetallicRoughness:{}};if(this.options.myOptions.helper.material.parseMaterial({material:e,materialDef:s,options:this}),!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results."),Bs(i=e.color.toArray().concat([e.opacity]),[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(i={index:this.processTexture(null)},this.applyTextureTransform(i,e.metalnessMap||e.roughnessMap),s.pbrMetallicRoughness.metallicRoughnessTexture=i),e.map&&(i={index:this.processTexture(e.map)},this.applyTextureTransform(i,e.map),s.pbrMetallicRoughness.baseColorTexture=i),e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity);var i=Math.max(t.r,t.g,t.b);1<i&&(t.multiplyScalar(1/i),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<i&&(s.emissiveFactor=t.toArray()),e.emissiveMap&&(i={index:this.processTexture(e.emissiveMap)},this.applyTextureTransform(i,e.emissiveMap),s.emissiveTexture=i)}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),s.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),s.occlusionTexture=t}return e.transparent?s.alphaMode="BLEND":0<e.alphaTest&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===n.DoubleSide&&(s.doubleSided=!0),""!==e.name&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,s)})),i=r.materials.push(s)-1,t.materials.set(e,i),i}processMesh(e){const t=this.cache,r=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)s.push(e.material[t].uuid);else s.push(e.material.uuid);var i=s.join(":");if(t.meshes.has(i))return t.meshes.get(i);const a=e.geometry;let o;if(o=e.isLineSegments?1:e.isLineLoop?2:e.isLine?3:e.isPoints?0:e.material.wireframe?1:4,!0!==a.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");const l={},h={},c=[],u=[];var d,p={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},m=a.getAttribute("normal");void 0===m||this.isNormalizedNormalAttribute(m)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(m)));let f=null;for(d in a.attributes)if("morph"!==d.slice(0,5)){var g,v=a.attributes[d];d=p[d]||d.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(d)||(d="_"+d),t.attributes.has(this.getUID(v))?h[d]=t.attributes.get(this.getUID(v)):(f=null,g=v.array,"JOINTS_0"!==d||g instanceof Uint16Array||g instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new n.BufferAttribute(new Uint16Array(g),v.itemSize,v.normalized)),null!==(g=this.processAccessor(f||v,a))&&(h[d]=g,t.attributes.set(this.getUID(v),g)))}if(void 0!==m&&a.setAttribute("normal",m),0===Object.keys(h).length)return null;if(void 0!==e.morphTargetInfluences&&0<e.morphTargetInfluences.length){const r=[],s=[],n={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let i=0;i<e.morphTargetInfluences.length;++i){const o={};let l=!1;for(const e in a.morphAttributes)if("position"!==e&&"normal"!==e)l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);else{const r=a.morphAttributes[e][i];var x=e.toUpperCase();const s=a.attributes[e];if(t.attributes.has(this.getUID(r)))o[x]=t.attributes.get(this.getUID(r));else{const e=r.clone();if(!a.morphTargetsRelative)for(let t=0,n=r.count;t<n;t++)e.setXYZ(t,r.getX(t)-s.getX(t),r.getY(t)-s.getY(t),r.getZ(t)-s.getZ(t));o[x]=this.processAccessor(e,a),t.attributes.set(this.getUID(s),o[x])}}u.push(o),r.push(e.morphTargetInfluences[i]),void 0!==e.morphTargetDictionary&&s.push(n[i])}l.weights=r,0<s.length&&(l.extras={},l.extras.targetNames=s)}if((m=Array.isArray(e.material))&&0===a.groups.length)return null;var y=m?e.material:[e.material],w=m?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=w.length;e<r;e++){const r={mode:o,attributes:h};if(this.serializeUserData(a,r),0<u.length&&(r.targets=u),null!==a.index){let s=this.getUID(a.index);void 0===w[e].start&&void 0===w[e].count||(s+=":"+w[e].start+":"+w[e].count),t.attributes.has(s)?r.indices=t.attributes.get(s):(r.indices=this.processAccessor(a.index,a,w[e].start,w[e].count),t.attributes.set(s,r.indices)),null===r.indices&&delete r.indices}var b=this.processMaterial(y[w[e].materialIndex]);null!==b&&(r.material=b),c.push(r)}return l.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,l)})),m=r.meshes.push(l)-1,t.meshes.set(i,m),m}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);var r=e.isOrthographicCamera;const s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:n.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){const r=this.json,s=this.nodeMap;r.animations||(r.animations=[]);var i=(e=Ls.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks;const a=[],o=[];for(let e=0;e<i.length;++e){const r=i[e];var l=n.PropertyBinding.parseTrackName(r.name);let c=n.PropertyBinding.findNode(t,l.nodeName);var h=ks[l.propertyName];if(!(c="bones"===l.objectName?!0===c.isSkinnedMesh?c.skeleton.getBoneByName(l.objectIndex):void 0:c)||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',r.name),null;let u,d=r.values.length/r.times.length;h===ks.morphTargetInfluences&&(d/=c.morphTargetInfluences.length),!0===r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",d/=3):u=r.getInterpolation()===n.InterpolateDiscrete?"STEP":"LINEAR",o.push({input:this.processAccessor(new n.BufferAttribute(r.times,1)),output:this.processAccessor(new n.BufferAttribute(r.values,d)),interpolation:u}),a.push({sampler:o.length-1,target:{node:s.get(c),path:h}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:o,channels:a}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)];var i=e.skeleton;if(void 0===i)return null;var a=e.skeleton.bones[0];if(void 0===a)return null;const o=[];var l=new Float32Array(16*i.bones.length);const h=new n.Matrix4;for(let t=0;t<i.bones.length;++t)o.push(r.get(i.bones[t])),h.copy(i.boneInverses[t]),h.multiply(e.bindMatrix).toArray(l,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new n.BufferAttribute(l,16)),joints:o,skeleton:r.get(a)}),s.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap,n=(t.nodes||(t.nodes=[]),{});var i,a,o;if(r.myOptions.helper.parseNode({object:e,nodeDef:n,options:this}),r.trs?(o=e.quaternion.toArray(),i=e.position.toArray(),a=e.scale.toArray(),Bs(o,[0,0,0,1])||(n.rotation=o),Bs(i,[0,0,0])||(n.translation=i),Bs(a,[1,1,1])||(n.scale=a)):(e.matrixAutoUpdate&&e.updateMatrix(),!1===Bs(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(n.matrix=e.matrix.elements)),""!==e.name&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints?null!==(o=this.processMesh(e))&&(n.mesh=o):e.isCamera&&(n.camera=this.processCamera(e)),e.isSkinnedMesh&&this.skins.push(e),0<e.children.length){const t=[];for(let s=0,n=e.children.length;s<n;s++){var l=e.children[s];if(l.visible||!1===r.onlyVisible){const e=this.processNode(l);null!==e&&t.push(e)}}0<t.length&&(n.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,n)}));const h=t.nodes.push(n)-1;return s.set(e,h),h}processScene(e){const t=this.json;var r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={},n=(""!==e.name&&(s.name=e.name),t.scenes.push(s),[]);for(let t=0,s=e.children.length;t<s;t++){var i=e.children[t];!i.visible&&!1!==r.onlyVisible||null!==(i=this.processNode(i))&&n.push(i)}0<n.length&&(s.nodes=n),this.serializeUserData(e,s)}processObjects(e){const t=new n.Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){var t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const r=[];for(let t=0;t<e.length;t++)e[t]instanceof n.Scene?this.processScene(e[t]):r.push(e[t]);if(1===r.length){let[e]=r;if(!["Group","Object3D"].includes(e.type)){const t=new n.Group;t.name="glb_model",t.add(e),e=t}this.processScene(e)}else 1<r.length&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class Vs{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(e.isLight)if(e.isDirectionalLight||e.isPointLight||e.isSpotLight){var r=this.writer;const s=r.json,n=r.extensionsUsed,i={},a=(e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",0<e.distance&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",0<e.distance&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,i.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."),n[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},n[this.name]=!0),s.extensions[this.name].lights);a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}else console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e)}}class Hs{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(e.isMeshBasicMaterial){const e=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},e[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}}class Gs{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(e.isGLTFSpecularGlossinessMaterial){const s=this.writer,n=s.extensionsUsed,i={};t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);var r=[1,1,1];e.specular.toArray(r,0),i.specularFactor=r,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap&&(r={index:s.processTexture(e.specularMap)},s.applyTextureTransform(r,e.specularMap),i.specularGlossinessTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}}}class Ws{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial){const s=this.writer,n=s.extensionsUsed,i={};var r;i.clearcoatFactor=e.clearcoat,e.clearcoatMap&&(r={index:s.processTexture(e.clearcoatMap)},s.applyTextureTransform(r,e.clearcoatMap),i.clearcoatTexture=r),i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap&&(r={index:s.processTexture(e.clearcoatRoughnessMap)},s.applyTextureTransform(r,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=r),e.clearcoatNormalMap&&(r={index:s.processTexture(e.clearcoatNormalMap)},s.applyTextureTransform(r,e.clearcoatNormalMap),i.clearcoatNormalTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}}}class Xs{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial&&0!==e.transmission){const s=this.writer,n=s.extensionsUsed,i={};var r;i.transmissionFactor=e.transmission,e.transmissionMap&&(r={index:s.processTexture(e.transmissionMap)},s.applyTextureTransform(r,e.transmissionMap),i.transmissionTexture=r),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}}}class qs{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(e.isMeshPhysicalMaterial&&0!==e.transmission){const s=this.writer,n=s.extensionsUsed,i={};var r;i.thicknessFactor=e.thickness,e.thicknessMap&&(r={index:s.processTexture(e.thicknessMap)},s.applyTextureTransform(r,e.thicknessMap),i.thicknessTexture=r),i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}}}Ls.Utils={insertKeyframe:function(e,t){var r=e.getValueSize();const s=new e.TimeBufferType(e.times.length+1),n=new e.ValueBufferType(e.values.length+r),i=e.createInterpolant(new e.ValueBufferType(r));let a;if(0===e.times.length){s[0]=t;for(let e=0;e<r;e++)n[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;s[0]=t,s.set(e.times,1),n.set(i.evaluate(t),0),n.set(e.values,r),a=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;s[s.length-1]=t,s.set(e.times,0),n.set(e.values,0),n.set(i.evaluate(t),e.values.length),a=s.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){s.set(e.times.slice(0,o+1),0),s[o+1]=t,s.set(e.times.slice(o+1),o+2),n.set(e.values.slice(0,(o+1)*r),0),n.set(i.evaluate(t),(o+1)*r),n.set(e.values.slice((o+1)*r),(o+2)*r),a=o+1;break}}return e.times=s,e.values=n,a},mergeMorphTargetTracks:function(e,t){const r=[],s={};var i=e.tracks;for(let e=0;e<i.length;++e){let u=i[e];var a=n.PropertyBinding.parseTrackName(u.name),o=n.PropertyBinding.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex)r.push(u);else{if(u.createInterpolant!==u.InterpolantFactoryMethodDiscrete&&u.createInterpolant!==u.InterpolantFactoryMethodLinear){if(u.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."),(u=u.clone()).setInterpolation(n.InterpolateLinear)}var l=o.morphTargetInfluences.length,h=o.morphTargetDictionary[a.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let e;if(void 0===s[o.uuid]){const t=new((e=u.clone()).ValueBufferType)(l*e.times.length);for(let r=0;r<e.times.length;r++)t[r*l+h]=e.values[r];e.name=(a.nodeName||"")+".morphTargetInfluences",e.values=t,s[o.uuid]=e,r.push(e)}else{const t=u.createInterpolant(new u.ValueBufferType(1));e=s[o.uuid];for(let r=0;r<e.times.length;r++)e.values[r*l+h]=t.evaluate(e.times[r]);for(let t=0;t<u.times.length;t++){var c=this.insertKeyframe(e,u.times[t]);e.values[c*l+h]=u.values[t]}}}}return e.tracks=r,e}};var Ys=function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};class Zs{constructor(e){this._gltf=new Ls,this.options=new Es,this.runScene=e}getArrayBuffer(e=this.runScene.sceneEx.getClear(),t="scene"){return Ys(this,void 0,void 0,(function*(){const r=new Rs(t,this.runScene),s=new As(t,this.runScene);var n=yield s.parse(e);return r.material.setMaterialMap(n),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 Ys(this,void 0,void 0,(function*(){var t=yield this.getArrayBuffer(e);(0,k.downloadFile)(new Blob([t]),"scene.glb")}))}model(){return Ys(this,void 0,void 0,(function*(){const e=this.runScene.modelEx.select;var t;e&&(t=yield this.getArrayBuffer(e.clone(),"model"),(0,k.downloadFile)(new Blob([t]),"scene.glb"))}))}material(){var e;return Ys(this,void 0,void 0,(function*(){var t=null==(e=this.runScene.modelEx.select)?void 0:e.material;if(t){const e=_s("Box");e.material=t,t=yield this.getArrayBuffer(e,"material"),(0,k.downloadFile)(new Blob([t]),"material.glb")}}))}scene(){return Ys(this,void 0,void 0,(function*(){var e=yield this.getArrayBuffer();(0,k.downloadFile)(new Blob([e]),"scene.glb")}))}}class Qs{constructor(e){this.runScene=e,this.gltf=new Zs(e)}}var Ks={},Js=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},$s=function(e){return new Worker(e)};try{URL.revokeObjectURL(Js(""))}catch(pn){Js=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},$s=function(e){return new Worker(e,{type:"module"})}}for(var en,tn=Uint8Array,rn=Uint16Array,sn=Uint32Array,nn=new tn([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]),an=new tn([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]),on=new tn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ln=(t=function(e,t){for(var r=new rn(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];var n=new sn(r[30]);for(s=1;s<30;++s)for(var i=r[s];i<r[s+1];++i)n[i]=i-r[s]<<5|s;return[r,n]},(en=t(nn,2))[0]),hn=en[1],cn=(ln[28]=258,hn[258]=28,en=t(an,0))[0],un=en[1],dn=new rn(32768),pn=0;pn<32768;++pn){var mn=(43690&pn)>>>1|(21845&pn)<<1;dn[pn]=((65280&(mn=(61680&(mn=(52428&mn)>>>2|(13107&mn)<<2))>>>4|(3855&mn)<<4))>>>8|(255&mn)<<8)>>>1}var fn=function(e,t,r){for(var s=e.length,n=0,i=new rn(t);n<s;++n)++i[e[n]-1];var a=new rn(t);for(n=0;n<t;++n)a[n]=a[n-1]+i[n-1]<<1;if(r){var o=new rn(1<<t),l=15-t;for(n=0;n<s;++n)if(e[n])for(var h=n<<4|e[n],c=t-e[n],u=a[e[n]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)o[dn[u]>>>l]=h}else for(o=new rn(s),n=0;n<s;++n)e[n]&&(o[n]=dn[a[e[n]-1]++]>>>15-e[n]);return o},gn=new tn(288);for(pn=0;pn<144;++pn)gn[pn]=8;for(pn=144;pn<256;++pn)gn[pn]=9;for(pn=256;pn<280;++pn)gn[pn]=7;for(pn=280;pn<288;++pn)gn[pn]=8;var vn=new tn(32);for(pn=0;pn<32;++pn)vn[pn]=5;function xn(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 yn(e,t,r,s,n){var i,a=Zn(e,s,n,(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(i)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,i=r],[e.buffer])},t.terminate=function(){a.terminate()}}function wn(e,t){return ai(e,t)+4294967296*ai(e,t+4)}var bn=fn(gn,9,0),Sn=fn(gn,9,1),Tn=fn(vn,5,0),Mn=fn(vn,5,1),_n=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},En=function(e,t,r){var s=t/8|0;return(e[s]|e[1+s]<<8)>>(7&t)&r},Pn=function(e,t){var r=t/8|0;return(e[r]|e[1+r]<<8|e[2+r]<<16)>>(7&t)},Cn=function(e){return(e/8|0)+(7&e&&1)},Rn=function(e,t,r){(null==r||r>e.length)&&(r=e.length);var s=new(e instanceof rn?rn:e instanceof sn?sn:tn)(r-(t=null==t||t<0?0:t));return s.set(e.subarray(t,r)),s},Dn=function(e,t,r){var s=e.length;if(!s||r&&!r.l&&s<5)return t||new tn(0);function n(e){var r=t.length;r<e&&((r=new tn(Math.max(2*r,e))).set(t),t=r)}var i=!t||r,a=!r||r.i,o=(r=r||{},t=t||new tn(3*s),r.f||0),l=r.p||0,h=r.b||0,c=r.l,u=r.d,d=r.m,p=r.n,m=8*s;do{if(!c){r.f=o=En(e,l,1);var f=En(e,l+1,3);if(l+=3,!f){var g=e[(_=Cn(l)+4)-4]|e[_-3]<<8;if(s<(S=_+g)){if(a)throw"unexpected EOF";break}i&&n(h+g),t.set(e.subarray(_,S),h),r.b=h+=g,r.p=l=8*S;continue}if(1==f)c=Sn,u=Mn,d=9,p=5;else{if(2!=f)throw"invalid block type";g=En(e,l,31)+257;for(var v=En(e,l+10,15)+4,x=g+En(e,l+5,31)+1,y=(l+=14,new tn(x)),w=new tn(19),b=0;b<v;++b)w[on[b]]=En(e,l+3*b,7);l+=3*v;var S,T=(1<<(S=_n(w)))-1,M=fn(w,S,1);for(b=0;b<x;){var _,E=M[En(e,l,T)];if(l+=15&E,(_=E>>>4)<16)y[b++]=_;else{var P=0,C=0;for(16==_?(C=3+En(e,l,3),l+=2,P=y[b-1]):17==_?(C=3+En(e,l,7),l+=3):18==_&&(C=11+En(e,l,127),l+=7);C--;)y[b++]=P}}f=y.subarray(0,g);var R=y.subarray(g);d=_n(f),p=_n(R),c=fn(f,d,1),u=fn(R,p,1)}if(m<l){if(a)throw"unexpected EOF";break}}i&&n(h+131072);for(var D=(1<<d)-1,A=(1<<p)-1,L=l;;L=l){var I=(P=c[Pn(e,l)&D])>>>4;if(m<(l+=15&P)){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(I<256)t[h++]=I;else{if(256==I){L=l,c=null;break}var O,U=I-254,k=(264<I&&(O=nn[b=I-257],U=En(e,l,(1<<O)-1)+ln[b],l+=O),(I=u[Pn(e,l)&A])>>>4);if(!I)throw"invalid distance";if(l+=15&I,R=cn[k],3<k&&(O=an[k],R+=Pn(e,l)&(1<<O)-1,l+=O),m<l){if(a)throw"unexpected EOF";break}i&&n(h+131072);for(var B=h+U;h<B;h+=4)t[h]=t[h-R],t[h+1]=t[h+1-R],t[h+2]=t[h+2-R],t[h+3]=t[h+3-R];h=B}}r.l=c,r.p=L,r.b=h,c&&(o=1,r.m=d,r.d=u,r.n=p)}while(!o);return h==t.length?t:Rn(t,0,h)},An=function(e,t,r){var s=t/8|0;e[s]|=r<<=7&t,e[1+s]|=r>>>8},Ln=function(e,t,r){var s=t/8|0;e[s]|=r<<=7&t,e[1+s]|=r>>>8,e[2+s]|=r>>>16},In=function(e,t){for(var r=[],s=0;s<e.length;++s)e[s]&&r.push({s,f:e[s]});var n=r.length,i=r.slice();if(!n)return[zn,0];if(1==n)return(f=new tn(r[0].s+1))[r[0].s]=1,[f,1];r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var a=r[0],o=r[1],l=0,h=1,c=2;for(r[0]={s:-1,f:a.f+o.f,l:a,r:o};h!=n-1;)a=r[r[l].f<r[c].f?l++:c++],o=r[l!=h&&r[l].f<r[c].f?l++:c++],r[h++]={s:-1,f:a.f+o.f,l:a,r:o};var u=i[0].s;for(s=1;s<n;++s)i[s].s>u&&(u=i[s].s);var d=new rn(u+1),p=On(r[h-1],d,0);if(t<p){s=0;var m=0,f=p-t,g=1<<f;for(i.sort((function(e,t){return d[t.s]-d[e.s]||e.f-t.f}));s<n;++s){var v=i[s].s;if(!(d[v]>t))break;m+=g-(1<<p-d[v]),d[v]=t}for(m>>>=f;0<m;){var x=i[s].s;d[x]<t?m-=1<<t-d[x]++-1:++s}for(;0<=s&&m;--s){var y=i[s].s;d[y]==t&&(--d[y],++m)}p=t}return[new tn(d),p]},On=function(e,t,r){return-1==e.s?Math.max(On(e.l,t,r+1),On(e.r,t,r+1)):t[e.s]=r},Un=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new rn(++t),s=0,n=e[0],i=1,a=function(e){r[s++]=e},o=1;o<=t;++o)if(e[o]==n&&o!=t)++i;else{if(!n&&2<i){for(;138<i;i-=138)a(32754);2<i&&(a(10<i?i-11<<5|28690:i-3<<5|12305),i=0)}else if(3<i){for(a(n),--i;6<i;i-=6)a(8304);2<i&&(a(i-3<<5|8208),i=0)}for(;i--;)a(n);i=1,n=e[o]}return[r.subarray(0,s),t]},kn=function(e,t){for(var r=0,s=0;s<t.length;++s)r+=e[s]*t[s];return r},Bn=function(e,t,r){var s=r.length,n=Cn(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i<s;++i)e[n+i+4]=r[i];return 8*(n+4+s)},Fn=function(e,t,r,s,n,i,a,o,l,h,c){An(t,c++,r),++n[256];for(var u=(r=In(n,15))[0],d=(r=r[1],(p=In(i,15))[0]),p=p[1],m=(f=Un(u))[0],f=f[1],g=(v=Un(d))[0],v=v[1],x=new rn(19),y=0;y<m.length;++y)x[31&m[y]]++;for(y=0;y<g.length;++y)x[31&g[y]]++;for(var w=(b=In(x,7))[0],b=b[1],S=19;4<S&&!w[on[S-1]];--S);var T,M=h+5<<3,_=kn(n,gn)+kn(i,vn)+a;if(n=kn(n,u)+kn(i,d)+a+14+3*S+kn(x,w)+(2*x[16]+3*x[17]+7*x[18]),M<=_&&M<=n)return Bn(t,c,e.subarray(l,l+h));if(An(t,c,1+(n<_)),c+=2,n<_){var E=fn(u,r,0),P=u,C=fn(d,p,0),R=d,D=fn(w,b,0);for(An(t,c,f-257),An(t,c+5,v-1),An(t,c+10,S-4),c+=14,y=0;y<S;++y)An(t,c+3*y,w[on[y]]);c+=3*S;for(var A=[m,g],L=0;L<2;++L){var I=A[L];for(y=0;y<I.length;++y){var O=31&I[y];An(t,c,D[O]),c+=w[O],15<O&&(An(t,c,I[y]>>>5&127),c+=I[y]>>>12)}}}else E=bn,P=gn,C=Tn,R=vn;for(y=0;y<o;++y)255<s[y]?(O=s[y]>>>18&31,Ln(t,c,E[O+257]),c+=P[O+257],7<O&&(An(t,c,s[y]>>>23&31),c+=nn[O]),T=31&s[y],Ln(t,c,C[T]),c+=R[T],3<T&&(Ln(t,c,s[y]>>>5&8191),c+=an[T])):(Ln(t,c,E[s[y]]),c+=P[s[y]]);return Ln(t,c,E[256]),c+P[256]},Nn=new sn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),zn=new tn(0),jn=function(e,t,r,s,n,i){var a=e.length,o=new tn(s+a+5*(1+Math.ceil(a/7e3))+n),l=o.subarray(s,o.length-n),h=0;if(!t||a<8)for(var c=0;c<=a;c+=65535){var u=c+65535;h=u<a?Bn(l,h,e.subarray(c,u)):(l[c]=i,Bn(l,h,e.subarray(c,a)))}else{for(var d=(t=Nn[t-1])>>>13,p=8191&t,m=(1<<r)-1,f=new rn(32768),g=new rn(1+m),v=Math.ceil(r/3),x=2*v,y=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<x)&m},w=new sn(25e3),b=new rn(288),S=new rn(32),T=0,M=0,_=(c=0,0),E=0,P=0;c<a;++c){var C=y(c),R=32767&c,D=g[C];if(f[R]=D,g[C]=R,E<=c){var A=a-c;if((7e3<T||24576<_)&&423<A){h=Fn(e,l,0,w,b,S,M,_,P,c-P,h),_=T=M=0,P=c;for(var L=0;L<286;++L)b[L]=0;for(L=0;L<30;++L)S[L]=0}var I=2,O=0,U=p,k=R-D&32767;if(2<A&&C==y(c-k))for(var B=Math.min(d,A)-1,F=Math.min(32767,c),N=Math.min(258,A);k<=F&&--U&&R!=D;){if(e[c+I]==e[c+I-k]){for(var z=0;z<N&&e[c+z]==e[c+z-k];++z);if(I<z){if(O=k,B<(I=z))break;var j=Math.min(k,z-2),V=0;for(L=0;L<j;++L){var H=c-k+L+32768&32767,G=H-f[H]+32768&32767;V<G&&(V=G,D=H)}}}k+=(R=D)-(D=f[R])+32768&32767}O?(w[_++]=268435456|hn[I]<<18|un[O],C=31&hn[I],A=31&un[O],M+=nn[C]+an[A],++b[257+C],++S[A],E=c+I,++T):(w[_++]=e[c],++b[e[c]])}}h=Fn(e,l,i,w,b,S,M,_,P,c-P,h),!i&&7&h&&(h=Bn(l,h+1,zn))}return Rn(o,0,s+Cn(h)+n)},Vn=function(){for(var e=new sn(256),t=0;t<256;++t){for(var r=t,s=9;--s;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),Hn=function(){var e=-1;return{p:function(t){for(var r=e,s=0;s<t.length;++s)r=Vn[255&r^t[s]]^r>>>8;e=r},d:function(){return~e}}},Gn=function(){var e=1,t=0;return{p:function(r){for(var s=e,n=t,i=r.length,a=0;a!=i;){for(var o=Math.min(a+2655,i);a<o;++a)n+=s+=r[a];s=(65535&s)+15*(s>>16),n=(65535&n)+15*(n>>16)}e=s,t=n},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},Wn=function(e,t,r,s,n){return jn(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,s,!n)},Xn=function(e,t){var r,s={};for(r in e)s[r]=e[r];for(r in t)s[r]=t[r];return s},qn=function(e,t,r){for(var s=e(),n=(e=e.toString()).slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/ /g,"").split(","),i=0;i<s.length;++i){var a=s[i],o=n[i];if("function"==typeof a){t+=";"+o+"=";var l=a.toString();if(a.prototype)if(-1!=l.indexOf("[native code]")){var h=l.indexOf(" ",8)+1;t+=l.slice(h,l.indexOf("(",h))}else for(var c in t+=l,a.prototype)t+=";"+o+".prototype."+c+"="+a.prototype[c].toString();else t+=l}else r[o]=a}return[t,r]},Yn=[],Zn=function(e,t,r,s){var n;if(!Yn[r]){for(var i="",a={},o=e.length-1,l=0;l<o;++l)i=(n=qn(e[l],i,a))[0],a=n[1];Yn[r]=qn(e[o],i,a)}var h=Xn({},Yn[r][1]);return function(e,t,r,s,n){return(t=$s(Ks[t]||(Ks[t]=Js(e)))).onerror=function(e){return n(e.error,null)},t.onmessage=function(e){return n(null,e.data)},t.postMessage(r,s),t}(Yn[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,h,function(e){var t,r=[];for(t in e)(e[t]instanceof tn||e[t]instanceof rn||e[t]instanceof sn)&&r.push((e[t]=new e[t].constructor(e[t])).buffer);return r}(h),s)},Qn=function(){return[tn,rn,sn,nn,an,on,ln,cn,Sn,Mn,dn,fn,_n,En,Pn,Cn,Rn,Dn,Si,ri,si]},Kn=function(){return[tn,rn,sn,nn,an,on,hn,un,bn,gn,Tn,vn,dn,Nn,zn,fn,An,Ln,In,On,Un,kn,Bn,Fn,Cn,Rn,jn,Wn,xi,ri]},Jn=function(){return[li,ui,oi,Hn,Vn]},$n=function(){return[hi,ci]},ei=function(){return[di,oi,Gn]},ti=function(){return[pi]},ri=function(e){return postMessage(e,[e.buffer])},si=function(e){return e&&e.size&&new tn(e.size)},ni=function(e,t,r,s,n,i){var a=Zn(r,s,n,(function(e,t){a.terminate(),i(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},ii=function(e,t){return e[t]|e[t+1]<<8},ai=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},oi=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},li=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&&oi(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var s=0;s<=r.length;++s)e[s+10]=r.charCodeAt(s)}},hi=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 s=(t>>3&1)+(t>>4&1);0<s;s-=!e[r++]);return r+(2&t)},ci=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},ui=function(e){return 10+(e.filename&&e.filename.length+1||0)},di=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)},pi=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 mi(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var fi=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(Wn(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}(),gi=function(e,t){yn([Kn,function(){return[xn,fi]}],this,mi.call(this,e,t),(function(e){e=new fi(e.data),onmessage=xn(e)}),6)};function vi(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Kn],(function(e){return ri(xi(e.data[0],e.data[1]))}),0,r)}function xi(e,t){return Wn(e,t||{},0,0)}var yi=function(){function e(e){this.s={},this.p=new tn(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 tn(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=Dn(this.p,this.o,this.s);this.ondata(Rn(t,e,this.s.b),this.d),this.o=Rn(t,this.s.b-32768),this.s.b=this.o.length,this.p=Rn(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),wi=function(e){this.ondata=e,yn([Qn,function(){return[xn,yi]}],this,0,(function(){var e=new yi;onmessage=xn(e)}),7)};function bi(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Qn],(function(e){return ri(Si(e.data[0],si(e.data[1])))}),1,r)}function Si(e,t){return Dn(e,t)}var Ti=function(){function e(e,t){this.c=Hn(),this.l=0,this.v=1,fi.call(this,e,t)}return e.prototype.push=function(e,t){fi.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length,e=Wn(e,this.o,this.v&&ui(this.o),t&&8,!t),this.v&&(li(e,this.o),this.v=0),t&&(oi(e,e.length-8,this.c.d()),oi(e,e.length-4,this.l)),this.ondata(e,t)},e}(),Mi=function(e,t){yn([Kn,Jn,function(){return[xn,fi,Ti]}],this,mi.call(this,e,t),(function(e){e=new Ti(e.data),onmessage=xn(e)}),8)};function _i(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Kn,Jn,function(){return[Ei]}],(function(e){return ri(Ei(e.data[0],e.data[1]))}),2,r)}function Ei(e,t){t=t||{};var r=Hn(),s=e.length,n=(r.p(e),e=Wn(e,t,ui(t),8)).length;return li(e,t),oi(e,n-8,r.d()),oi(e,n-4,s),e}var Pi=function(){function e(e){this.v=1,yi.call(this,e)}return e.prototype.push=function(e,t){if(yi.prototype.e.call(this,e),this.v){if((e=3<this.p.length?hi(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)}yi.prototype.c.call(this,t)},e}(),Ci=function(e){this.ondata=e,yn([Qn,$n,function(){return[xn,yi,Pi]}],this,0,(function(){var e=new Pi;onmessage=xn(e)}),9)};function Ri(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Qn,$n,function(){return[Di]}],(function(e){return ri(Di(e.data[0]))}),3,r)}function Di(e,t){return Dn(e.subarray(hi(e),-8),t||new tn(ci(e)))}var Ai=function(){function e(e,t){this.c=Gn(),this.v=1,fi.call(this,e,t)}return e.prototype.push=function(e,t){fi.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),e=Wn(e,this.o,this.v&&2,t&&4,!t),this.v&&(di(e,this.o),this.v=0),t&&oi(e,e.length-4,this.c.d()),this.ondata(e,t)},e}(),Li=function(e,t){yn([Kn,ei,function(){return[xn,fi,Ai]}],this,mi.call(this,e,t),(function(e){e=new Ai(e.data),onmessage=xn(e)}),10)};function Ii(e,t){t=t||{};var r=Gn();return r.p(e),e=Wn(e,t,2,4),di(e,t),oi(e,e.length-4,r.d()),e}var Oi=function(){function e(e){this.v=1,yi.call(this,e)}return e.prototype.push=function(e,t){if(yi.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)}yi.prototype.c.call(this,t)},e}(),Ui=function(e){this.ondata=e,yn([Qn,ti,function(){return[xn,yi,Oi]}],this,0,(function(){var e=new Oi;onmessage=xn(e)}),11)};function ki(e,t,r){if(r||(r=t,t={}),"function"!=typeof r)throw"no callback";return ni(e,t,[Qn,ti,function(){return[Bi]}],(function(e){return ri(Bi(e.data[0],si(e.data[1])))}),5,r)}function Bi(e,t){return Dn((pi(e),e.subarray(2,-4)),t)}var Fi=function(){function e(e){this.G=Pi,this.I=yi,this.Z=Oi,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";var r,s;this.s?this.s.push(e,t):(this.p&&this.p.length?((r=new tn(this.p.length+e.length)).set(this.p),r.set(e,this.p.length)):this.p=e,2<this.p.length&&((s=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(){s.ondata.apply(s,arguments)})),this.s.push(this.p,t),this.p=null))},e}(),Ni=function(){function e(e){this.G=Ci,this.I=wi,this.Z=Ui,this.ondata=e}return e.prototype.push=function(e,t){Fi.prototype.push.call(this,e,t)},e}(),zi=function(e,t,r,s){for(var n in e){var i=e[n];n=t+n,i instanceof tn?r[n]=[i,s]:Array.isArray(i)?r[n]=[i[0],Xn(s,i[1])]:zi(i,n+"/",r,s)}},ji="undefined"!=typeof TextEncoder&&new TextEncoder,Vi="undefined"!=typeof TextDecoder&&new TextDecoder,Hi=0;try{Vi.decode(zn,{stream:!0}),Hi=1}catch(pn){}var Gi=function(e){for(var t="",r=0;;){var s=e[r++],n=(127<s)+(223<s)+(239<s);if(r+n>e.length)return[t,Rn(e,r-1)];n?3==n?(s=((15&s)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|s>>10,56320|1023&s)):t+=1&n?String.fromCharCode((31&s)<<6|63&e[r++]):String.fromCharCode((15&s)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(s)}},Wi=function(){function e(e){this.ondata=e,Hi?this.t=new TextDecoder:this.p=zn}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 tn(this.p.length+e.length)).set(this.p),r.set(e,this.p.length),e=Gi(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}(),Xi=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(qi(e),this.d=t||!1)},e}();function qi(e,t){if(t){for(var r=new tn(e.length),s=0;s<e.length;++s)r[s]=e.charCodeAt(s);return r}if(ji)return ji.encode(e);var n=e.length,i=new tn(e.length+(e.length>>1)),a=0,o=function(e){i[a++]=e};for(s=0;s<n;++s){a+5>i.length&&((l=new tn(a+8+(n-s<<1))).set(i),i=l);var l=e.charCodeAt(s);l<128||t?o(l):(l<2048?o(192|l>>6):(55295<l&&l<57344?(o(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++s))>>18),o(128|l>>12&63)):o(224|l>>12),o(128|l>>6&63)),o(128|63&l))}return Rn(i,0,a)}function Yi(e,t){if(t){for(var r="",s=0;s<e.length;s+=16384)r+=String.fromCharCode.apply(null,e.subarray(s,s+16384));return r}if(Vi)return Vi.decode(e);var n=(t=Gi(e))[0];if(t[1].length)throw"invalid utf-8 data";return n}function Zi(e){return 1==e?3:e<6?2:9==e?1:0}var Qi=function(e,t){return t+30+ii(e,t+26)+ii(e,t+28)},Ki=function(e,t,r){var s=ii(e,t+28),n=Yi(e.subarray(t+46,t+46+s),!(2048&ii(e,t+8))),i=(s=t+46+s,ai(e,t+20)),a=(i=(r=r&&4294967295==i?Ji(e,s):[i,ai(e,t+24),ai(e,t+42)])[0],r[1]);return r=r[2],[ii(e,t+10),i,a,n,s+ii(e,t+30)+ii(e,t+32),r]},Ji=function(e,t){for(;1!=ii(e,t);t+=4+ii(e,t+2));return[wn(e,t+12),wn(e,t+4),wn(e,t+20)]},$i=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},ea=function(e,t,r,s,n,i,a,o){var l=s.length,h=r.extra,c=o&&o.length,u=$i(h),d=(oi(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==i&&8),e[t++]=n&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8,n=new Date(null==r.mtime?Date.now():r.mtime)).getFullYear()-1980;if(d<0||119<d)throw"date not in range 1980-2099";if(oi(e,t,d<<25|n.getMonth()+1<<21|n.getDate()<<16|n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>>1),t+=4,null!=i&&(oi(e,t,r.crc),oi(e,t+4,i),oi(e,t+8,r.size)),oi(e,t+12,l),oi(e,t+14,u),t+=16,null!=a&&(oi(e,t,c),oi(e,t+6,r.attrs),oi(e,t+10,a),t+=14),e.set(s,t),t+=l,u)for(var p in h){var m=h[p],f=m.length;oi(e,t,+p),oi(e,t+2,f),e.set(m,t+4),t+=4+f}return c&&(e.set(o,t),t+=c),t},ta=function(e,t,r,s,n){oi(e,t,101010256),oi(e,t+8,r),oi(e,t+10,r),oi(e,t+12,s),oi(e,t+16,n)},ra=function(){function e(e){this.filename=e,this.c=Hn(),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}(),sa=function(){function e(e,t){var r=this;t=t||{},ra.call(this,e),this.d=new fi(t,(function(e,t){r.ondata(null,e,t)})),this.compression=8,this.flag=Zi(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){ra.prototype.push.call(this,e,t)},e}(),na=function(){function e(e,t){var r=this;t=t||{},ra.call(this,e),this.d=new gi(t,(function(e,t,s){r.ondata(e,t,s)})),this.compression=8,this.flag=Zi(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){ra.prototype.push.call(this,e,t)},e}(),ia=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=qi(e.filename),s=r.length,n=(i=e.comment)&&qi(i),i=s!=e.filename.length||n&&i.length!=n.length,a=s+$i(e.extra)+30;if(65535<s)throw"filename too long";function o(){for(var e=0,r=l;e<r.length;e++){var s=r[e];t.ondata(null,s,!1)}l=[]}s=new tn(a);var l=(ea(s,0,e,r,i),[s]),h=this.d,c=(this.d=0,this.u.length),u=Xn(e,{f:r,u:i,o:n,t:function(){e.terminate&&e.terminate()},r:function(){var e;o(),h&&((e=t.u[c+1])?e.r():t.d=1),h=1}}),d=0;e.ondata=function(r,s,n){r?(t.ondata(r,s,n),t.terminate()):(d+=s.length,l.push(s),n?(r=new tn(16),oi(r,0,134695760),oi(r,4,e.crc),oi(r,8,d),oi(r,12,e.size),l.push(r),u.c=d,u.b=a+d+16,u.crc=e.crc,u.size=e.size,h&&u.r(),h=1):h&&o())},this.u.push(u)},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,s=0,n=this.u;s<n.length;s++)r+=46+(l=n[s]).f.length+$i(l.extra)+(l.o?l.o.length:0);for(var i=new tn(r+22),a=0,o=this.u;a<o.length;a++){var l=o[a];ea(i,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+$i(l.extra)+(l.o?l.o.length:0),t+=l.b}ta(i,e,this.u.length,r,t),this.ondata(null,i,!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}(),aa=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),oa=function(){function e(){var e=this;this.i=new yi((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}(),la=function(){function e(e,t){var r=this;t<32e4?this.i=new yi((function(e,t){r.ondata(null,e,t)})):(this.i=new wi((function(e,t,s){r.ondata(e,t,s)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Rn(e,0)),this.i.push(e,t)},e.compression=8,e}(),ha=function(){function e(e){this.onfile=e,this.k=[],this.o={0:aa},this.p=zn}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 s=Math.min(this.c,e.length),n=e.subarray(0,s);if(this.c-=s,this.d?this.d.push(n,!this.c):this.k[0].push(n),(e=e.subarray(s)).length)return this.push(e,t)}else{for(var i=0,a=0,o=void 0,l=void 0,h=(this.p.length?e.length?((l=new tn(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e,l.length),c=this.c,u=(n=c&&this.d,this);a<h-4&&"break"!==function(){var e,t,s,n,d,p,m,f,g,v,x,y=ai(l,a);return 67324752==y?(i=1,o=a,u.d=null,u.c=0,s=ii(l,a+6),e=ii(l,a+8),t=2048&s,s&=8,n=ii(l,a+26),d=ii(l,a+28),a+30+n+d<h&&(u.k.unshift(p=[]),i=2,m=ai(l,a+18),f=ai(l,a+22),g=Yi(l.subarray(a+30,a+=30+n),!t),4294967295==m?(n=s?[-2]:Ji(l,a),m=n[0],f=n[1]):s&&(m=-1),a+=d,u.c=m,x={name:g,compression:e,start:function(){if(!x.ondata)throw"no callback";if(m){var t=r.o[e];if(!t)throw"unknown compression type "+e;(v=m<0?new t(g):new t(g,m,f)).ondata=function(e,t,r){x.ondata(e,t,r)};for(var s=0,n=p;s<n.length;s++)v.push(n[s],!1);r.k[0]==p&&r.c?r.d=v:v.push(zn,!0)}else x.ondata(null,zn,!0)},terminate:function(){v&&v.terminate&&v.terminate()}},0<=m&&(x.size=m,x.originalSize=f),u.onfile(x)),"break"):c?134695760==y?(o=a+=12+(-2==c&&8),i=3,u.c=0,"break"):33639248==y?(o=a-=4,i=3,u.c=0,"break"):void 0:void 0}();++a);if(this.p=zn,c<0&&(s=i?l.subarray(0,o-12-(-2==c&&8)-(134695760==ai(l,o-16)&&4)):l.subarray(0,a),n?n.push(s,!!i):this.k[+(2==i)].push(s)),2&i)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 ca(e,t,r){var s=r.length-e-1;if(t>=r[s])return s-1;if(t<=r[e])return e;let n=e,i=s,a=Math.floor((n+i)/2);for(;t<r[a]||t>=r[a+1];)t<r[a]?i=a:n=a,a=Math.floor((n+i)/2);return a}class ua extends n.Curve{constructor(e,t,r,s,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=i||this.knots.length-1;for(let e=0;e<r.length;++e){var a=r[e];this.controlPoints[e]=new n.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t=new n.Vector3){const r=t;t=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]);const s=function(e,t,r,s){var i=ca(e,s,t),a=function(e,t,r,s){const n=[],i=[],a=[];for(let c=n[0]=1;c<=r;++c){i[c]=t-s[e+1-c],a[c]=s[e+c]-t;let r=0;for(let e=0;e<c;++e){var o=a[e+1],l=i[c-e],h=n[e]/(o+l);n[e]=r+o*h,r=l*h}n[c]=r}return n}(i,s,e,t);const o=new n.Vector4(0,0,0,0);for(let t=0;t<=e;++t){var l=r[i-e+t],h=a[t],c=l.w*h;o.x+=l.x*c,o.y+=l.y*c,o.z+=l.z*c,o.w+=l.w*h}return o}(this.degree,this.knots,this.controlPoints,t);return 1!==s.w&&s.divideScalar(s.w),r.set(s.x,s.y,s.z)}getTangent(e,t=new n.Vector3){const r=t;return t=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),e=function(e){var t=e.length;const r=[],s=[];for(let a=0;a<t;++a){var i=e[a];r[a]=new n.Vector3(i.x,i.y,i.z),s[a]=i.w}const a=[];for(let e=0;e<t;++e){const t=r[e].clone();for(let r=1;r<=e;++r)t.sub(a[e-r].clone().multiplyScalar(function(e,t){let r=1;for(let t=2;t<=e;++t)r*=t;let s=1;for(let e=2;e<=t;++e)s*=e;for(let r=2;r<=e-t;++r)s*=r;return r/s}(e,r)*s[r]));a[e]=t.divideScalar(s[0])}return a}(function(e,t,r,s,i){var a=1<e?1:e;const o=[];var l=ca(e,s,t),h=function(e,t,r,s,n){const i=[];for(let e=0;e<=r;++e)i[e]=0;const a=[];for(let e=0;e<=s;++e)a[e]=i.slice(0);const o=[];for(let e=0;e<=r;++e)o[e]=i.slice(0);o[0][0]=1;const l=i.slice(0),h=i.slice(0);for(let s=1;s<=r;++s){l[s]=t-n[e+1-s],h[s]=n[e+s]-t;let r=0;for(let e=0;e<s;++e){var c=h[e+1],u=l[s-e],d=(o[s][e]=c+u,o[e][s-1]/o[s][e]);o[e][s]=r+c*d,r=u*d}o[s][s]=r}for(let e=0;e<=r;++e)a[0][e]=o[e][r];for(let e=0;e<=r;++e){let t=0,n=1;const l=[];for(let e=0;e<=r;++e)l[e]=i.slice(0);for(let i=l[0][0]=1;i<=s;++i){let s=0;var p=e-i,m=r-i,f=(e>=i&&(l[n][0]=l[t][0]/o[1+m][p],s=l[n][0]*o[p][m]),-1<=p?1:-p),g=e-1<=m?i-1:r-e;for(let e=f;e<=g;++e)l[n][e]=(l[t][e]-l[t][e-1])/o[1+m][p+e],s+=l[n][e]*o[p+e][m];e<=m&&(l[n][i]=-l[t][i-1]/o[1+m][e],s+=l[n][i]*o[e][m]),a[i][e]=s,f=t,t=n,n=f}}let v=r;for(let e=1;e<=s;++e){for(let t=0;t<=r;++t)a[e][t]*=v;v*=r-e}return a}(l,s,e,a,t);const c=[];for(let e=0;e<r.length;++e){const t=r[e].clone();var u=t.w;t.x*=u,t.y*=u,t.z*=u,c[e]=t}for(let t=0;t<=a;++t){const r=c[l-e].clone().multiplyScalar(h[t][0]);for(let s=1;s<=e;++s)r.add(c[l-e+s].clone().multiplyScalar(h[t][s]));o[t]=r}for(let e=a+1;e<=2;++e)o[e]=new n.Vector4(0,0,0);return o}(e=this.degree,this.knots,this.controlPoints,t)),r.copy(e[1]).normalize(),r}}let da,pa,ma;class fa extends n.Loader{constructor(e){super(e)}load(e,t,r,s){const i=this,a=""===i.path?n.LoaderUtils.extractUrlBase(e):i.path,o=new n.FileLoader(this.manager);o.setPath(i.path),o.setResponseType("arraybuffer"),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(r){try{t(i.parse(r,a))}catch(r){s?s(r):console.error(r),i.manager.itemError(e)}}),r,s)}parse(e,t){if(s="Kaydara FBX Binary \0",(r=e).byteLength>=s.length&&s===La(r,0,s.length))da=(new wa).parse(e);else{if(!function(e){var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let r=0;for(let s=0;s<t.length;++s)if(function(t){var s=e[0];return e=e.slice(r+1),r++,s}()===t[s])return;return 1}(r=La(e)))throw new Error("THREE.FBXLoader: Unknown format.");if(Ta(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Ta(r));da=(new ya).parse(r)}var r,s=new n.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new ga(s,this.manager).parse(da)}}class ga{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){pa=this.parseConnections();var e=this.parseImages(),t=(e=this.parseTextures(e),e=this.parseMaterials(e),this.parseDeformers()),r=(new va).parse(t);return this.parseScene(t,r,e),ma}parseConnections(){const e=new Map;return"Connections"in da&&da.Connections.connections.forEach((function(t){var r=t[0],s=t[1],n=(t=t[2],e.has(r)||e.set(r,{parents:[],children:[]}),{ID:s,relationship:t});e.get(r).parents.push(n),e.has(s)||e.set(s,{parents:[],children:[]}),n={ID:r,relationship:t},e.get(s).children.push(n)})),e}parseImages(){const e={},t={};if("Video"in da.Objects){var r=da.Objects.Video;for(const a in r){var s,n=r[a],i=parseInt(a);e[i]=n.RelativeFilename||n.Filename,"Content"in n&&(i=n.Content instanceof ArrayBuffer&&0<n.Content.byteLength,s="string"==typeof n.Content&&""!==n.Content,(i||s)&&(i=this.parseImage(r[a]),t[n.RelativeFilename||n.Filename]=i))}}for(const r in e){var a=e[r];void 0!==t[a]?e[r]=t[a]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){var t=e.Content;const r=e.RelativeFilename||e.Filename;var s=r.slice(r.lastIndexOf(".")+1).toLowerCase();let n;switch(s){case"bmp":n="image/bmp";break;case"jpg":case"jpeg":n="image/jpeg";break;case"png":n="image/png";break;case"tif":n="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",r),n="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+s+'" is not supported.')}return"string"==typeof t?"data:"+n+";base64,"+t:(e=new Uint8Array(t),window.URL.createObjectURL(new Blob([e],{type:n})))}parseTextures(e){const t=new Map;if("Texture"in da.Objects){var r=da.Objects.Texture;for(const n in r){var s=this.parseTexture(r[n],e);t.set(parseInt(n),s)}}return t}parseTexture(e,t){const r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName,t=e.WrapModeU;var s=e.WrapModeV;return t=void 0!==t?t.value:0,s=void 0!==s?s.value:0,r.wrapS=0===t?n.RepeatWrapping:n.ClampToEdgeWrapping,r.wrapT=0===s?n.RepeatWrapping:n.ClampToEdgeWrapping,"Scaling"in e&&(t=e.Scaling.value,r.repeat.x=t[0],r.repeat.y=t[1]),"Translation"in e&&(s=e.Translation.value,r.offset.x=s[0],r.offset.y=s[1]),r}loadTexture(e,t){let r;var s=this.textureLoader.path,i=pa.get(e.id).children;let a;if(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)),"tga"===(t=e.FileName.slice(-3).toLowerCase())){const t=this.manager.getHandler(".tga");a=null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),new n.Texture):(t.setPath(this.textureLoader.path),t.load(r))}else a="psd"===t?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),new n.Texture):this.textureLoader.load(r);return this.textureLoader.setPath(s),a}parseMaterials(e){const t=new Map;if("Material"in da.Objects){var r=da.Objects.Material;for(const n in r){var s=this.parseMaterial(r[n],e);null!==s&&t.set(parseInt(n),s)}}return t}parseMaterial(e,t){var r=e.id,s=e.attrName;let i,a=e.ShadingModel;if("object"==typeof a&&(a=a.value),!pa.has(r))return null;switch(e=this.parseParameters(e,t,r),a.toLowerCase()){case"phong":i=new n.MeshPhongMaterial;break;case"lambert":i=new n.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),i=new n.MeshPhongMaterial}return i.setValues(e),i.name=s,i}parseParameters(e,t,r){const s={},i=(e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=(new n.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(s.color=(new n.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=(new n.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(s.emissive=(new n.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=(new n.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(s.specular=(new n.Color).fromArray(e.SpecularColor.value)),this);return pa.get(r).children.forEach((function(e){var r=e.relationship;switch(r){case"Bump":s.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":s.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=i.getTexture(t,e.ID),void 0!==s.map&&(s.map.encoding=n.sRGBEncoding);break;case"DisplacementColor":s.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":s.emissiveMap=i.getTexture(t,e.ID),void 0!==s.emissiveMap&&(s.emissiveMap.encoding=n.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":s.envMap=i.getTexture(t,e.ID),void 0!==s.envMap&&(s.envMap.mapping=n.EquirectangularReflectionMapping,s.envMap.encoding=n.sRGBEncoding);break;case"SpecularColor":s.specularMap=i.getTexture(t,e.ID),void 0!==s.specularMap&&(s.specularMap.encoding=n.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=i.getTexture(t,e.ID),s.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}})),s}getTexture(e,t){return"LayeredTexture"in da.Objects&&t in da.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=pa.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in da.Objects){var r=da.Objects.Deformer;for(const i in r){var s=r[i],n=pa.get(parseInt(i));if("Skin"===s.attrType){const t=this.parseSkeleton(n,r);t.ID=i,1<n.parents.length&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=n.parents[0].ID,e[i]=t}else if("BlendShape"===s.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(n,r),e.id=i,1<n.parents.length&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach((function(e){var s=t[e.ID];if("Cluster"===s.attrType){const t={ID:e.ID,indices:[],weights:[],transformLink:(new n.Matrix4).fromArray(s.TransformLink.a)};"Indexes"in s&&(t.indices=s.Indexes.a,t.weights=s.Weights.a),r.push(t)}})),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let i=0;i<e.children.length;i++){var s=e.children[i],n=t[s.ID];const a={name:n.attrName,initialWeight:n.DeformPercent,id:n.id,fullWeights:n.FullWeights.a};if("BlendShapeChannel"!==n.attrType)return;a.geoID=pa.get(parseInt(s.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,r.push(a)}return r}parseScene(e,t,r){ma=new n.Group;const s=this.parseModels(e.skeletons,t,r),i=da.Objects.Model,a=this;s.forEach((function(e){var t=i[e.ID];a.setLookAtProperties(e,t),pa.get(e.ID).parents.forEach((function(t){const r=s.get(t.ID);void 0!==r&&r.add(e)})),null===e.parent&&ma.add(e)})),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),ma.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=Ra(e.userData.transformData),e.applyMatrix4(t),e.updateWorldMatrix())})),r=(new xa).parse(),1===ma.children.length&&ma.children[0].isGroup&&(ma.children[0].animations=r,ma=ma.children[0]),ma.animations=r}parseModels(e,t,r){const s=new Map;var i=da.Objects.Model;for(const h in i){var a=parseInt(h),o=i[h],l=pa.get(a);let c=this.buildSkeleton(l,e,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,r);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new n.Bone;break;default:c=new n.Group}c.name=o.attrName?n.PropertyBinding.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),s.set(a,c)}return s}buildSkeleton(e,t,r,s){let i=null;return e.parents.forEach((function(e){for(const a in t){const o=t[a];o.rawBones.forEach((function(t,a){var l;t.ID===e.ID&&(l=i,(i=new n.Bone).matrixWorld.copy(t.transformLink),i.name=s?n.PropertyBinding.sanitizeNodeName(s):"",i.ID=r,o.bones[a]=i,null!==l&&i.add(l))}))}})),i}createCamera(e){let t,r;if(e.children.forEach((function(e){void 0!==(e=da.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new n.Object3D;else{let e=0,a=(void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(e=1),1),o=(void 0!==r.NearPlane&&(a=r.NearPlane.value/1e3),1e3),l=(void 0!==r.FarPlane&&(o=r.FarPlane.value/1e3),window.innerWidth),h=window.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(l=r.AspectWidth.value,h=r.AspectHeight.value);var s=l/h;let c=45;void 0!==r.FieldOfView&&(c=r.FieldOfView.value);var i=r.FocalLength?r.FocalLength.value:null;switch(e){case 0:t=new n.PerspectiveCamera(c,s,a,o),null!==i&&t.setFocalLength(i);break;case 1:t=new n.OrthographicCamera(-l/2,l/2,h/2,-h/2,a,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new n.Object3D}}return t}createLight(e){let t,r;if(e.children.forEach((function(e){void 0!==(e=da.Objects.NodeAttribute[e.ID])&&(r=e)})),void 0===r)t=new n.Object3D;else{let e,s=(e=void 0===r.LightType?0:r.LightType.value,16777215),i=(void 0!==r.Color&&(s=(new n.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 n.PointLight(s,i,a,1);break;case 1:t=new n.DirectionalLight(s,i);break;case 2:let e=Math.PI/3,o=(void 0!==r.InnerAngle&&(e=n.MathUtils.degToRad(r.InnerAngle.value)),0);void 0!==r.OuterAngle&&(o=n.MathUtils.degToRad(r.OuterAngle.value),o=Math.max(o,1)),t=new n.SpotLight(s,i,a,e,o,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new n.PointLight(s,i)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,r){let s,i=null,a=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),r.has(e.ID)&&o.push(r.get(e.ID))})),1<o.length?a=o:0<o.length?a=o[0]:(a=new n.MeshPhongMaterial({color:13421772}),o.push(a)),"color"in i.attributes&&o.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(s=new n.SkinnedMesh(i,a)).normalizeSkinWeights():s=new n.Mesh(i,a),s}createCurve(e,t){e=e.children.reduce((function(e,r){return t.has(r.ID)?t.get(r.ID):e}),null);var r=new n.LineBasicMaterial({color:3342591,linewidth:1});return new n.Line(e,r)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?Da(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}setLookAtProperties(e,t){"LookAtProperty"in t&&pa.get(e.ID).children.forEach((function(t){"LookAtProperty"===t.relationship&&"Lcl_Translation"in(t=da.Objects.Model[t.ID])&&(t=t.Lcl_Translation.value,void 0!==e.target?(e.target.position.fromArray(t),ma.add(e.target)):e.lookAt((new n.Vector3).fromArray(t)))}))}bindSkeleton(e,t,r){const s=this.parsePoseNodes();for(const i in e){const a=e[i];pa.get(parseInt(a.ID)).parents.forEach((function(e){t.has(e.ID)&&(e=e.ID,pa.get(e).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new n.Skeleton(a.bones),s[e.ID])})))}))}}parsePoseNodes(){const e={};if("Pose"in da.Objects){var t=da.Objects.Pose;for(const r in t)if("BindPose"===t[r].attrType&&0<t[r].NbPoseNodes){const s=t[r].PoseNode;Array.isArray(s)?s.forEach((function(t){e[t.Node]=(new n.Matrix4).fromArray(t.Matrix.a)})):e[s.Node]=(new n.Matrix4).fromArray(s.Matrix.a)}}return e}createAmbientLight(){var e,t,r;"GlobalSettings"in da&&"AmbientColor"in da.GlobalSettings&&(r=(t=da.GlobalSettings.AmbientColor.value)[0],e=t[1],t=t[2],0===r&&0===e&&0===t||(r=new n.Color(r,e,t),ma.add(new n.AmbientLight(r,1))))}}class va{parse(e){const t=new Map;if("Geometry"in da.Objects){var r=da.Objects.Geometry;for(const n in r){var s=pa.get(parseInt(n));s=this.parseGeometry(s,r[n],e),t.set(parseInt(n),s)}}return t}parseGeometry(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const s=r.skeletons,n=[];var i=e.parents.map((function(e){return da.Objects.Model[e.ID]}));if(0!==i.length){var a=e.children.reduce((function(e,t){return void 0!==s[t.ID]?s[t.ID]:e}),null);const o={};return"RotationOrder"in(e.children.forEach((function(e){void 0!==r.morphTargets[e.ID]&&n.push(r.morphTargets[e.ID])})),e=i[0])&&(o.eulerOrder=Da(e.RotationOrder.value)),"InheritType"in e&&(o.inheritType=parseInt(e.InheritType.value)),"GeometricTranslation"in e&&(o.translation=e.GeometricTranslation.value),"GeometricRotation"in e&&(o.rotation=e.GeometricRotation.value),"GeometricScaling"in e&&(o.scale=e.GeometricScaling.value),i=Ra(o),this.genGeometry(t,a,n,i)}}genGeometry(e,t,r,s){const i=new n.BufferGeometry;e.attrName&&(i.name=e.attrName);var a=this.parseGeoNode(e,t);const o=this.genBuffers(a),l=new n.Float32BufferAttribute(o.vertex,3);if(l.applyMatrix4(s),i.setAttribute("position",l),0<o.colors.length&&i.setAttribute("color",new n.Float32BufferAttribute(o.colors,3)),t&&(i.setAttribute("skinIndex",new n.Uint16BufferAttribute(o.weightsIndices,4)),i.setAttribute("skinWeight",new n.Float32BufferAttribute(o.vertexWeights,4)),i.FBX_Deformer=t),0<o.normal.length){t=(new n.Matrix3).getNormalMatrix(s);const e=new n.Float32BufferAttribute(o.normal,3);e.applyNormalMatrix(t),i.setAttribute("normal",e)}if(o.uvs.forEach((function(e,t){let r="uv"+(t+1).toString();0===t&&(r="uv"),i.setAttribute(r,new n.Float32BufferAttribute(o.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=o.materialIndex[0],r=0;o.materialIndex.forEach((function(t,s){t!==e&&(i.addGroup(r,s-r,e),e=t,r=s)})),0<i.groups.length&&(a=(t=i.groups[i.groups.length-1]).start+t.count)!==o.materialIndex.length&&i.addGroup(a,o.materialIndex.length-a,e),0===i.groups.length&&i.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(i,e,r,s),i}parseGeoNode(e,t){const 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=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return r.weightTable={},null!==t&&(r.skeleton=t).rawBones.forEach((function(e,t){e.indices.forEach((function(s,n){void 0===r.weightTable[s]&&(r.weightTable[s]=[]),r.weightTable[s].push({id:t,weight:e.weights[n]})}))})),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,s=0,n=!1,i=[],a=[],o=[],l=[],h=[],c=[];const u=this;return e.vertexIndices.forEach((function(d,p){let m,f=!1,g=(d<0&&(d^=-1,f=!0),[]),v=[];var x;if(i.push(3*d,3*d+1,3*d+2),e.color&&(x=Ea(p,r,d,e.color),o.push(x[0],x[1],x[2])),e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),4<v.length){n||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),n=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(r,s){let n=r,i=g[s];t.forEach((function(t,r,s){n>t&&(s[r]=n,n=t,s=e[r],e[r]=i,i=s)}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}e.normal&&(x=Ea(p,r,d,e.normal),a.push(x[0],x[1],x[2])),e.material&&"AllSame"!==e.material.mappingType&&(m=Ea(p,r,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){e=Ea(p,r,d,e),void 0===l[t]&&(l[t]=[]),l[t].push(e[0]),l[t].push(e[1])})),s++,f&&(u.genFace(t,e,i,m,a,o,l,h,c,s),r++,s=0,i=[],a=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,r,s,n,i,a,o,l,h){for(let c=2;c<h;c++)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*(c-1)]]),e.vertex.push(t.vertexPositions[r[3*(c-1)+1]]),e.vertex.push(t.vertexPositions[r[3*(c-1)+2]]),e.vertex.push(t.vertexPositions[r[3*c]]),e.vertex.push(t.vertexPositions[r[3*c+1]]),e.vertex.push(t.vertexPositions[r[3*c+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(c-1)]),e.vertexWeights.push(o[4*(c-1)+1]),e.vertexWeights.push(o[4*(c-1)+2]),e.vertexWeights.push(o[4*(c-1)+3]),e.vertexWeights.push(o[4*c]),e.vertexWeights.push(o[4*c+1]),e.vertexWeights.push(o[4*c+2]),e.vertexWeights.push(o[4*c+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*(c-1)]),e.weightsIndices.push(l[4*(c-1)+1]),e.weightsIndices.push(l[4*(c-1)+2]),e.weightsIndices.push(l[4*(c-1)+3]),e.weightsIndices.push(l[4*c]),e.weightsIndices.push(l[4*c+1]),e.weightsIndices.push(l[4*c+2]),e.weightsIndices.push(l[4*c+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[3*(c-1)]),e.colors.push(i[3*(c-1)+1]),e.colors.push(i[3*(c-1)+2]),e.colors.push(i[3*c]),e.colors.push(i[3*c+1]),e.colors.push(i[3*c+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(n[0]),e.normal.push(n[1]),e.normal.push(n[2]),e.normal.push(n[3*(c-1)]),e.normal.push(n[3*(c-1)+1]),e.normal.push(n[3*(c-1)+2]),e.normal.push(n[3*c]),e.normal.push(n[3*c+1]),e.normal.push(n[3*c+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*(c-1)]),e.uvs[r].push(a[r][2*(c-1)+1]),e.uvs[r].push(a[r][2*c]),e.uvs[r].push(a[r][2*c+1])}))}addMorphTargets(e,t,r,s){if(0!==r.length){e.morphTargetsRelative=!0,e.morphAttributes.position=[];const n=this;r.forEach((function(r){r.rawTargets.forEach((function(r){var i=da.Objects.Geometry[r.geoID];void 0!==i&&n.genMorphGeometry(e,t,i,s,r.name)}))}))}}genMorphGeometry(e,t,r,s,i){t=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[];var a=void 0!==r.Vertices?r.Vertices.a:[],o=void 0!==r.Indexes?r.Indexes.a:[],l=3*e.attributes.position.count;const h=new Float32Array(l);for(let e=0;e<o.length;e++){var c=3*o[e];h[c]=a[3*e],h[1+c]=a[3*e+1],h[2+c]=a[3*e+2]}l={vertexIndices:t,vertexPositions:h},t=this.genBuffers(l);const u=new n.Float32BufferAttribute(t.vertex,3);u.name=i||r.attrName,u.applyMatrix4(s),e.morphAttributes.position.push(u)}parseNormals(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,s=e.Normals.a;let n=[];return"IndexToDirect"===r&&("NormalIndex"in e?n=e.NormalIndex.a:"NormalsIndex"in e&&(n=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:n,mappingType:t,referenceType:r}}parseUVs(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;let s=[];return{dataSize:2,buffer:e.UV.a,indices:s="IndexToDirect"===r?e.UVIndex.a:s,mappingType:t,referenceType:r}}parseVertexColors(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;let s=[];return{dataSize:4,buffer:e.Colors.a,indices:s="IndexToDirect"===r?e.ColorIndex.a:s,mappingType:t,referenceType:r}}parseMaterialIndices(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};var s=e.Materials.a;const n=[];for(let e=0;e<s.length;++e)n.push(e);return{dataSize:1,buffer:s,indices:n,mappingType:t,referenceType:r}}parseNurbsGeometry(e){if(void 0===ua)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 n.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 n.BufferGeometry;var r=t-1;t=e.KnotVector.a;const s=[];var i=e.Points.a;for(let e=0,t=i.length;e<t;e+=4)s.push((new n.Vector4).fromArray(i,e));let a,o;if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){a=r,o=t.length-1-a;for(let e=0;e<r;++e)s.push(s[e])}return e=new ua(r,t,s,a,o).getPoints(12*s.length),(new n.BufferGeometry).setFromPoints(e)}}class xa{parse(){const e=[];var t=this.parseClips();if(void 0!==t)for(const s in t){var r=t[s];r=this.addClip(r),e.push(r)}return e}parseClips(){var e;if(void 0!==da.Objects.AnimationCurve)return e=this.parseAnimationCurveNodes(),this.parseAnimationCurves(e),e=this.parseAnimationLayers(e),this.parseAnimStacks(e)}parseAnimationCurveNodes(){var e,t=da.Objects.AnimationCurveNode;const r=new Map;for(const s in t){const n=t[s];null!==n.attrName.match(/S|R|T|DeformPercent/)&&(e={id:n.id,attr:n.attrName,curves:{}},r.set(e.id,e))}return r}parseAnimationCurves(e){const t=da.Objects.AnimationCurve;for(const i in t){var r={id:t[i].id,times:t[i].KeyTime.a.map(Ma),values:t[i].KeyValueFloat.a},s=pa.get(r.id);if(void 0!==s){var n=s.parents[0].ID;const t=s.parents[0].relationship;t.match(/X/)?e.get(n).curves.x=r:t.match(/Y/)?e.get(n).curves.y=r:t.match(/Z/)?e.get(n).curves.z=r:t.match(/d|DeformPercent/)&&e.has(n)&&(e.get(n).curves.morph=r)}}}parseAnimationLayers(e){var t=da.Objects.AnimationLayer;const r=new Map;for(const i in t){const t=[];var s=pa.get(parseInt(i));void 0!==s&&(s.children.forEach((function(r,s){if(e.has(r.ID)){var i,a=e.get(r.ID);if(void 0!==a.curves.x||void 0!==a.curves.y||void 0!==a.curves.z){if(void 0===t[s]){const e=pa.get(r.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const i=da.Objects.Model[e.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",r);const a={modelName:i.attrName?n.PropertyBinding.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ma.traverse((function(e){e.ID===i.id&&(a.transform=e.matrix,e.userData.transformData&&(a.eulerOrder=e.userData.transformData.eulerOrder))})),a.transform||(a.transform=new n.Matrix4),"PreRotation"in i&&(a.preRotation=i.PreRotation.value),"PostRotation"in i&&(a.postRotation=i.PostRotation.value),t[s]=a}}t[s]&&(t[s][a.attr]=a)}else void 0!==a.curves.morph&&(void 0===t[s]&&(r=pa.get(r.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,i=pa.get(r).parents[0].ID,i=pa.get(i).parents[0].ID,i=pa.get(i).parents[0].ID,i={modelName:(i=da.Objects.Model[i]).attrName?n.PropertyBinding.sanitizeNodeName(i.attrName):"",morphName:da.Objects.Deformer[r].attrName},t[s]=i),t[s][a.attr]=a)}})),r.set(parseInt(i),t))}return r}parseAnimStacks(e){var t=da.Objects.AnimationStack;const r={};for(const n in t){var s=pa.get(parseInt(n)).children;1<s.length&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers."),s=e.get(s[0].ID),r[n]={name:t[n].attrName,layer:s}}return r}addClip(e){let t=[];const r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new n.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let r=new n.Vector3,s=new n.Quaternion,i=new n.Vector3;var a;return e.transform&&e.transform.decompose(r,s,i),r=r.toArray(),s=(new n.Euler).setFromQuaternion(s,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&0<Object.keys(e.T.curves).length&&void 0!==(a=this.generateVectorTrack(e.modelName,e.T.curves,r,"position"))&&t.push(a),void 0!==e.R&&0<Object.keys(e.R.curves).length&&void 0!==(a=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder))&&t.push(a),void 0!==e.S&&0<Object.keys(e.S.curves).length&&void 0!==(a=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale"))&&t.push(a),void 0!==e.DeformPercent&&void 0!==(a=this.generateMorphTrack(e))&&t.push(a),t}generateVectorTrack(e,t,r,s){var i=this.getTimesForAllAxes(t);return t=this.getKeyframeTrackValues(i,t,r),new n.VectorKeyframeTrack(e+"."+s,i,t)}generateRotationTrack(e,t,r,s,i,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(n.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(n.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(n.MathUtils.degToRad));var o=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(o,t,r);void 0!==s&&((s=s.map(n.MathUtils.degToRad)).push(a),s=(new n.Euler).fromArray(s),s=(new n.Quaternion).setFromEuler(s)),void 0!==i&&((i=i.map(n.MathUtils.degToRad)).push(a),i=(new n.Euler).fromArray(i),i=(new n.Quaternion).setFromEuler(i).invert());const h=new n.Quaternion,c=new n.Euler;var u=[];for(let e=0;e<l.length;e+=3)c.set(l[e],l[e+1],l[e+2],a),h.setFromEuler(c),void 0!==s&&h.premultiply(s),void 0!==i&&h.multiply(i),h.toArray(u,e/3*4);return new n.QuaternionKeyframeTrack(e+".quaternion",o,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph;var r=t.values.map((function(e){return e/100})),s=ma.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new n.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,r)}getTimesForAllAxes(e){let 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){let e=1,s=t[0];for(let n=1;n<t.length;n++){var r=t[n];r!==s&&(t[e]=r,s=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,r){const s=r,n=[];let i=-1,a=-1,o=-1;return e.forEach((function(e){t.x&&(i=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(o=t.z.times.indexOf(e)),-1!==i?(e=t.x.values[i],n.push(e),s[0]=e):n.push(s[0]),-1!==a?(e=t.y.values[a],n.push(e),s[1]=e):n.push(s[1]),-1!==o?(e=t.z.values[o],n.push(e),s[2]=e):n.push(s[2])})),n}interpolateRotations(e){for(let a=1;a<e.values.length;a++){var t=e.values[a-1],r=e.values[a]-t;if(180<=(s=Math.abs(r))){var s,n=r/(s/=180);let o=t+n;r=e.times[a-1];var i=(e.times[a]-r)/s;let l=r+i;const h=[],c=[];for(;l<e.times[a];)h.push(l),l+=i,c.push(o),o+=n;e.times=Ia(e.times,a,h),e.values=Ia(e.values,a,c)}}}}class ya{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),--this.currentIndent}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Sa,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,r=e.split(/[\r\n]+/);return r.forEach((function(e,s){var n,i=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);i||a||(i=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),n=e.match("^\\t{"+(t.currentIndent-1)+"}}"),i?t.parseNodeBegin(e,i):a?t.parseNodeProperty(e,a,r[++s]):n?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e))})),this.allNodes}parseNodeBegin(e,t){var r=t[1].trim().replace(/^"/,"").replace(/"$/,"");t=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}));const s={name:r};t=this.parseNodeAttr(t);const n=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(r,s):r in n?("PoseNode"===r?n.PoseNode.push(s):void 0!==n[r].id&&(n[r]={},n[r][n[r].id]=n[r]),""!==t.id&&(n[r][t.id]=s)):"number"==typeof t.id?(n[r]={},n[r][t.id]=s):"Properties70"!==r&&(n[r]="PoseNode"===r?[s]:s),"number"==typeof t.id&&(s.id=t.id),""!==t.name&&(s.attrName=t.name),""!==t.type&&(s.attrType=t.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0],r=(""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0])),""),s="";return 1<e.length&&(r=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:r,type:s}}parseNodeProperty(e,t,r){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),n=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===s&&","===n&&(n=r.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if("Properties70"===i.name)this.parseNodeSpecialProperty(e,s,n);else{if("C"===s){t=n.split(",").slice(1),r=parseInt(t[0]),e=parseInt(t[1]);let l=n.split(",").slice(3);l=l.map((function(e){return e.trim().replace(/^"/,"")})),s="connections";var a=n=[r,e],o=l;for(let e=0,t=a.length,r=o.length;e<r;e++,t++)a[t]=o[e];void 0===i[s]&&(i[s]=[])}"Node"===s&&(i.id=n),s in i&&Array.isArray(i[s])?i[s].push(n):"a"!==s?i[s]=n:i.a=n,this.setCurrentProp(i,s),"a"===s&&","!==n.slice(-1)&&(i.a=Aa(n))}}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=Aa(t.a))}parseNodeSpecialProperty(e,t,r){r=r.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}));var s=r[0],n=r[1],i=r[2],a=r[3];let o=r[4];switch(n){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":o=parseFloat(o);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":o=Aa(o)}this.getPrevNode()[s]={type:n,type2:i,flag:a,value:o},this.setCurrentProp(this.getPrevNode(),s)}}class wa{parse(e){const t=new ba(e);t.skip(23);var r=t.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const s=new Sa;for(;!this.endOfContent(t);){var n=this.parseNode(t,r);null!==n&&s.add(n.name,n)}return s}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const r={};var s=7500<=t?e.getUint64():e.getUint32(),n=7500<=t?e.getUint64():e.getUint32(),i=(7500<=t?e.getUint64():e.getUint32(),e.getUint8()),a=e.getString(i);if(0===s)return null;const o=[];for(let t=0;t<n;t++)o.push(this.parseProperty(e));i=0<o.length?o[0]:"";var l=1<o.length?o[1]:"",h=2<o.length?o[2]:"";for(r.singleProperty=1===n&&e.getOffset()===s;s>e.getOffset();){var c=this.parseNode(e,t);null!==c&&this.parseSubNode(a,r,c)}return r.propertyList=o,"number"==typeof i&&(r.id=i),""!==l&&(r.attrName=l),""!==h&&(r.attrType=h),""!==a&&(r.name=a),r}parseSubNode(e,t,r){if(!0===r.singleProperty){var s=r.propertyList[0];Array.isArray(s)?(t[r.name]=r).a=s:t[r.name]=s}else if("Connections"===e&&"C"===r.name){const e=[];r.propertyList.forEach((function(t,r){0!==r&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===r.name)Object.keys(r).forEach((function(e){t[e]=r[e]}));else if("Properties70"===e&&"P"===r.name){let n,i=r.propertyList[0],a=r.propertyList[1];s=r.propertyList[2],e=r.propertyList[3],0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),0===a.indexOf("Lcl ")&&(a=a.replace("Lcl ","Lcl_")),n="Color"===a||"ColorRGB"===a||"Vector"===a||"Vector3D"===a||0===a.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[i]={type:a,type2:s,flag:e,value:n}}else 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)}parseProperty(t){var r=t.getString(1);let s;switch(r){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return s=t.getUint32(),t.getArrayBuffer(s);case"S":return s=t.getUint32(),t.getString(s);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var n=t.getUint32(),i=t.getUint32(),a=t.getUint32();if(0===i)switch(r){case"b":case"c":return t.getBooleanArray(n);case"d":return t.getFloat64Array(n);case"f":return t.getFloat32Array(n);case"i":return t.getInt32Array(n);case"l":return t.getInt64Array(n)}void 0===e&&console.error("THREE.FBXLoader: External library fflate.min.js required."),i=Bi(new Uint8Array(t.getArrayBuffer(a)));const o=new ba(i.buffer);switch(r){case"b":case"c":return o.getBooleanArray(n);case"d":return o.getFloat64Array(n);case"f":return o.getFloat32Array(n);case"i":return o.getInt32Array(n);case"l":return o.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+r)}}}class ba{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let r=0;r<e;r++)t.push(this.getBoolean());return t}getUint8(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getInt32());return t}getUint32(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,4294967295==(e=4294967295&~e)&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getFloat32());return t}getFloat64(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let r=0;r<e;r++)t.push(this.getFloat64());return t}getArrayBuffer(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let r=0;r<e;r++)t[r]=this.getUint8();var r=t.indexOf(0);return 0<=r&&(t=t.slice(0,r)),n.LoaderUtils.decodeText(new Uint8Array(t))}}class Sa{add(e,t){this[e]=t}}function Ta(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 Ma(e){return e/46186158e3}const _a=[];function Ea(e,t,r,s){let n;switch(s.mappingType){case"ByPolygonVertex":n=e;break;case"ByPolygon":n=t;break;case"ByVertice":n=r;break;case"AllSame":n=s.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+s.mappingType)}var i=(n="IndexToDirect"===s.referenceType?s.indices[n]:n)*s.dataSize,a=i+s.dataSize,o=_a,l=s.buffer,h=a;for(let e=i,t=0;e<h;e++,t++)o[t]=l[e];return o}const Pa=new n.Euler,Ca=new n.Vector3;function Ra(e){const t=new n.Matrix4,r=new n.Matrix4,s=new n.Matrix4,i=new n.Matrix4,a=new n.Matrix4,o=new n.Matrix4,l=new n.Matrix4,h=new n.Matrix4,c=new n.Matrix4,u=new n.Matrix4,d=new n.Matrix4,p=new n.Matrix4;var m=e.inheritType||0;if(e.translation&&t.setPosition(Ca.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(Pa.fromArray(t))}if(e.rotation){const t=e.rotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),s.makeRotationFromEuler(Pa.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(Pa.fromArray(t)),i.invert()}e.scale&&a.scale(Ca.fromArray(e.scale)),e.scalingOffset&&l.setPosition(Ca.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(Ca.fromArray(e.scalingPivot)),e.rotationOffset&&h.setPosition(Ca.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(Ca.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(d.copy(e.parentMatrix),u.copy(e.parentMatrixWorld)),e=r.clone().multiply(s).multiply(i);const f=new n.Matrix4,g=(f.extractRotation(u),new n.Matrix4);g.copyPosition(u);var v=g.clone().invert().multiply(u);const x=f.clone().invert().multiply(v);v=a;const y=new n.Matrix4;0===m?y.copy(f).multiply(e).multiply(x).multiply(v):1===m?y.copy(f).multiply(x).multiply(e).multiply(v):(m=(new n.Matrix4).scale((new n.Vector3).setFromMatrixScale(d)).clone().invert(),m=x.clone().multiply(m),y.copy(f).multiply(e).multiply(m).multiply(v)),e=c.clone().invert(),m=o.clone().invert();let w=t.clone().multiply(h).multiply(c).multiply(r).multiply(s).multiply(i).multiply(e).multiply(l).multiply(o).multiply(a).multiply(m);return v=(new n.Matrix4).copyPosition(w),e=u.clone().multiply(v),p.copyPosition(e),(w=p.clone().multiply(y)).premultiply(u.invert()),w}function Da(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 Aa(e){return e.split(",").map((function(e){return parseFloat(e)}))}function La(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),n.LoaderUtils.decodeText(new Uint8Array(e,t,r))}function Ia(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}const Oa=/^[og]\s*(.+)?/,Ua=/^mtllib /,ka=/^usemtl /,Ba=/^usemap /,Fa=new n.Vector3,Na=new n.Vector3,za=new n.Vector3,ja=new n.Vector3,Va=new n.Vector3,Ha=new n.Color;function Ga(){const 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);const r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(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){const t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}},this.materials.push(e),e},currentMaterial:function(){if(0<this.materials.length)return this.materials[this.materials.length-1]},_finalize:function(e){const 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(let e=this.materials.length-1;0<=e;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){const e=r.clone(0);e.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 s=this.vertices;const n=this.object.geometry.vertices;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[t+0],s[t+1],s[t+2]),n.push(s[r+0],s[r+1],s[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 s=this.normals;const n=this.object.geometry.normals;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[t+0],s[t+1],s[t+2]),n.push(s[r+0],s[r+1],s[r+2])},addFaceNormal:function(e,t,r){var s=this.vertices;const n=this.object.geometry.normals;Fa.fromArray(s,e),Na.fromArray(s,t),za.fromArray(s,r),Va.subVectors(za,Na),ja.subVectors(Fa,Na),Va.cross(ja),Va.normalize(),n.push(Va.x,Va.y,Va.z),n.push(Va.x,Va.y,Va.z),n.push(Va.x,Va.y,Va.z)},addColor:function(e,t,r){var s=this.colors;const n=this.object.geometry.colors;void 0!==s[e]&&n.push(s[e+0],s[e+1],s[e+2]),void 0!==s[t]&&n.push(s[t+0],s[t+1],s[t+2]),void 0!==s[r]&&n.push(s[r+0],s[r+1],s[r+2])},addUV:function(e,t,r){var s=this.uvs;const n=this.object.geometry.uvs;n.push(s[e+0],s[e+1]),n.push(s[t+0],s[t+1]),n.push(s[r+0],s[r+1])},addDefaultUV:function(){const 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,s,n,i,a,o,l){var h=this.vertices.length;let c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(r,h);this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==a&&""!==a?(e=this.normals.length,c=this.parseNormalIndex(a,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)):this.addFaceNormal(c,u,d),void 0!==s&&""!==s?(t=this.uvs.length,c=this.parseUVIndex(s,t),u=this.parseUVIndex(n,t),d=this.parseUVIndex(i,t),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0):this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";var t=this.vertices.length;for(let s=0,n=e.length;s<n;s++){var r=this.parseVertexIndex(e[s],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";var r=this.vertices.length,s=this.uvs.length;for(let t=0,s=e.length;t<s;t++)this.addVertexLine(this.parseVertexIndex(e[t],r));for(let e=0,r=t.length;e<r;e++)this.addUVLine(this.parseUVIndex(t[e],s))}};return e.startObject("",!1),e}class Wa extends n.Loader{constructor(e){super(e),this.materials=null}load(e,t,r,s){const i=this,a=new n.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){s?s(r):console.error(r),i.manager.itemError(e)}}),r,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Ga;var r=(e=-1!==(e=-1!==e.indexOf("\r\n")?e.replace(/\r\n/g,"\n"):e).indexOf("\\\n")?e.replace(/\\\n/g,""):e).split("\n");let s,i="",a=[];var o,l="function"==typeof"".trimLeft;for(let e=0,n=r.length;e<n;e++)if(i=r[e],0!==(i=l?i.trimLeft():i.trim()).length&&"#"!==(s=i.charAt(0)))if("v"===s){var h=i.split(/\s+/);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),7<=h.length?(Ha.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(Ha.r,Ha.g,Ha.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]))}}else if("f"===s){var c,u=i.slice(1).trim().split(/\s+/);const e=[];for(let t=0,r=u.length;t<r;t++){const r=u[t];0<r.length&&(c=r.split("/"),e.push(c))}var d=e[0];for(let r=1,s=e.length-1;r<s;r++){var p=e[r],m=e[r+1];t.addFace(d[0],p[0],m[0],d[1],p[1],m[1],d[2],p[2],m[2])}}else if("l"===s){const e=i.substring(1).trim().split(" ");let r=[];const s=[];if(-1===i.indexOf("/"))r=e;else for(let t=0,n=e.length;t<n;t++){var f=e[t].split("/");""!==f[0]&&r.push(f[0]),""!==f[1]&&s.push(f[1])}t.addLineGeometry(r,s)}else if("p"===s){var g=i.slice(1).trim().split(" ");t.addPointGeometry(g)}else if(null!==(a=Oa.exec(i)))g=(" "+a[0].slice(1).trim()).slice(1),t.startObject(g);else if(ka.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(Ua.test(i))t.materialLibraries.push(i.substring(7).trim());else if(Ba.test(i))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===s){1<(a=i.split(" ")).length?(o=a[1].trim().toLowerCase(),t.object.smooth="0"!==o&&"off"!==o):t.object.smooth=!0;const e=t.object.currentMaterial();e&&(e.smooth=t.object.smooth)}else"\0"!==i&&console.warn('THREE.OBJLoader: Unexpected line: "'+i+'"');t.finalize();const v=new n.Group;if(v.materialLibraries=[].concat(t.materialLibraries),1==!(1===t.objects.length&&0===t.objects[0].geometry.vertices.length))for(let e=0,r=t.objects.length;e<r;e++){var x=t.objects[e],y=x.geometry,w=x.materials,b="Line"===y.type,S="Points"===y.type;let r=!1;if(0!==y.vertices.length){const e=new n.BufferGeometry,s=(e.setAttribute("position",new n.Float32BufferAttribute(y.vertices,3)),0<y.normals.length&&e.setAttribute("normal",new n.Float32BufferAttribute(y.normals,3)),0<y.colors.length&&(r=!0,e.setAttribute("color",new n.Float32BufferAttribute(y.colors,3))),!0===y.hasUVIndices&&e.setAttribute("uv",new n.Float32BufferAttribute(y.uvs,2)),[]);for(let e=0,i=w.length;e<i;e++){var T=w[e],M=T.name+"_"+T.smooth+"_"+r;let i=t.materials[M];if(null!==this.materials)if(i=this.materials.create(T.name),!b||!i||i instanceof n.LineBasicMaterial){if(S&&i&&!(i instanceof n.PointsMaterial)){const e=new n.PointsMaterial({size:10,sizeAttenuation:!1});n.Material.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,i=e}}else{const e=new n.LineBasicMaterial;n.Material.prototype.copy.call(e,i),e.color.copy(i.color),i=e}void 0===i&&((i=b?new n.LineBasicMaterial:S?new n.PointsMaterial({size:1,sizeAttenuation:!1}):new n.MeshPhongMaterial).name=T.name,i.flatShading=!T.smooth,i.vertexColors=r,t.materials[M]=i),s.push(i)}let i;if(1<s.length){for(let t=0,r=w.length;t<r;t++){var _=w[t];e.addGroup(_.groupStart,_.groupCount,t)}i=new(b?n.LineSegments:S?n.Points:n.Mesh)(e,s)}else i=new(b?n.LineSegments:S?n.Points:n.Mesh)(e,s[0]);i.name=x.name,v.add(i)}}else if(0<t.vertices.length){const r=new n.PointsMaterial({size:1,sizeAttenuation:!1}),s=new n.BufferGeometry;s.setAttribute("position",new n.Float32BufferAttribute(t.vertices,3)),0<t.colors.length&&void 0!==t.colors[0]&&(s.setAttribute("color",new n.Float32BufferAttribute(t.colors,3)),r.vertexColors=!0),e=new n.Points(s,r),v.add(e)}return v}}var Xa=function(e,t,r,s){return new(r=r||Promise)((function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((s=s.apply(e,t||[])).next())}))};class qa{constructor(e){this.parses={fbx:new fa,obj:new Wa},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 Xa(this,void 0,void 0,(function*(){var t=yield(0,k.toResult)(e,"arrayBuffer");return this.runScene.loaderer.gltf.parse(t)}))}fbx(e){return Xa(this,void 0,void 0,(function*(){var t=yield(0,k.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 Xa(this,void 0,void 0,(function*(){var t=yield(0,k.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))}))}}const Ya=new n.Raycaster,Za=new n.Vector3,Qa=new n.Vector3,Ka=new n.Quaternion,Ja={X:new n.Vector3(1,0,0),Y:new n.Vector3(0,1,0),Z:new n.Vector3(0,0,1)},$a={type:"change"},eo={type:"mouseDown"},to={type:"mouseUp",mode:null},ro={type:"objectChange"};class so extends n.Object3D{constructor(e,t){super(),void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const r=new wo,s=(this._gizmo=r,this.add(r),new bo),i=(this._plane=s,this.add(s),this);function a(e,t){let n=t;Object.defineProperty(i,e,{get:function(){return void 0!==n?n:t},set:function(t){n!==t&&(n=t,s[e]=t,r[e]=t,i.dispatchEvent({type:e+"-changed",value:t}),i.dispatchEvent($a))}}),i[e]=t,s[e]=t,r[e]=t}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),t=new n.Vector3,e=new n.Vector3;var o=new n.Quaternion,l=new n.Quaternion,h=new n.Vector3,c=new n.Quaternion,u=new n.Vector3,d=new n.Vector3,p=new n.Vector3,m=new n.Vector3;a("worldPosition",t),a("worldPositionStart",e),a("worldQuaternion",o),a("worldQuaternionStart",l),a("cameraPosition",h),a("cameraQuaternion",c),a("pointStart",u),a("pointEnd",d),a("rotationAxis",p),a("rotationAngle",0),a("eye",m),this._offset=new n.Vector3,this._startNorm=new n.Vector3,this._endNorm=new n.Vector3,this._cameraScale=new n.Vector3,this._parentPosition=new n.Vector3,this._parentQuaternion=new n.Quaternion,this._parentQuaternionInv=new n.Quaternion,this._parentScale=new n.Vector3,this._worldScaleStart=new n.Vector3,this._worldQuaternionInv=new n.Quaternion,this._worldScale=new n.Vector3,this._positionStart=new n.Vector3,this._quaternionStart=new n.Quaternion,this._scaleStart=new n.Vector3,this._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(this),this._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(this),this._onPointerHover=function(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}.bind(this),this._onPointerMove=function(e){this.enabled&&this.pointerMove(this._getPointer(e))}.bind(this),this._onPointerUp=function(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){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(),super.updateMatrixWorld(this)}pointerHover(e){void 0!==this.object&&!0!==this.dragging&&(Ya.setFromCamera(e,this.camera),e=no(this._gizmo.picker[this.mode],Ya),this.axis=e?e.object.name:null)}pointerDown(e){void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis&&(Ya.setFromCamera(e,this.camera),(e=no(this._plane,Ya,!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,eo.mode=this.mode,this.dispatchEvent(eo))}pointerMove(e){const t=this.axis;var r=this.mode;const s=this.object;let n=this.space;if("scale"===r?n="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(n="world"),void 0!==s&&null!==t&&!1!==this.dragging&&-1===e.button&&(Ya.setFromCamera(e,this.camera),e=no(this._plane,Ya,!0))){if(this.pointEnd.copy(e.point).sub(this.worldPositionStart),"translate"===r)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===n&&"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"===n&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart):this._offset.applyQuaternion(this._parentQuaternionInv)).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===n&&(s.position.applyQuaternion(Ka.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),"world"===n&&(s.parent&&s.position.add(Za.setFromMatrixPosition(s.parent.matrixWorld)),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Za.setFromMatrixPosition(s.parent.matrixWorld))));else if("scale"===r){if(-1!==t.search("XYZ")){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),Qa.set(e,e,e)}else Za.copy(this.pointStart),Qa.copy(this.pointEnd),Za.applyQuaternion(this._worldQuaternionInv),Qa.applyQuaternion(this._worldQuaternionInv),Qa.divide(Za),-1===t.search("X")&&(Qa.x=1),-1===t.search("Y")&&(Qa.y=1),-1===t.search("Z")&&(Qa.z=1);s.scale.copy(this._scaleStart).multiply(Qa),this.scaleSnap&&(-1!==t.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else"rotate"===r&&(this._offset.copy(this.pointEnd).sub(this.pointStart),e=20/this.worldPosition.distanceTo(Za.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(Za.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Ja[t]),Za.copy(Ja[t]),"local"===n&&Za.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(Za.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===n&&"E"!==t&&"XYZE"!==t?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(Ka.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(Ka.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize()));this.dispatchEvent($a),this.dispatchEvent(ro)}}pointerUp(e){0===e.button&&(this.dragging&&null!==this.axis&&(to.mode=this.mode,this.dispatchEvent(to)),this.dragging=!1,this.axis=null)}dispose(){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()}))}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent($a),this.dispatchEvent(ro),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ya}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}update(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}function no(e,t,r){var s=t.intersectObject(e,!0);for(let e=0;e<s.length;e++)if(s[e].object.visible||r)return s[e];return!1}so.prototype.isTransformControls=!0;const io=new n.Euler,ao=new n.Vector3(0,1,0),oo=new n.Vector3(0,0,0),lo=new n.Matrix4,ho=new n.Quaternion,co=new n.Quaternion,uo=new n.Vector3,po=new n.Matrix4,mo=new n.Vector3(1,0,0),fo=new n.Vector3(0,1,0),go=new n.Vector3(0,0,1),vo=new n.Vector3,xo=new n.Vector3,yo=new n.Vector3;class wo extends n.Object3D{constructor(){super(),this.type="TransformControlsGizmo";const e=new n.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new n.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),r=e.clone(),s=(r.opacity=.15,t.clone()),i=(s.opacity=.5,e.clone()),a=(i.color.setHex(16711680),e.clone()),o=(a.color.setHex(65280),e.clone()),l=(o.color.setHex(255),e.clone()),h=(l.color.setHex(16711680),l.opacity=.5,e.clone()),c=(h.color.setHex(65280),h.opacity=.5,e.clone()),u=(c.color.setHex(255),c.opacity=.5,e.clone()),d=(u.opacity=.25,e.clone()),p=((d.color.setHex(16776960),d.opacity=.25,e.clone()).color.setHex(16776960),e.clone()),m=(p.color.setHex(7895160),new n.CylinderGeometry(0,.04,.1,12)),f=(m.translate(0,.05,0),new n.BoxGeometry(.08,.08,.08)),g=(f.translate(0,.04,0),new n.BufferGeometry),v=(g.setAttribute("position",new n.Float32BufferAttribute([0,0,0,1,0,0],3)),new n.CylinderGeometry(.0075,.0075,.5,3));function x(e,t){const r=new n.TorusGeometry(e,.0075,3,64,t*Math.PI*2);return r.rotateY(Math.PI/2),r.rotateX(Math.PI/2),r}v.translate(0,.25,0);var y={X:[[new n.Mesh(m,i),[.5,0,0],[0,0,-Math.PI/2]],[new n.Mesh(m,i),[-.5,0,0],[0,0,Math.PI/2]],[new n.Mesh(v,i),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new n.Mesh(m,a),[0,.5,0]],[new n.Mesh(m,a),[0,-.5,0],[Math.PI,0,0]],[new n.Mesh(v,a)]],Z:[[new n.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new n.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new n.Mesh(v,o),null,[Math.PI/2,0,0]]],XYZ:[[new n.Mesh(new n.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},w={X:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,.3,0]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new n.Mesh(new n.OctahedronGeometry(.2,0),r)]],XY:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new n.Mesh(new n.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new n.Mesh(new n.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new n.Line(function(){const e=new n.BufferGeometry;return e.setAttribute("position",new n.Float32BufferAttribute([0,0,0,1,1,1],3)),e}(),s),null,null,null,"helper"]],X:[[new n.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new n.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new n.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new n.Mesh(x(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new n.Mesh(x(.5,.5),i)]],Y:[[new n.Mesh(x(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new n.Mesh(x(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new n.Mesh(x(.75,1),d),null,[0,Math.PI/2,0]]]},T={AXIS:[[new n.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new n.Mesh(new n.SphereGeometry(.25,10,8),r)]],X:[[new n.Mesh(new n.TorusGeometry(.5,.1,4,24),r),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new n.Mesh(new n.TorusGeometry(.5,.1,4,24),r),[0,0,0],[Math.PI/2,0,0]]],Z:[[new n.Mesh(new n.TorusGeometry(.5,.1,4,24),r),[0,0,0],[0,0,-Math.PI/2]]],E:[[new n.Mesh(new n.TorusGeometry(.75,.1,2,24),r)]]},_={X:[[new n.Mesh(f,i),[.5,0,0],[0,0,-Math.PI/2]],[new n.Mesh(v,i),[0,0,0],[0,0,-Math.PI/2]],[new n.Mesh(f,i),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new n.Mesh(f,a),[0,.5,0]],[new n.Mesh(v,a)],[new n.Mesh(f,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new n.Mesh(f,o),[0,0,.5],[Math.PI/2,0,0]],[new n.Mesh(v,o),[0,0,0],[Math.PI/2,0,0]],[new n.Mesh(f,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new n.Mesh(new n.BoxGeometry(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new n.Mesh(new n.BoxGeometry(.1,.1,.1),u.clone())]]},E={X:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,.3,0]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new n.Mesh(new n.CylinderGeometry(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new n.Mesh(new n.BoxGeometry(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new n.Mesh(new n.BoxGeometry(.2,.2,.2),r),[0,0,0]]]},P={X:[[new n.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new n.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new n.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(e){const t=new n.Object3D;for(const n in e)for(let o=e[n].length;o--;){const l=e[n][o][0].clone();var r=e[n][o][1],s=e[n][o][2],i=e[n][o][3],a=e[n][o][4];l.name=n,l.tag=a,r&&l.position.set(r[0],r[1],r[2]),s&&l.rotation.set(s[0],s[1],s[2]),i&&l.scale.set(i[0],i[1],i[2]),l.updateMatrix();const h=l.geometry.clone();h.applyMatrix4(l.matrix),l.geometry=h,l.renderOrder=1/0,l.position.set(0,0,0),l.rotation.set(0,0,0),l.scale.set(1,1,1),t.add(l)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(y)),this.add(this.gizmo.rotate=C(S)),this.add(this.gizmo.scale=C(_)),this.add(this.picker.translate=C(w)),this.add(this.picker.rotate=C(M)),this.add(this.picker.scale=C(E)),this.add(this.helper.translate=C(b)),this.add(this.helper.rotate=C(T)),this.add(this.helper.scale=C(P)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){var t="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:co;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;let r=[];r=(r=(r=r.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(let e=0;e<r.length;e++){const s=r[e];let n;s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition),n=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(n*this.size/4),"helper"===s.tag?(s.visible=!1,"AXIS"===s.name?(s.position.copy(this.worldPositionStart),s.visible=!!this.axis,"X"===this.axis&&(Ka.setFromEuler(io.set(0,0,0)),s.quaternion.copy(t).multiply(Ka),.9<Math.abs(ao.copy(mo).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"Y"===this.axis&&(Ka.setFromEuler(io.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(Ka),.9<Math.abs(ao.copy(fo).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"Z"===this.axis&&(Ka.setFromEuler(io.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(Ka),.9<Math.abs(ao.copy(go).applyQuaternion(t).dot(this.eye))&&(s.visible=!1)),"XYZE"===this.axis&&(Ka.setFromEuler(io.set(0,Math.PI/2,0)),ao.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(lo.lookAt(oo,ao,fo)),s.quaternion.multiply(Ka),s.visible=this.dragging),"E"===this.axis&&(s.visible=!1)):"START"===s.name?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):"END"===s.name?(s.position.copy(this.worldPosition),s.visible=this.dragging):"DELTA"===s.name?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),Za.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Za.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(Za),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=-1!==this.axis.search(s.name)))):(s.quaternion.copy(t),"translate"===this.mode||"scale"===this.mode?("X"===s.name&&.99<Math.abs(ao.copy(mo).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Y"===s.name&&.99<Math.abs(ao.copy(fo).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Z"===s.name&&.99<Math.abs(ao.copy(go).applyQuaternion(t).dot(this.eye))&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XY"===s.name&&Math.abs(ao.copy(go).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"YZ"===s.name&&Math.abs(ao.copy(mo).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XZ"===s.name&&Math.abs(ao.copy(fo).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):"rotate"===this.mode&&(ho.copy(t),ao.copy(this.eye).applyQuaternion(Ka.copy(t).invert()),-1!==s.name.search("E")&&s.quaternion.setFromRotationMatrix(lo.lookAt(this.eye,oo,fo)),"X"===s.name&&(Ka.setFromAxisAngle(mo,Math.atan2(-ao.y,ao.z)),Ka.multiplyQuaternions(ho,Ka),s.quaternion.copy(Ka)),"Y"===s.name&&(Ka.setFromAxisAngle(fo,Math.atan2(ao.x,ao.z)),Ka.multiplyQuaternions(ho,Ka),s.quaternion.copy(Ka)),"Z"===s.name&&(Ka.setFromAxisAngle(go,Math.atan2(ao.y,ao.x)),Ka.multiplyQuaternions(ho,Ka),s.quaternion.copy(Ka))),s.visible=s.visible&&(-1===s.name.indexOf("X")||this.showX),s.visible=s.visible&&(-1===s.name.indexOf("Y")||this.showY),s.visible=s.visible&&(-1===s.name.indexOf("Z")||this.showZ),s.visible=s.visible&&(-1===s.name.indexOf("E")||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some((function(e){return s.name===e})))&&(s.material.color.setHex(16776960),s.material.opacity=1))}super.updateMatrixWorld(e)}}wo.prototype.isTransformControlsGizmo=!0;class bo extends n.Mesh{constructor(){super(new n.PlaneGeometry(1e5,1e5,2,2),new n.MeshBasicMaterial({visible:!1,wireframe:!0,side:n.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),vo.copy(mo).applyQuaternion("local"===t?this.worldQuaternion:co),xo.copy(fo).applyQuaternion("local"===t?this.worldQuaternion:co),yo.copy(go).applyQuaternion("local"===t?this.worldQuaternion:co),ao.copy(xo),this.mode){case"translate":case"scale":switch(this.axis){case"X":ao.copy(this.eye).cross(vo),uo.copy(vo).cross(ao);break;case"Y":ao.copy(this.eye).cross(xo),uo.copy(xo).cross(ao);break;case"Z":ao.copy(this.eye).cross(yo),uo.copy(yo).cross(ao);break;case"XY":uo.copy(yo);break;case"YZ":uo.copy(vo);break;case"XZ":ao.copy(yo),uo.copy(xo);break;case"XYZ":case"E":uo.set(0,0,0)}break;default:uo.set(0,0,0)}0===uo.length()?this.quaternion.copy(this.cameraQuaternion):(po.lookAt(Za.set(0,0,0),uo,ao),this.quaternion.setFromRotationMatrix(po)),super.updateMatrixWorld(e)}}bo.prototype.isTransformControlsPlane=!0;class So extends so{constructor(e,t){super(e,t),this.transGizmo=this.children[0],this.scaleCoefficient=new n.Vector3,this.beginScale=new n.Vector3,this.posStart=new n.Vector2,this.posEnd=new n.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 To{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 n.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 Rr.Vector3,this.transControlsStatusMap={position:"translate",rotation:"rotate",scale:"scale"},this.multipObj=null,this.worldOldVal=new Rr.Vector3,this.draggingChanged=e=>{const t=this.runScene.assetsEx.get().controls;var r=this.controlsMode;let s=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=Nr(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 n=Nr(e,this.runScene.sceneEx.get());this.runScene.multipSelector.setInfo(e,r,this.modelNewVal,e[r],n,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,!s){if(this.runScene.multipSelector.isEmpty())return;s=this.runScene.multipSelector.getLast()}t.enabled?(this.modelNewVal=this.runScene.modelEx.cloneV3(s[r]),this.isDraggingChange=!0,this.worldOldVal=Nr(s,this.runScene.sceneEx.get())):(this.runScene.multipSelector.isEmpty()?this.runScene.modelEx.setV3({model:s,info:r,newV3:this.runScene.modelEx.cloneV3(s[r]),oldV3:this.modelNewVal},!0,!1):(this.multipObj=s,this.runScene.events.mouse.enableUp=!1,this.runScene.helperEx.boxHelper.setFromObject(this.runScene.assetsEx.get().scene),n=Nr(s,this.runScene.sceneEx.get()),this.runScene.multipSelector.setInfo(s,r,this.modelNewVal,s[r],n,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 So(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 Rr.GridHelper(20,10);return e.name="helper",e.position.y=0,e.material instanceof n.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)}}class Mo extends n.Line{constructor(e,t){const r=new n.BufferGeometry;r.setAttribute("position",new n.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new n.LineBasicMaterial({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const s=new n.BufferGeometry;s.setAttribute("position",new n.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new n.Mesh(s,new n.MeshBasicMaterial({side:n.BackSide,fog:!1})))}updateMatrixWorld(){if(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);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const t=this.material.color;var e=Math.max(t.r,t.g,t.b);1<e&&t.multiplyScalar(1/e),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)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class _o{constructor(e){this.runScene=e}toJSON(e){const{type:t,intensity:r,name:s,visible:n,color:i}=e;return{type:t,intensity:r,name:s,visible:n,color:i.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("AmbientLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:n,color:i}=e;return t.intensity=r,t.type=e,t.name=s,t.visible=n,t.color=new Rr.Color("#"+i),t}}class Eo{constructor(e){this.runScene=e}toJSON(e){const{intensity:t,name:r,type:s,position:n,visible:i,color:a,castShadow:o,shadow:l,rotation:h,target:c}=e;var{mapSize:e,camera:u}=l,{scale:u,near:d,far:p}=u;return{type:s,intensity:t,name:r,visible:i,color:a.getHexString(),castShadow:o,shadow:{mapSize:e.x,camera:{near:d,far:p,scale:u.x}},position:{x:n.x,y:n.y,z:n.z},rotation:{x:h.x,y:h.y,z:h.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:s,position:n,visible:i,color:a,castShadow:o,shadow:l,rotation:h,type:c}=e,{mapSize:l,camera:u}=l,{scale:u,near:d,far:p}=u;return t.intensity=r,t.type=c,t.name=s,t.visible=i,t.castShadow=o,t.color=new Rr.Color("#"+a),t.position.set(n.x,n.y,n.z),t.rotation.set(h.x,h.y,h.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=u,t.shadow.camera.scale.y=u,t.shadow.camera.scale.z=u,t.shadow.camera.near=d,t.shadow.camera.far=p,t.shadow.camera.updateProjectionMatrix(),t.cameraHelper.update(),t}}class Po{constructor(e){this.runScene=e}toJSON(e){const{type:t,intensity:r,name:s,visible:n,color:i,groundColor:a,position:o}=e;return{name:s,type:t,intensity:r,visible:n,position:{x:o.x,y:o.y,z:o.z},groundColor:a.getHexString(),color:i.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("HemisphereLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:n,color:i,groundColor:a,position:o}=e;return t.type=e,t.intensity=r,t.name=s,t.visible=n,t.color=new Rr.Color("#"+i),t.groundColor=new Rr.Color("#"+a),t.position.set(o.x,o.y,o.z),t}}class Co{constructor(e){this.runScene=e}toJSON(e){const{name:t,type:r,intensity:s,distance:n,decay:i,renderOrder:a,color:o,visible:l,castShadow:h,shadow:c,position:u}=e;var{mapSize:e,camera:d,bias:p,radius:m}=c,{scale:d,near:f,far:g}=d;return{name:t,type:r,intensity:s,visible:l,color:o.getHexString(),castShadow:h,distance:n,decay:i,renderOrder:a,shadow:{mapSize:e.x,camera:{near:f,far:g,scale:d.x},radius:m,bias:p},position:{x:u.x,y:u.y,z:u.z}}}parseJSON(e){const t=this.runScene.lightEx.get("PointLight",{addUndo:!1});var{name:e,type:r,intensity:s,distance:n,decay:i,renderOrder:a,color:o,visible:l,castShadow:h,shadow:c,position:u}=e,{mapSize:c,camera:d,bias:p,radius:m}=c,{scale:d,near:f,far:g}=d;return t.intensity=s,t.type=r,t.name=e,t.visible=l,t.castShadow=h,t.distance=n,t.renderOrder=a,t.color=new Rr.Color("#"+o),t.position.set(u.x,u.y,u.z),t.shadow.mapSize.x=c,t.shadow.mapSize.y=c,t.shadow.bias=p,t.decay=i,t.shadow.radius=m,t.shadow.camera.scale.x=d,t.shadow.camera.scale.y=d,t.shadow.camera.scale.z=d,t.shadow.camera.near=f,t.shadow.camera.far=g,t.shadow.camera.updateProjectionMatrix(),t}}class Ro{constructor(e){this.runScene=e}toJSON(e){const{type:t,intensity:r,name:s,visible:n,color:i,position:a}=e;return{name:s,type:t,intensity:r,visible:n,position:{x:a.x,y:a.y,z:a.z},color:i.getHexString()}}parseJSON(e){const t=this.runScene.lightEx.get("RectAreaLight",{addUndo:!1});var{type:e,intensity:r,name:s,visible:n,color:i,position:a}=e;return t.type=e,t.intensity=r,t.name=s,t.visible=n,t.color=new Rr.Color("#"+i),t.position.set(a.x,a.y,a.z),t}}class Do{constructor(e){this.runScene=e}toJSON(e){const{name:t,type:r,color:s,distance:n,decay:i,intensity:a,angle:o,penumbra:l,visible:h,castShadow:c,shadow:u,renderOrder:d,position:p,target:m}=e;var{bias:e,camera:f,normalBias:g,mapSize:v,radius:x}=u,f=f.near;return{type:r,intensity:a,name:t,visible:h,distance:n,angle:o,decay:i,penumbra:l,renderOrder:d,color:s.getHexString(),castShadow:c,shadow:{bias:e,normalBias:g,mapSize:v.x,camera:{near:f},radius:x},position:{x:p.x,y:p.y,z:p.z},targetPosition:{x:m.position.x,y:m.position.y,z:m.position.z}}}parseJSON(e){const t=this.runScene.lightEx.get("SpotLight",{addUndo:!1});var{name:e,type:r,color:s,distance:n,decay:i,intensity:a,angle:o,penumbra:l,visible:h,castShadow:c,shadow:u,renderOrder:d,position:p,targetPosition:m}=e,{bias:u,camera:f,normalBias:g,mapSize:v,radius:x}=u,f=f.near;return t.intensity=a,t.type=r,t.name=e,t.visible=h,t.distance=n,t.decay=i,t.angle=o,t.penumbra=l,t.renderOrder=d,t.castShadow=c,t.color=new Rr.Color("#"+s),t.position.set(p.x,p.y,p.z),t.shadow.mapSize.x=v,t.shadow.mapSize.y=v,t.shadow.camera.near=f,t.target.position.set(m.x,m.y,m.z),t.shadow.bias=u,t.shadow.normalBias=g,t.shadow.radius=x,t.shadow.camera.updateProjectionMatrix(),t}}class Ao{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 Eo(e),PointLight:new Co(e),SpotLight:new Do(e),RectAreaLight:new Ro(e),HemisphereLight:new Po(e),AmbientLight:new _o(e)}}getLightsByScene(e=this.runScene.sceneEx.get()){return e.children.filter((e=>e.isLight))}get(e,t){var{isClone:t,id:r,addUndo:s}=t||{};let n=new Rr[e];if(n.position.y=10,n.name=e,n.userData.id=r,this.shadowList.includes(e)&&(n.castShadow=!0),this.setLight(n),this.helperList.includes(n.type)){const t=this.setLightHelper(n);t.push({model:n,parent:this.runScene.sceneEx.get(),addTree:!0}),r=t.map((e=>new ws(Object.assign(Object.assign({},e),{runScene:this.runScene})).execute())),void 0!==s&&s&&this.runScene.undoEx.addUndo(r),null!=(e=n.lightHelper)&&e.update()}else this.runScene.modelEx.add(n,void 0,s);return this.runScene.modelEx.setSelectByModel(n,{isClone:t}),n}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 Ss({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 Ss({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 s,n=[];switch(e){case"RectAreaLight":s=new Mo(t,16773120);break;case"DirectionalLight":if(s=new Rr.DirectionalLightHelper(t,1,16711680),t.children[0])t.target=t.children[0];else{let e=new Rr.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 Rr.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,n.push({model:e,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"PointLight":s=new Rr.PointLightHelper(t,1,16711935);break;case"SpotLight":s=new Rr.SpotLightHelper(t);let i=new Rr.Object3D;(t.target=i).name="helperModel",i.userData.isLightTarget=!0,i.userData.light=t,i.position.y=-10,t.shadow.autoUpdate=!0,t.add(i);const a=new Rr.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,n.push({model:a,parent:this.runScene.sceneEx.get(),addTree:!1});break;case"HemisphereLight":s=new Rr.HemisphereLightHelper(t,1,16773135)}return s.name="helperModel",this.runScene.helperEx.setHelper(s,!0,(e=>{e.userData.id=r})),s.userData.id=r,(s.light=t).helper=s,n.push({model:s,parent:this.runScene.sceneEx.get(),addTree:!1}),n}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:s,cb:n}=e;return new us({target:e,runScene:this.runScene,info:r,oldVal:e[r],newVal:s,cb:n}).execute()}setMultip(e,t,r=!0,s=!0){if(e instanceof Array)return n=e.map((e=>{var{model:e,typeList:s,newVal:n}=e;const i=new es({target:e,typeList:s,newVal:n,cb:t});return r?i.execute():i})),s&&this.runScene.undoEx.addUndo(n),n;{var{model:n,typeList:e,newVal:i}=e;const a=new es({target:n,typeList:e,newVal:i,cb:t});return s&&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,Qr.getId)()})}}const Lo=new WeakMap;class Io extends n.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,s){const i=new n.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{var r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(s)}),r,s)}decodeDracoFile(e,t,r,s){s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r},this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){var r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}var s=JSON.stringify(t);if(Lo.has(e)){var n=Lo.get(e);if(n.key===s)return n.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const a=this.workerNextTaskID++;n=e.byteLength;const o=this._getWorker(a,n).then((r=>(i=r,new Promise(((r,s)=>{i._callbacks[a]={resolve:r,reject:s},i.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&a&&this._releaseTask(i,a)})),Lo.set(e,{key:s,promise:o}),o}_createGeometry(e){const t=new n.BufferGeometry;e.index&&t.setIndex(new n.BufferAttribute(e.index.array,1));for(let a=0;a<e.attributes.length;a++){var r=e.attributes[a],s=r.name,i=r.array;r=r.itemSize,t.setAttribute(s,new n.BufferAttribute(i,r))}return t}_loadLibrary(e,t){const r=new n.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise(((t,s)=>{r.load(e,t,void 0,s)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const r=t[0],s=(e||(this.decoderConfig.wasmBinary=t[1]),function(){let e,t;onmessage=function(r){const s=r.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=s.buffer,n=s.taskConfig;t.then((e=>{const t=e.draco;e=new t.Decoder;const i=new t.DecoderBuffer;i.Init(new Int8Array(r),r.byteLength);try{const r=function(e,t,r,s){var n=s.attributeIDs,i=s.attributeTypes;let a,o;var l,h,c,u,d,p,m,f,g,v,x,y,w,b,S=t.GetEncodedGeometryType(r);if(S===e.TRIANGULAR_MESH)a=new e.Mesh,o=t.DecodeBufferToMesh(r,a);else{if(S!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,o=t.DecodeBufferToPointCloud(r,a)}if(!o.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+o.error_msg());const T={index:null,attributes:[]};for(const r in n){var M=self[i[r]];let o,x;if(s.useUniqueIDs)x=n[r],o=t.GetAttributeByUniqueId(a,x);else{if(-1===(x=t.GetAttributeId(a,e[n[r]])))continue;o=t.GetAttribute(a,x)}T.attributes.push((l=e,h=t,c=a,u=r,d=o,m=void 0,p=d.num_components(),m=c.num_points(),f=(m*=p)*M.BYTES_PER_ELEMENT,g=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}}(l,M),v=l._malloc(f),h.GetAttributeDataArrayForAllPoints(c,d,g,f,v),h=new M(l.HEAPF32.buffer,v,m).slice(),l._free(v),{name:u,array:h,itemSize:p}))}return S===e.TRIANGULAR_MESH&&(T.index=(r=e,S=t,y=(x=a).num_faces(),w=4*(y*=3),b=r._malloc(w),S.GetTrianglesUInt32Array(x,w,b),S=new Uint32Array(r.HEAPF32.buffer,b,y).slice(),r._free(b),{array:S,itemSize:1})),e.destroy(a),T}(t,e,i,n),a=r.attributes.map((e=>e.array.buffer));r.index&&a.push(r.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:r},a)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(i),t.destroy(e)}}))}}}.toString());t=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n"),this.workerSourceURL=URL.createObjectURL(new Blob([t]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){var r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}const Oo={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={}}},Uo=new class{constructor(e,t,r){const s=this;let n,i=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){o++,!1===i&&void 0!==s.onStart&&s.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,void 0!==s.onProgress&&s.onProgress(e,a,o),a===o&&(i=!1,void 0!==s.onLoad&&s.onLoad())},this.itemError=function(e){void 0!==s.onError&&s.onError(e)},this.resolveURL=function(e){return n?n(e):e},this.setURLModifier=function(e){return n=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){return-1!==(e=l.indexOf(e))&&l.splice(e,2),this},this.getHandler=function(e){for(let r=0,s=l.length;r<s;r+=2){const s=l[r];var t=l[r+1];if(s.global&&(s.lastIndex=0),s.test(e))return t}return null}}};class ko extends class{constructor(e){this.manager=void 0!==e?e:Uo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise((function(s,n){r.load(e,s,t,n)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,i=Oo.get(e);if(void 0!==i)return n.manager.itemStart(e),setTimeout((function(){t&&t(i),n.manager.itemEnd(e)}),0),i;const 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(n.options,{imageOrientation:"flipY"})),Promise.resolve(e)])})).then((function(r){var[r,s]=r;Oo.add(e,r),t&&t(r,s),n.manager.itemEnd(e)})).catch((function(t){s&&s(t),n.manager.itemError(e),n.manager.itemEnd(e)})),n.manager.itemStart(e)}}ko.prototype.isImageBitmapLoader=!0;class Bo extends n.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Vo(e)})),this.register((function(e){return new Yo(e)})),this.register((function(e){return new Zo(e)})),this.register((function(e){return new Ho(e)})),this.register((function(e){return new Go(e)})),this.register((function(e){return new Wo(e)})),this.register((function(e){return new Xo(e)})),this.register((function(e){return new qo(e)})),this.register((function(e){return new zo(e)})),this.register((function(e){return new Qo(e)}))}load(e,t,r,s){const i=this;let a;function o(t){s?s(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)}a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:n.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const l=new n.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(r){try{i.parse(r,a,(function(r){t(r),i.manager.itemEnd(e)}),o)}catch(r){o(r)}}),r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s,i){let a;const o={},l={};if("string"==typeof e)a=e;else if(n.LoaderUtils.decodeText(new Uint8Array(e,0,4))===Ko){try{o[No.KHR_BINARY_GLTF]=new Jo(e)}catch(e){return void(s&&s(e))}a=o[No.KHR_BINARY_GLTF].content}else a=n.LoaderUtils.decodeText(new Uint8Array(e));var h=JSON.parse(a);if(void 0===h.asset||h.asset.version[0]<2)s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{i.helper.beforeLoader(h);const e=new xl(h,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,myOptions:i});e.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){var c=this.pluginCallbacks[t](e);l[c.name]=c,o[c.name]=!0}if(h.extensionsUsed)for(let e=0;e<h.extensionsUsed.length;++e){var u=h.extensionsUsed[e];const t=h.extensionsRequired||[];switch(u){case No.KHR_MATERIALS_UNLIT:o[u]=new jo;break;case No.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[u]=new rl;break;case No.KHR_DRACO_MESH_COMPRESSION:o[u]=new $o(h,this.dracoLoader);break;case No.KHR_TEXTURE_TRANSFORM:o[u]=new el;break;case No.KHR_MESH_QUANTIZATION:o[u]=new sl;break;default:0<=t.indexOf(u)&&void 0===l[u]&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}e.setExtensions(o),e.setPlugins(l),e.parse(r,s)}}parseAsync(e,t){const r=this;return new Promise((function(s,n){r.parse(e,t,s,n)}))}}function Fo(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const No={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class zo{constructor(e){this.parser=e,this.name=No.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser;var t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){var r=t[s];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser;var r="light:"+e;let s=t.cache.get(r);if(s)return s;var i=t.json;const a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let o;const l=new n.Color(16777215);void 0!==a.color&&l.fromArray(a.color);var h=void 0!==a.range?a.range:0;switch(a.type){case"directional":(o=new n.DirectionalLight(l)).target.position.set(0,0,-1),o.add(o.target);break;case"point":(o=new n.PointLight(l)).distance=h;break;case"spot":(o=new n.SpotLight(l)).distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),o.decay=2,void 0!==a.intensity&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(o),t.cache.add(r,s),s}createNodeAttachment(e){const t=this,r=this.parser,s=((e=r.json.nodes[e]).extensions&&e.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then((function(e){return r._getNodeRef(t.cache,s,e)}))}}class jo{constructor(){this.name=No.KHR_MATERIALS_UNLIT}getMaterialType(){return n.MeshBasicMaterial}extendParams(e,t,r){const s=[];var i;return e.color=new n.Color(1,1,1),e.opacity=1,(t=t.pbrMetallicRoughness)&&(Array.isArray(t.baseColorFactor)&&(i=t.baseColorFactor,e.color.fromArray(i),e.opacity=i[3]),void 0!==t.baseColorTexture&&s.push(r.assignTexture(e,"map",t.baseColorTexture))),Promise.all(s)}}class Vo{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];return void 0!==(e=e.extensions[this.name]).clearcoatFactor&&(t.clearcoat=e.clearcoatFactor),void 0!==e.clearcoatTexture&&s.push(r.assignTexture(t,"clearcoatMap",e.clearcoatTexture)),void 0!==e.clearcoatRoughnessFactor&&(t.clearcoatRoughness=e.clearcoatRoughnessFactor),void 0!==e.clearcoatRoughnessTexture&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",e.clearcoatRoughnessTexture)),void 0!==e.clearcoatNormalTexture&&(s.push(r.assignTexture(t,"clearcoatNormalMap",e.clearcoatNormalTexture)),void 0!==e.clearcoatNormalTexture.scale&&(e=e.clearcoatNormalTexture.scale,t.clearcoatNormalScale=new n.Vector2(e,e))),Promise.all(s)}}class Ho{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_SHEEN}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];return t.sheenColor=new n.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,void 0!==(e=e.extensions[this.name]).sheenColorFactor&&t.sheenColor.fromArray(e.sheenColorFactor),void 0!==e.sheenRoughnessFactor&&(t.sheenRoughness=e.sheenRoughnessFactor),void 0!==e.sheenColorTexture&&s.push(r.assignTexture(t,"sheenColorMap",e.sheenColorTexture)),void 0!==e.sheenRoughnessTexture&&s.push(r.assignTexture(t,"sheenRoughnessMap",e.sheenRoughnessTexture)),Promise.all(s)}}class Go{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];return void 0!==(e=e.extensions[this.name]).transmissionFactor&&(t.transmission=e.transmissionFactor),void 0!==e.transmissionTexture&&s.push(r.assignTexture(t,"transmissionMap",e.transmissionTexture)),Promise.all(s)}}class Wo{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_VOLUME}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];return e=e.extensions[this.name],t.thickness=void 0!==e.thicknessFactor?e.thicknessFactor:0,void 0!==e.thicknessTexture&&s.push(r.assignTexture(t,"thicknessMap",e.thicknessTexture)),t.attenuationDistance=e.attenuationDistance||0,e=e.attenuationColor||[1,1,1],t.attenuationColor=new n.Color(e[0],e[1],e[2]),Promise.all(s)}}class Xo{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_IOR}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(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()}}class qo{constructor(e){this.parser=e,this.name=No.KHR_MATERIALS_SPECULAR}getMaterialType(e){return(e=this.parser.json.materials[e]).extensions&&e.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser;if(!(e=r.json.materials[e]).extensions||!e.extensions[this.name])return Promise.resolve();const s=[];e=e.extensions[this.name];var i=(t.specularIntensity=void 0!==e.specularFactor?e.specularFactor:1,void 0!==e.specularTexture&&s.push(r.assignTexture(t,"specularIntensityMap",e.specularTexture)),e.specularColorFactor||[1,1,1]);return t.specularColor=new n.Color(i[0],i[1],i[2]),void 0!==e.specularColorTexture&&s.push(r.assignTexture(t,"specularColorMap",e.specularColorTexture).then((function(e){e.encoding=n.sRGBEncoding}))),Promise.all(s)}}class Yo{constructor(e){this.parser=e,this.name=No.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json;if(!(s=r.textures[e]).extensions||!s.extensions[this.name])return null;var s=s.extensions[this.name],n=t.options.ktx2Loader;if(n)return t.loadTextureImage(e,s.source,n);if(r.extensionsRequired&&0<=r.extensionsRequired.indexOf(this.name))throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}}class Zo{constructor(e){this.parser=e,this.name=No.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json;if(!(n=s.textures[e]).extensions||!n.extensions[t])return null;var n=n.extensions[t];const i=s.images[n.source];let a=r.textureLoader;return i.uri&&null!==(n=r.options.manager.getHandler(i.uri))&&(a=n),this.detectSupport().then((function(n){if(n)return r.loadTextureImage(e,i,a);if(s.extensionsRequired&&0<=s.extensionsRequired.indexOf(t))throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Qo{constructor(e){this.name=No.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json;if((e=t.bufferViews[e]).extensions&&e.extensions[this.name]){const r=e.extensions[this.name];e=this.parser.getDependency("buffer",r.buffer);const s=this.parser.options.meshoptDecoder;if(s&&s.supported)return Promise.all([e,s.ready]).then((function(e){var t=r.byteOffset||0,n=r.byteLength||0,i=r.count,a=r.byteStride,o=new ArrayBuffer(i*a);return e=new Uint8Array(e[0],t,n),s.decodeGltfBuffer(new Uint8Array(o),i,a,e,r.mode,r.filter),o}));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}}const Ko="glTF";class Jo{constructor(e){this.name=No.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:n.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ko)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");var r=this.header.length-12;const s=new DataView(e,12);let i=0;for(;i<r;){var a,o=s.getUint32(i,!0),l=(i+=4,s.getUint32(i,!0));i+=4,1313821514===l?(a=new Uint8Array(e,12+i,o),this.content=n.LoaderUtils.decodeText(a)):5130562===l&&(a=12+i,this.body=e.slice(a,a+o)),i+=o}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class $o{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=No.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){var r=this.json;const s=this.dracoLoader;var n=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes;const a={},o={},l={};for(const e in i){var h=ul[e]||e.toLowerCase();a[h]=i[e]}for(const t in e.attributes){var c,u,d=ul[t]||t.toLowerCase();void 0!==i[t]&&(c=r.accessors[e.attributes[t]],u=ol[c.componentType],l[d]=u,o[d]=!0===c.normalized)}return t.getDependency("bufferView",n).then((function(e){return new Promise((function(t){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const s=e.attributes[t];var r=o[t];void 0!==r&&(s.normalized=r)}t(e)}),a,l)}))}))}}class el{constructor(){this.name=No.KHR_TEXTURE_TRANSFORM}extendTexture(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}}class tl extends n.MeshStandardMaterial{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),r=["#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"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),a=["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"),o={specular:{value:(new n.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",r).replace("#include <roughnessmap_fragment>",s).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",a)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){(o.specularMap.value=e)?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){(o.glossinessMap.value=e)?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(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}}class rl{constructor(){this.name=No.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return tl}extendParams(e,t,r){var s;t=t.extensions[this.name],e.color=new n.Color(1,1,1),e.opacity=1;const i=[];return Array.isArray(t.diffuseFactor)&&(s=t.diffuseFactor,e.color.fromArray(s),e.opacity=s[3]),void 0!==t.diffuseTexture&&i.push(r.assignTexture(e,"map",t.diffuseTexture)),e.emissive=new n.Color(0,0,0),e.glossiness=void 0!==t.glossinessFactor?t.glossinessFactor:1,e.specular=new n.Color(1,1,1),Array.isArray(t.specularFactor)&&e.specular.fromArray(t.specularFactor),void 0!==t.specularGlossinessTexture&&(s=t.specularGlossinessTexture,i.push(r.assignTexture(e,"glossinessMap",s)),i.push(r.assignTexture(e,"specularMap",s))),Promise.all(i)}createMaterial(e){const t=new tl(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=n.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}}class sl{constructor(){this.name=No.KHR_MESH_QUANTIZATION}}class nl extends n.Interpolant{constructor(e,t,r,s){super(e,t,r,s)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,n=e*s*3+s;for(let e=0;e!==s;e++)t[e]=r[n+e];return t}}nl.prototype.beforeStart_=nl.prototype.copySampleValue_,nl.prototype.afterEnd_=nl.prototype.copySampleValue_,nl.prototype.interpolate_=function(e,t,r,s){const n=this.resultBuffer;var i=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=s-t,c=e*l,u=c-l,d=-2*(t=(r=(s=(r-t)/h)*s)*s)+3*r,p=t-r,m=1-d,f=p-r+s;for(let e=0;e!==a;e++){var g=i[u+e+a],v=i[u+e+o]*h,x=i[c+e+a],y=i[c+e]*h;n[e]=m*g+f*v+d*x+p*y}return n};const il=new n.Quaternion;class al extends nl{interpolate_(e,t,r,s){return e=super.interpolate_(e,t,r,s),il.fromArray(e).normalize().toArray(e),e}}const ol={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ll={9728:n.NearestFilter,9729:n.LinearFilter,9984:n.NearestMipmapNearestFilter,9985:n.LinearMipmapNearestFilter,9986:n.NearestMipmapLinearFilter,9987:n.LinearMipmapLinearFilter},hl={33071:n.ClampToEdgeWrapping,33648:n.MirroredRepeatWrapping,10497:n.RepeatWrapping},cl={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ul={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},dl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},pl={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function ml(e,t,r){for(const s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function fl(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function gl(e){let t="";var r=Object.keys(e).sort();for(let s=0,n=r.length;s<n;s++)t+=r[s]+":"+e[r[s]]+";";return t}function vl(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.")}}class xl{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Fo,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 ko(this.options.manager):this.textureLoader=new n.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new n.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,s=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.options.myOptions.helper.processInput(s,this),...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){const i={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};ml(n,i,s),fl(i,s),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){r.options.myOptions.helper.done(i),e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[];var t=this.json.skins||[];const r=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){var s=t[r].joints;for(let t=0,r=s.length;t<r;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){var n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(r[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const s=r.clone(),n=(e,t)=>{var r,s,i=this.associations.get(e);for([r,s]of(null!=i&&this.associations.set(t,i),e.children.entries()))n(s,t.children[r])};return n(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){var r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins),r=(t.unshift(this),[]);for(let n=0;n<t.length;n++){var s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){var r=e+":"+t;let s=this.cache.get(r);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this.loadNode(t);break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this.loadAnimation(t);break;case"camera":s=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const 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[No.KHR_BINARY_GLTF].body);const s=this.options;return new Promise((function(e,i){r.load(n.LoaderUtils.resolveURL(t.uri,s.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))}loadAccessor(e){const t=this,r=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse)return Promise.resolve(null);const i=[];return void 0!==s.bufferView?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),void 0!==s.sparse&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then((function(e){var i=e[0],a=cl[s.type];const o=ol[s.componentType];var l=o.BYTES_PER_ELEMENT,h=l*a,c=s.byteOffset||0,u=void 0!==s.bufferView?r.bufferViews[s.bufferView].byteStride:void 0,d=!0===s.normalized;let p,m;if(u&&u!==h){h=Math.floor(c/u);var f="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+h+":"+s.count;let e=t.cache.get(f);e||(p=new o(i,h*u,s.count*u/l),e=new n.InterleavedBuffer(p,u/l),t.cache.add(f,e)),m=new n.InterleavedBufferAttribute(e,a,c%u/l,d)}else p=null===i?new o(s.count*a):new o(i,c,s.count*a),m=new n.BufferAttribute(p,a,d);if(void 0!==s.sparse){h=cl.SCALAR;const t=ol[s.sparse.indices.componentType];f=s.sparse.indices.byteOffset||0,u=s.sparse.values.byteOffset||0;var g=new t(e[1],f,s.sparse.count*h),v=new o(e[2],u,s.sparse.count*a);null!==i&&(m=new n.BufferAttribute(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=g.length;e<t;e++){var x=g[e];if(m.setX(x,v[e*a]),2<=a&&m.setY(x,v[e*a+1]),3<=a&&m.setZ(x,v[e*a+2]),4<=a&&m.setW(x,v[e*a+3]),5<=a)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){var t=this.json;const r=this.options;var s=t.textures[e].source;t=t.images[s];let n=this.textureLoader;return t.uri&&null!==(t=r.manager.getHandler(t.uri))&&(n=t),this.loadTextureImage(e,s,n)}loadTextureImage(e,t,r){const s=this,i=this.json,a=i.textures[e];var o=((o=i.images[t]).uri||o.bufferView)+":"+a.sampler;return this.textureCache[o]?this.textureCache[o]:(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=ll[r.magFilter]||n.LinearFilter,t.minFilter=ll[r.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=hl[r.wrapS]||n.RepeatWrapping,t.wrapT=hl[r.wrapT]||n.RepeatWrapping,s.associations.set(t,{textures:e}),s.options.myOptions.helper.material.processTexture({texture:t,textureDef:a}),t})).catch((function(){return null})),this.textureCache[o]=t)}loadImageSource(e,t){var r=this.json;const s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((function(e){return e.clone()})).catch((function(e){throw e}));const i=r.images[e],a=self.URL||self.webkitURL;let o=i.uri||"";if(void 0!==i.bufferView)o=this.getDependency("bufferView",i.bufferView).then((function(e){return e=new Blob([e],{type:i.mimeType}),o=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(o).then((function(e){return new Promise((function(r,i){let a=r;!0===t.isImageBitmapLoader&&(a=function(e,t){const s=new n.Texture(e);s.needsUpdate=!0,r({texture:s,blob:t})}),t.load(n.LoaderUtils.resolveURL(e,s.path),a,void 0,i)}))})).then((function(e){const{texture:t,blob:r}=e;return t.userData.url=o,t.userData.blob=r,t.url=o,t})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e})),this.sourceCache[e]=r}assignTexture(e,t,r){const s=this;return this.getDependency("texture",r.index).then((function(n){var i,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."),s.extensions[No.KHR_TEXTURE_TRANSFORM]&&(i=void 0!==r.extensions?r.extensions[No.KHR_TEXTURE_TRANSFORM]:void 0)&&(a=s.associations.get(n),n=s.extensions[No.KHR_TEXTURE_TRANSFORM].extendTexture(n,i),s.associations.set(n,a)),e[t]=n}))}assignFinalMaterial(e){const t=e.geometry;let r=e.material;var s=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){var o="PointsMaterial:"+r.uuid;let e=this.cache.get(o);e||(e=new n.PointsMaterial,n.Material.prototype.copy.call(e,r),e.color.copy(r.color),e.map=r.map,e.sizeAttenuation=!1,this.cache.add(o,e)),r=e}else if(e.isLine){o="LineBasicMaterial:"+r.uuid;let e=this.cache.get(o);e||(e=new n.LineBasicMaterial,n.Material.prototype.copy.call(e,r),e.color.copy(r.color),this.cache.add(o,e)),r=e}if(s||i||a){let e="ClonedMaterial:"+r.uuid+":",t=(r.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),s&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),a&&(e+="flat-shading:"),this.cache.get(e));t||(t=r.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}r.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),this.options.myOptions.helper.material.process({material:r,materialDef:r.userData,model:e}),e.material=r}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){const t=this;var r=this.json;const s=this.extensions,i=r.materials[e];let a;const o={},l=[];if((r=i.extensions||{})[No.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=s[No.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];a=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else if(r[No.KHR_MATERIALS_UNLIT]){const e=s[No.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else r=i.pbrMetallicRoughness||{},o.color=new n.Color(1,1,1),o.opacity=1,Array.isArray(r.baseColorFactor)&&(h=r.baseColorFactor,o.color.fromArray(h),o.opacity=h[3]),void 0!==r.baseColorTexture&&l.push(t.assignTexture(o,"map",r.baseColorTexture)),o.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,o.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",r.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",r.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))));!0===i.doubleSided&&(o.side=n.DoubleSide);var h=i.alphaMode||"OPAQUE";return"BLEND"===h?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===h&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==n.MeshBasicMaterial&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new n.Vector2(1,1),void 0!==i.normalTexture.scale&&(r=i.normalTexture.scale,o.normalScale.set(r,r))),void 0!==i.occlusionTexture&&a!==n.MeshBasicMaterial&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==n.MeshBasicMaterial&&(o.emissive=(new n.Color).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&a!==n.MeshBasicMaterial&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let r;return r=a===tl?s[No.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new a(o),i.name&&(r.name=i.name),r.map&&(r.map.encoding=n.sRGBEncoding),r.emissiveMap&&(r.emissiveMap.encoding=n.sRGBEncoding),fl(r,i),t.associations.set(r,{materials:e}),i.extensions&&ml(s,r,i),r}))}createUniqueName(e){var t=n.PropertyBinding.sanitizeNodeName(e||"");let r=t;for(let e=1;this.nodeNamesUsed[r];++e)r=t+"_"+e;return this.nodeNamesUsed[r]=!0,r}loadGeometries(e){const t=this,r=this.extensions,s=this.primitiveCache,i=[];for(let h=0,c=e.length;h<c;h++){var a=e[h],o=function(e){var t=e.extensions&&e.extensions[No.KHR_DRACO_MESH_COMPRESSION];return t?"draco:"+t.bufferView+":"+t.indices+":"+gl(t.attributes):e.indices+":"+gl(e.attributes)+":"+e.mode}(a),l=s[o];if(l)i.push(l.promise);else{let e;e=a.extensions&&a.extensions[No.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[No.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return yl(r,e,t)}))}(a):yl(new n.BufferGeometry,a,t),s[o]={primitive:a,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this;var r,s=this.json;const i=this.extensions,a=s.meshes[e],o=a.primitives,l=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(r=this.cache).DefaultMaterial&&(r.DefaultMaterial=new n.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:n.FrontSide})),r.DefaultMaterial):this.getDependency("material",o[e].material);t.then((e=>{})),l.push(t)}return l.push(t.loadGeometries(o)),Promise.all(l).then((function(r){var s=r.slice(0,r.length-1),l=r[r.length-1];const h=[];for(let r=0,g=l.length;r<g;r++){var c=l[r],u=o[r];let g;var d=s[r];if(4===u.mode||5===u.mode||6===u.mode||void 0===u.mode)!0!==(g=new(!0===a.isSkinnedMesh?n.SkinnedMesh:n.Mesh)(c,d)).isSkinnedMesh||g.geometry.attributes.skinWeight.normalized||g.normalizeSkinWeights(),5===u.mode?g.geometry=wl(g.geometry,n.TriangleStripDrawMode):6===u.mode&&(g.geometry=wl(g.geometry,n.TriangleFanDrawMode));else if(1===u.mode)g=new n.LineSegments(c,d);else if(3===u.mode)g=new n.Line(c,d);else if(2===u.mode)g=new n.LineLoop(c,d);else{if(0!==u.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);g=new n.Points(c,d)}if(0<Object.keys(g.geometry.morphAttributes).length){f=p=void 0;var p=g,m=a;if(p.updateMorphTargets(),void 0!==m.weights)for(let e=0,t=m.weights.length;e<t;e++)p.morphTargetInfluences[e]=m.weights[e];if(m.extras&&Array.isArray(m.extras.targetNames)){var f=m.extras.targetNames;if(p.morphTargetInfluences.length===f.length){p.morphTargetDictionary={};for(let e=0,t=f.length;e<t;e++)p.morphTargetDictionary[f[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}g.name=t.createUniqueName(a.name||"mesh_"+e),fl(g,a),u.extensions&&ml(i,g,u),t.assignFinalMaterial(g),h.push(g)}for(let r=0,s=h.length;r<s;r++)t.associations.set(h[r],{meshes:e,primitives:r});if(1===h.length)return h[0];const g=new n.Group;t.associations.set(g,{meshes:e});for(let e=0,t=h.length;e<t;e++)g.add(h[e]);return g}))}loadCamera(e){let t;var r=(e=this.json.cameras[e])[e.type];if(r)return"perspective"===e.type?t=new n.PerspectiveCamera(n.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===e.type&&(t=new n.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),e.name&&(t.name=this.createUniqueName(e.name)),fl(t,e),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const 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}))}loadAnimation(e){const t=this.json.animations[e],r=[],s=[],i=[],a=[],o=[];for(let e=0,n=t.channels.length;e<n;e++){var l=t.channels[e],h=t.samplers[l.sampler],c=void 0!==(l=l.target).node?l.node:l.id,u=void 0!==t.parameters?t.parameters[h.input]:h.input,d=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",c)),s.push(this.getDependency("accessor",u)),i.push(this.getDependency("accessor",d)),a.push(h),o.push(l)}return Promise.all([Promise.all(r),Promise.all(s),Promise.all(i),Promise.all(a),Promise.all(o)]).then((function(r){var s=r[0],i=r[1],a=r[2],o=r[3],l=r[4];const h=[];for(let e=0,t=s.length;e<t;e++){const t=s[e];var c=i[e],u=a[e],d=o[e],p=l[e];if(void 0!==t){let e;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,dl[p.path]){case dl.weights:e=n.NumberKeyframeTrack;break;case dl.rotation:e=n.QuaternionKeyframeTrack;break;default:e=n.VectorKeyframeTrack}var m=t.name||t.uuid,f=void 0!==d.interpolation?pl[d.interpolation]:n.InterpolateLinear;const r=[];dl[p.path]===dl.weights?t.traverse((function(e){e.morphTargetInfluences&&r.push(e.name||e.uuid)})):r.push(m);let s=u.array;if(u.normalized){var g=vl(s.constructor);const e=new Float32Array(s.length);for(let t=0,r=s.length;t<r;t++)e[t]=s[t]*g;s=e}for(let t=0,i=r.length;t<i;t++){const i=new e(r[t]+"."+dl[p.path],c.array,s,f);"CUBICSPLINE"===d.interpolation&&(i.createInterpolant=function(e){return new(this instanceof n.QuaternionKeyframeTrack?al:nl)(this.times,this.values,this.getValueSize()/3,e)},i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),h.push(i)}}}return r=t.name||"animation_"+e,new n.AnimationClip(r,void 0,h)}))}createNodeMesh(e){var t=this.json;const r=this,s=t.nodes[e];return void 0===s.mesh?null:r.getDependency("mesh",s.mesh).then((function(e){const t=r._getNodeRef(r.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,r=s.weights.length;t<r;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){var t=this.json;const r=this.extensions,s=this,i=t.nodes[e],a=i.name?s.createUniqueName(i.name):"";return function(){const t=[];var r=s._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return r&&t.push(r),void 0!==i.camera&&t.push(s.getDependency("camera",i.camera).then((function(e){return s._getNodeRef(s.cameraCache,i.camera,e)}))),s._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if((o=!0===i.isBone?new n.Bone:1<t.length?new n.Group:1===t.length?t[0]:new n.Object3D)!==t[0])for(let e=0,r=t.length;e<r;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),fl(o,i),i.extensions&&ml(r,o,i),void 0!==i.matrix){const e=new n.Matrix4;e.fromArray(i.matrix),o.applyMatrix4(e)}else void 0!==i.translation&&o.position.fromArray(i.translation),void 0!==i.rotation&&o.quaternion.fromArray(i.rotation),void 0!==i.scale&&o.scale.fromArray(i.scale);return s.associations.has(o)||s.associations.set(o,{}),s.associations.get(o).nodes=e,s.options.myOptions.helper.processNode({node:o,nodeDef:i})||o}))}loadScene(e){var t=this.json,r=this.extensions;e=this.json.scenes[e];const s=this;s.options.myOptions;const i=new n.Group;e.name&&(i.name=s.createUniqueName(e.name)),fl(i,e),e.extensions&&ml(r,i,e);var a=e.nodes||[];const o=[];for(let e=0,r=a.length;e<r;e++)o.push(function e(t,r,s,i){const a=s.nodes[t];return i.getDependency("node",t).then((function(e){if(void 0===a.skin)return e;let t;return i.getDependency("skin",a.skin).then((function(e){t=e;const r=[];for(let e=0,s=t.joints.length;e<s;e++)r.push(i.getDependency("node",t.joints[e]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){const s=[],i=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){s.push(a);const r=new n.Matrix4;void 0!==t.inverseBindMatrices&&r.fromArray(t.inverseBindMatrices.array,16*e),i.push(r)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new n.Skeleton(s,i),e.matrixWorld)}})),e}))})).then((function(t){r.add(t);const n=[];if(a.children){const r=a.children;for(let a=0,o=r.length;a<o;a++){const o=r[a];n.push(e(o,t,s,i))}}return Promise.all(n)}))}(a[e],i,t,s));return Promise.all(o).then((function(){return console.log(i,i.children,"scene"),s.options.myOptions?.models.push(i),s.associations=(e=>{const t=new Map;for(var[r,i]of s.associations)(r instanceof n.Material||r instanceof n.Texture)&&t.set(r,i);return e.traverse((e=>{var r=s.associations.get(e);null!=r&&t.set(e,r)})),t})(i),i}))}}function yl(e,t,r){var s=t.attributes;const i=[];for(const t in s){var a=ul[t]||t.toLowerCase();a in e.attributes||i.push(function(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}(s[t],a))}void 0===t.indices||e.index||(o=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)})),i.push(o)),fl(e,t);{var o=e,l=t,h=r,c=l.attributes;const s=new n.Box3;if(void 0!==c.POSITION){var u=(c=h.json.accessors[c.POSITION]).min,d=c.max;if(void 0===u||void 0===d)console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");else{s.set(new n.Vector3(u[0],u[1],u[2]),new n.Vector3(d[0],d[1],d[2])),c.normalized&&(u=vl(ol[c.componentType]),s.min.multiplyScalar(u),s.max.multiplyScalar(u));var p=l.targets;if(void 0!==p){const e=new n.Vector3,t=new n.Vector3;for(let r=0,s=p.length;r<s;r++){var m,f,g=p[r];void 0!==g.POSITION&&(f=(g=h.json.accessors[g.POSITION]).min,m=g.max,void 0!==f&&void 0!==m?(t.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),t.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),t.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),g.normalized&&(f=vl(ol[g.componentType]),t.multiplyScalar(f)),e.max(t)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."))}s.expandByVector(e)}o.boundingBox=s;const e=new n.Sphere;s.getCenter(e.center),e.radius=s.min.distanceTo(s.max)/2,o.boundingSphere=e}}}return Promise.all(i).then((function(){if(void 0===t.targets)return e;{var s=e,n=t.targets,i=r;let h=!1,c=!1,u=!1;for(let e=0,t=n.length;e<t;e++){var a=n[e];if(void 0!==a.POSITION&&(h=!0),void 0!==a.NORMAL&&(c=!0),void 0!==a.COLOR_0&&(u=!0),h&&c&&u)break}if(!h&&!c&&!u)return Promise.resolve(s);const d=[],p=[],m=[];for(let e=0,t=n.length;e<t;e++){var o,l=n[e];h&&(o=void 0!==l.POSITION?i.getDependency("accessor",l.POSITION):s.attributes.position,d.push(o)),c&&(o=void 0!==l.NORMAL?i.getDependency("accessor",l.NORMAL):s.attributes.normal,p.push(o)),u&&(l=void 0!==l.COLOR_0?i.getDependency("accessor",l.COLOR_0):s.attributes.color,m.push(l))}return Promise.all([Promise.all(d),Promise.all(p),Promise.all(m)]).then((function(e){var t=e[0],r=e[1];return e=e[2],h&&(s.morphAttributes.position=t),c&&(s.morphAttributes.normal=r),u&&(s.morphAttributes.color=e),s.morphTargetsRelative=!0,s}))}}))}function wl(e,t){let r=e.getIndex();if(null===r){const t=[];var s=e.getAttribute("position");if(void 0===s)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}var i=r.count-2;const a=[];if(t===n.TriangleFanDrawMode)for(let e=1;e<=i;e++)a.push(r.getX(0)),a.push(r.getX(e)),a.push(r.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(a.push(r.getX(e)),a.push(r.getX(e+1)),a.push(r.getX(e+2))):(a.push(r.getX(e+2)),a.push(r.getX(e+1)),a.push(r.getX(e)));a.length/3!=i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(a),o}class bl{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,O.js)(t,((e,t)=>{var s;(t=this.textureIns[t])&&(this.runScene.optionsEx.options.lazyLoadTexture&&"scene"===(null==(s=this.parser)?void 0:s.json.asset.ex.type)&&(null==(s=this.parser)?void 0:s.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:s,type:n,material:i}=r;this.runScene.uniqueEx.texture.addMaterial(s,{material:i,type:n}),i[n]=s,i.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,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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;console.log(e,"materialDef.id"),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,O.js)(e,((e,t)=>{var{format:t,center:r,rotation:s,offset:n,repeat:i}=t;const a=this.textureIns[e];a&&(a.format=t,void 0!==i&&(({x:e,y:t}="object"==typeof i?i:{x:i,y:i}),a.repeat.x=e,a.repeat.y=t),void 0!==r&&(({x:i,y:e}="object"==typeof r?r:{x:r,y:r}),a.center.x=i,a.center.y=e),void 0!==n&&(({x:t,y:r}="object"==typeof n?n:{x:n,y:n}),a.offset.x=t,a.offset.y=r),s&&(a.rotation=s),this.runScene.textureEx.bindData(a))}))}processMaterialMap(e){(0,O.js)(e,((e,t)=>{const{material:r,models:s}=this.materialIns[e];if(r){var{normal:e,textures:n}=t;if(e.type){const t=(0,O.js)(n,((e,t)=>({type:e,texture:this.textureIns[t]}))),i=this.runScene.materialEx.getDataByType(e.type,{normal:e,textures:t,models:s,material:r});if(this.runScene.materialEx.parseNromals(e,i),!i)return;s.map((e=>e.material=i))}else this.runScene.optionsEx.options.notTexture||this.processBaseMaterialTextures({material:r,textures:n}),this.runScene.materialEx.parseNromals(e,r),s.map((e=>e.material=r));r.needsUpdate=!0}}))}}class Sl{constructor(e){this.runScene=e}done(e){var t,r,s,n;e.asset.ex&&(({camera:e,lights:t,sceneEx:r,options:s,controls:n}=e.asset.ex),this.camera(e),this.controls(n),this.lights(t),this.ex(r),this.options(s))}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:s,name:n,userData:i}=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=s,a.name=n,a.updateProjectionMatrix(),a.userData.id=i.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 s=this.runScene.sceneEx.get();e&&(({color:e,near:t,far:r}=e),s.fog=new n.Fog(e,t,r),this.runScene.optionsEx.cb.setScene.cb({scene:s,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 Tl{constructor(e){this.parser=null,this.helperModels=[],this.nodeType={MySpriteMaterial:xs},this.cloneMap={},this.runScene=e,this.material=new bl(e),this.scene=new Sl(e)}processInput(e,t){return function(e,t,r,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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:s}=e;if(console.log(s,r,"nodeDef"),(0,O.js)(this.runScene.modelEx.defNodeMap,((e,t)=>{var n=s[e];null!=n&&(r[e]=n)})),s.extras){const{layers:i,normal:a,local:o,cloneId:l,id:h}=s.extras;if(l&&(this.cloneMap[l]||(this.cloneMap[l]=new Set),h&&this.cloneMap[l].add(h)),o&&([e,t,n]=o.split(","),r.position.set(e,t,n)),i&&(r.layers.enable(1),this.runScene.optionsEx.cb.model.setLayers.cb({model:r,val:1})),s.extras.isHelper&&this.helperModels.push(r),a){const s=this.nodeType[null==a?void 0:a.type].modelTools.parseData(r,a);var n=null==(t=null==(e=null==r?void 0:r.material)?void 0:e.userData)?void 0:t.id;if(n){const e=this.material.materialIns[n];if(e){const t=[];e.models.map((e=>{e===r?t.push(s):t.push(e)})),e.models=t}}r=s}}return s.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(),this.runScene.optionsEx.cb.load.done.cb("")}mergeGeometry(){}mergeClone(){this.runScene.optionsEx.options.instanceClone&&((0,O.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:s}=e;const n=new Rr.InstancedMesh(s,r,t.length+1);return[e,...t].map(((e,t)=>{n.setMatrixAt(t,e.matrix)})),n})(r,e),this.runScene.modelEx.add(t,r.parent),this.runScene.modelEx.remove(r,!1))})),console.log(this.cloneMap,"this.cloneMap"))}sceneEx(e){const t=this.runScene.sceneEx.get();var r=this.material.materialIns,{materialId:e,backgroundMapping:s,backgroundColor:i,fog:a}=e.asset.ex.sceneEx;if(e&&(e=null==(r=r[e])?void 0:r.material)){const{map:r,envMap:n}=e;r&&(r.mapping=s||300,r.needsUpdate=!0,this.runScene.sceneEx.setBackground(r,!1),r.userData.isBackgroud=!0),n&&(t.environment=this.runScene.textureEx.toThree(n))}i&&(t.background=new n.Color("#"+i)),a&&(({color:r,far:e,near:s}=a),t.fog=new n.Fog("#"+r,s,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 Ml{constructor(e){this.dracoPath="./draco/",this._gltf=new Bo,this.runScene=e;const t=new Io;t.setDecoderPath((null==(e=this.runScene.optionsEx.options)?void 0:e.decodePath)||this.dracoPath),this._gltf.dracoLoader=t}parse(e){return new Promise((t=>{try{e instanceof ArrayBuffer&&this._gltf.parse(e,"",(e=>{t(e),this.afterParse(e.parser.options.myOptions,e)}),(e=>{console.log(e,"a")}),{rootModel:this.runScene.assetsEx.get().scene,models:[],helper:new Tl(this.runScene),runScene:this.runScene})}catch(e){console.log(e,"e")}}))}beforeParse(e){"scene"===e&&this.runScene.optionsEx.sceneOptions.loaded&&this.runScene.sceneEx.clean()}afterParse(e,t){const r=e.models;if("material"===t.asset.ex.type){var s,[s]=r;if(!(s=this.runScene.sceneEx.cleanUnlessLevel(s).material))return;this.runScene.materialEx.add(s);var n=this.runScene.modelEx.select;n&&this.runScene.materialEx.resetMaterial(n,s)}else n=r[0].children.filter((e=>{if(!this.runScene.modelEx.isUnless(e))return"model"===t.asset.ex.type&&(e.userData.id=(0,Qr.getId)()),e})),this.runScene.modelEx.add(n,void 0,!1,!1,!1),"scene"===t.asset.ex.type&&this.runScene.timeLineEx.parseSavedGroupMap(t.asset.ex.timeLine||{}),this.runScene.modelEx.selectNull(),this.runScene.helperEx.unfocus(),e.helper.mergeClone();console.log(t,e,"json,options"),(0,O.js)(t,(e=>delete t[e])),t=null,this.runScene.optionsEx.sceneOptions.loaded=!0}}class _l{constructor(e){this.imgBitMap=new n.ImageBitmapLoader,this.object=new n.ObjectLoader,this.runScene=e,this.gltf=new Ml(e)}}var El=a(185);class Pl{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,El.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,s,n,i){"position"!==t&&(n=s,i=r);const a=this.getSelectedList("value");var{x:n,y:o,z:l}=n;const h=n-i.x,c=o-i.y,u=l-i.z,d=[new Ts({target:e,info:t,oldV3:this.runScene.modelEx.cloneV3(r),newV3:s,runScene:this.runScene}).execute()];a.map((r=>{if(r!==e){var{x:s,y:n,z:i}=r[t],s=s+=h,n=n+=c,i=i+=u;let e=r[t].clone();e.x=s,e.y=n,e.z=i,s=new Ts({target:r,info:t,oldV3:this.runScene.modelEx.cloneV3(r[t]),newV3:e,runScene:this.runScene}).execute(),d.push(s),this.boxHelperMap[r.uuid].setFromObject(r)}})),this.runScene.undoEx.addUndo(d)}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 n.Group;const t=new n.Group;this.runScene.modelEx.add(e,void 0,!1),this.runScene.modelEx.add(t);var r=[...this.getSelectedList("value")],s=(this.runScene.optionsEx.cb.model.multipDrop.cb(this.getSelectedList("value"),e),qr().group.getCenter(e));t.position.copy(s),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 n.Group;return e.forEach((e=>t.add(e.clone()))),this.setEmpty(),t}}class Cl{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 Rl{constructor(){this.resize=new Cl,this.setSelectMaterial=new Cl,this.setScene=new Cl,this.reset=new Cl,this.render=new Cl,this.baseLog=new Cl,this.inited=new Cl,this.texture={add:new Cl,remove:new Cl},this.model={setSelect:new Cl,add:new Cl,remove:new Cl,multipDrop:new Cl,focus:new Cl,unFocus:new Cl,changeName:new Cl,setOpen:new Cl,setMainStatue:new Cl,setVisible:new Cl,setParent:new Cl,setLayers:new Cl,clone:new Cl,dispose:new Cl},this.material={add:new Cl,dispose:new Cl,setName:new Cl},this.unique={material:{add:new Cl}},this.undo={addUndos:new Cl,removeUndos:new Cl,undoByIndex:new Cl,reset:new Cl},this.scene={save:new Cl,saveNet:new Cl},this.timeLine={setProgress:new Cl,playGroup:new Cl,setGroupMap:new Cl,reset:new Cl,closeGroup:new Cl},this.events={key:{g:new Cl},mouse:{move:new Cl,down:new Cl,up:new Cl},pointer:{down:new Cl,up:new Cl}},this.bloom={glow:{setData:new Cl}},this.load={lazyLoadedTexture:new Cl,done:new Cl,models:new Cl}}}function Dl(){var e=0,t=document.createElement("div");function r(e){return t.appendChild(e.dom),e}function s(r){for(var s=0;s<t.children.length;s++)t.children[s].style.display=s===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(),s(++e%t.children.length)}),!1);var n,i=(performance||Date).now(),a=i,o=0,l=r(new Dl.Panel("FPS","#0ff","#002")),h=r(new Dl.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(n=r(new Dl.Panel("MB","#f08","#201"))),s(0),{REVISION:16,dom:t,addPanel:r,showPanel:s,begin:function(){i=(performance||Date).now()},end:function(){o++;var e,t=(performance||Date).now();return h.update(t-i,200),a+1e3<=t&&(l.update(1e3*o/(t-a),100),a=t,o=0,n&&(e=performance.memory,n.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){i=this.end()},domElement:t,setMode:s}}Dl.Panel=function(e,t,r){var s=1/0,n=0,i=Math.round,a=i(window.devicePixelRatio||1),o=80*a,l=48*a,h=3*a,c=2*a,u=3*a,d=15*a,p=74*a,m=30*a,f=document.createElement("canvas"),g=(f.width=o,f.height=l,f.style.cssText="width:80px;height:48px",f.getContext("2d"));return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=r,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(u,d,p,m),{dom:f,update:function(l,v){s=Math.min(s,l),n=Math.max(n,l),g.fillStyle=r,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(i(l)+" "+e+" ("+i(s)+"-"+i(n)+")",h,c),g.drawImage(f,u+a,d,p-a,m,u,d,p-a,m),g.fillRect(u+p-a,d,a,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(u+p-a,d,a,i((1-l/v)*m))}}};const Al=Dl;class Ll{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},this.exporterOptions={compressTexture:!1,notMaterial:!1},this.sceneOptions={loaded:!1},this.setLoadInterval=(()=>{let e=null;return t=>{const{inputInterval:r,cb:s}=t;e&&clearTimeout(e),e=setTimeout((()=>{s(),e=null,clearTimeout(e)}),r)}})(),this.cb=new Rl,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=Al(),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 s;null!=(s=null==(s=this.options)?void 0:s.msg)&&s.show&&("base"===this.options.msg.level&&"base"===t&&this.cb.baseLog.cb(e,r),console.log(e))}}class Il{constructor(e){this.setSize=(e,t)=>{var{w:r,h:s}=this.getDomSize(),r=(e=e||r,t||s);const{camera:n,renderer:i}=this.runScene.assetsEx.get();n.aspect=e/r,n.updateProjectionMatrix(),i.setSize(e,r),this.runScene.bloom.glow.setSize(e,r)},this.runScene=e}create(e){let t=new n.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=n.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 Ol=(e,t)=>{t=(t||{}).removeDom,!(e.render=()=>{})!==t&&e.domElement.remove(),e.setAnimationLoop(null),e.dispose(),e.renderLists&&e.renderLists.dispose()};class Ul{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:s,remove:n}=this.removeMap[r];if(s(e))return t.push(...(0,Yr.multiArrToArr)(n(e)))}t.push(new Ss({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:s}=this.removeMap[t];if(r(e))return s(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 n.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 n.Texture&&(e.userData.isBackgroud=!0);var r=this.get(),s=new us({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(s),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:s}=e;if(r&&(null!=r&&r.dispose(),delete e.geometry),s){{var n=e.material;n.dispose();const t=vs(n);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)})),Ol(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(),Ol(e),t.dispose(),this.runScene.bloom.glow.dispose(),n.Cache.clear()}render(){}create(){return new n.Scene}setEnv(e,t){return function(e,t,r,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.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:s}=e;e=new us({target:e,info:r,oldVal:e[r],newVal:s,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 n.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 es({target:e,typeList:["fog",t],newVal:r}).execute(),this.runScene.undoEx.addUndo(e)}getFogJson(e){const{color:t,far:r,near:s}=e;return{color:t.getHexString(),far:r,near:s}}sreenShotDefFile(){this.runScene.helperEx.unfocus();var{w:e,h:t}=this.runScene.renderEx.getDomSize();const r=this.runScene.assetsEx.get().renderer.domElement,{renderer:s,scene:n,camera:i}=(r.width=1920,r.height=1080,this.runScene.renderEx.setSize(1920,1080),this.runScene.assetsEx.get());s.render(n,i);var a=r.toDataURL("image/webp",1);return a=(0,k.base64ToFile)(a,"screenShot.jpg"),r.width=e,r.height=t,this.runScene.renderEx.setSize(),s.render(n,i),a}}class kl{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,s)=>{const n={},i={};if(e=kl.isNotNow(e)?this.getAllData():e,(0,O.js)(s,((r,s)=>{void 0!==e[r]&&("number"===(s=s.type)?(n[r]=t[r],i[r]=e[r]):"color"===s&&(0,O.js)(e[r],((e,s)=>{var a=r+e;n[a]=t[r][e],i[a]=s})))})),!(0,O.CV)(n))return{begin:n,end:i}};return(t,r,s,n=!1,i)=>{let a=n?s.time:0;const o=Object.keys(t).sort(((e,t)=>n?Number(t)-Number(e):Number(e)-Number(t)));var l=(0,Yr.lastArrayEle)(o),h=n?"0.00":String(s.time);return l!==h&&(t[h]=Object.assign({},l),o.push(h)),o.map((o=>{var l=t[String(o)],h=.001*((h=n?a-o:o-a)<=0?.001:h)*s.speed;a=o;{var c=r,u=l,d=h,p=i;const t={color(e){const{animaData:t,defType:r}=e,s={};(0,O.js)(t,(e=>{var n;-1!==e.indexOf(r)&&(n=e.substring(r.length),["r","g","b"].includes(n)&&(s[n]=t[e]))}));var{r:e,g:n,b:i}=s;if((0,El.isTrue)(e)&&(0,El.isTrue)(n)&&(0,El.isTrue)(i))return s}};return()=>{let r;return{promise:new Promise((s=>{var n=e(u,c,0,p);if(console.log(n,"leftAndRight"),!n)return s(0);var{begin:n,end:i}=n;return r=Fr(n,i,d,(e=>{(0,O.js)(p,((r,s)=>{s=s.type;var n,i=e[r];"number"===s?c[r]=i:"color"===s&&(i=t.color({animaData:e,defType:r}))&&(({r:s,g:i,b:n}=i),c[r].setRGB(s,i,n))}))}),s)})),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 s={};return(0,O.js)(e,(n=>{s[n]=r?"notNow":kl.getValByType(t,n,e)})),s}static getValByType(e,t,r){var s,n;return r=r[t].type,e=e[t],"number"===r?e:"color"===r?(({r:t,g:s,b:n}=e),{r:t,g:s,b:n}):"V3"===r?qr().model.v3ToMap(e):""}static SetTargetByData(e){const{baseType:t,data:r,defType:s,target:n}=e;var i,a;"number"===t?n[s]=r:"color"===t&&(({r:e,g:i,b:a}=r),n[s].setRGB(e,i,a))}getAllData(e=!1){return kl.getAllDefValByType(this.defOptions,this.target,e)}getData(e){return kl.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){kl.setTargetByBetween(e,t,r,this.defOptions,this.target)}clone(e){var{data:t,type:r}=this;const s=new(0,Fl[r])(e);return s.data=t,s}reset(){(0,O.js)(this.defOptions,((e,t)=>{kl.SetTargetByData({baseType:t.type,data:kl.getValByType(this.beginData,e,this.defOptions),target:this.target,defType:e})}))}remove(){delete this.target.userData.isTimeLineUsed}}kl.setTargetByBetween=(()=>{const e=(e,t,r)=>e!==t?(t-e)*r+e:e;return(t,r,s,n,i)=>{(0,O.js)(n,((n,a)=>{var o,l,h,c,u,d;a=a.type,void 0!==t[n]&&void 0!==r[n]&&kl.SetTargetByData({baseType:a,data:(o=t[n],l=r[n],h=s,"number"===a?e(o,l,h):"color"===a?(({r:a,g:o,b:c}=o),({r:l,g:u,b:d}=l),{r:e(a,l,h),g:e(o,u,h),b:e(c,d,h)}):void 0),defType:n,target:i})}))}})();const Bl=kl,Fl={model:class extends Bl{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:s,z:n}=e,{x:t,y:i,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:s!==i?(i-s)*r+s:s,z:n!==a?(a-n)*r+n:n}};return(t,r,s)=>{var n,{position:t,scale:i,rotation:a}=t,{position:r,scale:o,rotation:l}=r;t&&r&&(({x:t,y:r,z:n}=e(t,r,s)),this.target.position.set(t,r,n)),i&&o&&(({x:t,y:r,z:n}=e(i,o,s)),this.target.scale.set(t,r,n)),a&&l&&(({x:i,y:o,z:t}=e(a,l,s)),this.target.rotation.set(i,o,t))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:s,rotation:n}=t,{position:e,scale:i,rotation:a}=Bl.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},i?{sx:s.x,sy:s.y,sz:s.z}:{},a?{rx:n.x,ry:n.y,rz:n.z}:{}),end:Object.assign({},r.curve?{ease:"none"}:{},e?{px:e.x,py:e.y,pz:e.z}:{},i?{sx:i.x,sy:i.y,sz:i.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{})}};return(t,r,s,n=!1)=>{let i=n?s.time:0;const a=Object.keys(t).sort(((e,t)=>n?Number(t)-Number(e):Number(e)-Number(t)));var o=(0,Yr.lastArrayEle)(a),l=n?"0.00":String(s.time)+".00";return o!==l&&(console.log(o,"last"),t[l]={position:"notNow",rotation:"notNow",scale:"notNow"},a.push(l)),a.map((a=>{var o,l,h,c,u=t[String(a)],d=.001*((d=n?i-a:a-i)<=0?.001:d)*s.speed;return i=a,o=r,l=u,h=d,c=s,()=>{let t;return{promise:new Promise((r=>{var{begin:s,end:n}=e(l,o,c);return t=Fr(s,n,h,(e=>{var{px:e,py:t,pz:r,sx:s,sy:n,sz:i,rx:a,ry:h,rz:c}=e;l.position&&o.position.set(e,t,r),l.scale&&o.scale.set(s,n,i),l.rotation&&o.rotation.set(a,h,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 Bl{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:s,z:n}=e,{x:t,y:i,z:a}=t;return{x:e!==t?(t-e)*r+e:e,y:s!==i?(i-s)*r+s:s,z:n!==a?(a-n)*r+n:n}};return(t,r,s)=>{var n,{position:t,scale:i,rotation:a,target:o}=t,{position:r,scale:l,rotation:h,target:c}=r;t&&r&&(({x:t,y:r,z:n}=e(t,r,s)),this.target.position.set(t,r,n)),i&&l&&(({x:t,y:r,z:n}=e(i,l,s)),this.target.scale.set(t,r,n)),a&&h&&(({x:i,y:l,z:t}=e(a,h,s)),this.target.rotation.set(i,l,t)),o&&c&&(({x:r,y:n,z:a}=e(o,c,s)),this.controls.target.set(r,n,a))}})(),this.getAnimaByModelData=(()=>{const e=(e,t,r)=>{var{position:t,scale:s,rotation:n}=t,{position:e,scale:i,rotation:a,target:o}=Bl.isNotNow(e)?this.getAllData():e;return{begin:Object.assign({},e?{px:t.x,py:t.y,pz:t.z}:{},i?{sx:s.x,sy:s.y,sz:s.z}:{},a?{rx:n.x,ry:n.y,rz:n.z}:{},o?{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}:{},i?{sx:i.x,sy:i.y,sz:i.z}:{},a?{rx:a.x,ry:a.y,rz:a.z}:{},o?{tx:o.x,ty:o.y,tz:o.z}:{})}},t=(t,r,s,n)=>()=>{let i;return{promise:new Promise((a=>{var{begin:o,end:l}=e(r,t,n);return i=Fr(o,l,s,(e=>{var{px:e,py:s,pz:n,sx:i,sy:a,sz:o,rx:l,ry:h,rz:c,tx:u,ty:d,tz:p}=e;r.position&&t.position.set(e,s,n),r.scale&&t.scale.set(i,a,o),r.rotation&&t.rotation.set(l,h,c),r.target&&this.controls.target.set(u,d,p)}),a)})),anima:Fr}};return(e,r,s,n=!1)=>{let i=n?s.time:0;const a=Object.keys(e).sort(((e,t)=>n?Number(t)-Number(e):Number(e)-Number(t)));var o=(0,Yr.lastArrayEle)(a),l=n?"0.00":String(s.time);return o!==l&&(e[l]=Object.assign({},o),a.push(l)),a.map((a=>{var o=e[String(a)],l=.001*((l=n?i-a:a-i)<=0?.001:l)*s.speed;return i=a,t(r,o,l,s)}))}})(),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:s}=this.target;return{position:e?"notNow":qr().model.v3ToMap(t),scale:e?"notNow":qr().model.v3ToMap(r),rotation:e?"notNow":qr().model.v3ToMap(s),target:e?"notNow":qr().model.v3ToMap(this.controls.target)}}getData(e){var{position:t,scale:r,rotation:s}=this.target;let n;if("position"===e)n=qr().model.v3ToMap(t);else if("scale"===e)n=qr().model.v3ToMap(r);else if("rotation"===e)n=qr().model.v3ToMap(s);else{if("target"!==e)throw TypeError("输入值不存在");n=qr().model.v3ToMap(this.controls.target)}return n}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:s}=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(s.x,s.y,s.z)}},material:class extends Bl{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 Nl{constructor(e){this.map={},this.removes=[],this.unique=e}add(e,t,r){if(e.userData){let s=e.userData.id;s||(s=(0,Qr.getId)(),e.userData.id=s),this.map[s]||(this.map[s]={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,O.js)(this.map,((e,t)=>{t.material.dispose()})),this.map={}}}var zl=a(1);class jl 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,Qr.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),zl.type.isNumber(e)?Number.parseInt(e):-1)},t=(r,s)=>{var n=(t=>{if(-1===e(t))return t;var r=t.lastIndexOf("_");return-1===r?t:t.slice(0,r)})(r)+"_"+s++;return this.nameMap[n]?t(r,s):n},r=["PerspectiveCamera"];return s=>{if(r.includes(s.type))return s.name=s.type;let n=s.name;if(zl.valid.isTrue(n)||(n=s.type),this.nameMap[n]){var i=this.nameMap[n];if(this.unique.model.get(i)!==s)return i=-1===(i=e(n))?0:i,i=t(n,i),this.nameMap[i]=this.unique.getId(s),s.name=i}else this.nameMap[n]=this.unique.getId(s)}})()}add(e,t){var{reset:r,hasReset:s}=t||{};if(e instanceof Array)return e.map((e=>this.add(e,t)));if(e){let n=e.userData.id;if(n&&!r||(n=(0,Qr.getId)(),e.userData.id=n),this.map[n]){if(!s)return;n=(0,Qr.getId)(),e.userData.id=n}return this.map[n]=e,this.parseName(e),e.material&&this.unique.material.add(e.material,e),e.children.length?this.add(e.children,t):n}}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 Vl{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,Qr.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 s=e.userData.id;this.map[s]||this.add(e),t&&(({material:e,type:t}=t),this.map[s].materialMap[e.userData.id]||(this.map[s].materialMap[e.userData.id]=new Set),this.map[s].materialMap[e.userData.id].add(t)),r&&(({material:e,type:t}=r),this.map[s].materialMap[e.userData.id]&&this.map[s].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,O.js)(this.map,((e,t)=>{t.texture.dispose()})),this.map={}}}class Hl{constructor(e){this.runScene=e,this.model=new jl(this),this.material=new Nl(this),this.texture=new Vl(this)}getId(e){return e.userData.id}dispose(){this.material.dispose(),this.model.dispose(),this.texture.dispose()}}const Gl=class{constructor(e){this.uniqueEx=new Hl(this),this.fileEx=new qa(this),this.optionsEx=new Ll(this),this.undoEx=new Jr(this),this.textureEx=new Ur(this),this.controlsEx=new L,this.assetsEx=new s(this),this.renderEx=new Il(this),this.events=new class{constructor(e){this.key=new Wr(this),this.mouse=new Xr(this),this.drag=new I(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 Pl(this),this.helperEx=null,this.materialEx=new ms(this),this.cameraEx=new P(this),this.sceneEx=new Ul(this),this.modelEx=new Ms(this),this.loaderer=new _l(this),this.exporter=new Qs(this),this.lightEx=new Ao(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,s,n=((e,t)=>{let r=-1,s=1e3;const n=Object.keys(e).sort(((e,t)=>Number(e)-Number(t)));if(1!==n.length&&(n.map(((e,n)=>{e=Number(e),0<(e=t-e)&&e<s&&(s=e,r=n)})),-1!==r)){var i=n[r],a=n[r+1],o=e[i];if(e=e[a],o&&e){var l=Object.values(o)[0],h=Object.values(e)[0];if("notNow"!==l&&"notNow"!==h)return{left:o,right:e,progress:(t-Number(i))/(Number(a)-Number(i))}}}})(e.data,t);n&&(({left:n,right:r,progress:s}=n),e.setTargetByBetween(n,r,s))}))},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 s=this.animaMap[e];s&&s.length&&s.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,O.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],s={};(0,O.js)(r.data,((e,t)=>{var{type:r,data:n}=t;console.log(t,"modelData");const i=Fl[r];if(t=i.getTarget(e,this.runScene),console.log(t,"target"),t){const r=new i(t,this.runScene);r.data=n,s[e]=r}})),r.data=s,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 s=Object.keys(t.data).map((e=>{const r=t.data[e],s=(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),s.push(...e)),s})),n=(this.animaMap[e]||(this.animaMap[e]=[]),this.animaMap[e]=s.map((e=>(0,Yr.eachTriggerArrGetControls)(e))),t.time*t.speed*(t.reverse?2:1)),i=(new Date).valueOf(),a=n;var r=setInterval((()=>{var t=((new Date).valueOf()-i)/a;this.runScene.optionsEx.cb.timeLine.playGroup.cb({groupName:e,progress:t})}),16.6);let o;const l=new Promise((e=>o=setTimeout(e,n)));return this.timerMap[e]={setProgressTime:r,awaitRuned:o},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 E(this)};var{rootDom:t,options:r}=e;if(console.log(t,"rootDom"),!t)throw TypeError("根节点或路径不可为空");(t=(r||{}).loadInterval)&&0<t?this.optionsEx.setLoadInterval({inputInterval:t,cb:this.load.bind(this,e)}):this.load(e)}load(e){var{path:e,rootDom:t,options:r}=e;this.optionsEx.init(r||{}),this.events.init(t),this.assetsEx.init(t),this.helperEx=new To(this),this.helperEx.init();const{camera:s,controls:n}=this.assetsEx.get();this.uniqueEx.model.add(s),this.renderEx.setSize(),n.update(),(window.engine=this).bloom.glow.init(this.assetsEx.get()),this.optionsEx.cb.inited.cb(""),this.cameraEx.reset(s),this.loadScene(e)}loadScene(e){return function(e,t,r,s){return new(r=r||Promise)((function(t,n){function i(e){try{o(s.next(e))}catch(e){n(e)}}function a(e){try{o(s.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?t(e.value):((s=e.value)instanceof r?s:new r((function(e){e(s)}))).then(i,a)}o((s=s.apply(e,[])).next())}))}(this,0,void 0,(function*(){if(e){this.optionsEx.log("正在拉取场景","base","info");var t=yield r().get(e,{responseType:"arraybuffer"}).then((e=>e.data));if(t)return this.optionsEx.log("拉取场景成功、正在解析","base","success"),this.loaderer.gltf.parse(t)}}))}render(){var e;null!=(e=this.optionsEx.options)&&e.run&&(this.optionsEx.cb.render.cb(""),this.bloom.glow.update())}dispose(){this.sceneEx.clean()}}})(),h.default;function a(e){var t=l[e];return void 0!==t||(t=l[e]={exports:{}},o[e].call(t.exports,t,t.exports,a)),t.exports}var o,l,h}));
|