@realsee/five-webgpu 1.0.0-alpha.3 → 1.0.0-alpha.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.
Files changed (66) hide show
  1. package/docs/assets/hierarchy.js +1 -1
  2. package/docs/assets/navigation.js +1 -1
  3. package/docs/assets/search.js +1 -1
  4. package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
  5. package/docs/classes/index.EyeDomeLightingPass.html +1 -1
  6. package/docs/classes/index.FivePass.html +1 -1
  7. package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
  8. package/docs/classes/index.FlowingLight2DPass.html +1 -1
  9. package/docs/classes/index.FlowingLight3DPass.html +1 -1
  10. package/docs/classes/index.GaussianBlurPass.html +1 -1
  11. package/docs/classes/index.Model.html +1 -1
  12. package/docs/classes/index.ModelScene.html +1 -1
  13. package/docs/classes/index.PBMMeshBasicMaterial.html +4 -3
  14. package/docs/classes/index.PBMMeshBasicNodeMaterial.html +4 -3
  15. package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +4 -3
  16. package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +4 -3
  17. package/docs/classes/index.PBMMeshPhongMaterial.html +4 -3
  18. package/docs/classes/index.PBMMeshPhongNodeMaterial.html +4 -3
  19. package/docs/classes/index.PBMMeshPhysicalMaterial.html +4 -3
  20. package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +4 -3
  21. package/docs/classes/index.PBMPanoFilter.html +8 -8
  22. package/docs/classes/index.PBMUpdateable.html +1 -1
  23. package/docs/classes/index.Parameter.html +53 -51
  24. package/docs/classes/index.Tile3D.html +1 -1
  25. package/docs/classes/index.TileNode.html +1 -1
  26. package/docs/classes/index.TrajectoryNode.html +1 -1
  27. package/docs/classes/index.WorkResolvedObserver.html +1 -1
  28. package/docs/hierarchy.html +1 -1
  29. package/docs/interfaces/index.IPBMMaterial.html +3 -2
  30. package/docs/interfaces/index.LooseWorkWithExtrinsics.html +1 -1
  31. package/docs/interfaces/index.PBMClipperParameter.html +2 -2
  32. package/docs/interfaces/index.PBMHDRConfig.html +2 -2
  33. package/docs/interfaces/index.PBMPanoDepth.html +5 -5
  34. package/docs/interfaces/index.PBMPanoFilterValue.html +2 -2
  35. package/docs/interfaces/index.PBMPanoPicture.html +8 -8
  36. package/docs/interfaces/index.PBMRefinedScreen.html +2 -2
  37. package/docs/interfaces/index.ParameterMaterialValue.html +38 -36
  38. package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
  39. package/docs/interfaces/index.ParameterValue.html +52 -50
  40. package/docs/interfaces/index.ResolvedParameterValue.html +52 -50
  41. package/docs/interfaces/index.ViewLayer.html +1 -1
  42. package/docs/interfaces/index.WorkCubeImage.html +1 -1
  43. package/docs/interfaces/index.WorkImage.html +1 -1
  44. package/docs/interfaces/index.WorkObserver.html +1 -1
  45. package/docs/interfaces/index.WorkTile.html +1 -1
  46. package/docs/modules/index.html +1 -1
  47. package/docs/types/index.PBMColorStyle.html +1 -1
  48. package/docs/types/index.PBMPointBack.html +1 -1
  49. package/docs/types/index.PBMPointShape.html +1 -1
  50. package/docs/types/index.PBMPointSize.html +1 -1
  51. package/docs/types/index.PBMRoofStyle.html +6 -0
  52. package/docs/types/index.ParseOptions.html +1 -1
  53. package/five/index.js +8 -8
  54. package/five/index.mjs +48 -31
  55. package/five/model/index.d.ts +1 -1
  56. package/five/model/materials/pbmMaterial.d.ts +7 -0
  57. package/five/model/parameter.d.ts +3 -1
  58. package/five/utils/ktx2.d.ts +3 -3
  59. package/package.json +1 -1
  60. package/plugins/index.js +2 -2
  61. package/plugins/index.mjs +2 -2
  62. package/react/index.js +2 -2
  63. package/react/index.mjs +2 -2
  64. package/umd/five-plugins.js +2 -2
  65. package/umd/five-react.js +2 -2
  66. package/umd/five.js +58 -58
package/five/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five-webgpu
4
- * Generated: 2026/8/11
5
- * Version: 1.0.0-alpha.3
4
+ * Generated: 2026/8/19
5
+ * Version: 1.0.0-alpha.4
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -299,7 +299,7 @@
299
299
  `}else if(l===`subjectAltName`){var h=e(this.getExtSubjectAltName());i+=` `+h+`
300
300
  `}else if(l===`cRLDistributionPoints`){var g=this.getExtCRLDistributionPoints();i+=n(g)}else if(l===`authorityInfoAccess`){var _=this.getExtAuthorityInfoAccess();i+=r(_)}else l===`certificatePolicies`&&(i+=t(this.getExtCertificatePolicies()))}}return i+=`signature algorithm: `+this.getSignatureAlgorithmName()+`
301
301
  `,i+=`signature: `+this.getSignatureValueHex().substr(0,16)+`...
302
- `,i},typeof e==`string`&&(e.indexOf(`-----BEGIN`)==-1?p.lang.String.isHex(e)&&this.readCertHex(e):this.readCertPEM(e))}V.hex2dn=function(e,t){t===void 0&&(t=0);var n=new V;return B.getTLV(e,t),n.getX500Name(e).str},V.hex2rdn=function(e,t){if(t===void 0&&(t=0),e.substr(t,2)!==`31`)throw Error(`malformed RDN`);for(var n=[],r=B.getChildIdx(e,t),i=0;i<r.length;i++)n.push(V.hex2attrTypeValue(e,r[i]));return n=n.map(function(e){return e.replace(`+`,`\\+`)}),n.join(`+`)},V.hex2attrTypeValue=function(e,t){var n=B,r=n.getV;if(t===void 0&&(t=0),e.substr(t,2)!==`30`)throw Error(`malformed attribute type and value`);var i=n.getChildIdx(e,t);i.length!==2||e.substr(i[0],2);var a=r(e,i[0]),o=p.asn1.ASN1Util.oidHexToInt(a),s=p.asn1.x509.OID.oid2atype(o),c=$e(r(e,i[1]));return s+`=`+c},V.getPublicKeyFromCertHex=function(e){var t=new V;return t.readCertHex(e),t.getPublicKey()},V.getPublicKeyFromCertPEM=function(e){var t=new V;return t.readCertPEM(e),t.getPublicKey()},V.getPublicKeyInfoPropOfCertPEM=function(e){var t=B.getVbyList,n={},r,i;return n.algparam=null,r=new V,r.readCertPEM(e),i=r.getPublicKeyHex(),n.keyhex=t(i,0,[1],`03`).substr(2),n.algoid=t(i,0,[0,0],`06`),n.algoid===`2a8648ce3d0201`&&(n.algparam=t(i,0,[0,1],`06`)),n},V.KEYUSAGE_NAME=[`digitalSignature`,`nonRepudiation`,`keyEncipherment`,`dataEncipherment`,`keyAgreement`,`keyCertSign`,`cRLSign`,`encipherOnly`,`decipherOnly`];function _t(e){return m.SHA256(e).toString()}var vt=[(()=>{let e=new V;return e.readCertPEM(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@ PPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\x07\\QN>Z N\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@\x07ebN[bqx=ng? S^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFo\x07FgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP P>}A^VP}Ex\bU\x07Za=syDw}>Ya\x078wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr sof[wA}e{\\z}w[YDQ|dt=wC Nv\x07bR\x07Z@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`\x07N\0RXt^Z}vEpdC=\bY?\x07=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac Z guf\bF]\x07DCP?znNYf uaYu[`\x07=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB D8{B>\\sPY\x07bEU FQXz\0@\x07`zsqgfD\0[WY\bPeZc} \0bx?Rfed\x07}BUe\x07|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YB\x07Y`Ffg=sY>{t<fu]x\x07rFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw= PCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw= PCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=E\x07nO}Pud8TA ?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V OUwY=>X[\\E`tW[8}VwpF\x07BQcnrPF}yUtd8<Doe_\b[oOVU\x07ep@pYY\0cegY{r ?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<\x07StX Nx\x07\0\b \0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V CVrRVtAAc[ Qp|d|tqoQ=T|XX =u\\N8XNCx\\aU>wz X<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ P\bZ\b\\YNNSZ_\\w^|TsD8db _ Y\\o^Cw>Z\0x\\^aN]wWf\bA} C^d_{\x07ZC@\by]gY@E BFY?OsaqbDcVgQbZeFc ovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z ZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),e})()];function yt(e,t){for(let n of t)if(n.getSubjectHex()===e)return n}function bt(e,t){let n=e.getIssuerHex();if(n===e.getSubjectHex())return e.verifySignature(e.getPublicKey());let r=yt(n,t);return!r||e.verifySignature(r.getPublicKey())===!1?!1:bt(r,t)}function xt(e){return e.getIssuerHex()===e.getSubjectHex()?!1:bt(e,vt)}function St(e){let t=new V;typeof e==`string`?t.readCertPEM(e):t.readCertHex(e.hex);let n=xt(t);return vt.push(t),n}function Ct(e,t,n){let r=new V;if(typeof n==`string`?r.readCertPEM(n):r.readCertHex(n.hex),xt(r)===!1)return!1;let i=new z;return i.readCertPubKeyHex(r.hex,6),!!i.verify(e,Ne(t))}St(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU PPONrtNVONtVWNW=_SVw VE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ [QSnS=\b[aNBZQZ\\aZ [QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg RbZOVTN>bRPtYoTyuoz}}f`Bwo?=\x07RQN\\Ot[cONZO>Wyfd\x07 gdb\x07RaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdy\x07ndB{^T\x07}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F SA\x07e`tn[t u\b8^a]qx\bE_^\x07ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQ\x07FO=Yw\0_TePCOFV@|\x07N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{] b=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r Ao\0 F`fdzCnRtq\br \b8eBp=Z\\TRaadc}@Eub`\x07quuNqAdF\0aUay{}x>tgVz` _YBFwu_q?egt8v[o\x008 wTQcrA <z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw XDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYP\x07\x07dWV]OE^\bOFwA}<uXoO}_NDz8aon\x07zWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT| OZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO d_D}eBb?Uq^b [y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zU\x07xOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`Fy\x07WadZcAD peXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw= PCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx a[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef` ?^x>X}esa{>\\r?eE]CC_cZ[vQs >gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC\x07>>g\x07vb}ACd ``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc XSq {\0\x07DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy RNRg@\x07NZCaaq8?` ^`?ryD =obzw?E]Ou\x07]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug\x078^f[YQAWad8FNqxFQE?ZOo }RnO\bsQc xyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var wt=class extends l.Group{},Tt=null;function Et(e){if(Tt!==null&&typeof Tt.property){let e=Tt;return Tt=Et.prototype=null,e}return Tt=Et.prototype=e==null?Object.create(null):e,new Et}var Dt=10;for(let e=0;e<=Dt;e++)Et();function Ot(e){return Et(e)}var kt=class extends l.Mesh{constructor(e,t){super(e,t),Ot(this)}},At=class extends l.SkinnedMesh{constructor(e,t,n){super(e,t,n),Ot(this)}},jt=o({PBMGaussianSplattingObject:()=>Mt}),Mt=class e extends l.Points{get positions(){let e=this.geometry.getAttribute(`position`);return e?e.array:new Float32Array}get rotations(){let e=this.geometry.getAttribute(`rotation`);return e?e.array:new Float32Array}get scales(){let e=this.geometry.getAttribute(`scale`);return e?e.array:new Float32Array}get colors(){let e=this.geometry.getAttribute(`color`);return e?e.array:new Uint8Array}get selection(){let e=this.geometry.getAttribute(`selection`);return e?e.array:new Uint8Array}get sh1(){let e=this.geometry.getAttribute(`sh1`);return e?e.array:void 0}get sh2(){let e=this.geometry.getAttribute(`sh2`);return e?e.array:void 0}get sh3(){let e=this.geometry.getAttribute(`sh3`);return e?e.array:void 0}constructor(e){var t,n;let r=new l.BufferGeometry;super(r),this.transformChanged=!1,this.selectedChanged=!1,this.transferDetached=!1,this.maxSHDegree=0,this.usedSHDegree=0,this.gsViewLayerKey=``,this.gsClippers=[],this._selected=!1,this.material.visible=!1,this.numPoints=e?e.numPoints:0,this.maxSHDegree=(t=e==null?void 0:e.shDegree)==null?0:t,this.usedSHDegree=0,this.packedData=(n=e==null?void 0:e.packedData)==null?new Uint32Array:n,e&&e.positions?r.setAttribute(`position`,new l.BufferAttribute(e.positions,3)):r.setAttribute(`position`,new l.BufferAttribute(new Float32Array,3)),e&&e.rotations?r.setAttribute(`rotation`,new l.BufferAttribute(e.rotations,4)):r.setAttribute(`rotation`,new l.BufferAttribute(new Float32Array,4)),e&&e.scales?r.setAttribute(`scale`,new l.BufferAttribute(e.scales,3)):r.setAttribute(`scale`,new l.BufferAttribute(new Float32Array,3)),e&&e.colors?r.setAttribute(`color`,new l.BufferAttribute(e.colors,4,!0)):r.setAttribute(`color`,new l.BufferAttribute(new Uint8Array,4,!0));let i=new Uint8Array(this.numPoints);if(r.setAttribute(`selection`,new l.BufferAttribute(i,1)),e!=null&&e.sh1&&r.setAttribute(`sh1`,new l.BufferAttribute(e.sh1,9)),e!=null&&e.sh2&&r.setAttribute(`sh2`,new l.BufferAttribute(e.sh2,15)),e!=null&&e.sh3&&r.setAttribute(`sh3`,new l.BufferAttribute(e.sh3,21)),this._boundingBox=new l.Box3(new l.Vector3(1/0,1/0,1/0),new l.Vector3(-1/0,-1/0,-1/0)),this.packedData.length>=this.numPoints*8){let e=new Float32Array(this.packedData.buffer,this.packedData.byteOffset,this.packedData.length);for(let t=0;t<this.numPoints;t++){let n=e[t*8+0],r=e[t*8+1],i=e[t*8+2];n<this._boundingBox.min.x&&(this._boundingBox.min.x=n),r<this._boundingBox.min.y&&(this._boundingBox.min.y=r),i<this._boundingBox.min.z&&(this._boundingBox.min.z=i),n>this._boundingBox.max.x&&(this._boundingBox.max.x=n),r>this._boundingBox.max.y&&(this._boundingBox.max.y=r),i>this._boundingBox.max.z&&(this._boundingBox.max.z=i)}}else if(e&&e.positions)for(let t=0;t<this.numPoints;t++)this._boundingBox.expandByPoint(new l.Vector3(e.positions[3*t],e.positions[3*t+1],e.positions[3*t+2]));this.matrixAutoUpdate=!1,this.lastMatrixWorld=null}serialize(){let t=new Uint8Array(this.numPoints*e.RowLength),n=new Float32Array(t.buffer),r=new Uint8Array(t.buffer),i=this.positions,a=this.colors,o=this.scales,s=this.rotations;for(let e=0;e<this.numPoints;e++)n[8*e+0]=i[3*e+0],n[8*e+1]=i[3*e+1],n[8*e+2]=i[3*e+2],r[32*e+24+0]=a[4*e+0],r[32*e+24+1]=a[4*e+1],r[32*e+24+2]=a[4*e+2],r[32*e+24+3]=a[4*e+3],n[8*e+3+0]=o[3*e+0],n[8*e+3+1]=o[3*e+1],n[8*e+3+2]=o[3*e+2],r[32*e+28+0]=s[4*e+0]*128+128&255,r[32*e+28+1]=s[4*e+1]*128+128&255,r[32*e+28+2]=s[4*e+2]*128+128&255,r[32*e+28+3]=s[4*e+3]*128+128&255;return t}reattach(e,t,n,r,i){let a=new Float32Array(e),o=new Float32Array(t),s=new Float32Array(n),c=new Uint8Array(r),u=new Uint8Array(i);this.geometry.setAttribute(`position`,new l.BufferAttribute(a,3)),this.geometry.setAttribute(`rotation`,new l.BufferAttribute(o,4)),this.geometry.setAttribute(`scale`,new l.BufferAttribute(s,3)),this.geometry.setAttribute(`color`,new l.BufferAttribute(c,4,!0)),this.geometry.setAttribute(`selection`,new l.BufferAttribute(u,1)),this.transferDetached=!1}get selected(){return this._selected}set selected(e){this._selected!==e&&(this._selected=e,this.selectedChanged=!0)}get boundingBox(){let e=new l.Vector3;this._boundingBox.getCenter(e),e.add(this.position);let t=new l.Vector3;this._boundingBox.getSize(t),t.multiply(this.scale);let n=new l.Vector3;return n.copy(t).multiplyScalar(.5),new l.Box3(e.clone().sub(n),e.clone().add(n))}decodeCov3D(e){if(e<0||this.packedData.length<(e+1)*8)return null;let t=this.packedData[e*8+4],n=this.packedData[e*8+5],r=this.packedData[e*8+6],i=new Float32Array(6);return i[0]=Nt(t&65535)/4,i[1]=Nt(t>>>16&65535)/4,i[2]=Nt(n&65535)/4,i[3]=Nt(n>>>16&65535)/4,i[4]=Nt(r&65535)/4,i[5]=Nt(r>>>16&65535)/4,i}dispose(){this.geometry.dispose()}raycast(e,t){var n,r;let i=this.matrixWorld,a=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r;if(this._boundingBox.isEmpty())return;let o=new l.Vector3;this._boundingBox.getCenter(o);let s=new l.Vector3;this._boundingBox.getSize(s);let c=Math.max(s.x,s.y,s.z)*.5,u=new l.Sphere(o,c);if(u.applyMatrix4(i),u.radius+=a,e.ray.intersectsSphere(u)===!1)return;let d=new l.Matrix4;d.copy(i).invert();let f=new l.Ray;f.copy(e.ray).applyMatrix4(d);let p=a/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.geometry.getAttribute(`position`);if(!h)return;let g=h.array,_=this.numPoints;for(let n=0;n<_;n++){let r=new l.Vector3(g[n*3],g[n*3+1],g[n*3+2]),a=f.distanceSqToPoint(r);if(a<m){let o=new l.Vector3;f.closestPointToPoint(r,o),o.applyMatrix4(i);let s=e.ray.origin.distanceTo(o);if(s<e.near||s>e.far)continue;t.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:n,face:null,object:this})}}}};Mt.RowLength=32;function Nt(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023;if(n===0){if(r===0)return t?-0:0;let e=r/1024*Math.pow(2,-14);return t?-e:e}else if(n===31)return r===0?t?-1/0:1/0:NaN;let i=Math.pow(2,n-15)*(1+r/1024);return t?-i:i}function Pt(){return((1+Math.random())*65536|0).toString(16).substring(1)}function Ft(){return(Pt()+Pt()+`-`+Pt()+`-4`+Pt().substr(0,3)+`-`+Pt()+`-`+Pt()+Pt()+Pt()).toLowerCase()}function H(e,t,n){return e<t?t:typeof n==`number`&&e>n?n:e}function It(e){return typeof Symbol>`u`?`$Symbol<${e}>$`:Symbol(e)}var Lt=It(`$$FIVE_EVENT$$`);function Rt(e){return e[Lt]||(e[Lt]={}),e[Lt]}function zt(e){e[Lt]&&delete e[Lt]}var Bt=class{hasListener(e){let t=Rt(this);return t&&t[e]&&t[e].callbacks.length>0}on(e,t,n){let r=Rt(this);return r[e]||(r[e]={callbacks:[]}),r[e].callbacks.push([t,n||!1]),()=>this.off(e,t)}once(e,t){return this.on(e,t,!0)}off(e,t){if(e===void 0){zt(this);return}let n=Rt(this);if(n[e]||(n[e]={callbacks:[]}),t===void 0){n[e].callbacks.length=0;return}let r=0;for(;r<n[e].callbacks.length&&n[e].callbacks[r][0]!==t;r++);r<n[e].callbacks.length&&n[e].callbacks.splice(r,1)}emit(e,...t){let n=!1,r=Rt(this);r[e]||(r[e]={callbacks:[]});let i=r[e].callbacks.slice();for(let[r,a=!1]of i){let i=r(...t);a&&this.off(e,r),i===!1&&(n=!0)}return n}waitUntil(e,t){return new Promise(n=>{let r=this.on(e,(...e)=>{(!t||t(...e)!==!1)&&(n(e),r())})})}},Vt=class extends Bt{},Ht=class e extends Vt{static computeLut(e,t,n,r=1024,i=1,a,o){let s=H(e,-255,255)/255,c=H(t,-255,255)/255,l=H(n,-255,255)/255,u=new Float32Array(5),d=new Float32Array(5),f=new Float32Array(5);u[0]=0,u[1]=.125,u[2]=.5,u[3]=.875,u[4]=1;for(let e=0;e<5;e++)f[e]=u[e]*(1+l);f[4]=Math.max(1,f[4]);for(let e=0;e<5;e++){let t=Math.pow(f[e]/f[4],2.2),n=Math.pow(f[e]/f[4],.45454545454545453);e<2?d[e]=f[e]+n*c:e>2?d[e]=f[e]+t*s:d[e]=f[e]}d[0]=0,d[4]=Math.max(1,d[4]),d[1]=Math.max(d[0]+.05,d[1]),d[3]=Math.min(d[4]-.0875,d[3]),d[2]=Math.max(Math.min(d[3]-.275,d[2]),d[1]+.275),a=a==null?new Float32Array(r*i):a,o=o==null?0:o;let p=r*2;for(let e=0;e<p;e++){let t=e/p,n=t*t,s=n*t,c=s*t,l=1-t,f=l*l,m=f*l,h=m*l,g=h*u[0]+4*m*t*u[1]+6*f*n*u[2]+4*l*s*u[3]+c*u[4],_=h*d[0]+4*m*t*d[1]+6*f*n*d[2]+4*l*s*d[3]+c*d[4],v=H(Math.round(g*(r-1)),0,r-1);for(let e=0;e<i;e++)a[o+v*i+e]=_}return a}constructor(){super(),this.id=Ft();let t=()=>this.emit(`update`),n=0;this.contrast={get contrastBias(){return n},set contrastBias(e){n=e,t()}};let r=0;this.saturation={get saturationBias(){return r},set saturationBias(e){r=e,t()}};let i=0,a=0;this.color={get temperatureBias(){return i},set temperatureBias(e){i=e,t()},get tintBias(){return a},set tintBias(e){a=e,t()}};let o=0,s=0,c=0,u=[0,0,0].join(`:`),d=1024,f=new Float32Array(d*4);e.computeLut(0,0,0,d,4,f);let p=new l.DataTexture(f,d,1);p.flipY=!1,p.format=l.RGBAFormat,p.type=l.FloatType,p.minFilter=l.NearestFilter,p.magFilter=l.NearestFilter,p.generateMipmaps=!1,p.needsUpdate=!0;let m=()=>{let t=[o,s,c].join(`:`);return t!==u&&(e.computeLut(o,s,c,d,4,f),p.needsUpdate=!0,u=t),p};this.highlightShadow={lutMap:p,get highlightBias(){return o},set highlightBias(e){o=e,m(),t()},get shadowBias(){return s},set shadowBias(e){s=e,m(),t()},get globalBias(){return c},set globalBias(e){c=e,m(),t()}}}toValue(){return{saturationSaturationBias:this.saturation.saturationBias,contrastContrastBias:this.contrast.contrastBias,highlightShadowLutMap:this.highlightShadow.lutMap,colorTemperatureBias:this.color.temperatureBias,colorTintBias:this.color.tintBias}}},Ut=`pano0Map.pano0MapSize.pano0Histogram.pano0Matrix.pano0Zoom.pano0GainMap.pano0HdrMaxContentBoost.pano0HdrMinContentBoost.pano0HdrCapacityMin.pano0HdrCapacityMax.pano0HdrGamma.pano0DepthMap.pano0DepthMaxDepth.pano1Map.pano1MapSize.pano1Histogram.pano1Matrix.pano1Zoom.pano1GainMap.pano1HdrMaxContentBoost.pano1HdrMinContentBoost.pano1HdrCapacityMin.pano1HdrCapacityMax.pano1HdrGamma.pano1DepthMap.pano1DepthMaxDepth.panoFilterSaturationBias.panoFilterContrastBias.panoFilterLutMap.panoFilterTemperatureBias.panoFilterTintBias.refinedScreenMap.refinedScreenProjectionMatrix.refinedScreenMatrixInverse.refinedScreenOpacity.refinedScreenPano.pointSize.pointShape.pointBack.pointScale.pointMinPixel.pointMaxPixel.vertexMarks.colorAlpha.alphaMode.modelAlpha.progress.transition.colorStyle.constantColor.floorIndex.shownFloorIndex.floorStyle.brightness.colorSaturation.colorBrightness.gradientTexture.useHDR.maxDisplayBoost.modelBoundingMin.modelBoundingMax`.split(`.`);function Wt(){return{pano0Map:null,pano0MapSize:1,pano0Histogram:new l.Vector4,pano0Matrix:new l.Matrix4,pano0Zoom:1,pano0GainMap:null,pano0HdrMaxContentBoost:1,pano0HdrMinContentBoost:1,pano0HdrCapacityMin:1,pano0HdrCapacityMax:1e3,pano0HdrGamma:1,pano0DepthMap:null,pano0DepthMaxDepth:1,pano1Map:null,pano1MapSize:1,pano1Histogram:new l.Vector4,pano1Matrix:new l.Matrix4,pano1Zoom:1,pano1GainMap:null,pano1HdrMaxContentBoost:1,pano1HdrMinContentBoost:1,pano1HdrCapacityMin:1,pano1HdrCapacityMax:1e3,pano1HdrGamma:1,pano1DepthMap:null,pano1DepthMaxDepth:1,panoFilterSaturationBias:0,panoFilterContrastBias:0,panoFilterLutMap:null,panoFilterTemperatureBias:0,panoFilterTintBias:0,refinedScreenMap:null,refinedScreenProjectionMatrix:new l.Matrix4,refinedScreenMatrixInverse:new l.Matrix4,refinedScreenOpacity:0,refinedScreenPano:0,pointSize:`ATTENUATION`,pointBack:`DARK`,pointShape:`CIRCLE`,pointScale:.02,pointMaxPixel:40,pointMinPixel:0,vertexMarks:!1,colorAlpha:1,alphaMode:`OPAQUE`,modelAlpha:1,progress:0,transition:`FADE`,colorStyle:`RGB`,constantColor:new l.Vector3,floorIndex:-1,shownFloorIndex:-1,floorStyle:`OPACITY`,brightness:1,colorSaturation:0,colorBrightness:0,gradientTexture:null,useHDR:!1,maxDisplayBoost:1,modelBoundingMin:new l.Vector3,modelBoundingMax:new l.Vector3}}function Gt(e,t){e.pano0Map=t.pano0Map,e.pano0MapSize=t.pano0MapSize,e.pano0Histogram.copy(t.pano0Histogram),e.pano0Matrix.copy(t.pano0Matrix),e.pano0Zoom=t.pano0Zoom,e.pano0GainMap=t.pano0GainMap,e.pano0HdrMaxContentBoost=t.pano0HdrMaxContentBoost,e.pano0HdrMinContentBoost=t.pano0HdrMinContentBoost,e.pano0HdrCapacityMin=t.pano0HdrCapacityMin,e.pano0HdrCapacityMax=t.pano0HdrCapacityMax,e.pano0HdrGamma=t.pano0HdrGamma,e.pano0DepthMap=t.pano0DepthMap,e.pano0DepthMaxDepth=t.pano0DepthMaxDepth,e.pano1Map=t.pano1Map,e.pano1MapSize=t.pano1MapSize,e.pano1Histogram.copy(t.pano1Histogram),e.pano1Matrix.copy(t.pano1Matrix),e.pano1Zoom=t.pano1Zoom,e.pano1GainMap=t.pano1GainMap,e.pano1HdrMaxContentBoost=t.pano1HdrMaxContentBoost,e.pano1HdrMinContentBoost=t.pano1HdrMinContentBoost,e.pano1HdrCapacityMin=t.pano1HdrCapacityMin,e.pano1HdrCapacityMax=t.pano1HdrCapacityMax,e.pano1HdrGamma=t.pano1HdrGamma,e.pano1DepthMap=t.pano1DepthMap,e.pano1DepthMaxDepth=t.pano1DepthMaxDepth,e.panoFilterSaturationBias=t.panoFilterSaturationBias,e.panoFilterContrastBias=t.panoFilterContrastBias,e.panoFilterLutMap=t.panoFilterLutMap,e.panoFilterTemperatureBias=t.panoFilterTemperatureBias,e.panoFilterTintBias=t.panoFilterTintBias,e.refinedScreenMap=t.refinedScreenMap,e.refinedScreenProjectionMatrix.copy(t.refinedScreenProjectionMatrix),e.refinedScreenMatrixInverse.copy(t.refinedScreenMatrixInverse),e.refinedScreenOpacity=t.refinedScreenOpacity,e.refinedScreenPano=t.refinedScreenPano,e.pointSize=t.pointSize,e.pointShape=t.pointShape,e.pointScale=t.pointScale,e.pointMaxPixel=t.pointMaxPixel,e.pointMinPixel=t.pointMinPixel,e.vertexMarks=t.vertexMarks,e.colorAlpha=t.colorAlpha,e.alphaMode=t.alphaMode,e.modelAlpha=t.modelAlpha,e.progress=t.progress,e.transition=t.transition,e.colorStyle=t.colorStyle,e.floorStyle=t.floorStyle,e.brightness=t.brightness,e.colorSaturation=t.colorSaturation,e.colorBrightness=t.colorBrightness,e.floorIndex=t.floorIndex,e.shownFloorIndex=t.shownFloorIndex,e.useHDR=t.useHDR,e.maxDisplayBoost=t.maxDisplayBoost,e.gradientTexture=t.gradientTexture,e.constantColor.copy(t.constantColor),e.modelBoundingMin.copy(t.modelBoundingMin),e.modelBoundingMax.copy(t.modelBoundingMax)}function Kt(e){return e!=null&&e.isPBMMaterial===!0}function qt(e){return[`useHDR:${e.useHDR}`,`pano0Map:${!!e.pano0Map}`,`pano0GainMap:${!!e.pano0GainMap}`,`pano0DepthMap:${!!e.pano0DepthMap}`,`pano1Map:${!!e.pano1Map}`,`pano1GainMap:${!!e.pano1GainMap}`,`pano1DepthMap:${!!e.pano1DepthMap}`,`floorStyle:${e.floorStyle}`,`colorStyle:${e.colorStyle}`,`gradientTexture:${e.gradientTexture}`,`refinedScreenMap:${e.refinedScreenMap}`,`panoFilterLutMap:${!!e.panoFilterLutMap}`,`panoFilterLutMap:${!!e.panoFilterLutMap}`,`transition:${e.transition}`,`pointBack:${e.pointBack}`,`pointSize:${e.pointSize}`,`pointShape:${e.pointShape}`,`transparent:${e.transparent}`].join(`-`)}function Jt(e,t,n){var r,i,a,o,s,c,l,u,d,f,p,m;let h=t===0?`pano0`:`pano1`;n===null?(e[`${h}Map`]=null,e[`${h}MapSize`]=1,e[`${h}Histogram`].set(0,0,0,0),e[`${h}Matrix`].identity(),e[`${h}Zoom`]=1,e[`${h}GainMap`]=null,e[`${h}HdrMaxContentBoost`]=1,e[`${h}HdrMinContentBoost`]=1,e[`${h}HdrCapacityMin`]=1,e[`${h}HdrCapacityMax`]=1e3,e[`${h}HdrGamma`]=1):(e[`${h}Map`]=n.map,e[`${h}MapSize`]=n.mapSize,e[`${h}Histogram`].copy(n.mapHistogram),e[`${h}Matrix`].copy(n.matrix),e[`${h}Zoom`]=n.zoom,e[`${h}GainMap`]=(i=(r=n.hdrConfig)==null?void 0:r.map)==null?null:i,e[`${h}HdrMaxContentBoost`]=(o=(a=n.hdrConfig)==null?void 0:a.maxContentBoost)==null?1:o,e[`${h}HdrMinContentBoost`]=(c=(s=n.hdrConfig)==null?void 0:s.minContentBoost)==null?1:c,e[`${h}HdrCapacityMin`]=(u=(l=n.hdrConfig)==null?void 0:l.hdrCapacityMin)==null?1:u,e[`${h}HdrCapacityMax`]=(f=(d=n.hdrConfig)==null?void 0:d.hdrCapacityMax)==null?1e3:f,e[`${h}HdrGamma`]=(m=(p=n.hdrConfig)==null?void 0:p.gamma)==null?1:m)}function Yt(e,t,n){let r=t===0?`pano0`:`pano1`;n===null?(e[`${r}DepthMap`]=null,e[`${r}DepthMaxDepth`]=1):(e[`${r}DepthMap`]=n.map,e[`${r}DepthMaxDepth`]=n.maxDepth)}function Xt(e,t){t?(e.panoFilterSaturationBias=t.saturationSaturationBias,e.panoFilterContrastBias=t.contrastContrastBias,e.panoFilterLutMap=t.highlightShadowLutMap,e.panoFilterTemperatureBias=t.colorTemperatureBias,e.panoFilterTintBias=t.colorTintBias):(e.panoFilterSaturationBias=0,e.panoFilterContrastBias=0,e.panoFilterLutMap=null,e.panoFilterTemperatureBias=0,e.panoFilterTintBias=0)}function Zt(e,t){t===null?(e.refinedScreenMap=null,e.refinedScreenProjectionMatrix.identity(),e.refinedScreenMatrixInverse.identity(),e.refinedScreenOpacity=0,e.refinedScreenPano=0):(e.refinedScreenMap=t.map,e.refinedScreenProjectionMatrix=t.projectionMatrix.clone(),e.refinedScreenMatrixInverse=t.matrixInverse.clone(),e.refinedScreenOpacity=t.opacity,e.refinedScreenPano=t.pano)}function Qt(e,t){var n,r;let i=qt(e);Jt(e,0,t.pano0),Yt(e,0,t.pano0Depth),Jt(e,1,t.pano1),Yt(e,1,t.pano1Depth),Xt(e,(r=(n=t.panoFilter)==null?void 0:n.toValue())==null?null:r),Zt(e,t.refinedScreen),e.pointSize=t.pointSize,e.pointShape=t.pointShape,e.pointScale=t.pointScale,e.pointMaxPixel=t.pointMaxPixel,e.pointMinPixel=t.pointMinPixel,e.vertexMarks=t.vertexMarks,e.transition=t.transition,e.floorStyle=t.floorStyle,e.colorStyle=t.colorStyle,e.constantColor.copy(t.constantColor),e.shownFloorIndex=t.shownFloorIndex,e.useHDR=t.useHDR,e.maxDisplayBoost=t.maxDisplayBoost,e.colorSaturation=t.colorSaturation,e.colorBrightness=t.colorBrightness,e.gradientTexture=t.gradientTexture,e.modelBoundingMin.copy(t.boundingBox.min),e.modelBoundingMax.copy(t.boundingBox.max),e.modelAlpha=t.modelAlpha,e.progress=t.progress,e.opacity=t.opacity,e.brightness=t.brightness,e.transparent=e.alphaMode===`BLEND`,e.blending=l.NormalBlending,e.depthWrite=!0,e.depthTest=!0,t.useAddBlend&&(e.depthWrite=!1,e.depthTest=!1,e.blending=l.AdditiveBlending),e.shownFloorIndex>-1&&e.shownFloorIndex!==e.floorIndex&&(e.transparent=!0),e.opacity<1&&(e.transparent=!0),e.alphaMap&&e.alphaMode===`BLEND`&&(e.transparent=!0),e.colorAlpha<1&&e.alphaMode===`BLEND`&&(e.transparent=!0),e.brightness<1&&(e.transparent=!0),e.modelAlpha<=0&&(e.transparent=!1),e.depthWrite=!e.transparent,t.useAddBlend&&(e.depthWrite=!1,e.depthTest=!1,e.blending=l.AdditiveBlending),i!==qt(e)&&(e.needsUpdate=!0)}var $t=class extends l.Material{constructor(){super(),this.isPBMMaterial=!0,this.shaderType=`standard`,this.type=`PBMPointCloudMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}};function en(e,t){return!!e&&e.length>=t*4}function tn(e,t,n){let r=t*4;n.set(e[r]/127,e[r+1]/127,e[r+2]/127)}function nn(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;if(!(e!=null&&e.array)||t<=0)return null;let v=e.array,y=Math.max(1,e.itemSize),b=e.normalized===!0,x=e.array;if(x instanceof Int8Array&&y===4&&b&&x.length>=t*4)return x;let S=new Int8Array(t*4);if(b&&x instanceof Int8Array){for(let e=0;e<t;e++){let t=e*y,s=e*4;S[s]=(n=v[t])==null?0:n,S[s+1]=(i=(r=v[t+1])==null?v[t]:r)==null?0:i,S[s+2]=(o=(a=v[t+2])==null?v[t]:a)==null?0:o}return S}if(b&&x instanceof Uint8Array){for(let e=0;e<t;e++){let t=e*y,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((s=v[t])==null?0:s)/255*2-1)*127)),S[n+1]=Math.max(-127,Math.min(127,Math.round(((l=(c=v[t+1])==null?v[t]:c)==null?0:l)/255*2-1)*127)),S[n+2]=Math.max(-127,Math.min(127,Math.round(((d=(u=v[t+2])==null?v[t]:u)==null?0:d)/255*2-1)*127))}return S}if(x instanceof Float32Array&&y===3&&!b){for(let e=0;e<t;e++){let t=e*3,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((f=v[t])==null?0:f)*127))),S[n+1]=Math.max(-127,Math.min(127,Math.round(((p=v[t+1])==null?0:p)*127))),S[n+2]=Math.max(-127,Math.min(127,Math.round(((m=v[t+2])==null?0:m)*127)))}return S}for(let e=0;e<t;e++){let t=e*y,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((h=v[t])==null?0:h)*127))),S[n+1]=Math.max(-127,Math.min(127,Math.round(((g=v[t+1])==null?0:g)*127))),S[n+2]=Math.max(-127,Math.min(127,Math.round(((_=v[t+2])==null?0:_)*127)))}return S}var rn=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),an=[0,1,2,0,2,3],on=class e extends l.Mesh{constructor(t,n){var r;let i=n==null?new $t:n,a=e.createInstancedGeometry(t);super(a,i),this.isPBMPointCloud=!0,this.pointSize=`ATTENUATION`,this.pointShape=`CIRCLE`,this.pointScale=.02,this.pointMinPixel=0,this.pointMaxPixel=40,this.pointBack=`VISIBLE`,this.floorIndex=0,this.maxDisplayBoost=1,this.opacity=1,this.modelAlpha=1,this.brightness=1,this.floorStyle=`VISIBILITY`,this.shownFloorIndex=-1,this.colorStyle=`RGB`,this.constantColor=new l.Vector3(.6,.6,.6),this.gradientTexture=null,this.colorSaturation=0,this.colorBrightness=0,this.outlineGain=0,this.distanceGain=0,this.useAddBlend=!1,this.vertexMarks=!1,this.clippers=[],this.modelBoundingMin=new l.Vector3,this.modelBoundingMax=new l.Vector3,this.styleRevision=0,this._positionVersion=0,this.numPoints=(r=t==null?void 0:t.numPoints)==null?0:r,this.matrixAutoUpdate=!1,this.frustumCulled=!1,t!=null&&t.normals||(i.flatShading=!0),this._boundingBox=new l.Box3(new l.Vector3(1/0,1/0,1/0),new l.Vector3(-1/0,-1/0,-1/0)),t!=null&&t.positions&&this._computeBoundsFromArray(t.positions,this.numPoints,this._boundingBox)}get positions(){var e,t;return(t=(e=this.geometry.getAttribute(`instancePosition`))==null?void 0:e.array)==null?new Float32Array:t}get colors(){var e,t;return(t=(e=this.geometry.getAttribute(`instanceColor`))==null?void 0:e.array)==null?new Float32Array:t}get normals(){let e=this.geometry.getAttribute(`instanceNormal`);return e?e.array:null}get positionVersion(){return this._positionVersion}get pointCount(){return this.numPoints}get visiblePointCount(){return this.geometry.instanceCount===1/0?this.numPoints:this.geometry.instanceCount}set visiblePointCount(e){this.geometry.instanceCount=Math.max(0,Math.min(e,this.numPoints))}swapPositionsBuffer(e){let t=this.geometry.getAttribute(`instancePosition`);t&&t.array===e||(this.geometry.setAttribute(`instancePosition`,new l.InstancedBufferAttribute(e,3)),this._positionVersion=this._positionVersion+1|0)}setLocalBoundingBox(e){this._boundingBox.copy(e)}getLocalBoundingBoxExtents(){if(this._boundingBox.isEmpty())return;let{min:e,max:t}=this._boundingBox;return[e.x,e.y,e.z,t.x,t.y,t.z]}get boundingBox(){let e=new l.Vector3;this._boundingBox.getCenter(e),e.add(this.position);let t=new l.Vector3;this._boundingBox.getSize(t),t.multiply(this.scale);let n=new l.Vector3().copy(t).multiplyScalar(.5);return new l.Box3(e.clone().sub(n),e.clone().add(n))}dispose(){this.dispatchEvent({type:`dispose`}),this.geometry.dispose(),this.material.dispose()}raycast(e,t){var n,r;let i=this.matrixWorld,a=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r;if(this._boundingBox.isEmpty())return;let o=new l.Vector3;this._boundingBox.getCenter(o);let s=new l.Vector3;this._boundingBox.getSize(s);let c=Math.max(s.x,s.y,s.z)*.5,u=new l.Sphere(o,c);if(u.applyMatrix4(i),u.radius+=a,e.ray.intersectsSphere(u)===!1)return;let d=new l.Matrix4().copy(i).invert(),f=new l.Ray().copy(e.ray).applyMatrix4(d),p=a/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.positions,g=this.normals,_=this.numPoints,v=en(g,_),y=v?new l.Matrix3().getNormalMatrix(i):null,b=v?new l.Vector3:null;for(let n=0;n<_;n++){let r=new l.Vector3(h[n*3],h[n*3+1],h[n*3+2]),a=f.distanceSqToPoint(r);if(a<m){let o=new l.Vector3;f.closestPointToPoint(r,o),o.applyMatrix4(i);let s=e.ray.origin.distanceTo(o);if(s<e.near||s>e.far)continue;let c=null;v&&b&&y&&g&&(tn(g,n,b),b.lengthSq()>1e-12&&(b.applyMatrix3(y).normalize(),c={a:n,b:n,c:n,normal:b.clone(),materialIndex:0})),t.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:n,face:c,object:this})}}}_computeBoundsFromArray(e,t,n){let r=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,c=-1/0;for(let n=0;n<t;n++){let t=n*3,l=e[t],u=e[t+1],d=e[t+2];l<r&&(r=l),u<i&&(i=u),d<a&&(a=d),l>o&&(o=l),u>s&&(s=u),d>c&&(c=d)}Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(a)&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isFinite(c)&&(n.min.set(r,i,a),n.max.set(o,s,c))}static createInstancedGeometry(e){var t;let n=new l.InstancedBufferGeometry;n.setAttribute(`position`,new l.BufferAttribute(rn,3)),n.setIndex(an);let r=(t=e==null?void 0:e.numPoints)==null?0:t;if(e!=null&&e.positions&&n.setAttribute(`instancePosition`,new l.InstancedBufferAttribute(e.positions,3)),e!=null&&e.colors){let t=e.colors instanceof Uint8Array;n.setAttribute(`instanceColor`,new l.InstancedBufferAttribute(e.colors,3,t))}e!=null&&e.normals&&n.setAttribute(`instanceNormal`,new l.InstancedBufferAttribute(e.normals,4,!0)),n.instanceCount=r;let i=new l.Box3;if(e!=null&&e.positions){let t=new l.Vector3;for(let n=0;n<r;n++)t.set(e.positions[n*3],e.positions[n*3+1],e.positions[n*3+2]),i.expandByPoint(t)}return n.boundingBox=i,n.boundingSphere=new l.Sphere,i.getBoundingSphere(n.boundingSphere),n}},sn=`(function(){function e(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function t(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,c,\`next\`,e)}function c(e){t(o,i,a,s,c,\`throw\`,e)}s(void 0)})}}function r(){return i.apply(this,arguments)}function i(){return i=n(function*(e={}){var t,r=e,i=!1,a=!0,o=self.location.href;if(i||a){try{new URL(\`.\`,o).href}catch(e){}(function(){var e=n(function*(e){var t=yield fetch(e,{credentials:\`same-origin\`});if(t.ok)return t.arrayBuffer();throw Error(t.status+\` : \`+t.url)});return function(t){return e.apply(this,arguments)}})()}console.log.bind(console),console.error.bind(console);var s=!1;function c(e){for(var t=0,n=e.length,r=new Uint8Array(n),i;t<n;++t)i=e.charCodeAt(t),r[t]=~i>>8&i;return r}var l,u,d=!1;function f(){var e=N.buffer;new Int8Array(e),new Int16Array(e),r.HEAPU8=u=new Uint8Array(e),new Uint16Array(e),new Int32Array(e),r.HEAPU32=new Uint32Array(e),r.HEAPF32=new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function p(){if(r.preRun)for(typeof r.preRun==\`function\`&&(r.preRun=[r.preRun]);r.preRun.length;)E(r.preRun.shift());S(T)}function m(){d=!0,L.c()}function h(){if(r.postRun)for(typeof r.postRun==\`function\`&&(r.postRun=[r.postRun]);r.postRun.length;)w(r.postRun.shift());S(C)}var g;function _(){return c(\`\\0asm\\0\\0\\0\\\`\\\`\\0\\\`
302
+ `,i},typeof e==`string`&&(e.indexOf(`-----BEGIN`)==-1?p.lang.String.isHex(e)&&this.readCertHex(e):this.readCertPEM(e))}V.hex2dn=function(e,t){t===void 0&&(t=0);var n=new V;return B.getTLV(e,t),n.getX500Name(e).str},V.hex2rdn=function(e,t){if(t===void 0&&(t=0),e.substr(t,2)!==`31`)throw Error(`malformed RDN`);for(var n=[],r=B.getChildIdx(e,t),i=0;i<r.length;i++)n.push(V.hex2attrTypeValue(e,r[i]));return n=n.map(function(e){return e.replace(`+`,`\\+`)}),n.join(`+`)},V.hex2attrTypeValue=function(e,t){var n=B,r=n.getV;if(t===void 0&&(t=0),e.substr(t,2)!==`30`)throw Error(`malformed attribute type and value`);var i=n.getChildIdx(e,t);i.length!==2||e.substr(i[0],2);var a=r(e,i[0]),o=p.asn1.ASN1Util.oidHexToInt(a),s=p.asn1.x509.OID.oid2atype(o),c=$e(r(e,i[1]));return s+`=`+c},V.getPublicKeyFromCertHex=function(e){var t=new V;return t.readCertHex(e),t.getPublicKey()},V.getPublicKeyFromCertPEM=function(e){var t=new V;return t.readCertPEM(e),t.getPublicKey()},V.getPublicKeyInfoPropOfCertPEM=function(e){var t=B.getVbyList,n={},r,i;return n.algparam=null,r=new V,r.readCertPEM(e),i=r.getPublicKeyHex(),n.keyhex=t(i,0,[1],`03`).substr(2),n.algoid=t(i,0,[0,0],`06`),n.algoid===`2a8648ce3d0201`&&(n.algparam=t(i,0,[0,1],`06`)),n},V.KEYUSAGE_NAME=[`digitalSignature`,`nonRepudiation`,`keyEncipherment`,`dataEncipherment`,`keyAgreement`,`keyCertSign`,`cRLSign`,`encipherOnly`,`decipherOnly`];function _t(e){return m.SHA256(e).toString()}var vt=[(()=>{let e=new V;return e.readCertPEM(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@ PPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\x07\\QN>Z N\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@\x07ebN[bqx=ng? S^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFo\x07FgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP P>}A^VP}Ex\bU\x07Za=syDw}>Ya\x078wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr sof[wA}e{\\z}w[YDQ|dt=wC Nv\x07bR\x07Z@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`\x07N\0RXt^Z}vEpdC=\bY?\x07=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac Z guf\bF]\x07DCP?znNYf uaYu[`\x07=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB D8{B>\\sPY\x07bEU FQXz\0@\x07`zsqgfD\0[WY\bPeZc} \0bx?Rfed\x07}BUe\x07|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YB\x07Y`Ffg=sY>{t<fu]x\x07rFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw= PCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw= PCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=E\x07nO}Pud8TA ?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V OUwY=>X[\\E`tW[8}VwpF\x07BQcnrPF}yUtd8<Doe_\b[oOVU\x07ep@pYY\0cegY{r ?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<\x07StX Nx\x07\0\b \0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V CVrRVtAAc[ Qp|d|tqoQ=T|XX =u\\N8XNCx\\aU>wz X<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ P\bZ\b\\YNNSZ_\\w^|TsD8db _ Y\\o^Cw>Z\0x\\^aN]wWf\bA} C^d_{\x07ZC@\by]gY@E BFY?OsaqbDcVgQbZeFc ovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z ZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),e})()];function yt(e,t){for(let n of t)if(n.getSubjectHex()===e)return n}function bt(e,t){let n=e.getIssuerHex();if(n===e.getSubjectHex())return e.verifySignature(e.getPublicKey());let r=yt(n,t);return!r||e.verifySignature(r.getPublicKey())===!1?!1:bt(r,t)}function xt(e){return e.getIssuerHex()===e.getSubjectHex()?!1:bt(e,vt)}function St(e){let t=new V;typeof e==`string`?t.readCertPEM(e):t.readCertHex(e.hex);let n=xt(t);return vt.push(t),n}function Ct(e,t,n){let r=new V;if(typeof n==`string`?r.readCertPEM(n):r.readCertHex(n.hex),xt(r)===!1)return!1;let i=new z;return i.readCertPubKeyHex(r.hex,6),!!i.verify(e,Ne(t))}St(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU PPONrtNVONtVWNW=_SVw VE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg R]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ [QSnS=\b[aNBZQZ\\aZ [QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg R^ZNATN>bROU^zc}nzyg RbZOVTN>bRPtYoTyuoz}}f`Bwo?=\x07RQN\\Ot[cONZO>Wyfd\x07 gdb\x07RaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdy\x07ndB{^T\x07}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F SA\x07e`tn[t u\b8^a]qx\bE_^\x07ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQ\x07FO=Yw\0_TePCOFV@|\x07N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{] b=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r Ao\0 F`fdzCnRtq\br \b8eBp=Z\\TRaadc}@Eub`\x07quuNqAdF\0aUay{}x>tgVz` _YBFwu_q?egt8v[o\x008 wTQcrA <z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw XDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYP\x07\x07dWV]OE^\bOFwA}<uXoO}_NDz8aon\x07zWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT| OZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO d_D}eBb?Uq^b [y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zU\x07xOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`Fy\x07WadZcAD peXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw= PCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx a[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef` ?^x>X}esa{>\\r?eE]CC_cZ[vQs >gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC\x07>>g\x07vb}ACd ``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc XSq {\0\x07DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy RNRg@\x07NZCaaq8?` ^`?ryD =obzw?E]Ou\x07]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug\x078^f[YQAWad8FNqxFQE?ZOo }RnO\bsQc xyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var wt=class extends l.Group{},Tt=null;function Et(e){if(Tt!==null&&typeof Tt.property){let e=Tt;return Tt=Et.prototype=null,e}return Tt=Et.prototype=e==null?Object.create(null):e,new Et}var Dt=10;for(let e=0;e<=Dt;e++)Et();function Ot(e){return Et(e)}var kt=class extends l.Mesh{constructor(e,t){super(e,t),Ot(this)}},At=class extends l.SkinnedMesh{constructor(e,t,n){super(e,t,n),Ot(this)}},jt=o({PBMGaussianSplattingObject:()=>Mt}),Mt=class e extends l.Points{get positions(){let e=this.geometry.getAttribute(`position`);return e?e.array:new Float32Array}get rotations(){let e=this.geometry.getAttribute(`rotation`);return e?e.array:new Float32Array}get scales(){let e=this.geometry.getAttribute(`scale`);return e?e.array:new Float32Array}get colors(){let e=this.geometry.getAttribute(`color`);return e?e.array:new Uint8Array}get selection(){let e=this.geometry.getAttribute(`selection`);return e?e.array:new Uint8Array}get sh1(){let e=this.geometry.getAttribute(`sh1`);return e?e.array:void 0}get sh2(){let e=this.geometry.getAttribute(`sh2`);return e?e.array:void 0}get sh3(){let e=this.geometry.getAttribute(`sh3`);return e?e.array:void 0}constructor(e){var t,n;let r=new l.BufferGeometry;super(r),this.transformChanged=!1,this.selectedChanged=!1,this.transferDetached=!1,this.maxSHDegree=0,this.usedSHDegree=0,this.gsViewLayerKey=``,this.gsClippers=[],this._selected=!1,this.material.visible=!1,this.numPoints=e?e.numPoints:0,this.maxSHDegree=(t=e==null?void 0:e.shDegree)==null?0:t,this.usedSHDegree=0,this.packedData=(n=e==null?void 0:e.packedData)==null?new Uint32Array:n,e&&e.positions?r.setAttribute(`position`,new l.BufferAttribute(e.positions,3)):r.setAttribute(`position`,new l.BufferAttribute(new Float32Array,3)),e&&e.rotations?r.setAttribute(`rotation`,new l.BufferAttribute(e.rotations,4)):r.setAttribute(`rotation`,new l.BufferAttribute(new Float32Array,4)),e&&e.scales?r.setAttribute(`scale`,new l.BufferAttribute(e.scales,3)):r.setAttribute(`scale`,new l.BufferAttribute(new Float32Array,3)),e&&e.colors?r.setAttribute(`color`,new l.BufferAttribute(e.colors,4,!0)):r.setAttribute(`color`,new l.BufferAttribute(new Uint8Array,4,!0));let i=new Uint8Array(this.numPoints);if(r.setAttribute(`selection`,new l.BufferAttribute(i,1)),e!=null&&e.sh1&&r.setAttribute(`sh1`,new l.BufferAttribute(e.sh1,9)),e!=null&&e.sh2&&r.setAttribute(`sh2`,new l.BufferAttribute(e.sh2,15)),e!=null&&e.sh3&&r.setAttribute(`sh3`,new l.BufferAttribute(e.sh3,21)),this._boundingBox=new l.Box3(new l.Vector3(1/0,1/0,1/0),new l.Vector3(-1/0,-1/0,-1/0)),this.packedData.length>=this.numPoints*8){let e=new Float32Array(this.packedData.buffer,this.packedData.byteOffset,this.packedData.length);for(let t=0;t<this.numPoints;t++){let n=e[t*8+0],r=e[t*8+1],i=e[t*8+2];n<this._boundingBox.min.x&&(this._boundingBox.min.x=n),r<this._boundingBox.min.y&&(this._boundingBox.min.y=r),i<this._boundingBox.min.z&&(this._boundingBox.min.z=i),n>this._boundingBox.max.x&&(this._boundingBox.max.x=n),r>this._boundingBox.max.y&&(this._boundingBox.max.y=r),i>this._boundingBox.max.z&&(this._boundingBox.max.z=i)}}else if(e&&e.positions)for(let t=0;t<this.numPoints;t++)this._boundingBox.expandByPoint(new l.Vector3(e.positions[3*t],e.positions[3*t+1],e.positions[3*t+2]));this.matrixAutoUpdate=!1,this.lastMatrixWorld=null}serialize(){let t=new Uint8Array(this.numPoints*e.RowLength),n=new Float32Array(t.buffer),r=new Uint8Array(t.buffer),i=this.positions,a=this.colors,o=this.scales,s=this.rotations;for(let e=0;e<this.numPoints;e++)n[8*e+0]=i[3*e+0],n[8*e+1]=i[3*e+1],n[8*e+2]=i[3*e+2],r[32*e+24+0]=a[4*e+0],r[32*e+24+1]=a[4*e+1],r[32*e+24+2]=a[4*e+2],r[32*e+24+3]=a[4*e+3],n[8*e+3+0]=o[3*e+0],n[8*e+3+1]=o[3*e+1],n[8*e+3+2]=o[3*e+2],r[32*e+28+0]=s[4*e+0]*128+128&255,r[32*e+28+1]=s[4*e+1]*128+128&255,r[32*e+28+2]=s[4*e+2]*128+128&255,r[32*e+28+3]=s[4*e+3]*128+128&255;return t}reattach(e,t,n,r,i){let a=new Float32Array(e),o=new Float32Array(t),s=new Float32Array(n),c=new Uint8Array(r),u=new Uint8Array(i);this.geometry.setAttribute(`position`,new l.BufferAttribute(a,3)),this.geometry.setAttribute(`rotation`,new l.BufferAttribute(o,4)),this.geometry.setAttribute(`scale`,new l.BufferAttribute(s,3)),this.geometry.setAttribute(`color`,new l.BufferAttribute(c,4,!0)),this.geometry.setAttribute(`selection`,new l.BufferAttribute(u,1)),this.transferDetached=!1}get selected(){return this._selected}set selected(e){this._selected!==e&&(this._selected=e,this.selectedChanged=!0)}get boundingBox(){let e=new l.Vector3;this._boundingBox.getCenter(e),e.add(this.position);let t=new l.Vector3;this._boundingBox.getSize(t),t.multiply(this.scale);let n=new l.Vector3;return n.copy(t).multiplyScalar(.5),new l.Box3(e.clone().sub(n),e.clone().add(n))}decodeCov3D(e){if(e<0||this.packedData.length<(e+1)*8)return null;let t=this.packedData[e*8+4],n=this.packedData[e*8+5],r=this.packedData[e*8+6],i=new Float32Array(6);return i[0]=Nt(t&65535)/4,i[1]=Nt(t>>>16&65535)/4,i[2]=Nt(n&65535)/4,i[3]=Nt(n>>>16&65535)/4,i[4]=Nt(r&65535)/4,i[5]=Nt(r>>>16&65535)/4,i}dispose(){this.geometry.dispose()}raycast(e,t){var n,r;let i=this.matrixWorld,a=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r;if(this._boundingBox.isEmpty())return;let o=new l.Vector3;this._boundingBox.getCenter(o);let s=new l.Vector3;this._boundingBox.getSize(s);let c=Math.max(s.x,s.y,s.z)*.5,u=new l.Sphere(o,c);if(u.applyMatrix4(i),u.radius+=a,e.ray.intersectsSphere(u)===!1)return;let d=new l.Matrix4;d.copy(i).invert();let f=new l.Ray;f.copy(e.ray).applyMatrix4(d);let p=a/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.geometry.getAttribute(`position`);if(!h)return;let g=h.array,_=this.numPoints;for(let n=0;n<_;n++){let r=new l.Vector3(g[n*3],g[n*3+1],g[n*3+2]),a=f.distanceSqToPoint(r);if(a<m){let o=new l.Vector3;f.closestPointToPoint(r,o),o.applyMatrix4(i);let s=e.ray.origin.distanceTo(o);if(s<e.near||s>e.far)continue;t.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:n,face:null,object:this})}}}};Mt.RowLength=32;function Nt(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023;if(n===0){if(r===0)return t?-0:0;let e=r/1024*Math.pow(2,-14);return t?-e:e}else if(n===31)return r===0?t?-1/0:1/0:NaN;let i=Math.pow(2,n-15)*(1+r/1024);return t?-i:i}function Pt(){return((1+Math.random())*65536|0).toString(16).substring(1)}function Ft(){return(Pt()+Pt()+`-`+Pt()+`-4`+Pt().substr(0,3)+`-`+Pt()+`-`+Pt()+Pt()+Pt()).toLowerCase()}function H(e,t,n){return e<t?t:typeof n==`number`&&e>n?n:e}function It(e){return typeof Symbol>`u`?`$Symbol<${e}>$`:Symbol(e)}var Lt=It(`$$FIVE_EVENT$$`);function Rt(e){return e[Lt]||(e[Lt]={}),e[Lt]}function zt(e){e[Lt]&&delete e[Lt]}var Bt=class{hasListener(e){let t=Rt(this);return t&&t[e]&&t[e].callbacks.length>0}on(e,t,n){let r=Rt(this);return r[e]||(r[e]={callbacks:[]}),r[e].callbacks.push([t,n||!1]),()=>this.off(e,t)}once(e,t){return this.on(e,t,!0)}off(e,t){if(e===void 0){zt(this);return}let n=Rt(this);if(n[e]||(n[e]={callbacks:[]}),t===void 0){n[e].callbacks.length=0;return}let r=0;for(;r<n[e].callbacks.length&&n[e].callbacks[r][0]!==t;r++);r<n[e].callbacks.length&&n[e].callbacks.splice(r,1)}emit(e,...t){let n=!1,r=Rt(this);r[e]||(r[e]={callbacks:[]});let i=r[e].callbacks.slice();for(let[r,a=!1]of i){let i=r(...t);a&&this.off(e,r),i===!1&&(n=!0)}return n}waitUntil(e,t){return new Promise(n=>{let r=this.on(e,(...e)=>{(!t||t(...e)!==!1)&&(n(e),r())})})}},Vt=class extends Bt{},Ht=class e extends Vt{static computeLut(e,t,n,r=1024,i=1,a,o){let s=H(e,-255,255)/255,c=H(t,-255,255)/255,l=H(n,-255,255)/255,u=new Float32Array(5),d=new Float32Array(5),f=new Float32Array(5);u[0]=0,u[1]=.125,u[2]=.5,u[3]=.875,u[4]=1;for(let e=0;e<5;e++)f[e]=u[e]*(1+l);f[4]=Math.max(1,f[4]);for(let e=0;e<5;e++){let t=Math.pow(f[e]/f[4],2.2),n=Math.pow(f[e]/f[4],.45454545454545453);e<2?d[e]=f[e]+n*c:e>2?d[e]=f[e]+t*s:d[e]=f[e]}d[0]=0,d[4]=Math.max(1,d[4]),d[1]=Math.max(d[0]+.05,d[1]),d[3]=Math.min(d[4]-.0875,d[3]),d[2]=Math.max(Math.min(d[3]-.275,d[2]),d[1]+.275),a=a==null?new Float32Array(r*i):a,o=o==null?0:o;let p=r*2;for(let e=0;e<p;e++){let t=e/p,n=t*t,s=n*t,c=s*t,l=1-t,f=l*l,m=f*l,h=m*l,g=h*u[0]+4*m*t*u[1]+6*f*n*u[2]+4*l*s*u[3]+c*u[4],_=h*d[0]+4*m*t*d[1]+6*f*n*d[2]+4*l*s*d[3]+c*d[4],v=H(Math.round(g*(r-1)),0,r-1);for(let e=0;e<i;e++)a[o+v*i+e]=_}return a}constructor(){super(),this.id=Ft();let t=()=>this.emit(`update`),n=0;this.contrast={get contrastBias(){return n},set contrastBias(e){n=e,t()}};let r=0;this.saturation={get saturationBias(){return r},set saturationBias(e){r=e,t()}};let i=0,a=0;this.color={get temperatureBias(){return i},set temperatureBias(e){i=e,t()},get tintBias(){return a},set tintBias(e){a=e,t()}};let o=0,s=0,c=0,u=[0,0,0].join(`:`),d=1024,f=new Float32Array(d*4);e.computeLut(0,0,0,d,4,f);let p=new l.DataTexture(f,d,1);p.flipY=!1,p.format=l.RGBAFormat,p.type=l.FloatType,p.minFilter=l.NearestFilter,p.magFilter=l.NearestFilter,p.generateMipmaps=!1,p.needsUpdate=!0;let m=()=>{let t=[o,s,c].join(`:`);return t!==u&&(e.computeLut(o,s,c,d,4,f),p.needsUpdate=!0,u=t),p};this.highlightShadow={lutMap:p,get highlightBias(){return o},set highlightBias(e){o=e,m(),t()},get shadowBias(){return s},set shadowBias(e){s=e,m(),t()},get globalBias(){return c},set globalBias(e){c=e,m(),t()}}}toValue(){return{saturationSaturationBias:this.saturation.saturationBias,contrastContrastBias:this.contrast.contrastBias,highlightShadowLutMap:this.highlightShadow.lutMap,colorTemperatureBias:this.color.temperatureBias,colorTintBias:this.color.tintBias}}},Ut=`pano0Map.pano0MapSize.pano0Histogram.pano0Matrix.pano0Zoom.pano0GainMap.pano0HdrMaxContentBoost.pano0HdrMinContentBoost.pano0HdrCapacityMin.pano0HdrCapacityMax.pano0HdrGamma.pano0DepthMap.pano0DepthMaxDepth.pano1Map.pano1MapSize.pano1Histogram.pano1Matrix.pano1Zoom.pano1GainMap.pano1HdrMaxContentBoost.pano1HdrMinContentBoost.pano1HdrCapacityMin.pano1HdrCapacityMax.pano1HdrGamma.pano1DepthMap.pano1DepthMaxDepth.panoFilterSaturationBias.panoFilterContrastBias.panoFilterLutMap.panoFilterTemperatureBias.panoFilterTintBias.refinedScreenMap.refinedScreenProjectionMatrix.refinedScreenMatrixInverse.refinedScreenOpacity.refinedScreenPano.pointSize.pointShape.pointBack.pointScale.pointMinPixel.pointMaxPixel.vertexMarks.colorAlpha.alphaMode.modelAlpha.progress.transition.colorStyle.constantColor.floorIndex.shownFloorIndex.floorStyle.roofStyle.brightness.colorSaturation.colorBrightness.gradientTexture.useHDR.maxDisplayBoost.modelBoundingMin.modelBoundingMax`.split(`.`);function Wt(){return{pano0Map:null,pano0MapSize:1,pano0Histogram:new l.Vector4,pano0Matrix:new l.Matrix4,pano0Zoom:1,pano0GainMap:null,pano0HdrMaxContentBoost:1,pano0HdrMinContentBoost:1,pano0HdrCapacityMin:1,pano0HdrCapacityMax:1e3,pano0HdrGamma:1,pano0DepthMap:null,pano0DepthMaxDepth:1,pano1Map:null,pano1MapSize:1,pano1Histogram:new l.Vector4,pano1Matrix:new l.Matrix4,pano1Zoom:1,pano1GainMap:null,pano1HdrMaxContentBoost:1,pano1HdrMinContentBoost:1,pano1HdrCapacityMin:1,pano1HdrCapacityMax:1e3,pano1HdrGamma:1,pano1DepthMap:null,pano1DepthMaxDepth:1,panoFilterSaturationBias:0,panoFilterContrastBias:0,panoFilterLutMap:null,panoFilterTemperatureBias:0,panoFilterTintBias:0,refinedScreenMap:null,refinedScreenProjectionMatrix:new l.Matrix4,refinedScreenMatrixInverse:new l.Matrix4,refinedScreenOpacity:0,refinedScreenPano:0,pointSize:`ATTENUATION`,pointBack:`DARK`,pointShape:`CIRCLE`,pointScale:.02,pointMaxPixel:40,pointMinPixel:0,vertexMarks:!1,colorAlpha:1,alphaMode:`OPAQUE`,modelAlpha:1,progress:0,transition:`FADE`,colorStyle:`RGB`,constantColor:new l.Vector3,floorIndex:-1,shownFloorIndex:-1,floorStyle:`OPACITY`,roofStyle:`AUTO`,brightness:1,colorSaturation:0,colorBrightness:0,gradientTexture:null,useHDR:!1,maxDisplayBoost:1,modelBoundingMin:new l.Vector3,modelBoundingMax:new l.Vector3}}function Gt(e,t){e.pano0Map=t.pano0Map,e.pano0MapSize=t.pano0MapSize,e.pano0Histogram.copy(t.pano0Histogram),e.pano0Matrix.copy(t.pano0Matrix),e.pano0Zoom=t.pano0Zoom,e.pano0GainMap=t.pano0GainMap,e.pano0HdrMaxContentBoost=t.pano0HdrMaxContentBoost,e.pano0HdrMinContentBoost=t.pano0HdrMinContentBoost,e.pano0HdrCapacityMin=t.pano0HdrCapacityMin,e.pano0HdrCapacityMax=t.pano0HdrCapacityMax,e.pano0HdrGamma=t.pano0HdrGamma,e.pano0DepthMap=t.pano0DepthMap,e.pano0DepthMaxDepth=t.pano0DepthMaxDepth,e.pano1Map=t.pano1Map,e.pano1MapSize=t.pano1MapSize,e.pano1Histogram.copy(t.pano1Histogram),e.pano1Matrix.copy(t.pano1Matrix),e.pano1Zoom=t.pano1Zoom,e.pano1GainMap=t.pano1GainMap,e.pano1HdrMaxContentBoost=t.pano1HdrMaxContentBoost,e.pano1HdrMinContentBoost=t.pano1HdrMinContentBoost,e.pano1HdrCapacityMin=t.pano1HdrCapacityMin,e.pano1HdrCapacityMax=t.pano1HdrCapacityMax,e.pano1HdrGamma=t.pano1HdrGamma,e.pano1DepthMap=t.pano1DepthMap,e.pano1DepthMaxDepth=t.pano1DepthMaxDepth,e.panoFilterSaturationBias=t.panoFilterSaturationBias,e.panoFilterContrastBias=t.panoFilterContrastBias,e.panoFilterLutMap=t.panoFilterLutMap,e.panoFilterTemperatureBias=t.panoFilterTemperatureBias,e.panoFilterTintBias=t.panoFilterTintBias,e.refinedScreenMap=t.refinedScreenMap,e.refinedScreenProjectionMatrix.copy(t.refinedScreenProjectionMatrix),e.refinedScreenMatrixInverse.copy(t.refinedScreenMatrixInverse),e.refinedScreenOpacity=t.refinedScreenOpacity,e.refinedScreenPano=t.refinedScreenPano,e.pointSize=t.pointSize,e.pointShape=t.pointShape,e.pointScale=t.pointScale,e.pointMaxPixel=t.pointMaxPixel,e.pointMinPixel=t.pointMinPixel,e.vertexMarks=t.vertexMarks,e.colorAlpha=t.colorAlpha,e.alphaMode=t.alphaMode,e.modelAlpha=t.modelAlpha,e.progress=t.progress,e.transition=t.transition,e.colorStyle=t.colorStyle,e.floorStyle=t.floorStyle,e.roofStyle=t.roofStyle,e.brightness=t.brightness,e.colorSaturation=t.colorSaturation,e.colorBrightness=t.colorBrightness,e.floorIndex=t.floorIndex,e.shownFloorIndex=t.shownFloorIndex,e.useHDR=t.useHDR,e.maxDisplayBoost=t.maxDisplayBoost,e.gradientTexture=t.gradientTexture,e.constantColor.copy(t.constantColor),e.modelBoundingMin.copy(t.modelBoundingMin),e.modelBoundingMax.copy(t.modelBoundingMax)}function Kt(e){return e!=null&&e.isPBMMaterial===!0}function qt(e){return[`useHDR:${e.useHDR}`,`pano0Map:${!!e.pano0Map}`,`pano0GainMap:${!!e.pano0GainMap}`,`pano0DepthMap:${!!e.pano0DepthMap}`,`pano1Map:${!!e.pano1Map}`,`pano1GainMap:${!!e.pano1GainMap}`,`pano1DepthMap:${!!e.pano1DepthMap}`,`floorStyle:${e.floorStyle}`,`roofStyle:${e.roofStyle}`,`colorStyle:${e.colorStyle}`,`gradientTexture:${e.gradientTexture}`,`refinedScreenMap:${e.refinedScreenMap}`,`panoFilterLutMap:${!!e.panoFilterLutMap}`,`panoFilterLutMap:${!!e.panoFilterLutMap}`,`transition:${e.transition}`,`pointBack:${e.pointBack}`,`pointSize:${e.pointSize}`,`pointShape:${e.pointShape}`,`transparent:${e.transparent}`].join(`-`)}function Jt(e,t,n){var r,i,a,o,s,c,l,u,d,f,p,m;let h=t===0?`pano0`:`pano1`;n===null?(e[`${h}Map`]=null,e[`${h}MapSize`]=1,e[`${h}Histogram`].set(0,0,0,0),e[`${h}Matrix`].identity(),e[`${h}Zoom`]=1,e[`${h}GainMap`]=null,e[`${h}HdrMaxContentBoost`]=1,e[`${h}HdrMinContentBoost`]=1,e[`${h}HdrCapacityMin`]=1,e[`${h}HdrCapacityMax`]=1e3,e[`${h}HdrGamma`]=1):(e[`${h}Map`]=n.map,e[`${h}MapSize`]=n.mapSize,e[`${h}Histogram`].copy(n.mapHistogram),e[`${h}Matrix`].copy(n.matrix),e[`${h}Zoom`]=n.zoom,e[`${h}GainMap`]=(i=(r=n.hdrConfig)==null?void 0:r.map)==null?null:i,e[`${h}HdrMaxContentBoost`]=(o=(a=n.hdrConfig)==null?void 0:a.maxContentBoost)==null?1:o,e[`${h}HdrMinContentBoost`]=(c=(s=n.hdrConfig)==null?void 0:s.minContentBoost)==null?1:c,e[`${h}HdrCapacityMin`]=(u=(l=n.hdrConfig)==null?void 0:l.hdrCapacityMin)==null?1:u,e[`${h}HdrCapacityMax`]=(f=(d=n.hdrConfig)==null?void 0:d.hdrCapacityMax)==null?1e3:f,e[`${h}HdrGamma`]=(m=(p=n.hdrConfig)==null?void 0:p.gamma)==null?1:m)}function Yt(e,t,n){let r=t===0?`pano0`:`pano1`;n===null?(e[`${r}DepthMap`]=null,e[`${r}DepthMaxDepth`]=1):(e[`${r}DepthMap`]=n.map,e[`${r}DepthMaxDepth`]=n.maxDepth)}function Xt(e,t){t?(e.panoFilterSaturationBias=t.saturationSaturationBias,e.panoFilterContrastBias=t.contrastContrastBias,e.panoFilterLutMap=t.highlightShadowLutMap,e.panoFilterTemperatureBias=t.colorTemperatureBias,e.panoFilterTintBias=t.colorTintBias):(e.panoFilterSaturationBias=0,e.panoFilterContrastBias=0,e.panoFilterLutMap=null,e.panoFilterTemperatureBias=0,e.panoFilterTintBias=0)}function Zt(e,t){t===null?(e.refinedScreenMap=null,e.refinedScreenProjectionMatrix.identity(),e.refinedScreenMatrixInverse.identity(),e.refinedScreenOpacity=0,e.refinedScreenPano=0):(e.refinedScreenMap=t.map,e.refinedScreenProjectionMatrix=t.projectionMatrix.clone(),e.refinedScreenMatrixInverse=t.matrixInverse.clone(),e.refinedScreenOpacity=t.opacity,e.refinedScreenPano=t.pano)}function Qt(e,t){var n,r;let i=qt(e);Jt(e,0,t.pano0),Yt(e,0,t.pano0Depth),Jt(e,1,t.pano1),Yt(e,1,t.pano1Depth),Xt(e,(r=(n=t.panoFilter)==null?void 0:n.toValue())==null?null:r),Zt(e,t.refinedScreen),e.pointSize=t.pointSize,e.pointShape=t.pointShape,e.pointScale=t.pointScale,e.pointMaxPixel=t.pointMaxPixel,e.pointMinPixel=t.pointMinPixel,e.vertexMarks=t.vertexMarks,e.transition=t.transition,e.floorStyle=t.floorStyle,e.roofStyle=t.roofStyle,e.colorStyle=t.colorStyle,e.constantColor.copy(t.constantColor),e.shownFloorIndex=t.shownFloorIndex,e.useHDR=t.useHDR,e.maxDisplayBoost=t.maxDisplayBoost,e.colorSaturation=t.colorSaturation,e.colorBrightness=t.colorBrightness,e.gradientTexture=t.gradientTexture,e.modelBoundingMin.copy(t.boundingBox.min),e.modelBoundingMax.copy(t.boundingBox.max),e.modelAlpha=t.modelAlpha,e.progress=t.progress,e.opacity=t.opacity,e.brightness=t.brightness,e.transparent=e.alphaMode===`BLEND`,e.blending=l.NormalBlending,e.depthWrite=!0,e.depthTest=!0,t.useAddBlend&&(e.depthWrite=!1,e.depthTest=!1,e.blending=l.AdditiveBlending),e.shownFloorIndex>-1&&e.shownFloorIndex!==e.floorIndex&&(e.transparent=!0),e.opacity<1&&(e.transparent=!0),e.alphaMap&&e.alphaMode===`BLEND`&&(e.transparent=!0),e.colorAlpha<1&&e.alphaMode===`BLEND`&&(e.transparent=!0),e.brightness<1&&(e.transparent=!0),e.modelAlpha<=0&&(e.transparent=!1),e.depthWrite=!e.transparent,t.useAddBlend&&(e.depthWrite=!1,e.depthTest=!1,e.blending=l.AdditiveBlending),i!==qt(e)&&(e.needsUpdate=!0)}var $t=class extends l.Material{constructor(){super(),this.isPBMMaterial=!0,this.shaderType=`standard`,this.type=`PBMPointCloudMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}};function en(e,t){return!!e&&e.length>=t*4}function tn(e,t,n){let r=t*4;n.set(e[r]/127,e[r+1]/127,e[r+2]/127)}function nn(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;if(!(e!=null&&e.array)||t<=0)return null;let v=e.array,y=Math.max(1,e.itemSize),b=e.normalized===!0,x=e.array;if(x instanceof Int8Array&&y===4&&b&&x.length>=t*4)return x;let S=new Int8Array(t*4);if(b&&x instanceof Int8Array){for(let e=0;e<t;e++){let t=e*y,s=e*4;S[s]=(n=v[t])==null?0:n,S[s+1]=(i=(r=v[t+1])==null?v[t]:r)==null?0:i,S[s+2]=(o=(a=v[t+2])==null?v[t]:a)==null?0:o}return S}if(b&&x instanceof Uint8Array){for(let e=0;e<t;e++){let t=e*y,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((s=v[t])==null?0:s)/255*2-1)*127)),S[n+1]=Math.max(-127,Math.min(127,Math.round(((l=(c=v[t+1])==null?v[t]:c)==null?0:l)/255*2-1)*127)),S[n+2]=Math.max(-127,Math.min(127,Math.round(((d=(u=v[t+2])==null?v[t]:u)==null?0:d)/255*2-1)*127))}return S}if(x instanceof Float32Array&&y===3&&!b){for(let e=0;e<t;e++){let t=e*3,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((f=v[t])==null?0:f)*127))),S[n+1]=Math.max(-127,Math.min(127,Math.round(((p=v[t+1])==null?0:p)*127))),S[n+2]=Math.max(-127,Math.min(127,Math.round(((m=v[t+2])==null?0:m)*127)))}return S}for(let e=0;e<t;e++){let t=e*y,n=e*4;S[n]=Math.max(-127,Math.min(127,Math.round(((h=v[t])==null?0:h)*127))),S[n+1]=Math.max(-127,Math.min(127,Math.round(((g=v[t+1])==null?0:g)*127))),S[n+2]=Math.max(-127,Math.min(127,Math.round(((_=v[t+2])==null?0:_)*127)))}return S}var rn=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),an=[0,1,2,0,2,3],on=class e extends l.Mesh{constructor(t,n){var r;let i=n==null?new $t:n,a=e.createInstancedGeometry(t);super(a,i),this.isPBMPointCloud=!0,this.pointSize=`ATTENUATION`,this.pointShape=`CIRCLE`,this.pointScale=.02,this.pointMinPixel=0,this.pointMaxPixel=40,this.pointBack=`VISIBLE`,this.floorIndex=0,this.maxDisplayBoost=1,this.opacity=1,this.modelAlpha=1,this.brightness=1,this.floorStyle=`VISIBILITY`,this.shownFloorIndex=-1,this.colorStyle=`RGB`,this.constantColor=new l.Vector3(.6,.6,.6),this.gradientTexture=null,this.colorSaturation=0,this.colorBrightness=0,this.outlineGain=0,this.distanceGain=0,this.useAddBlend=!1,this.vertexMarks=!1,this.clippers=[],this.modelBoundingMin=new l.Vector3,this.modelBoundingMax=new l.Vector3,this.styleRevision=0,this._positionVersion=0,this.numPoints=(r=t==null?void 0:t.numPoints)==null?0:r,this.matrixAutoUpdate=!1,this.frustumCulled=!1,t!=null&&t.normals||(i.flatShading=!0),this._boundingBox=new l.Box3(new l.Vector3(1/0,1/0,1/0),new l.Vector3(-1/0,-1/0,-1/0)),t!=null&&t.positions&&this._computeBoundsFromArray(t.positions,this.numPoints,this._boundingBox)}get positions(){var e,t;return(t=(e=this.geometry.getAttribute(`instancePosition`))==null?void 0:e.array)==null?new Float32Array:t}get colors(){var e,t;return(t=(e=this.geometry.getAttribute(`instanceColor`))==null?void 0:e.array)==null?new Float32Array:t}get normals(){let e=this.geometry.getAttribute(`instanceNormal`);return e?e.array:null}get positionVersion(){return this._positionVersion}get pointCount(){return this.numPoints}get visiblePointCount(){return this.geometry.instanceCount===1/0?this.numPoints:this.geometry.instanceCount}set visiblePointCount(e){this.geometry.instanceCount=Math.max(0,Math.min(e,this.numPoints))}swapPositionsBuffer(e){let t=this.geometry.getAttribute(`instancePosition`);t&&t.array===e||(this.geometry.setAttribute(`instancePosition`,new l.InstancedBufferAttribute(e,3)),this._positionVersion=this._positionVersion+1|0)}setLocalBoundingBox(e){this._boundingBox.copy(e)}getLocalBoundingBoxExtents(){if(this._boundingBox.isEmpty())return;let{min:e,max:t}=this._boundingBox;return[e.x,e.y,e.z,t.x,t.y,t.z]}get boundingBox(){let e=new l.Vector3;this._boundingBox.getCenter(e),e.add(this.position);let t=new l.Vector3;this._boundingBox.getSize(t),t.multiply(this.scale);let n=new l.Vector3().copy(t).multiplyScalar(.5);return new l.Box3(e.clone().sub(n),e.clone().add(n))}dispose(){this.dispatchEvent({type:`dispose`}),this.geometry.dispose(),this.material.dispose()}raycast(e,t){var n,r;let i=this.matrixWorld,a=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r;if(this._boundingBox.isEmpty())return;let o=new l.Vector3;this._boundingBox.getCenter(o);let s=new l.Vector3;this._boundingBox.getSize(s);let c=Math.max(s.x,s.y,s.z)*.5,u=new l.Sphere(o,c);if(u.applyMatrix4(i),u.radius+=a,e.ray.intersectsSphere(u)===!1)return;let d=new l.Matrix4().copy(i).invert(),f=new l.Ray().copy(e.ray).applyMatrix4(d),p=a/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.positions,g=this.normals,_=this.numPoints,v=en(g,_),y=v?new l.Matrix3().getNormalMatrix(i):null,b=v?new l.Vector3:null;for(let n=0;n<_;n++){let r=new l.Vector3(h[n*3],h[n*3+1],h[n*3+2]),a=f.distanceSqToPoint(r);if(a<m){let o=new l.Vector3;f.closestPointToPoint(r,o),o.applyMatrix4(i);let s=e.ray.origin.distanceTo(o);if(s<e.near||s>e.far)continue;let c=null;v&&b&&y&&g&&(tn(g,n,b),b.lengthSq()>1e-12&&(b.applyMatrix3(y).normalize(),c={a:n,b:n,c:n,normal:b.clone(),materialIndex:0})),t.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:n,face:c,object:this})}}}_computeBoundsFromArray(e,t,n){let r=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,c=-1/0;for(let n=0;n<t;n++){let t=n*3,l=e[t],u=e[t+1],d=e[t+2];l<r&&(r=l),u<i&&(i=u),d<a&&(a=d),l>o&&(o=l),u>s&&(s=u),d>c&&(c=d)}Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(a)&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isFinite(c)&&(n.min.set(r,i,a),n.max.set(o,s,c))}static createInstancedGeometry(e){var t;let n=new l.InstancedBufferGeometry;n.setAttribute(`position`,new l.BufferAttribute(rn,3)),n.setIndex(an);let r=(t=e==null?void 0:e.numPoints)==null?0:t;if(e!=null&&e.positions&&n.setAttribute(`instancePosition`,new l.InstancedBufferAttribute(e.positions,3)),e!=null&&e.colors){let t=e.colors instanceof Uint8Array;n.setAttribute(`instanceColor`,new l.InstancedBufferAttribute(e.colors,3,t))}e!=null&&e.normals&&n.setAttribute(`instanceNormal`,new l.InstancedBufferAttribute(e.normals,4,!0)),n.instanceCount=r;let i=new l.Box3;if(e!=null&&e.positions){let t=new l.Vector3;for(let n=0;n<r;n++)t.set(e.positions[n*3],e.positions[n*3+1],e.positions[n*3+2]),i.expandByPoint(t)}return n.boundingBox=i,n.boundingSphere=new l.Sphere,i.getBoundingSphere(n.boundingSphere),n}},sn=`(function(){function e(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function t(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,c,\`next\`,e)}function c(e){t(o,i,a,s,c,\`throw\`,e)}s(void 0)})}}function r(){return i.apply(this,arguments)}function i(){return i=n(function*(e={}){var t,r=e,i=!1,a=!0,o=self.location.href;if(i||a){try{new URL(\`.\`,o).href}catch(e){}(function(){var e=n(function*(e){var t=yield fetch(e,{credentials:\`same-origin\`});if(t.ok)return t.arrayBuffer();throw Error(t.status+\` : \`+t.url)});return function(t){return e.apply(this,arguments)}})()}console.log.bind(console),console.error.bind(console);var s=!1;function c(e){for(var t=0,n=e.length,r=new Uint8Array(n),i;t<n;++t)i=e.charCodeAt(t),r[t]=~i>>8&i;return r}var l,u,d=!1;function f(){var e=N.buffer;new Int8Array(e),new Int16Array(e),r.HEAPU8=u=new Uint8Array(e),new Uint16Array(e),new Int32Array(e),r.HEAPU32=new Uint32Array(e),r.HEAPF32=new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function p(){if(r.preRun)for(typeof r.preRun==\`function\`&&(r.preRun=[r.preRun]);r.preRun.length;)E(r.preRun.shift());S(T)}function m(){d=!0,L.c()}function h(){if(r.postRun)for(typeof r.postRun==\`function\`&&(r.postRun=[r.postRun]);r.postRun.length;)w(r.postRun.shift());S(C)}var g;function _(){return c(\`\\0asm\\0\\0\\0\\\`\\\`\\0\\\`
303
303
  \\0\\\`\\0\\0\\x07aa\\0\\0\\0\\0\\x07‚€€\\bA€Œ\\v\\x07b\\0c\\0d\\0e\\0f\\0\\f
304
304
  ü8T~@A€\\b(\\0"­ \\0­B\\x07|Bøÿÿÿƒ|"BÿÿÿÿX@ §"\\0?\\0AtM\\r \\0\\0\\r\\vA„\\bA06\\0A\\vA€\\b \\x006\\0 \\vß\\v\\b@ \\0E\\r\\0 \\0A\\bk" \\0Ak(\\0"Axq"\\0j!@ Aq\\r\\0 AqE\\r  (\\0"k"A˜\\b(\\0I\\r \\0 j!\\0@@@Aœ\\b(\\0 G@ (\\f! AÿM@  (\\b"G\\rAˆ\\bAˆ\\b(\\0A~ Avwq6\\0\\f\\v (!\\x07  G@ (\\b" 6\\f  6\\b\\f\\v (" Aj ("E\\r Aj\\v!@ ! "Aj! ("\\r\\0 Aj! ("\\r\\0\\v A\\x006\\0\\f\\v ("AqAG\\rA\\b \\x006\\0  A~q6  \\0Ar6  \\x006\\0\\v  6\\f  6\\b\\f\\vA\\0!\\v \\x07E\\r\\0@ ("At"(¸
305
305
  F@ A¸
@@ -342,7 +342,7 @@ Aj$\\0 \\0\\v†
342
342
  *\\b ”
343
343
  *\\0 ”
344
344
  * ”’’’! \\v!
345
- \\v  j   ”  ”  ”’’’¼"\\v \\vAsAÿÿÿÿ\\x07q \\vA\\0H\\x1B"\\v6\\0 \\b \\vAÿÿqAtj" (\\0Aj6\\0 \\vAvAüÿqj"\\v \\v(\\0Aj6\\0 \\fAj!\\f\\f\\v\\v\\v\\0\\v\\v \\0A\\b\\v\`)}function v(e){return e}function y(e,t){var n,r=v(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}function b(){return{a:F}}function x(){function e(e,t){return L=e.exports,P(L),f(),L}var t=b();return r.instantiateWasm?new Promise((n,i)=>{r.instantiateWasm(t,(t,r)=>{n(e(t,r))})}):(g!=null||(g=_()),e(y(g,t)[0]))}for(var S=e=>{for(;e.length>0;)e.shift()(r)},C=[],w=e=>C.push(e),T=[],E=e=>T.push(e),D=()=>2147483648,O=(e,t)=>Math.ceil(e/t)*t,k=e=>{var t=(e-N.buffer.byteLength+65535)/65536|0;try{return N.grow(t),f(),1}catch(e){}},A=e=>{var t=u.length;e>>>=0;var n=D();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),k(Math.min(n,O(Math.max(e,i),65536))))return!0}return!1},j=new Uint8Array(123),M=25;M>=0;--M)j[48+M]=52+M,j[65+M]=M,j[97+M]=26+M;if(j[43]=62,j[47]=63,r.noExitRuntime&&r.noExitRuntime,r.print&&r.print,r.printErr&&r.printErr,r.wasmBinary&&r.wasmBinary,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram,r.preInit)for(typeof r.preInit==\`function\`&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.shift()();var N;function P(e){r._sort=e.d,r._malloc=e.e,r._free=e.f,N=e.b,e.__indirect_function_table}var F={a:A};function I(){p();function e(){var e;r.calledRun=!0,!s&&(m(),l==null||l(r),(e=r.onRuntimeInitialized)==null||e.call(r),h())}r.setStatus?(r.setStatus(\`Running...\`),setTimeout(()=>{setTimeout(()=>r.setStatus(\`\`),1),e()},1)):e()}var L=x();return I(),t=d?r:new Promise((e,t)=>{l=e}),t}),i.apply(this,arguments)}let a,o=!1;function s(){return e(this,void 0,void 0,function*(){if(!(a||o))try{a=yield r()}catch(e){o=!0,self.postMessage({error:e instanceof Error?e.message:String(e)})}})}let c,l,u,d,f,p,m,h,g,_,v=0,y=0,b=!1,x=[],S=!0,C=!0,w=!1,T=!1,E=!1;function D(e,t){if(t.length!==16)return!0;for(let n=0;n<16;n++)if(Math.abs(e[n]-t[n])>1e-7)return!0;return!1}let O=[],k=65536,A=()=>e(void 0,void 0,void 0,function*(){if(w){T=!0;return}if(w=!0,T=!1,a||(yield s()),!a){w=!1;return}let e=Math.pow(2,Math.ceil(Math.log2(c.vertexCount)));v<e&&(v>0&&(a._free(l),a._free(d),a._free(f),a._free(p),a._free(m),a._free(h)),v=e,l=a._malloc(64),d=a._malloc(v*4),f=a._malloc(3*v*4),p=a._malloc(v*4),m=a._malloc(v*4),h=a._malloc(v*4)),b||(g=a._malloc(k*4),_=a._malloc(k*4),b=!0),y<c.transforms.length&&(y>0&&a._free(u),y=c.transforms.length,u=a._malloc(y*4)),w=!1,T&&(T=!1,yield A())}),j=()=>{if(w||T||!a)return;w=!0,C&&(a.HEAPF32.set(c.positions,f/4),a.HEAPF32.set(c.transforms,u/4),a.HEAPU32.set(c.transformIndices,d/4),C=!1),a.HEAPF32.set(new Float32Array(x),l/4),a._sort(l,u,d,c.vertexCount,f,p,m,h,g,_);let e=c.vertexCount,t=new Uint32Array(a.HEAPU32.buffer,m,e),n=e*4,r=O.pop();(!r||r.byteLength<n)&&(r=new ArrayBuffer(n));let i=new Uint32Array(r,0,e);i.set(t),self.postMessage({depthIndex:i,generation:c.generation},[r]),w=!1,S=!1},M=()=>{E||(E=!0,S&&j(),setTimeout(()=>{E=!1,M()}))};self.onmessage=t=>new Promise(n=>{e(void 0,void 0,void 0,function*(){var e;if(t.data.warmup){yield s(),n(!0);return}if(t.data.returnBuffer){O.length<3&&O.push(t.data.returnBuffer),n(!0);return}if(o){n(!0);return}let r=!1,i=!!t.data.sortData;if(t.data.sortData&&(c={positions:t.data.sortData.positions,transforms:t.data.sortData.transforms,transformIndices:t.data.sortData.transformIndices,vertexCount:t.data.sortData.vertexCount,generation:(e=t.data.sortData.generation)==null?0:e},S=!0,C=!0,yield A(),r=!0),t.data.viewProj){let e=t.data.viewProj;(D(e,x)||i)&&(x=e,S=!0,r=!0)}r&&S&&M(),n(!0)})})})();`,cn=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,sn],{type:`text/javascript;charset=utf-8`});function ln(e){let t;try{if(t=cn&&(self.URL||self.webkitURL).createObjectURL(cn),!t)throw``;let n=new Worker(t,{name:e==null?void 0:e.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(sn),{name:e==null?void 0:e.name})}}var{Fn:un,vec2:dn,vec3:fn,vec4:pn,ivec2:mn,float:U,int:hn,uint:gn,mat3:_n,mat4:vn,bool:yn,If:bn,Loop:xn,Discard:Sn,Return:Cn,attribute:wn,varyingProperty:Tn,uniform:En,uniformArray:Dn,textureLoad:On,instanceIndex:kn,positionGeometry:An,cameraPosition:jn,cameraProjectionMatrix:Mn,cameraViewMatrix:Nn,viewportSize:Pn,abs:Fn,sign:In,max:Ln,min:Rn,clamp:zn,floor:Bn,fract:Vn,sqrt:Hn,exp:Un,sin:Wn,cos:Gn,normalize:Kn,length:qn,dot:Jn,mix:Yn,select:Xn,transpose:Zn,unpackHalf2x16:Qn,uintBitsToFloat:$n,colorSpaceToWorking:er}=l.TSL,tr=.3,nr=2048,rr=.4886025119029199,ir=1.0925484,ar=-1.0925484,or=.3153916,sr=-1.0925484,cr=.5462742;function lr(e){let t=e===`RGBA32UI`?new l.DataTexture(new Uint32Array(4),1,1,l.RGBAIntegerFormat,l.UnsignedIntType):new l.DataTexture(new Uint32Array(1),1,1,l.RedIntegerFormat,l.UnsignedIntType);return t.minFilter=l.NearestFilter,t.magFilter=l.NearestFilter,t.generateMipmaps=!1,t.flipY=!1,t.needsUpdate=!0,t}function ur(){let e=new l.DataTexture(new Float32Array(4),1,1,l.RGBAFormat,l.FloatType);return e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.generateMipmaps=!1,e.flipY=!1,e.needsUpdate=!0,e}var dr=class extends l.NodeMaterial{constructor(e={}){var t,n,r;super(),this.isPBMGaussianSplattingMaterial=!0,this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.numPoints=0,this.shTextureSize=new l.Vector2(1,1),this.aggregationEnabled=!1,this.aggregationProgress=0,this.aggregationPointDuration=.6,this.aggregationBoundsMin=new l.Vector3,this.aggregationBoundsMax=new l.Vector3,this.layerClipperRanges=[],this.clipperMatricesInverse=[],this._uDataTex=null,this._uNumPoints=null,this._uTransformsTex=null,this._uTransformIndicesTex=null,this._uLayerIndicesTex=null,this._uShTex=null,this._uShTextureSize=null,this._uAggregationEnabled=null,this._uAggregationProgress=null,this._uAggregationPointDuration=null,this._uAggregationBoundsMin=null,this._uAggregationBoundsMax=null,this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=-1,this._cachedClipperCount=-1,this.type=`PBMGaussianSplattingNodeMaterial`,this.lights=!1,this.side=l.DoubleSide,this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.blending=l.NormalBlending,this.maxShDegree=(t=e.maxShDegree)==null?0:t,this.numGsLayers=(n=e.numGsLayers)==null?0:n,this.numGsClippers=(r=e.numGsClippers)==null?0:r}customProgramCacheKey(){return super.customProgramCacheKey()+`,`+[this.maxShDegree,this.numGsLayers,this.numGsClippers].join(`,`)}syncDynamicUniforms(){this._uDataTex!==null&&(this.dataTexture&&this._uDataTex.value!==this.dataTexture&&(this._uDataTex.value=this.dataTexture),this._uNumPoints&&(this._uNumPoints.value=this.numPoints),this.transformsTexture&&this._uTransformsTex.value!==this.transformsTexture&&(this._uTransformsTex.value=this.transformsTexture),this.transformIndicesTexture&&this._uTransformIndicesTex.value!==this.transformIndicesTexture&&(this._uTransformIndicesTex.value=this.transformIndicesTexture),this.layerIndicesTexture&&this._uLayerIndicesTex.value!==this.layerIndicesTexture&&(this._uLayerIndicesTex.value=this.layerIndicesTexture),this.shTexture&&this._uShTex.value!==this.shTexture&&(this._uShTex.value=this.shTexture),this._uAggregationEnabled.value=+!!this.aggregationEnabled,this._uAggregationProgress.value=this.aggregationProgress,this._uAggregationPointDuration.value=this.aggregationPointDuration)}_ensureUniforms(){var e,t,n,r,i;this._uDataTex===null?(this._uDataTex=On((e=this.dataTexture)==null?lr(`RGBA32UI`):e),this._uNumPoints=En(this.numPoints,`uint`),this._uTransformsTex=On((t=this.transformsTexture)==null?ur():t),this._uTransformIndicesTex=On((n=this.transformIndicesTexture)==null?lr(`R32UI`):n),this._uLayerIndicesTex=On((r=this.layerIndicesTexture)==null?lr(`R32UI`):r),this._uShTex=On((i=this.shTexture)==null?ur():i),this._uShTextureSize=En(this.shTextureSize),this._uAggregationEnabled=En(+!!this.aggregationEnabled),this._uAggregationProgress=En(this.aggregationProgress),this._uAggregationPointDuration=En(this.aggregationPointDuration),this._uAggregationBoundsMin=En(this.aggregationBoundsMin),this._uAggregationBoundsMax=En(this.aggregationBoundsMax),this.numGsClippers>0&&(this._uLayerClipperRanges=Dn(this.layerClipperRanges.length?this.layerClipperRanges:[new l.Vector2],`vec2`),this._uClipperMatricesInverse=Dn(this.clipperMatricesInverse.length?this.clipperMatricesInverse:[new l.Matrix4],`mat4`),this._cachedLayerCount=this.numGsLayers,this._cachedClipperCount=this.numGsClippers)):(this.dataTexture&&(this._uDataTex.value=this.dataTexture),this._uNumPoints.value=this.numPoints,this.transformsTexture&&(this._uTransformsTex.value=this.transformsTexture),this.transformIndicesTexture&&(this._uTransformIndicesTex.value=this.transformIndicesTexture),this.layerIndicesTexture&&(this._uLayerIndicesTex.value=this.layerIndicesTexture),this.shTexture&&(this._uShTex.value=this.shTexture),this._uShTextureSize.value=this.shTextureSize,this._uAggregationEnabled.value=+!!this.aggregationEnabled,this._uAggregationProgress.value=this.aggregationProgress,this._uAggregationPointDuration.value=this.aggregationPointDuration,this._uAggregationBoundsMin.value=this.aggregationBoundsMin,this._uAggregationBoundsMax.value=this.aggregationBoundsMax,this.numGsClippers>0&&(this._cachedLayerCount!==this.numGsLayers||this._cachedClipperCount!==this.numGsClippers||!this._uLayerClipperRanges)?(this._uLayerClipperRanges=Dn(this.layerClipperRanges.length?this.layerClipperRanges:[new l.Vector2],`vec2`),this._uClipperMatricesInverse=Dn(this.clipperMatricesInverse.length?this.clipperMatricesInverse:[new l.Matrix4],`mat4`),this._cachedLayerCount=this.numGsLayers,this._cachedClipperCount=this.numGsClippers):this.numGsClippers===0&&(this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=0,this._cachedClipperCount=0))}_buildSHUv(e,t,n){let r=this.maxShDegree,i=0;r>=1&&(i+=9),r>=2&&(i+=15),r>=3&&(i+=21);let a=i;a%4!=0&&(a=(Math.floor(a/4)+1)*4);let o=e.mul(a/4).add(t/4).toInt(),s=n.x.toInt();return mn(o.mod(s),o.div(s))}setup(e){this._ensureUniforms();let t=this._uDataTex,n=this._uNumPoints,r=this._uTransformsTex,i=this._uShTex,a=this._uShTextureSize,o=this._uAggregationEnabled,s=this._uAggregationProgress,c=this._uAggregationPointDuration,u=this._uAggregationBoundsMin,d=this._uAggregationBoundsMax,f=this._uLayerClipperRanges,p=this._uClipperMatricesInverse,m=this,h=Tn(`vec4`,`vColorGS`),g=Tn(`vec2`,`vPositionGS`),_=un(()=>{let e=wn(`splatIndex`,`float`).add(.5).toUint().toVar(),_=e.toInt(),v=e.greaterThanEqual(n).toVar(),y=gn(2048),b=e.mul(gn(2)).toVar(),x=b.add(gn(1)).toVar(),S=mn(b.mod(y).toInt(),b.div(y).toInt()),C=mn(x.mod(y).toInt(),x.div(y).toInt()),w=t.load(S).toVar(),T=t.load(C).toVar(),E=fn($n(w.x.toUint()),$n(w.y.toUint()),$n(w.z.toUint())).toVar(),D=pn(U(w.w.toUint().bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(8)).bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(16)).bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(24)).bitAnd(gn(255)))).div(255).toVar(),O=Qn(T.x.toUint()),k=Qn(T.y.toUint()),A=Qn(T.z.toUint()),j=_n(fn(O.x,O.y,k.x),fn(O.y,k.y,A.x),fn(k.x,A.x,A.y)).toVar(),M=T.w.toUint().shiftRight(gn(16)).toInt(),N=T.w.toUint().bitAnd(gn(65535)).toInt(),ee=vn(r.load(mn(0,M)),r.load(mn(1,M)),r.load(mn(2,M)),r.load(mn(3,M))).toVar(),P=()=>vn(r.load(mn(5,M)),r.load(mn(6,M)),r.load(mn(7,M)),r.load(mn(8,M))),te=Nn.mul(ee).toVar(),F=ee.mul(pn(E,1)).toVar(),ne=pn(0,0,2,1).toVar(),re=U(0).toVar(),ie=yn(!1).toVar();bn(o.equal(1).and(s.lessThan(1)),()=>{bn(F.x.greaterThanEqual(u.x).and(F.x.lessThanEqual(d.x)).and(F.z.greaterThanEqual(u.z)).and(F.z.lessThanEqual(d.z)),()=>{ie.assign(!0);let e=d.y.sub(u.y),t=Xn(e.greaterThan(.001),zn(F.y.sub(u.y).div(e),0,1),U(.5)),n=zn(c,.01,1),r=U(1).sub(t).mul(U(1).sub(n)),i=zn(s.sub(r).div(n),0,1).toVar(),a=i.mul(i).mul(U(3).sub(i.mul(2)));re.assign(i.mul(i).mul(i));let o=u.add(d).mul(.5),l=qn(F.xyz.sub(o)),f=Jn(E,fn(12.9898,78.233,45.164)),p=Vn(Wn(f).mul(43758.5453)),m=f.mul(10),h=Kn(fn(Gn(m),Yn(-.7,.1,Vn(Wn(f.mul(1.7)).mul(43758.5453))),Wn(m))),g=U(1).sub(a).mul(U(1).add(p)),_=h.mul(l).mul(g);F.assign(pn(F.xyz.add(_),F.w)),E.assign(P().mul(F).xyz)})});let ae=yn(!1).toVar();if(m.numGsClippers>0&&m.numGsLayers>0){let e=N.toVar();bn(e.greaterThanEqual(0).and(e.lessThan(m.numGsLayers)),()=>{let t=f.element(e),n=t.x.add(.5).toInt(),r=t.y.add(.5).toInt(),i=n.add(r);xn({start:hn(0),end:hn(m.numGsClippers),type:`int`},({i:e})=>{bn(e.greaterThanEqual(n).and(e.lessThan(i)),()=>{let t=p.element(e).mul(F);bn(t.x.greaterThan(-.5).and(t.x.lessThan(.5)).and(t.y.greaterThan(-.5)).and(t.y.lessThan(.5)).and(t.z.greaterThan(-.5)).and(t.z.lessThan(.5)),()=>{ae.assign(!0)})})})})}let I=te.mul(pn(E,1)).toVar(),L=Mn.mul(I).toVar(),R=L.w.mul(1.2),oe=L.z.lessThan(L.w.negate()).or(L.z.greaterThan(L.w)),se=L.x.lessThan(R.negate()).or(L.x.greaterThan(R)),ce=L.y.lessThan(R.negate()).or(L.y.greaterThan(R)),le=oe.or(se).or(ce);return bn(v.not().and(ae.not()).and(le.not()),()=>{let e=L.xyz.div(L.w),t=Pn,n=dn(Mn.element(0).element(0).mul(t.x).mul(.5),Mn.element(1).element(1).mul(t.y).mul(.5)),r=Mn.element(3).element(3).greaterThan(.7),c=U(1).div(I.z.mul(I.z)),u=_n(fn(n.x.div(I.z),U(0),n.x.mul(I.x).mul(c).negate()),fn(U(0),n.y.div(I.z),n.y.mul(I.y).mul(c).negate()),fn(U(0),U(0),U(0))),d=_n(fn(n.x,U(0),U(0)),fn(U(0),n.y,U(0)),fn(U(0),U(0),U(0))),f=_n(Xn(r,d.element(0),u.element(0)),Xn(r,d.element(1),u.element(1)),Xn(r,d.element(2),u.element(2))),p=te,v=Zn(_n(p.element(0).xyz,p.element(1).xyz,p.element(2).xyz)).mul(f),y=Zn(v).mul(j).mul(v).toVar(),b=y.element(0).element(0).add(tr),x=y.element(1).element(1).add(tr),S=y.element(0).element(1),C=b,w=x,T=S,O=C.mul(w).sub(T.mul(T)),k=C.add(w).mul(.5),A=Hn(Ln(.1,k.mul(k).sub(O))),M=k.add(A),N=k.sub(A);bn(N.greaterThan(0),()=>{let n=Kn(dn(T,M.sub(C))),r=dn(n.y,n.x.negate()),c=n.mul(Rn(Hn(M.mul(2)),U(nr))),u=r.mul(Rn(Hn(N.mul(2)),U(nr))),d=dn(U(1).div(t.x),U(1).div(t.y)),f=An.xy,p=dn(f.x.mul(c.x).add(f.y.mul(u.x)),f.x.mul(c.y).add(f.y.mul(u.y))).mul(d).mul(2).toVar();bn(o.equal(1),()=>{let e=Xn(ie,re,s.mul(s).mul(s));p.assign(p.mul(Yn(.1,1,e)))});let v=D.toVar();if(m.maxShDegree>=1){let e=P().mul(pn(jn,1)).xyz,t=Kn(E.sub(e)),n=t.x,r=t.y,o=t.z,s=m._buildSHUv(_,0,a),c=m._buildSHUv(_,4,a),l=m._buildSHUv(_,8,a),u=i.load(s),d=i.load(c),f=i.load(l),p=u.rgb,h=fn(u.a,d.r,d.g),g=fn(d.b,d.a,f.r),y=p.mul(U(-.4886025119029199).mul(r)).add(h.mul(U(rr).mul(o))).add(g.mul(U(-.4886025119029199).mul(n)));if(v.assign(pn(v.rgb.add(y),v.a)),m.maxShDegree>=2){let e=m._buildSHUv(_,12,a),t=m._buildSHUv(_,16,a),s=m._buildSHUv(_,20,a),c=i.load(e),l=i.load(t),u=i.load(s),d=f.gba,p=c.rgb,h=fn(c.a,l.r,l.g),g=fn(l.b,l.a,u.r),y=u.gba,b=n.mul(n),x=r.mul(r),S=o.mul(o),C=n.mul(r),w=r.mul(o),T=n.mul(o),E=d.mul(U(ir).mul(C)).add(p.mul(U(ar).mul(w))).add(h.mul(U(or).mul(S.mul(2).sub(b).sub(x)))).add(g.mul(U(sr).mul(T))).add(y.mul(U(cr).mul(b.sub(x))));v.assign(pn(v.rgb.add(E),v.a))}}v.assign(pn(zn(v.rgb,fn(0),fn(1)),v.a)),h.assign(er(v,l.SRGBColorSpace)),g.assign(f.mul(2)),ne.assign(pn(e.xy.add(p),e.z,1))})}),ne});this.vertexNode=_();let v=un(()=>{let e=Jn(g,g).negate();Sn(e.lessThan(-4));let t=Un(e).mul(h.a);return pn(h.rgb,t)});this.fragmentNode=v(),super.setup(e)}copy(e){return super.copy(e),this.dataTexture=e.dataTexture,this.numPoints=e.numPoints,this.transformsTexture=e.transformsTexture,this.transformIndicesTexture=e.transformIndicesTexture,this.layerIndicesTexture=e.layerIndicesTexture,this.shTexture=e.shTexture,this.shTextureSize.copy(e.shTextureSize),this.aggregationEnabled=e.aggregationEnabled,this.aggregationProgress=e.aggregationProgress,this.aggregationPointDuration=e.aggregationPointDuration,this.aggregationBoundsMin.copy(e.aggregationBoundsMin),this.aggregationBoundsMax.copy(e.aggregationBoundsMax),this.maxShDegree=e.maxShDegree,this.numGsLayers=e.numGsLayers,this.numGsClippers=e.numGsClippers,this.layerClipperRanges=e.layerClipperRanges.map(e=>e.clone()),this.clipperMatricesInverse=e.clipperMatricesInverse.map(e=>e.clone()),this._uDataTex=null,this._uNumPoints=null,this._uTransformsTex=null,this._uTransformIndicesTex=null,this._uLayerIndicesTex=null,this._uShTex=null,this._uShTextureSize=null,this._uAggregationEnabled=null,this._uAggregationProgress=null,this._uAggregationPointDuration=null,this._uAggregationBoundsMin=null,this._uAggregationBoundsMax=null,this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=-1,this._cachedClipperCount=-1,this}},fr=2,pr=8,mr=4,hr=fr*mr,gr=7,_r=class{constructor(e=2048){this.regionMap=new Map,this.regionList=[],this.data=new Uint32Array,this._tex=null,this.texHeight=0,this.width=e}get totalPoints(){let e=0;for(let t of this.regionList)e+=t.count;return e}get regions(){return this.regionList}get dataTexture(){return this._tex}sync(e,t){let n=new Set(e);for(let e of Array.from(this.regionMap.keys()))n.has(e)||this.regionMap.delete(e);let r=[],i=0;for(let n of e){let e=this.regionMap.get(n),{transformIndex:a,layerIndex:o}=t(n);e?(e.transformIndex=a,e.layerIndex=o):(e={object:n,start:0,count:n.numPoints,transformIndex:a,layerIndex:o},this.regionMap.set(n,e)),e.start=i,i+=e.count,r.push(e)}this.regionList=r}assemble(){let e=0;for(let t of this.regionList)t.start=e,e+=t.count;let t=e;if(t<=0){this.disposeTexture();return}let n=Math.max(1,Math.ceil(t*fr/this.width)),r=this.width*n*mr,i=!this._tex||n!==this.texHeight||this.data.length<r;i&&(this.data=new Uint32Array(r));let a=this.data;for(let e of this.regionList){let t=e.object.packedData,n=e.start*hr,r=((e.transformIndex&65535)<<16|e.layerIndex&65535)>>>0;if(!t||t.length<e.count*pr){a.fill(0,n,n+e.count*hr);continue}a.set(t.subarray(0,e.count*pr),n);for(let t=0;t<e.count;t++)a[n+t*hr+gr]=r}if(i){this.disposeTexture();let e=new l.DataTexture(a,this.width,n,l.RGBAIntegerFormat,l.UnsignedIntType);e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.generateMipmaps=!1,e.flipY=!1,e.needsUpdate=!0,this._tex=e,this.texHeight=n}else this._tex.image.data=a,this._tex.needsUpdate=!0}extractSortInputs(){let e=this.totalPoints,t=new Float32Array(e*3),n=new Uint32Array(e);for(let e of this.regionList){let r=e.object.packedData;if(r.length<e.count*pr)continue;let i=new Float32Array(r.buffer,r.byteOffset,r.length);for(let r=0;r<e.count;r++){let a=e.start+r;t[a*3+0]=i[r*8+0],t[a*3+1]=i[r*8+1],t[a*3+2]=i[r*8+2],n[a]=e.transformIndex>>>0}}return{positions:t,transformIndices:n,count:e}}dispose(){this.regionMap.clear(),this.regionList=[],this.disposeTexture(),this.data=new Uint32Array}disposeTexture(){this._tex&&(this._tex.dispose(),this._tex=null),this.texHeight=0}},vr=9,yr=vr*4,br=20,xr=new l.Matrix4,Sr=class{constructor(){this.texture=null,this.width=vr,this.data=new Float32Array,this.sortTransforms=new Float32Array,this.indexMap=new Map,this.count=0}indexOf(e){return this.indexMap.get(e)}get objectCount(){return this.count}get transforms(){return this.sortTransforms}sync(e){this.indexMap.clear(),this.count=e.length;let t=Math.max(1,this.count)*yr;this.data.length<t&&(this.data=new Float32Array(t));let n=Math.max(1,this.count)*br;this.sortTransforms.length<n&&(this.sortTransforms=new Float32Array(n));for(let t=0;t<e.length;t++){let n=e[t];this.indexMap.set(n,t),this.writeObject(t,n)}this.rebuildTexture()}updateOne(e){let t=this.indexMap.get(e);t!==void 0&&(this.writeObject(t,e),this.texture&&(this.texture.needsUpdate=!0))}writeObject(e,t){let n=t.matrixWorld.elements,r=+!!t.selected,i=e*yr;this.data.set(n,i),this.data[i+16]=r,this.data[i+17]=0,this.data[i+18]=0,this.data[i+19]=0,xr.copy(t.matrixWorld).invert(),this.data.set(xr.elements,i+20);let a=e*br;this.sortTransforms.set(n,a),this.sortTransforms[a+16]=r,this.sortTransforms[a+17]=0,this.sortTransforms[a+18]=0,this.sortTransforms[a+19]=0}rebuildTexture(){let e=Math.max(1,this.count);this.texture&&this.texture.dispose();let t=new l.DataTexture(this.data,this.width,e,l.RGBAFormat,l.FloatType);t.minFilter=l.NearestFilter,t.magFilter=l.NearestFilter,t.generateMipmaps=!1,t.needsUpdate=!0,this.texture=t}dispose(){this.texture&&(this.texture.dispose(),this.texture=null)}},Cr=class{constructor(){this.layerKeys=[],this.layerKeyToIndex=new Map,this.objectLayerIndex=new Map}sync(e){this.layerKeys=[],this.layerKeyToIndex.clear(),this.objectLayerIndex.clear();for(let t of e){let e=t.gsViewLayerKey||t.uuid,n=this.layerKeyToIndex.get(e);n===void 0&&(n=this.layerKeys.length,this.layerKeys.push(e),this.layerKeyToIndex.set(e,n)),this.objectLayerIndex.set(t,n)}}layerIndexOf(e){var t;return(t=this.objectLayerIndex.get(e))==null?0:t}get layerCount(){return this.layerKeys.length}},wr=2048,Tr=4,Er=class{constructor(){this.texture=null,this.textureSize=new l.Vector2,this.dataMaxDegree=0,this.appliedDegree=0}sync(e,t){let n=0,r=0;for(let t of e)t.maxSHDegree>n&&(n=t.maxSHDegree),r+=t.numPoints;this.dataMaxDegree=n;let i=Math.min(t,n);if(this.appliedDegree=i,i<=0||r===0)return this.appliedDegree=0,!1;let a=0;i>=1&&(a+=9),i>=2&&(a+=15),i>=3&&(a+=21);let o=a;o%Tr!==0&&(o=Math.ceil(o/Tr)*Tr);let s=o/Tr,c=r*s,u=wr,d=Math.ceil(c/u),f=new Float32Array(u*d*Tr),p=0;for(let t of e){let e=t.sh1,n=t.sh2,r=t.sh3;for(let a=0;a<t.numPoints;a++){let t=(p+a)*s,o=0;if(e&&i>=1)for(let n=0;n<9;n++){let r=t+Math.floor(o/Tr),i=o%Tr;f[r*Tr+i]=e[a*9+n],o++}if(n&&i>=2)for(let e=0;e<15;e++){let r=t+Math.floor(o/Tr),i=o%Tr;f[r*Tr+i]=n[a*15+e],o++}if(r&&i>=3)for(let e=0;e<21;e++){let n=t+Math.floor(o/Tr),i=o%Tr;f[n*Tr+i]=r[a*21+e],o++}}p+=t.numPoints}this.texture&&this.texture.dispose();let m=new l.DataTexture(f,u,d,l.RGBAFormat,l.FloatType);return m.minFilter=l.NearestFilter,m.magFilter=l.NearestFilter,m.generateMipmaps=!1,m.needsUpdate=!0,this.texture=m,this.textureSize.set(u,d),!0}dispose(){this.texture&&(this.texture.dispose(),this.texture=null)}},Dr=new l.Vector3,Or=new l.Vector3,kr=new l.Quaternion,Ar=new l.Quaternion,jr=new l.Vector3,Mr=class extends l.Mesh{constructor(){super(),this.needsRender=!1,this.assembler=new _r,this.transformStore=new Sr,this.layerRegistry=new Cr,this.shStore=new Er,this.sortWorker=null,this.assemblePending=!1,this.splatIndexCapacity=0,this.sortGeneration=0,this.sortDataUploaded=!1,this.sortInputsDirty=!1,this.forceClipperUniformRefresh=!1,this.sortWorkerFailed=!1,this.orderCount=0,this.orderData=null,this.orderDirty=!1,this.layoutDirty=!1,this.aliveCount=0,this.orderBaseSnapshot=[],this.snapshotByGen=new Map,this.prevSortCameraMatrix=null,this.sortCameraDistance=1,this.sortCameraCoorient=.99,this.sortMinIntervalMs=0,this.sortLastTime=-1/0,this._scratchViewProj=new l.Matrix4,this.usedSHDegree=0,this.onBeforeRender=(e,t,n,...r)=>{let i=n,a=this.collectObjects(t);if(a.length===0){this.geometry.instanceCount=0;return}let o=0;for(let e of a)e.usedSHDegree>o&&(o=e.usedSHDegree);let s=o!==this.usedSHDegree;this.usedSHDegree=o,this.isSceneNeedsRebuild(a)?(this.rebuildScene(a),this.gsSceneState.lastClipperHash=``,this.forceClipperUniformRefresh=!0,this.sortDataUploaded=!1,this.sortInputsDirty=!0,this.layoutDirty=!0):s&&this.shStore.sync(a,this.usedSHDegree);for(let e of a)e.transformChanged&&(this.transformStore.updateOne(e),e.transformChanged=!1,e.selectedChanged=!1,this.sortInputsDirty=!0);let c=this._scratchViewProj.multiplyMatrices(i.perspectiveProjectionMatrix,i.matrixWorldInverse);this.requestSort(i,c.elements),(this.orderDirty||this.layoutDirty)&&(this.applyReorderCPU(this.snapshotLayout()),this.orderDirty=!1,this.layoutDirty=!1);let l=this.getClipperHash(a);(this.forceClipperUniformRefresh||l!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(a),this.gsSceneState.lastClipperHash=l,this.forceClipperUniformRefresh=!1,this.needsRender=!0),this.assemblePending&&(this.assembler.assemble(),this.assemblePending=!1),this.syncMaterialTextures(),this.material.syncDynamicUniforms();let u=!this.sortWorkerFailed&&this.assembler.totalPoints>0&&this.material.dataTexture!==null&&this.orderCount>0&&this.aliveCount>0;this.geometry.instanceCount=u?this.aliveCount:0};let e=this.createGeometry(),t=this.createMaterial();this.geometry=e,this.material=t,this.frustumCulled=!1,this.renderOrder=-99999999999,this.gsSceneState={lastObjectsHash:``,lastClipperHash:``},this.sortWorker=new ln,this.sortWorker.postMessage({warmup:!0}),this.sortWorker.onmessage=e=>{var t;if(e.data.error){this.sortWorkerFailed=!0,this.geometry.instanceCount=0;return}if(e.data.depthIndex){let n=e.data.depthIndex,r=e.data.generation;this.applyDepthIndex(n,r);let i=n.buffer;i.byteLength>0&&((t=this.sortWorker)==null||t.postMessage({returnBuffer:i},[i]))}}}createGeometry(){let e=new l.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new l.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new l.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity),i=new l.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(l.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}ensureSplatIndexCapacity(e){let t=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return t;let n=Math.max(this.splatIndexCapacity,1);for(;n<e;)n*=2;let r=new Float32Array(n);r.set(t.array.subarray(0,Math.min(t.array.length,n)));let i=new l.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(l.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,i),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,i}createMaterial(){return new dr({numGsLayers:0,numGsClippers:0,maxShDegree:0})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new l.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new l.Matrix4)}applyDepthIndex(e,t){this.orderData=e.slice(),this.orderCount=this.orderData.length,this.orderDirty=!0;let n=this.snapshotByGen.get(t);if(n){this.orderBaseSnapshot=n;for(let e of Array.from(this.snapshotByGen.keys()))e<t&&this.snapshotByGen.delete(e)}this.needsRender=!0}snapshotLayout(){return this.assembler.regions.map(e=>({object:e.object,start:e.start,count:e.count}))}buildSegments(e,t){let n=new Map;for(let e of t)n.set(e.object,e.start);let r=[];for(let t of e){let e=n.get(t.object),i=e===void 0,a=i?0:e-t.start,o=r[r.length-1];o&&o.removed===i&&(i||o.delta===a)&&o.oldEnd===t.start?o.oldEnd=t.start+t.count:r.push({oldStart:t.start,oldEnd:t.start+t.count,delta:a,removed:i})}return r}findSegment(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>1,a=e[i];if(t<a.oldStart)r=i-1;else if(t>=a.oldEnd)n=i+1;else return a}return null}applyReorderCPU(e){if(this.orderCount<=0||!this.orderData){this.aliveCount=0,this.geometry.instanceCount=0;return}let t=this.buildSegments(this.orderBaseSnapshot,e),n=this.ensureSplatIndexCapacity(this.orderCount),r=n.array,i=this.orderData,a=0;for(let e=0;e<this.orderCount;e++){let n=i[e],o=this.findSegment(t,n);!o||o.removed||(r[a++]=n+o.delta)}n.needsUpdate=!0,this.aliveCount=a,this.geometry.instanceCount=a,this.material.numPoints=this.assembler.totalPoints}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof Mt&&e.visible&&t.push(e)}),t.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:+(n>r)}),t}isSceneNeedsRebuild(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`),n=t!==this.gsSceneState.lastObjectsHash;return this.gsSceneState.lastObjectsHash=t,n}getClipperHash(e){return e.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`)}updateClipperCounts(e,t){let n=Math.max(0,e|0),r=Math.max(0,t|0);(this.material.numGsLayers!==n||this.material.numGsClippers!==r)&&(this.material.numGsLayers=n,this.material.numGsClippers=r,this.material.needsUpdate=!0)}updateClipperUniforms(e){var t,n;let r=this.layerRegistry.layerCount;if(r===0){this.material.layerClipperRanges=[],this.material.clipperMatricesInverse=[],this.updateClipperCounts(0,0);return}let i=new Map;for(let t of e){let e=t.gsViewLayerKey||t.uuid;i.has(e)||i.set(e,t.gsClippers)}let a=0;for(let e of this.layerRegistry.layerKeys)a+=((t=i.get(e))==null?[]:t).length;let o=this.createDefaultLayerClipperRanges(r),s=this.createDefaultClipperMatrices(a),c=0;for(let e of this.layerRegistry.layerKeys){let t=this.layerRegistry.layerKeyToIndex.get(e);if(t===void 0)continue;let r=(n=i.get(e))==null?[]:n,a=c,l=0;for(let e of r)s[c].copy(e.clippingBoxMatrix).invert(),c++,l++;l>0&&o[t].set(a,l)}this.material.layerClipperRanges=o,this.material.clipperMatricesInverse=s,this.updateClipperCounts(r,c)}rebuildScene(e){this.layerRegistry.sync(e),this.transformStore.sync(e),this.assembler.sync(e,e=>{let t=this.transformStore.indexOf(e);return t===void 0?(console.error(`[GS] resolveIndices: 对象缺少 transformIndex(布局不一致)。`),{transformIndex:0,layerIndex:this.layerRegistry.layerIndexOf(e)}):{transformIndex:t,layerIndex:this.layerRegistry.layerIndexOf(e)}}),this.assemblePending=!0,this.shStore.sync(e,this.usedSHDegree),this.assertLayoutConsistency(e)}assertLayoutConsistency(e){let t=this.assembler.regions;if(t.length!==e.length||this.transformStore.objectCount!==e.length){console.error(`[GS] 布局不一致:objects=${e.length} regions=${t.length} transforms=${this.transformStore.objectCount}`);return}for(let n=0;n<e.length;n++)if(t[n].object!==e[n]||this.transformStore.indexOf(e[n])!==n){console.error(`[GS] 布局不一致:第 ${n} 个对象在 regionList / TransformStore 中错位。`);break}}postSortData(){var e;let{positions:t,transformIndices:n,count:r}=this.assembler.extractSortInputs();if(r<=0){this.sortDataUploaded=!1;return}let i=++this.sortGeneration;this.snapshotByGen.set(i,this.snapshotLayout());let a=this.transformStore.objectCount*20,o=this.transformStore.transforms.slice(0,a);(e=this.sortWorker)==null||e.postMessage({sortData:{positions:t,transforms:o,transformIndices:n,vertexCount:r,generation:i}},[t.buffer,o.buffer,n.buffer]),this.sortDataUploaded=!0,this.sortInputsDirty=!1}shouldSort(e){if(this.sortInputsDirty||!this.sortDataUploaded||!this.prevSortCameraMatrix)return!0;this.prevSortCameraMatrix.decompose(Dr,kr,jr),e.matrixWorld.decompose(Or,Ar,jr);let t=Dr.distanceTo(Or),n=Math.abs(kr.dot(Ar));return t>this.sortCameraDistance||n<this.sortCameraCoorient}requestSort(e,t){var n;this.assembler.totalPoints<=0||this.shouldSort(e)&&(performance.now()-this.sortLastTime<this.sortMinIntervalMs||((this.sortInputsDirty||!this.sortDataUploaded)&&this.postSortData(),(n=this.sortWorker)==null||n.postMessage({viewProj:t}),this.prevSortCameraMatrix||(this.prevSortCameraMatrix=new l.Matrix4),this.prevSortCameraMatrix.copy(e.matrixWorld),this.sortLastTime=performance.now()))}syncMaterialTextures(){this.material.transformsTexture=this.transformStore.texture;let e=this.shStore.appliedDegree;this.material.maxShDegree!==e&&(this.material.maxShDegree=e,this.material.needsUpdate=!0),e>0&&this.shStore.texture?(this.material.shTexture=this.shStore.texture,this.material.shTextureSize.copy(this.shStore.textureSize)):this.material.shTexture=null,this.material.dataTexture=this.assembler.dataTexture,this.material.numPoints=this.assembler.totalPoints,this.material.transformIndicesTexture=null,this.material.layerIndicesTexture=null}dispose(){this.assembler.dispose(),this.transformStore.dispose(),this.shStore.dispose(),this.orderData=null,this.snapshotByGen.clear(),this.sortWorker&&(this.sortWorker.terminate(),this.sortWorker=null),this.geometry.dispose(),this.material.dispose()}},Nr=class extends l.MeshBasicMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`baisc`,this.type=`PBMMeshBasicMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Pr=class extends l.MeshBasicMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`panoOnly`,this.type=`PBMPanoOnlyMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Fr=class extends l.MeshPhongMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`phong`,this.type=`PBMMeshPhongMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Ir=class extends l.MeshPhysicalMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`standard`,this.type=`PBMMeshPhysicalMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}};function Lr(e){switch(typeof e==`object`?e==null?void 0:e.shaderType:e){case`basic`:return new Nr;case`panoOnly`:return new Pr;case`phong`:return new Fr;default:return new Ir}}l.Material;var{materialReference:Rr,attribute:zr,float:Br,vec3:Vr,vec4:Hr,mat4:Ur}=l.TSL;function Wr(e,t=0){let n=`float`,r=zr(e,n),i=r.generate.bind(r);return r.generate=function(r){return r.hasGeometryAttribute(e)?i(r):r.generateConst(n,t)},Br(r)}function W(e){return Br(Rr(e,`float`)).toVar(e)}function Gr(e){return Vr(Rr(e,`vec3`)).toVar(e)}function Kr(e){return Hr(Rr(e,`vec4`)).toVar(e)}function qr(e){return Ur(Rr(e,`mat4`)).toVar(e)}function Jr(e,t){let n=Rr(e,`cubeTexture`),r=n.setup;return n.setup=function(n){let i=r.call(this,n);return i&&(t&&(i.uvNode=t),i.getUniformHash=function(){return[e,this.value.uuid].join(`-`)}),i},Hr(n).toVar(e)}function Yr(e,t){let n=Rr(e,`texture`),r=n.setup;return n.setup=function(n){let i=r.call(this,n);return i&&(t&&(i.uvNode=t),i.getUniformHash=function(){return[e,this.value.uuid].join(`-`)}),i},Hr(n).toVar(e)}var{Fn:Xr,vec3:Zr,vec4:Qr,float:$r,abs:ei,clamp:ti,min:ni,mix:ri,step:ii,fract:ai,dot:oi,log2:si,exp2:ci,pow:li,normalize:ui}=l.TSL,di=Xr(([e])=>{let t=Zr(e).toVar(),n=Qr(0,-1/3,2/3,-1),r=ri(Qr(t.b,t.g,n.w,n.z),Qr(t.g,t.b,n.x,n.y),ii(t.b,t.g)).toVar(),i=ri(Qr(r.x,r.y,r.w,t.r),Qr(t.r,r.y,r.z,r.x),ii(r.x,t.r)).toVar(),a=i.x.sub(ni(i.w,i.y)),o=$r(1e-10);return Zr(ei(i.z.add(i.w.sub(i.y).div(a.mul(6).add(o)))),a.div(i.x.add(o)),i.x)}).setLayout({name:`FN_rgb2hsv`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),fi=Xr(([e])=>{let t=Zr(e).toVar(),n=Qr(1,2/3,1/3,3),r=ei(ai(Zr(t.x,t.x,t.x).add(Zr(n.x,n.y,n.z))).mul(6).sub(Zr(n.w,n.w,n.w)));return t.z.mul(ri(Zr(n.x,n.x,n.x),ti(r.sub(Zr(n.x,n.x,n.x)),0,1),t.y))}).setLayout({name:`FN_hsv2rgb`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),pi=Xr(([e])=>oi(e,Qr(1/(256*256*256),1/(256*256),1/256,1))).setLayout({name:`FN_hsv2rgb`,type:`float`,inputs:[{name:`color`,type:`vec4`}]}),mi=Xr(([e,t,n,r,i,a,o])=>{let s=ti(si(t).sub(si(i)).div(si(a).sub(si(i))),$r(0),$r(1)),c=Zr(li(e.r,o),li(e.g,o),li(e.b,o)),l=si(r),u=si(n),d=Zr(l).add(c.mul(Zr(u.sub(l)))).mul(s);return Zr(ci(d.x),ci(d.y),ci(d.z))}).setLayout({name:`FN_hdrBoost`,type:`vec3`,inputs:[{name:`gainRGB`,type:`vec3`},{name:`maxDisplayBoost`,type:`float`},{name:`maxContentBoost`,type:`float`},{name:`minContentBoost`,type:`float`},{name:`capacityMin`,type:`float`},{name:`capacityMax`,type:`float`},{name:`gamma`,type:`float`}]}),hi=Xr(([e,t,n])=>{let r=oi(e,t),i=e.mul(r),a=t.sub(i).div(n);return ui(i.add(a))}).setLayout({name:`FN_zoomVector`,type:`vec3`,inputs:[{name:`direction`,type:`vec3`},{name:`vector`,type:`vec3`},{name:`zoom`,type:`float`}]}),gi=Xr(([e,t,n,r])=>{let i=e.mul(Qr(0,0,0,1)).xyz,a=hi(n,ui(r.sub(i)),t);return e.toMat3().transpose().mul(a)}).setLayout({name:`FN_sampleDirection`,type:`vec3`,inputs:[{name:`direction`,type:`mat4`},{name:`vector`,type:`float`},{name:`zoom`,type:`vec3`},{name:`positionWorld`,type:`vec3`}]}),_i=Math.PI*2;function vi(e){return e>=0&&e<_i?e:(e%_i+_i)%_i}function yi(e,t){let n=Math.abs(Math.cos(e.latitude)),r=-Math.sin(e.longitude)*n,i=-Math.sin(e.latitude),a=-Math.cos(e.longitude)*n;return t?t.set(r,i,a):new l.Vector3(r,i,a)}function bi(e){return{longitude:vi(-Math.atan2(e.x,-e.z)),latitude:-Math.asin(e.y/1)}}function xi(e){return(-e/Math.PI*180-90)/360+.25}function Si(e){return-((e-.25)*360+90)/180*Math.PI}var Ci=Date.now();typeof performance<`u`&&(typeof performance.timeOrigin==`number`?Ci=performance.timeOrigin:performance.timing!==void 0&&(Ci=performance.timing.navigationStart));var G=typeof performance<`u`?(()=>Ci+performance.now()):(()=>Date.now());function wi(e){return e-Ci}var Ti=1,Ei=.1,Di=2e3,Oi=Math.PI*2,ki=Math.PI/2;function Ai(e){return e>0&&e<=Oi?e:(e%Oi+Oi)%Oi}function ji(e,t,n,r){n=Math.pow(n,4);for(var i=0;i<16;i++)r.elements[i]=e.elements[i]+(t.elements[i]-e.elements[i])*n;return r}var Mi=class extends l.Camera{constructor(e,t=Ti,n=Ei,r=Di,i=new l.Vector2,a=new l.Vector2(512,512),o=1){super(),this.fov=e,this.aspect=t,this.near=n,this.far=r,this.perspToOrtho=i,this.resolution=a,this.pixelRatio=o,this.time=0,this.controllerMode=null,this.needsRender=!0,this.refineModel=!0,this.pose={longitude:0,latitude:0,fov:e,distance:0,offset:new l.Vector3},this.computePose(),this.perspectiveCamera=new l.PerspectiveCamera(this.fov,this.aspect,.001,this.far);let s=Math.max(this.orthoDistance,.01)*Math.tan(.5*this.fov/180*Math.PI),c=-.5*this.aspect*2*s;this.orthographicCamera=new l.OrthographicCamera(c,-c,s,-s,.001,this.far),this.computeProjectionMatrix(),this.lastValues={position:this.position.clone(),quaternion:this.quaternion.clone(),scale:this.scale.clone(),fov:this.fov,aspect:this.aspect,near:this.near,far:this.far,orthoDistance:this.orthoDistance,perspToOrtho:this.perspToOrtho.clone()},this.type=this.perspToOrtho.x<1?`PerspectiveCamera`:`OrthographicCamera`,this.autoNearFar=!0}get orthoDistance(){return this.pose.distance>1?this.pose.distance:1+(this.pose.distance-1)*this.perspToOrtho.x}get zoom(){return this.type===`OrthographicCamera`?this.orthographicCamera.zoom:this.type===`PerspectiveCamera`?this.perspectiveCamera.zoom:1}get top(){return this.type===`OrthographicCamera`?this.orthographicCamera.top:0}get bottom(){return this.type===`OrthographicCamera`?this.orthographicCamera.bottom:0}get left(){return this.type===`OrthographicCamera`?this.orthographicCamera.left:0}get right(){return this.type===`OrthographicCamera`?this.orthographicCamera.right:0}getDirection(e){return yi(this.pose,e)}computePose(e=0){this.updateMatrix();let t=this.matrix.elements;return this.pose.latitude=Math.asin(H(t[9],-1,1)),Math.abs(t[9])<.9999999?this.pose.longitude=Ai(Math.atan2(t[8],t[10])):this.pose.longitude=Ai(Math.atan2(-t[2],t[0])),this.pose.fov=this.fov,this.pose.distance=e,this.pose.offset=new l.Vector3(-t[8],-t[9],-t[10]).setLength(this.pose.distance).add(this.position),this}setFromPose(e){var t,n,r,i,a;let o=Ai((t=e.longitude)==null?this.pose.longitude:t),s=Math.max(-ki+1e-4,Math.min(ki-1e-4,(n=e.latitude)==null?this.pose.latitude:n)),c=(r=e.fov)==null?this.pose.fov:r,l=(i=e.distance)==null?this.pose.distance:i,u=(a=e.offset)==null?this.pose.offset:a,d=yi({longitude:o,latitude:s}).normalize();return this.position.set(0,0,0),this.lookAt(d),this.position.add(u).sub(d.clone().setLength(l)),this.fov!==c&&(this.fov=c,this.perspectiveCamera.fov=c,this.updateProjectionMatrix()),this.updateMatrixWorld(!0),this.pose.longitude=o,this.pose.latitude=s,this.pose.fov=c,this.pose.distance=l,this.pose.offset.copy(u),this.needsRender=!0,this}copyPose(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,distance:this.pose.distance,offset:this.pose.offset.clone()}}computeProjectionMatrix(){ji(this.orthographicCamera.projectionMatrix,this.perspectiveCamera.projectionMatrix,1-this.perspToOrtho.x,this.projectionMatrix),this.projectionMatrixInverse.copy(this.projectionMatrix).invert(),this.needsRender=!0}setViewOffset(e,t,n,r,i,a){this.perspectiveCamera.setViewOffset(e,t,n,r,i,a),this.orthographicCamera.setViewOffset(e,t,n,r,i,a),this.computeProjectionMatrix()}get view(){return this.perspectiveCamera.view?Object.assign({},this.perspectiveCamera.view):null}clearViewOffset(){this.perspectiveCamera.clearViewOffset(),this.orthographicCamera.clearViewOffset(),this.computeProjectionMatrix()}updateProjectionMatrix(){this.perspectiveCamera.coordinateSystem=this.coordinateSystem,this.orthographicCamera.coordinateSystem=this.coordinateSystem,this.perspectiveCamera.updateProjectionMatrix(),this.orthographicCamera.updateProjectionMatrix(),this.computeProjectionMatrix()}get perspectiveProjectionMatrix(){return this.perspectiveCamera.projectionMatrix}get perspectiveProjectionMatrixInverse(){return this.perspectiveCamera.projectionMatrixInverse}get orthographicProjectionMatrix(){return this.orthographicCamera.projectionMatrix}get orthographicProjectionMatrixInverse(){return this.orthographicCamera.projectionMatrixInverse}updateTime(e){this.time=e;let t=!1;if((this.lastValues.fov!==this.fov||this.lastValues.near!==this.near||this.lastValues.far!==this.far||this.lastValues.aspect!==this.aspect)&&(this.perspectiveCamera.coordinateSystem=this.coordinateSystem,this.perspectiveCamera.fov=this.fov,this.perspectiveCamera.near=this.near,this.perspectiveCamera.far=this.far,this.perspectiveCamera.aspect=this.aspect,this.perspectiveCamera.updateProjectionMatrix(),t=!0),!this.lastValues.position.equals(this.position)||!this.lastValues.quaternion.equals(this.quaternion)||!this.lastValues.scale.equals(this.scale)||!this.lastValues.perspToOrtho.equals(this.perspToOrtho)||this.lastValues.fov!==this.fov||this.lastValues.near!==this.near||this.lastValues.far!==this.far||this.lastValues.orthoDistance!==this.orthoDistance||this.lastValues.aspect!==this.aspect){let e=Math.max(this.orthoDistance,.01)*Math.tan(.5*this.fov/180*Math.PI),n=-.5*this.aspect*2*e;this.orthographicCamera.coordinateSystem=this.coordinateSystem,this.orthographicCamera.left=n,this.orthographicCamera.right=-n,this.orthographicCamera.top=e,this.orthographicCamera.bottom=-e,this.orthographicCamera.near=this.near,this.orthographicCamera.far=this.far,this.orthographicCamera.updateProjectionMatrix(),t=!0}t&&this.computeProjectionMatrix(),this.lastValues.position.copy(this.position),this.lastValues.quaternion.copy(this.quaternion),this.lastValues.scale.copy(this.scale),this.lastValues.fov=this.fov,this.lastValues.aspect=this.aspect,this.lastValues.near=this.near,this.lastValues.far=this.far,this.lastValues.orthoDistance=this.orthoDistance,this.lastValues.perspToOrtho.copy(this.perspToOrtho),this.type=this.perspToOrtho.x<1?`PerspectiveCamera`:`OrthographicCamera`}get isPerspectiveCamera(){return this.perspToOrtho.x<1}get isOrthographicCamera(){return this.perspToOrtho.x>=1}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.aspect=e.aspect,this.near=e.near,this.far=e.far,this.perspToOrtho.copy(e.perspToOrtho),this.updateTime(G()),this}},{vec2:Ni,vec3:Pi,vec4:Fi,float:Ii,int:Li,bool:Ri,normalize:zi,mix:Bi,min:Vi,step:Hi,abs:Ui,clamp:Wi,length:Gi,smoothstep:Ki,pow:qi,uniform:Ji,property:Yi,cameraViewMatrix:Xi,positionWorld:Zi,Fn:Qi}=l.TSL,$i=Fi(0,0,0,0),ea=new l.Vector4,ta=Ji(new l.Vector2(512,512)).onFrameUpdate(function(e){let t=e.camera;t instanceof Mi?this.value.copy(t.resolution):e.renderer&&(e.renderer.getViewport(ea),this.value.set(ea.width,ea.height))}),na=Ji(1).onFrameUpdate(function(e){let t=e.camera;t instanceof Mi?this.value=t.pixelRatio:e.renderer&&(this.value=e.renderer.getPixelRatio())}),ra=Pi(Xi.element(Li(0)).element(Li(2)),Xi.element(Li(1)).element(Li(2)),Xi.element(Li(2)).element(Li(2))).negate().normalize().toVarying(`v_cameraDirection`),ia=Ki(Ii(0),Ii(1),Wr(`_feature_id_rsmask`,0)).toVarying(`v_roofMark`),aa=W(`progress`),oa=W(`maxDisplayBoost`),sa=W(`modelAlpha`),ca=qr(`pano0Matrix`),la=W(`pano0Zoom`),ua=Kr(`pano0Histogram`),da=W(`pano0HdrMaxContentBoost`),fa=W(`pano0HdrMinContentBoost`),pa=W(`pano0HdrCapacityMin`),ma=W(`pano0HdrCapacityMax`),ha=W(`pano0HdrGamma`),ga=W(`pano0DepthMaxDepth`),_a=qr(`pano1Matrix`),va=W(`pano1Zoom`),ya=Kr(`pano1Histogram`),ba=W(`pano1HdrMaxContentBoost`),xa=W(`pano1HdrMinContentBoost`),Sa=W(`pano1HdrCapacityMin`),Ca=W(`pano1HdrCapacityMax`),wa=W(`pano1HdrGamma`),Ta=W(`pano1DepthMaxDepth`),Ea=W(`panoFilterSaturationBias`),Da=W(`panoFilterContrastBias`),Oa=W(`panoFilterTemperatureBias`),ka=W(`panoFilterTintBias`),Aa=qr(`refinedScreenProjectionMatrix`),ja=qr(`refinedScreenMatrixInverse`),Ma=W(`refinedScreenOpacity`),Na=W(`refinedScreenPano`),Pa=W(`colorAlpha`);W(`brightness`);var Fa=W(`floorIndex`),Ia=W(`shownFloorIndex`),La=Gr(`modelBoundingMin`),Ra=Gr(`modelBoundingMax`),za=Gr(`constantColor`),Ba=W(`pointScale`),Va=W(`pointMinPixel`),Ha=W(`pointMaxPixel`),Ua=W(`colorSaturation`),Wa=W(`colorBrightness`),Ga=Ia.lessThan(-.01).or(Ui(Fa.sub(Ia)).lessThan(.99)).toVar(`isCurrentFloor`),Ka=ia.greaterThan(.001).toVar(`isRoof`),qa=Qi(()=>{let e=Ri().toVar(`isRoofCut`),t=qi(Wi(ra.y.negate(),0,1),3),n=Ra.y.sub(t.mul(Ra.y.sub(La.y)));return e.assign(Ka.and(Zi.y.greaterThan(n))),e})(),Ja=ca.mul(Fi(0,0,0,1)).xyz.toVar(`pano0Origin`),Ya=gi(ca,la,ra,Zi).toVar(`pano0SampleDirection`),Xa=_a.mul(Fi(0,0,0,1)).xyz.toVar(`pano1Origin`),Za=gi(_a,va,ra,Zi).toVar(`pano1SampleDirection`),Qa=Jr(`pano0Map`,Ya).rgb.toVar(`pano0SdrColor`),$a=Jr(`pano1Map`,Za).rgb.toVar(`pano1SdrColor`),eo=Jr(`pano0GainMap`,Ya).rgb.toVar(`pano0GainColor`),to=Jr(`pano1GainMap`,Za).rgb.toVar(`pano1GainColor`),no=Qi(()=>{let e=Pi().toVar(`pano0HdrColor`),t=mi(eo,oa,da,fa,pa,ma,ha);return e.assign(Qa.mul(t)),e})(),ro=Qi(()=>{let e=Pi().toVar(`pano1HdrColor`),t=mi(to,oa,ba,xa,Sa,Ca,wa);return e.assign($a.mul(t)),e})(),io=Qi(()=>{let e=Fi().toVar(`refinedScreenColor`),t=ja.mul(Fi(Zi,1)).toVar(),n=Bi(la,va,Na),r=hi(Pi(0,0,1),zi(t.xyz),n),i=Aa.mul(Fi(r,1)).toVar();i.divAssign(i.w);let a=Pi(i.x,i.y.negate(),0).add(1).div(2);e.assign(Yr(`refinedScreenMap`,a.xy)),e.a.mulAssign(Ma);let o=Hi(Ui(i.x),1).mul(Hi(Ui(i.y),1)).mul(Hi(t.z,0));return e.assign(Bi($i,e,o)),e})(),ao=Bi(io,$i,Na).toVar(`refinedScreenPano0Color`),oo=Bi(io,$i,Ii(1).sub(Na)).toVar(`refinedScreenPano1Color`),so=.03,co=Qi(()=>{let e=Ii().toVar(`pano0DepthTrust`),t=Wi(Gi(Zi.sub(Ja)),0,Ii(ga)).toVar(),n=Ui(pi(Fi(Jr(`pano0DepthMap`,Ya))).mul(ga).sub(t)),r=Ii(so).mul(t);return e.assign(Hi(r,n)),e})(),lo=Qi(()=>{let e=Ii().toVar(`pano1DepthTrust`),t=Wi(Gi(Zi.sub(Xa)),0,Ii(Ta)).toVar(),n=Ui(pi(Fi(Jr(`pano1DepthMap`,Za))).mul(Ta).sub(t)),r=Ii(so).mul(t);return e.assign(Hi(r,n)),e})(),uo=Qi(()=>{let e=Pi().toVar(`gradientColor`),t=Ii(Zi.y.sub(La.y)).div(Ra.y.sub(La.y));return e.assign(Yr(`gradientTexture`,Ni(t,.5)).rgb),e})(),fo=Bi(Wi(Ii(.2).mul(Vi(Ii(1).add(ra.y),1)),0,1),Ii(1),Ii(Ga)).toVar(`floorOpacity`),po=Yi(`vec3`).toVar(`pano0Color`),mo=Yi(`vec3`).toVar(`pano1Color`),{Fn:ho,vec2:go,vec3:_o,vec4:vo,float:yo,clamp:bo,max:xo,mix:So,step:Co}=l.TSL,wo=ho(([e,t])=>{let n=_o(e).toVar(),r=bo(t,-100,100);return n.r.assign(n.r.mul(yo(1).add(r.div(300)))),n.b.assign(n.b.mul(yo(1).sub(r.div(300)))),bo(n,0,1)}).setLayout({name:`FN_filterColorTemperature`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`temperatureBias`,type:`float`}]}),To=ho(([e,t])=>{let n=_o(e).toVar(),r=bo(t,-100,100),i=yo(1).add(r.mul(-.5).div(200).mul(Co(r,0))),a=yo(1).sub(So(r.mul(.5).div(200),r.div(200),Co(yo(0),r))),o=yo(1).add(r.mul(-.5).div(200).mul(Co(r,0)));return n.r.assign(n.r.mul(i)),n.g.assign(n.g.mul(a)),n.b.assign(n.b.mul(o)),bo(n,0,1)}).setLayout({name:`FN_filterColorTint`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`tintBias`,type:`float`}]}),Eo=ho(([e,t,n])=>{let r=_o(e).toVar(),i=t.y,a=t.z,o=t.w,s=bo(n,-1,1).toVar(),c=s.add(1).toVar(),l=s.mul(s).div(2).toVar(),u=c.sub(1).div(i).toVar(),d=yo(1).sub(c).div(yo(1).sub(i)).toVar(),f=c.sub(i).div(yo(1).sub(i)).toVar(),p=yo(1).div(o.sub(a)).toVar(),m=r.toVar(),h=xo(xo(r.r,r.g),r.b).toVar();m.assign(So(m,m.mul(yo(1).sub(l)).add(h.mul(l)),Co(s,0)));let g=So(d.mul(m.r).add(f),u.mul(m.r).add(1),Co(m.r,i)),_=So(d.mul(m.g).add(f),u.mul(m.g).add(1),Co(m.g,i)),v=So(d.mul(m.b).add(f),u.mul(m.b).add(1),Co(m.b,i));return r.assign(m.sub(i).mul(_o(g,_,v).mul(p)).add(i)),bo(r,0,1)}).setLayout({name:`FN_filterContrast`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`histogram`,type:`vec4`},{name:`contrastBias`,type:`float`}]}),Do=ho(([e,t])=>{let n=_o(e).toVar(),r=yo(1).add(t),i=yo(.299).mul(n.r).add(yo(.587).mul(n.g)).add(yo(.114).mul(n.b));return n.assign(n.sub(i).mul(r).add(i)),bo(n,0,1)}).setLayout({name:`FN_filterSaturation`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`saturationBias`,type:`float`}]});function Oo(e,t,n,r,i){return ho(([a,o])=>{let s=_o(a).toVar(),c=di(s).toVar();return c.z.assign(vo(i(go(c.z,0))).r),s.assign(fi(c)),s.assign(bo(s,0,1)),s.assign(wo(s,n)),s.assign(To(s,r)),s.assign(Eo(s,o,t)),s.assign(Do(s,e)),s})}var{Fn:ko,vec3:Ao,vec4:jo,float:Mo,acos:No,max:Po,min:Fo,mix:Io,length:Lo,distance:Ro,smoothstep:zo,screenCoordinate:Bo}=l.TSL;function Vo(e){return ko(([t,n,r])=>{let i=Ao().toVar();if(e.transition===`BLACK`){let e=jo(.086,.106,.149,1),a=No(Mo(-2).mul(r).add(1)).toVar();i.assign(Io(t,e,Fo(Mo(1),a))),i.assign(Io(i,n,Po(Mo(0),a.sub(Math.PI).add(1))))}else if(e.transition===`SPREAD`){let e=ta.mul(na).div(2).toVar(),a=Lo(e).mul(1.2),o=Ro(Bo.xy,e).div(a);i.assign(Io(t,n,zo(0,.2,r.sub(o))))}else i.assign(Io(t,n,r));return i})}var{vec3:Ho,vec4:Uo,float:Wo,clamp:Go,mix:Ko,Fn:qo}=l.TSL;function Jo(e){return qo(([t])=>{if(e.useHDR?(po.assign(no),mo.assign(ro)):(po.assign(Qa),mo.assign($a)),e.useRefinedScreen&&(po.assign(Ko(po,ao.rgb,ao.a)),mo.assign(Ko(mo,oo.rgb,oo.a))),!e.useHDR&&e.usePanoFilter){let e=Oo(Ea,Da,Oa,ka,e=>Yr(`panoFilterLutMap`,e));po.assign(e(po,ua)),mo.assign(e(mo,ya))}if(e.usePanoDepth){let e=Uo(t).toVar(`depthFallback`),n=Go(aa.mul(10),0,1),r=Go(Wo(1).sub(aa).mul(10),0,1);po.assign(Ko(po,Ko(po,e,n),co)),mo.assign(Ko(mo,Ko(mo,e,r),lo))}let n=Ho(0).toVar(`panoColor`),r=Vo(e);return n.assign(r(po,mo,aa)),n})}var{Fn:Yo,vec3:Xo,vec4:Zo,float:Qo,int:$o,varyingProperty:es,attribute:ts,positionGeometry:ns,positionWorld:rs,positionView:is,modelWorldMatrix:as,cameraProjectionMatrix:os,cameraPosition:ss,normalize:cs,clamp:ls,length:us,dot:ds,mix:fs,min:ps,max:ms,Discard:hs,colorSpaceToWorking:gs,output:_s}=l.TSL;function vs(e,t){let n=e.pano0Map!=null&&e.pano1Map!=null,r=e.vertexMarks,i=e.floorStyle===`VISIBILITY`,a=e.gradientTexture!=null,o=e.refinedScreenMap!=null,s=e.panoFilterLutMap!=null,c=e.useHDR,l=e.colorStyle,u=e.transition;e.outputNode=Yo(()=>{i&&Ga.not().discard(),r&&qa.discard();let e=Zo(0).toVar(`result`);if(e.assign(_s),l===`ALTITUDE`&&a?e.rgb.assign(uo):l===`CONSTANT`&&e.rgb.assign(za),e.a.mulAssign(fo.mul(Pa)),n){let t=Jo({transition:u,usePanoFilter:s,useRefinedScreen:o,useHDR:c,usePanoDepth:!1});e.assign(fs(Zo(t(_s),1),e,sa))}return e})()}function ys(e,t){let n=e.pano0Map!=null&&e.pano1Map!=null,r=e.refinedScreenMap!=null,i=e.panoFilterLutMap!=null,a=e.useHDR,o=e.transition;e.outputNode=Yo(()=>{let e=Zo(0).toVar(`result`);if(n){let t=Jo({transition:o,usePanoFilter:i,useRefinedScreen:r,useHDR:a,usePanoDepth:!1});e.rgb.assign(t(_s))}return e.a.assign(Qo(1).sub(ls(sa.mul(30),0,1))),e})()}function bs(e,t){e.positionNode=ts(`instancePosition`,`vec3`);let n=t;n.addStack(),e.setupPosition(t),n.context.position=n.removeStack();let r=is.z.negate(),i=os.element($o(1)).element($o(1)),a=os.element($o(2)).element($o(3)),o=Qo(0).sub(a),s=fs(Qo(1),r,o),c;if(e.pointSize===`ATTENUATION`){let e=Qo(1).div(i).mul(s).mul(2);c=ta.y.mul(Ba).mul(na).div(e)}else c=Ba.mul(na);c=ls(c,Va.mul(na),Ha.mul(na));let l=Ha.mul(na);if(c=ms(c,ps(Qo(1),l)),c=ps(c,l),e.pointBack===`HIDDEN`&&!e.flatShading){let e=ts(`instanceNormal`,`vec3`),t=cs(as.mul(Zo(e,0)).xyz),n=ds(cs(ss.sub(rs)),t);c=fs(Qo(0),c,Qo(n.greaterThan(0)))}es(`float`,`v_pointSize`).assign(c);let u=ta.y.mul(na),d=c.mul(Qo(2)).mul(s).div(i.mul(u)),f=ns.xy,p=is,m=Xo(f.x.mul(d),f.y.mul(d),Qo(0));return os.mul(Zo(p.add(m),Qo(1)))}function xs(e,t){let n=e.gradientTexture!=null,r=e.colorStyle,i=e.pointBack,a=e.pointShape,o=e.flatShading;e.colorNode=Yo(()=>{let e;return e=r===`ALTITUDE`&&n?uo:r===`CONSTANT`?za:gs(ts(`instanceColor`,`vec3`),l.SRGBColorSpace),i===`DARK`&&!o&&(e=Yo(([e])=>{let t=Xo(e).toVar(),n=ts(`instanceNormal`,`vec3`),r=cs(as.mul(Zo(n,0)).xyz),i=ds(cs(ss.sub(rs)),r);return t.assign(fs(t.mul(.8),t,Qo(i.greaterThan(0)))),t})(e)),e=Yo(([e])=>{let t=Xo(e).toVar(),n=di(t).toVar();return n.y.assign(n.y.add(Ua)),n.z.assign(n.z.add(Wa)),t.assign(ms(fi(n),Qo(0))),t})(e),e})(),e.outputNode=Yo(([e])=>{let t=es(`float`,`v_pointSize`);if(hs(t.lessThan(.001)),a===`CIRCLE`){let e=ns.xy,n=us(e);hs(t.greaterThan(Qo(3)).and(n.greaterThan(.5)))}let n=Zo(e).toVar(`result`);return n.a.assign(fo.mul(sa)),n})(_s)}var Ss=new Nr,Cs=class extends l.MeshBasicNodeMaterial{static get type(){return`PBMMeshBasicNodeMaterial`}constructor(e){super(e),this.isPBMMeshBasicNodeMaterial=!0,this.setDefaultValues(Ss),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},ws=new Fr,Ts=class extends l.MeshPhongNodeMaterial{static get type(){return`PBMMeshPhongNodeMaterial`}constructor(e){super(e),this.isPBMMeshPhongNodeMaterial=!0,this.setDefaultValues(ws),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},Es=new Ir,Ds=class extends l.MeshPhysicalNodeMaterial{static get type(){return`PBMMeshPhysicalNodeMaterial`}constructor(e){super(e),this.isPBMMeshPhysicalNodeMaterial=!0,this.setDefaultValues(Es),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},Os=new Pr,ks=class extends l.MeshBasicNodeMaterial{static get type(){return`PBMPanoOnlyNodeMaterial`}constructor(e){super(e),this.isPBMPanoOnlyNodeMaterial=!0,this.setDefaultValues(Os),this.setValues(e)}setup(e){ys(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},As=new $t,js=class extends l.NodeMaterial{static get type(){return`PBMPointCloudNodeMaterial`}constructor(){super(),this.isPBMPointCloudNodeMaterial=!0,this.setDefaultValues(As),this.lights=!1,this.side=l.DoubleSide}customProgramCacheKey(){return super.customProgramCacheKey()+`,`+[this.pointSize,this.pointShape,this.pointBack,this.colorStyle,this.floorStyle,this.vertexMarks,this.flatShading,!!this.gradientTexture].join(`,`)}setupVertex(e){return bs(this,e)}setup(e){xs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}};function Ms(e){e.library.addMaterial(Cs,`PBMMeshBasicMaterial`),e.library.addMaterial(Ts,`PBMMeshPhongMaterial`),e.library.addMaterial(Ds,`PBMMeshPhysicalMaterial`),e.library.addMaterial(ks,`PBMPanoOnlyMaterial`),e.library.addMaterial(js,`PBMPointCloudMaterial`)}var Ns=new l.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),Ps=new l.Matrix4().copy(Ns).invert();function K(...e){}var Fs=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i],Is=typeof location<`u`?location.href:``,Ls=/^https\:/.test(Is),Rs=class extends Error{constructor(e,t,n){super(`[NETWORK]: request proxy error(type: ${t}, reason: ${n}): ${e}`)}},zs=class extends Error{constructor(e,t,n){super(`[NETWORK]: response error(type: ${t}, status: ${n}): ${e}`),this.httpStatus=n}},Bs=class extends Error{constructor(e,t,n){super(`[NETWORK]: request timeout(type: ${t}, timeout: ${n}ms): ${e}`)}};function Vs(e){if(!e)return{};let t={},n=e.trim().split(`
345
+ \\v  j   ”  ”  ”’’’¼"\\v \\vAsAÿÿÿÿ\\x07q \\vA\\0H\\x1B"\\v6\\0 \\b \\vAÿÿqAtj" (\\0Aj6\\0 \\vAvAüÿqj"\\v \\v(\\0Aj6\\0 \\fAj!\\f\\f\\v\\v\\v\\0\\v\\v \\0A\\b\\v\`)}function v(e){return e}function y(e,t){var n,r=v(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}function b(){return{a:F}}function x(){function e(e,t){return L=e.exports,P(L),f(),L}var t=b();return r.instantiateWasm?new Promise((n,i)=>{r.instantiateWasm(t,(t,r)=>{n(e(t,r))})}):(g!=null||(g=_()),e(y(g,t)[0]))}for(var S=e=>{for(;e.length>0;)e.shift()(r)},C=[],w=e=>C.push(e),T=[],E=e=>T.push(e),D=()=>2147483648,O=(e,t)=>Math.ceil(e/t)*t,k=e=>{var t=(e-N.buffer.byteLength+65535)/65536|0;try{return N.grow(t),f(),1}catch(e){}},A=e=>{var t=u.length;e>>>=0;var n=D();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),k(Math.min(n,O(Math.max(e,i),65536))))return!0}return!1},j=new Uint8Array(123),M=25;M>=0;--M)j[48+M]=52+M,j[65+M]=M,j[97+M]=26+M;if(j[43]=62,j[47]=63,r.noExitRuntime&&r.noExitRuntime,r.print&&r.print,r.printErr&&r.printErr,r.wasmBinary&&r.wasmBinary,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram,r.preInit)for(typeof r.preInit==\`function\`&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.shift()();var N;function P(e){r._sort=e.d,r._malloc=e.e,r._free=e.f,N=e.b,e.__indirect_function_table}var F={a:A};function I(){p();function e(){var e;r.calledRun=!0,!s&&(m(),l==null||l(r),(e=r.onRuntimeInitialized)==null||e.call(r),h())}r.setStatus?(r.setStatus(\`Running...\`),setTimeout(()=>{setTimeout(()=>r.setStatus(\`\`),1),e()},1)):e()}var L=x();return I(),t=d?r:new Promise((e,t)=>{l=e}),t}),i.apply(this,arguments)}let a,o=!1;function s(){return e(this,void 0,void 0,function*(){if(!(a||o))try{a=yield r()}catch(e){o=!0,self.postMessage({error:e instanceof Error?e.message:String(e)})}})}let c,l,u,d,f,p,m,h,g,_,v=0,y=0,b=!1,x=[],S=!0,C=!0,w=!1,T=!1,E=!1;function D(e,t){if(t.length!==16)return!0;for(let n=0;n<16;n++)if(Math.abs(e[n]-t[n])>1e-7)return!0;return!1}let O=[],k=65536,A=()=>e(void 0,void 0,void 0,function*(){if(w){T=!0;return}if(w=!0,T=!1,a||(yield s()),!a){w=!1;return}let e=Math.pow(2,Math.ceil(Math.log2(c.vertexCount)));v<e&&(v>0&&(a._free(l),a._free(d),a._free(f),a._free(p),a._free(m),a._free(h)),v=e,l=a._malloc(64),d=a._malloc(v*4),f=a._malloc(3*v*4),p=a._malloc(v*4),m=a._malloc(v*4),h=a._malloc(v*4)),b||(g=a._malloc(k*4),_=a._malloc(k*4),b=!0),y<c.transforms.length&&(y>0&&a._free(u),y=c.transforms.length,u=a._malloc(y*4)),w=!1,T&&(T=!1,yield A())}),j=()=>{if(w||T||!a)return;w=!0,C&&(a.HEAPF32.set(c.positions,f/4),a.HEAPF32.set(c.transforms,u/4),a.HEAPU32.set(c.transformIndices,d/4),C=!1),a.HEAPF32.set(new Float32Array(x),l/4),a._sort(l,u,d,c.vertexCount,f,p,m,h,g,_);let e=c.vertexCount,t=new Uint32Array(a.HEAPU32.buffer,m,e),n=e*4,r=O.pop();(!r||r.byteLength<n)&&(r=new ArrayBuffer(n));let i=new Uint32Array(r,0,e);i.set(t),self.postMessage({depthIndex:i,generation:c.generation},[r]),w=!1,S=!1},M=()=>{E||(E=!0,S&&j(),setTimeout(()=>{E=!1,M()}))};self.onmessage=t=>new Promise(n=>{e(void 0,void 0,void 0,function*(){var e;if(t.data.warmup){yield s(),n(!0);return}if(t.data.returnBuffer){O.length<3&&O.push(t.data.returnBuffer),n(!0);return}if(o){n(!0);return}let r=!1,i=!!t.data.sortData;if(t.data.sortData&&(c={positions:t.data.sortData.positions,transforms:t.data.sortData.transforms,transformIndices:t.data.sortData.transformIndices,vertexCount:t.data.sortData.vertexCount,generation:(e=t.data.sortData.generation)==null?0:e},S=!0,C=!0,yield A(),r=!0),t.data.viewProj){let e=t.data.viewProj;(D(e,x)||i)&&(x=e,S=!0,r=!0)}r&&S&&M(),n(!0)})})})();`,cn=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,sn],{type:`text/javascript;charset=utf-8`});function ln(e){let t;try{if(t=cn&&(self.URL||self.webkitURL).createObjectURL(cn),!t)throw``;let n=new Worker(t,{name:e==null?void 0:e.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(sn),{name:e==null?void 0:e.name})}}var{Fn:un,vec2:dn,vec3:fn,vec4:pn,ivec2:mn,float:U,int:hn,uint:gn,mat3:_n,mat4:vn,bool:yn,If:bn,Loop:xn,Discard:Sn,Return:Cn,attribute:wn,varyingProperty:Tn,uniform:En,uniformArray:Dn,textureLoad:On,instanceIndex:kn,positionGeometry:An,cameraPosition:jn,cameraProjectionMatrix:Mn,cameraViewMatrix:Nn,viewportSize:Pn,abs:Fn,sign:In,max:Ln,min:Rn,clamp:zn,floor:Bn,fract:Vn,sqrt:Hn,exp:Un,sin:Wn,cos:Gn,normalize:Kn,length:qn,dot:Jn,mix:Yn,select:Xn,transpose:Zn,unpackHalf2x16:Qn,uintBitsToFloat:$n,colorSpaceToWorking:er}=l.TSL,tr=.3,nr=2048,rr=.4886025119029199,ir=1.0925484,ar=-1.0925484,or=.3153916,sr=-1.0925484,cr=.5462742;function lr(e){let t=e===`RGBA32UI`?new l.DataTexture(new Uint32Array(4),1,1,l.RGBAIntegerFormat,l.UnsignedIntType):new l.DataTexture(new Uint32Array(1),1,1,l.RedIntegerFormat,l.UnsignedIntType);return t.minFilter=l.NearestFilter,t.magFilter=l.NearestFilter,t.generateMipmaps=!1,t.flipY=!1,t.needsUpdate=!0,t}function ur(){let e=new l.DataTexture(new Float32Array(4),1,1,l.RGBAFormat,l.FloatType);return e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.generateMipmaps=!1,e.flipY=!1,e.needsUpdate=!0,e}var dr=class extends l.NodeMaterial{constructor(e={}){var t,n,r;super(),this.isPBMGaussianSplattingMaterial=!0,this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.numPoints=0,this.shTextureSize=new l.Vector2(1,1),this.aggregationEnabled=!1,this.aggregationProgress=0,this.aggregationPointDuration=.6,this.aggregationBoundsMin=new l.Vector3,this.aggregationBoundsMax=new l.Vector3,this.layerClipperRanges=[],this.clipperMatricesInverse=[],this._uDataTex=null,this._uNumPoints=null,this._uTransformsTex=null,this._uTransformIndicesTex=null,this._uLayerIndicesTex=null,this._uShTex=null,this._uShTextureSize=null,this._uAggregationEnabled=null,this._uAggregationProgress=null,this._uAggregationPointDuration=null,this._uAggregationBoundsMin=null,this._uAggregationBoundsMax=null,this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=-1,this._cachedClipperCount=-1,this.type=`PBMGaussianSplattingNodeMaterial`,this.lights=!1,this.side=l.DoubleSide,this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.blending=l.NormalBlending,this.maxShDegree=(t=e.maxShDegree)==null?0:t,this.numGsLayers=(n=e.numGsLayers)==null?0:n,this.numGsClippers=(r=e.numGsClippers)==null?0:r}customProgramCacheKey(){return super.customProgramCacheKey()+`,`+[this.maxShDegree,this.numGsLayers,this.numGsClippers].join(`,`)}syncDynamicUniforms(){this._uDataTex!==null&&(this.dataTexture&&this._uDataTex.value!==this.dataTexture&&(this._uDataTex.value=this.dataTexture),this._uNumPoints&&(this._uNumPoints.value=this.numPoints),this.transformsTexture&&this._uTransformsTex.value!==this.transformsTexture&&(this._uTransformsTex.value=this.transformsTexture),this.transformIndicesTexture&&this._uTransformIndicesTex.value!==this.transformIndicesTexture&&(this._uTransformIndicesTex.value=this.transformIndicesTexture),this.layerIndicesTexture&&this._uLayerIndicesTex.value!==this.layerIndicesTexture&&(this._uLayerIndicesTex.value=this.layerIndicesTexture),this.shTexture&&this._uShTex.value!==this.shTexture&&(this._uShTex.value=this.shTexture),this._uAggregationEnabled.value=+!!this.aggregationEnabled,this._uAggregationProgress.value=this.aggregationProgress,this._uAggregationPointDuration.value=this.aggregationPointDuration)}_ensureUniforms(){var e,t,n,r,i;this._uDataTex===null?(this._uDataTex=On((e=this.dataTexture)==null?lr(`RGBA32UI`):e),this._uNumPoints=En(this.numPoints,`uint`),this._uTransformsTex=On((t=this.transformsTexture)==null?ur():t),this._uTransformIndicesTex=On((n=this.transformIndicesTexture)==null?lr(`R32UI`):n),this._uLayerIndicesTex=On((r=this.layerIndicesTexture)==null?lr(`R32UI`):r),this._uShTex=On((i=this.shTexture)==null?ur():i),this._uShTextureSize=En(this.shTextureSize),this._uAggregationEnabled=En(+!!this.aggregationEnabled),this._uAggregationProgress=En(this.aggregationProgress),this._uAggregationPointDuration=En(this.aggregationPointDuration),this._uAggregationBoundsMin=En(this.aggregationBoundsMin),this._uAggregationBoundsMax=En(this.aggregationBoundsMax),this.numGsClippers>0&&(this._uLayerClipperRanges=Dn(this.layerClipperRanges.length?this.layerClipperRanges:[new l.Vector2],`vec2`),this._uClipperMatricesInverse=Dn(this.clipperMatricesInverse.length?this.clipperMatricesInverse:[new l.Matrix4],`mat4`),this._cachedLayerCount=this.numGsLayers,this._cachedClipperCount=this.numGsClippers)):(this.dataTexture&&(this._uDataTex.value=this.dataTexture),this._uNumPoints.value=this.numPoints,this.transformsTexture&&(this._uTransformsTex.value=this.transformsTexture),this.transformIndicesTexture&&(this._uTransformIndicesTex.value=this.transformIndicesTexture),this.layerIndicesTexture&&(this._uLayerIndicesTex.value=this.layerIndicesTexture),this.shTexture&&(this._uShTex.value=this.shTexture),this._uShTextureSize.value=this.shTextureSize,this._uAggregationEnabled.value=+!!this.aggregationEnabled,this._uAggregationProgress.value=this.aggregationProgress,this._uAggregationPointDuration.value=this.aggregationPointDuration,this._uAggregationBoundsMin.value=this.aggregationBoundsMin,this._uAggregationBoundsMax.value=this.aggregationBoundsMax,this.numGsClippers>0&&(this._cachedLayerCount!==this.numGsLayers||this._cachedClipperCount!==this.numGsClippers||!this._uLayerClipperRanges)?(this._uLayerClipperRanges=Dn(this.layerClipperRanges.length?this.layerClipperRanges:[new l.Vector2],`vec2`),this._uClipperMatricesInverse=Dn(this.clipperMatricesInverse.length?this.clipperMatricesInverse:[new l.Matrix4],`mat4`),this._cachedLayerCount=this.numGsLayers,this._cachedClipperCount=this.numGsClippers):this.numGsClippers===0&&(this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=0,this._cachedClipperCount=0))}_buildSHUv(e,t,n){let r=this.maxShDegree,i=0;r>=1&&(i+=9),r>=2&&(i+=15),r>=3&&(i+=21);let a=i;a%4!=0&&(a=(Math.floor(a/4)+1)*4);let o=e.mul(a/4).add(t/4).toInt(),s=n.x.toInt();return mn(o.mod(s),o.div(s))}setup(e){this._ensureUniforms();let t=this._uDataTex,n=this._uNumPoints,r=this._uTransformsTex,i=this._uShTex,a=this._uShTextureSize,o=this._uAggregationEnabled,s=this._uAggregationProgress,c=this._uAggregationPointDuration,u=this._uAggregationBoundsMin,d=this._uAggregationBoundsMax,f=this._uLayerClipperRanges,p=this._uClipperMatricesInverse,m=this,h=Tn(`vec4`,`vColorGS`),g=Tn(`vec2`,`vPositionGS`),_=un(()=>{let e=wn(`splatIndex`,`float`).add(.5).toUint().toVar(),_=e.toInt(),v=e.greaterThanEqual(n).toVar(),y=gn(2048),b=e.mul(gn(2)).toVar(),x=b.add(gn(1)).toVar(),S=mn(b.mod(y).toInt(),b.div(y).toInt()),C=mn(x.mod(y).toInt(),x.div(y).toInt()),w=t.load(S).toVar(),T=t.load(C).toVar(),E=fn($n(w.x.toUint()),$n(w.y.toUint()),$n(w.z.toUint())).toVar(),D=pn(U(w.w.toUint().bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(8)).bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(16)).bitAnd(gn(255))),U(w.w.toUint().shiftRight(gn(24)).bitAnd(gn(255)))).div(255).toVar(),O=Qn(T.x.toUint()),k=Qn(T.y.toUint()),A=Qn(T.z.toUint()),j=_n(fn(O.x,O.y,k.x),fn(O.y,k.y,A.x),fn(k.x,A.x,A.y)).toVar(),M=T.w.toUint().shiftRight(gn(16)).toInt(),N=T.w.toUint().bitAnd(gn(65535)).toInt(),ee=vn(r.load(mn(0,M)),r.load(mn(1,M)),r.load(mn(2,M)),r.load(mn(3,M))).toVar(),P=()=>vn(r.load(mn(5,M)),r.load(mn(6,M)),r.load(mn(7,M)),r.load(mn(8,M))),te=Nn.mul(ee).toVar(),F=ee.mul(pn(E,1)).toVar(),ne=pn(0,0,2,1).toVar(),re=U(0).toVar(),ie=yn(!1).toVar();bn(o.equal(1).and(s.lessThan(1)),()=>{bn(F.x.greaterThanEqual(u.x).and(F.x.lessThanEqual(d.x)).and(F.z.greaterThanEqual(u.z)).and(F.z.lessThanEqual(d.z)),()=>{ie.assign(!0);let e=d.y.sub(u.y),t=Xn(e.greaterThan(.001),zn(F.y.sub(u.y).div(e),0,1),U(.5)),n=zn(c,.01,1),r=U(1).sub(t).mul(U(1).sub(n)),i=zn(s.sub(r).div(n),0,1).toVar(),a=i.mul(i).mul(U(3).sub(i.mul(2)));re.assign(i.mul(i).mul(i));let o=u.add(d).mul(.5),l=qn(F.xyz.sub(o)),f=Jn(E,fn(12.9898,78.233,45.164)),p=Vn(Wn(f).mul(43758.5453)),m=f.mul(10),h=Kn(fn(Gn(m),Yn(-.7,.1,Vn(Wn(f.mul(1.7)).mul(43758.5453))),Wn(m))),g=U(1).sub(a).mul(U(1).add(p)),_=h.mul(l).mul(g);F.assign(pn(F.xyz.add(_),F.w)),E.assign(P().mul(F).xyz)})});let ae=yn(!1).toVar();if(m.numGsClippers>0&&m.numGsLayers>0){let e=N.toVar();bn(e.greaterThanEqual(0).and(e.lessThan(m.numGsLayers)),()=>{let t=f.element(e),n=t.x.add(.5).toInt(),r=t.y.add(.5).toInt(),i=n.add(r);xn({start:hn(0),end:hn(m.numGsClippers),type:`int`},({i:e})=>{bn(e.greaterThanEqual(n).and(e.lessThan(i)),()=>{let t=p.element(e).mul(F);bn(t.x.greaterThan(-.5).and(t.x.lessThan(.5)).and(t.y.greaterThan(-.5)).and(t.y.lessThan(.5)).and(t.z.greaterThan(-.5)).and(t.z.lessThan(.5)),()=>{ae.assign(!0)})})})})}let I=te.mul(pn(E,1)).toVar(),L=Mn.mul(I).toVar(),R=L.w.mul(1.2),oe=L.z.lessThan(L.w.negate()).or(L.z.greaterThan(L.w)),se=L.x.lessThan(R.negate()).or(L.x.greaterThan(R)),ce=L.y.lessThan(R.negate()).or(L.y.greaterThan(R)),le=oe.or(se).or(ce);return bn(v.not().and(ae.not()).and(le.not()),()=>{let e=L.xyz.div(L.w),t=Pn,n=dn(Mn.element(0).element(0).mul(t.x).mul(.5),Mn.element(1).element(1).mul(t.y).mul(.5)),r=Mn.element(3).element(3).greaterThan(.7),c=U(1).div(I.z.mul(I.z)),u=_n(fn(n.x.div(I.z),U(0),n.x.mul(I.x).mul(c).negate()),fn(U(0),n.y.div(I.z),n.y.mul(I.y).mul(c).negate()),fn(U(0),U(0),U(0))),d=_n(fn(n.x,U(0),U(0)),fn(U(0),n.y,U(0)),fn(U(0),U(0),U(0))),f=_n(Xn(r,d.element(0),u.element(0)),Xn(r,d.element(1),u.element(1)),Xn(r,d.element(2),u.element(2))),p=te,v=Zn(_n(p.element(0).xyz,p.element(1).xyz,p.element(2).xyz)).mul(f),y=Zn(v).mul(j).mul(v).toVar(),b=y.element(0).element(0).add(tr),x=y.element(1).element(1).add(tr),S=y.element(0).element(1),C=b,w=x,T=S,O=C.mul(w).sub(T.mul(T)),k=C.add(w).mul(.5),A=Hn(Ln(.1,k.mul(k).sub(O))),M=k.add(A),N=k.sub(A);bn(N.greaterThan(0),()=>{let n=Kn(dn(T,M.sub(C))),r=dn(n.y,n.x.negate()),c=n.mul(Rn(Hn(M.mul(2)),U(nr))),u=r.mul(Rn(Hn(N.mul(2)),U(nr))),d=dn(U(1).div(t.x),U(1).div(t.y)),f=An.xy,p=dn(f.x.mul(c.x).add(f.y.mul(u.x)),f.x.mul(c.y).add(f.y.mul(u.y))).mul(d).mul(2).toVar();bn(o.equal(1),()=>{let e=Xn(ie,re,s.mul(s).mul(s));p.assign(p.mul(Yn(.1,1,e)))});let v=D.toVar();if(m.maxShDegree>=1){let e=P().mul(pn(jn,1)).xyz,t=Kn(E.sub(e)),n=t.x,r=t.y,o=t.z,s=m._buildSHUv(_,0,a),c=m._buildSHUv(_,4,a),l=m._buildSHUv(_,8,a),u=i.load(s),d=i.load(c),f=i.load(l),p=u.rgb,h=fn(u.a,d.r,d.g),g=fn(d.b,d.a,f.r),y=p.mul(U(-.4886025119029199).mul(r)).add(h.mul(U(rr).mul(o))).add(g.mul(U(-.4886025119029199).mul(n)));if(v.assign(pn(v.rgb.add(y),v.a)),m.maxShDegree>=2){let e=m._buildSHUv(_,12,a),t=m._buildSHUv(_,16,a),s=m._buildSHUv(_,20,a),c=i.load(e),l=i.load(t),u=i.load(s),d=f.gba,p=c.rgb,h=fn(c.a,l.r,l.g),g=fn(l.b,l.a,u.r),y=u.gba,b=n.mul(n),x=r.mul(r),S=o.mul(o),C=n.mul(r),w=r.mul(o),T=n.mul(o),E=d.mul(U(ir).mul(C)).add(p.mul(U(ar).mul(w))).add(h.mul(U(or).mul(S.mul(2).sub(b).sub(x)))).add(g.mul(U(sr).mul(T))).add(y.mul(U(cr).mul(b.sub(x))));v.assign(pn(v.rgb.add(E),v.a))}}v.assign(pn(zn(v.rgb,fn(0),fn(1)),v.a)),h.assign(er(v,l.SRGBColorSpace)),g.assign(f.mul(2)),ne.assign(pn(e.xy.add(p),e.z,1))})}),ne});this.vertexNode=_();let v=un(()=>{let e=Jn(g,g).negate();Sn(e.lessThan(-4));let t=Un(e).mul(h.a);return pn(h.rgb,t)});this.fragmentNode=v(),super.setup(e)}copy(e){return super.copy(e),this.dataTexture=e.dataTexture,this.numPoints=e.numPoints,this.transformsTexture=e.transformsTexture,this.transformIndicesTexture=e.transformIndicesTexture,this.layerIndicesTexture=e.layerIndicesTexture,this.shTexture=e.shTexture,this.shTextureSize.copy(e.shTextureSize),this.aggregationEnabled=e.aggregationEnabled,this.aggregationProgress=e.aggregationProgress,this.aggregationPointDuration=e.aggregationPointDuration,this.aggregationBoundsMin.copy(e.aggregationBoundsMin),this.aggregationBoundsMax.copy(e.aggregationBoundsMax),this.maxShDegree=e.maxShDegree,this.numGsLayers=e.numGsLayers,this.numGsClippers=e.numGsClippers,this.layerClipperRanges=e.layerClipperRanges.map(e=>e.clone()),this.clipperMatricesInverse=e.clipperMatricesInverse.map(e=>e.clone()),this._uDataTex=null,this._uNumPoints=null,this._uTransformsTex=null,this._uTransformIndicesTex=null,this._uLayerIndicesTex=null,this._uShTex=null,this._uShTextureSize=null,this._uAggregationEnabled=null,this._uAggregationProgress=null,this._uAggregationPointDuration=null,this._uAggregationBoundsMin=null,this._uAggregationBoundsMax=null,this._uLayerClipperRanges=null,this._uClipperMatricesInverse=null,this._cachedLayerCount=-1,this._cachedClipperCount=-1,this}},fr=2,pr=8,mr=4,hr=fr*mr,gr=7,_r=class{constructor(e=2048){this.regionMap=new Map,this.regionList=[],this.data=new Uint32Array,this._tex=null,this.texHeight=0,this.width=e}get totalPoints(){let e=0;for(let t of this.regionList)e+=t.count;return e}get regions(){return this.regionList}get dataTexture(){return this._tex}sync(e,t){let n=new Set(e);for(let e of Array.from(this.regionMap.keys()))n.has(e)||this.regionMap.delete(e);let r=[],i=0;for(let n of e){let e=this.regionMap.get(n),{transformIndex:a,layerIndex:o}=t(n);e?(e.transformIndex=a,e.layerIndex=o):(e={object:n,start:0,count:n.numPoints,transformIndex:a,layerIndex:o},this.regionMap.set(n,e)),e.start=i,i+=e.count,r.push(e)}this.regionList=r}assemble(){let e=0;for(let t of this.regionList)t.start=e,e+=t.count;let t=e;if(t<=0){this.disposeTexture();return}let n=Math.max(1,Math.ceil(t*fr/this.width)),r=this.width*n*mr,i=!this._tex||n!==this.texHeight||this.data.length<r;i&&(this.data=new Uint32Array(r));let a=this.data;for(let e of this.regionList){let t=e.object.packedData,n=e.start*hr,r=((e.transformIndex&65535)<<16|e.layerIndex&65535)>>>0;if(!t||t.length<e.count*pr){a.fill(0,n,n+e.count*hr);continue}a.set(t.subarray(0,e.count*pr),n);for(let t=0;t<e.count;t++)a[n+t*hr+gr]=r}if(i){this.disposeTexture();let e=new l.DataTexture(a,this.width,n,l.RGBAIntegerFormat,l.UnsignedIntType);e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.generateMipmaps=!1,e.flipY=!1,e.needsUpdate=!0,this._tex=e,this.texHeight=n}else this._tex.image.data=a,this._tex.needsUpdate=!0}extractSortInputs(){let e=this.totalPoints,t=new Float32Array(e*3),n=new Uint32Array(e);for(let e of this.regionList){let r=e.object.packedData;if(r.length<e.count*pr)continue;let i=new Float32Array(r.buffer,r.byteOffset,r.length);for(let r=0;r<e.count;r++){let a=e.start+r;t[a*3+0]=i[r*8+0],t[a*3+1]=i[r*8+1],t[a*3+2]=i[r*8+2],n[a]=e.transformIndex>>>0}}return{positions:t,transformIndices:n,count:e}}dispose(){this.regionMap.clear(),this.regionList=[],this.disposeTexture(),this.data=new Uint32Array}disposeTexture(){this._tex&&(this._tex.dispose(),this._tex=null),this.texHeight=0}},vr=9,yr=vr*4,br=20,xr=new l.Matrix4,Sr=class{constructor(){this.texture=null,this.width=vr,this.data=new Float32Array,this.sortTransforms=new Float32Array,this.indexMap=new Map,this.count=0}indexOf(e){return this.indexMap.get(e)}get objectCount(){return this.count}get transforms(){return this.sortTransforms}sync(e){this.indexMap.clear(),this.count=e.length;let t=Math.max(1,this.count)*yr;this.data.length<t&&(this.data=new Float32Array(t));let n=Math.max(1,this.count)*br;this.sortTransforms.length<n&&(this.sortTransforms=new Float32Array(n));for(let t=0;t<e.length;t++){let n=e[t];this.indexMap.set(n,t),this.writeObject(t,n)}this.rebuildTexture()}updateOne(e){let t=this.indexMap.get(e);t!==void 0&&(this.writeObject(t,e),this.texture&&(this.texture.needsUpdate=!0))}writeObject(e,t){let n=t.matrixWorld.elements,r=+!!t.selected,i=e*yr;this.data.set(n,i),this.data[i+16]=r,this.data[i+17]=0,this.data[i+18]=0,this.data[i+19]=0,xr.copy(t.matrixWorld).invert(),this.data.set(xr.elements,i+20);let a=e*br;this.sortTransforms.set(n,a),this.sortTransforms[a+16]=r,this.sortTransforms[a+17]=0,this.sortTransforms[a+18]=0,this.sortTransforms[a+19]=0}rebuildTexture(){let e=Math.max(1,this.count);this.texture&&this.texture.dispose();let t=new l.DataTexture(this.data,this.width,e,l.RGBAFormat,l.FloatType);t.minFilter=l.NearestFilter,t.magFilter=l.NearestFilter,t.generateMipmaps=!1,t.needsUpdate=!0,this.texture=t}dispose(){this.texture&&(this.texture.dispose(),this.texture=null)}},Cr=class{constructor(){this.layerKeys=[],this.layerKeyToIndex=new Map,this.objectLayerIndex=new Map}sync(e){this.layerKeys=[],this.layerKeyToIndex.clear(),this.objectLayerIndex.clear();for(let t of e){let e=t.gsViewLayerKey||t.uuid,n=this.layerKeyToIndex.get(e);n===void 0&&(n=this.layerKeys.length,this.layerKeys.push(e),this.layerKeyToIndex.set(e,n)),this.objectLayerIndex.set(t,n)}}layerIndexOf(e){var t;return(t=this.objectLayerIndex.get(e))==null?0:t}get layerCount(){return this.layerKeys.length}},wr=2048,Tr=4,Er=class{constructor(){this.texture=null,this.textureSize=new l.Vector2,this.dataMaxDegree=0,this.appliedDegree=0}sync(e,t){let n=0,r=0;for(let t of e)t.maxSHDegree>n&&(n=t.maxSHDegree),r+=t.numPoints;this.dataMaxDegree=n;let i=Math.min(t,n);if(this.appliedDegree=i,i<=0||r===0)return this.appliedDegree=0,!1;let a=0;i>=1&&(a+=9),i>=2&&(a+=15),i>=3&&(a+=21);let o=a;o%Tr!==0&&(o=Math.ceil(o/Tr)*Tr);let s=o/Tr,c=r*s,u=wr,d=Math.ceil(c/u),f=new Float32Array(u*d*Tr),p=0;for(let t of e){let e=t.sh1,n=t.sh2,r=t.sh3;for(let a=0;a<t.numPoints;a++){let t=(p+a)*s,o=0;if(e&&i>=1)for(let n=0;n<9;n++){let r=t+Math.floor(o/Tr),i=o%Tr;f[r*Tr+i]=e[a*9+n],o++}if(n&&i>=2)for(let e=0;e<15;e++){let r=t+Math.floor(o/Tr),i=o%Tr;f[r*Tr+i]=n[a*15+e],o++}if(r&&i>=3)for(let e=0;e<21;e++){let n=t+Math.floor(o/Tr),i=o%Tr;f[n*Tr+i]=r[a*21+e],o++}}p+=t.numPoints}this.texture&&this.texture.dispose();let m=new l.DataTexture(f,u,d,l.RGBAFormat,l.FloatType);return m.minFilter=l.NearestFilter,m.magFilter=l.NearestFilter,m.generateMipmaps=!1,m.needsUpdate=!0,this.texture=m,this.textureSize.set(u,d),!0}dispose(){this.texture&&(this.texture.dispose(),this.texture=null)}},Dr=new l.Vector3,Or=new l.Vector3,kr=new l.Quaternion,Ar=new l.Quaternion,jr=new l.Vector3,Mr=class extends l.Mesh{constructor(){super(),this.needsRender=!1,this.assembler=new _r,this.transformStore=new Sr,this.layerRegistry=new Cr,this.shStore=new Er,this.sortWorker=null,this.assemblePending=!1,this.splatIndexCapacity=0,this.sortGeneration=0,this.sortDataUploaded=!1,this.sortInputsDirty=!1,this.forceClipperUniformRefresh=!1,this.sortWorkerFailed=!1,this.orderCount=0,this.orderData=null,this.orderDirty=!1,this.layoutDirty=!1,this.aliveCount=0,this.orderBaseSnapshot=[],this.snapshotByGen=new Map,this.prevSortCameraMatrix=null,this.sortCameraDistance=1,this.sortCameraCoorient=.99,this.sortMinIntervalMs=0,this.sortLastTime=-1/0,this._scratchViewProj=new l.Matrix4,this.usedSHDegree=0,this.onBeforeRender=(e,t,n,...r)=>{let i=n,a=this.collectObjects(t);if(a.length===0){this.geometry.instanceCount=0;return}let o=0;for(let e of a)e.usedSHDegree>o&&(o=e.usedSHDegree);let s=o!==this.usedSHDegree;this.usedSHDegree=o,this.isSceneNeedsRebuild(a)?(this.rebuildScene(a),this.gsSceneState.lastClipperHash=``,this.forceClipperUniformRefresh=!0,this.sortDataUploaded=!1,this.sortInputsDirty=!0,this.layoutDirty=!0):s&&this.shStore.sync(a,this.usedSHDegree);for(let e of a)e.transformChanged&&(this.transformStore.updateOne(e),e.transformChanged=!1,e.selectedChanged=!1,this.sortInputsDirty=!0);let c=this._scratchViewProj.multiplyMatrices(i.perspectiveProjectionMatrix,i.matrixWorldInverse);this.requestSort(i,c.elements),(this.orderDirty||this.layoutDirty)&&(this.applyReorderCPU(this.snapshotLayout()),this.orderDirty=!1,this.layoutDirty=!1);let l=this.getClipperHash(a);(this.forceClipperUniformRefresh||l!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(a),this.gsSceneState.lastClipperHash=l,this.forceClipperUniformRefresh=!1,this.needsRender=!0),this.assemblePending&&(this.assembler.assemble(),this.assemblePending=!1),this.syncMaterialTextures(),this.material.syncDynamicUniforms();let u=!this.sortWorkerFailed&&this.assembler.totalPoints>0&&this.material.dataTexture!==null&&this.orderCount>0&&this.aliveCount>0;this.geometry.instanceCount=u?this.aliveCount:0};let e=this.createGeometry(),t=this.createMaterial();this.geometry=e,this.material=t,this.frustumCulled=!1,this.renderOrder=-99999999999,this.gsSceneState={lastObjectsHash:``,lastClipperHash:``},this.sortWorker=new ln,this.sortWorker.postMessage({warmup:!0}),this.sortWorker.onmessage=e=>{var t;if(e.data.error){this.sortWorkerFailed=!0,this.geometry.instanceCount=0;return}if(e.data.depthIndex){let n=e.data.depthIndex,r=e.data.generation;this.applyDepthIndex(n,r);let i=n.buffer;i.byteLength>0&&((t=this.sortWorker)==null||t.postMessage({returnBuffer:i},[i]))}}}createGeometry(){let e=new l.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new l.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new l.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity),i=new l.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(l.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}ensureSplatIndexCapacity(e){let t=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return t;let n=Math.max(this.splatIndexCapacity,1);for(;n<e;)n*=2;let r=new Float32Array(n);r.set(t.array.subarray(0,Math.min(t.array.length,n)));let i=new l.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(l.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,i),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,i}createMaterial(){return new dr({numGsLayers:0,numGsClippers:0,maxShDegree:0})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new l.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new l.Matrix4)}applyDepthIndex(e,t){this.orderData=e.slice(),this.orderCount=this.orderData.length,this.orderDirty=!0;let n=this.snapshotByGen.get(t);if(n){this.orderBaseSnapshot=n;for(let e of Array.from(this.snapshotByGen.keys()))e<t&&this.snapshotByGen.delete(e)}this.needsRender=!0}snapshotLayout(){return this.assembler.regions.map(e=>({object:e.object,start:e.start,count:e.count}))}buildSegments(e,t){let n=new Map;for(let e of t)n.set(e.object,e.start);let r=[];for(let t of e){let e=n.get(t.object),i=e===void 0,a=i?0:e-t.start,o=r[r.length-1];o&&o.removed===i&&(i||o.delta===a)&&o.oldEnd===t.start?o.oldEnd=t.start+t.count:r.push({oldStart:t.start,oldEnd:t.start+t.count,delta:a,removed:i})}return r}findSegment(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>1,a=e[i];if(t<a.oldStart)r=i-1;else if(t>=a.oldEnd)n=i+1;else return a}return null}applyReorderCPU(e){if(this.orderCount<=0||!this.orderData){this.aliveCount=0,this.geometry.instanceCount=0;return}let t=this.buildSegments(this.orderBaseSnapshot,e),n=this.ensureSplatIndexCapacity(this.orderCount),r=n.array,i=this.orderData,a=0;for(let e=0;e<this.orderCount;e++){let n=i[e],o=this.findSegment(t,n);!o||o.removed||(r[a++]=n+o.delta)}n.needsUpdate=!0,this.aliveCount=a,this.geometry.instanceCount=a,this.material.numPoints=this.assembler.totalPoints}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof Mt&&e.visible&&t.push(e)}),t.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:+(n>r)}),t}isSceneNeedsRebuild(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`),n=t!==this.gsSceneState.lastObjectsHash;return this.gsSceneState.lastObjectsHash=t,n}getClipperHash(e){return e.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`)}updateClipperCounts(e,t){let n=Math.max(0,e|0),r=Math.max(0,t|0);(this.material.numGsLayers!==n||this.material.numGsClippers!==r)&&(this.material.numGsLayers=n,this.material.numGsClippers=r,this.material.needsUpdate=!0)}updateClipperUniforms(e){var t,n;let r=this.layerRegistry.layerCount;if(r===0){this.material.layerClipperRanges=[],this.material.clipperMatricesInverse=[],this.updateClipperCounts(0,0);return}let i=new Map;for(let t of e){let e=t.gsViewLayerKey||t.uuid;i.has(e)||i.set(e,t.gsClippers)}let a=0;for(let e of this.layerRegistry.layerKeys)a+=((t=i.get(e))==null?[]:t).length;let o=this.createDefaultLayerClipperRanges(r),s=this.createDefaultClipperMatrices(a),c=0;for(let e of this.layerRegistry.layerKeys){let t=this.layerRegistry.layerKeyToIndex.get(e);if(t===void 0)continue;let r=(n=i.get(e))==null?[]:n,a=c,l=0;for(let e of r)s[c].copy(e.clippingBoxMatrix).invert(),c++,l++;l>0&&o[t].set(a,l)}this.material.layerClipperRanges=o,this.material.clipperMatricesInverse=s,this.updateClipperCounts(r,c)}rebuildScene(e){this.layerRegistry.sync(e),this.transformStore.sync(e),this.assembler.sync(e,e=>{let t=this.transformStore.indexOf(e);return t===void 0?(console.error(`[GS] resolveIndices: 对象缺少 transformIndex(布局不一致)。`),{transformIndex:0,layerIndex:this.layerRegistry.layerIndexOf(e)}):{transformIndex:t,layerIndex:this.layerRegistry.layerIndexOf(e)}}),this.assemblePending=!0,this.shStore.sync(e,this.usedSHDegree),this.assertLayoutConsistency(e)}assertLayoutConsistency(e){let t=this.assembler.regions;if(t.length!==e.length||this.transformStore.objectCount!==e.length){console.error(`[GS] 布局不一致:objects=${e.length} regions=${t.length} transforms=${this.transformStore.objectCount}`);return}for(let n=0;n<e.length;n++)if(t[n].object!==e[n]||this.transformStore.indexOf(e[n])!==n){console.error(`[GS] 布局不一致:第 ${n} 个对象在 regionList / TransformStore 中错位。`);break}}postSortData(){var e;let{positions:t,transformIndices:n,count:r}=this.assembler.extractSortInputs();if(r<=0){this.sortDataUploaded=!1;return}let i=++this.sortGeneration;this.snapshotByGen.set(i,this.snapshotLayout());let a=this.transformStore.objectCount*20,o=this.transformStore.transforms.slice(0,a);(e=this.sortWorker)==null||e.postMessage({sortData:{positions:t,transforms:o,transformIndices:n,vertexCount:r,generation:i}},[t.buffer,o.buffer,n.buffer]),this.sortDataUploaded=!0,this.sortInputsDirty=!1}shouldSort(e){if(this.sortInputsDirty||!this.sortDataUploaded||!this.prevSortCameraMatrix)return!0;this.prevSortCameraMatrix.decompose(Dr,kr,jr),e.matrixWorld.decompose(Or,Ar,jr);let t=Dr.distanceTo(Or),n=Math.abs(kr.dot(Ar));return t>this.sortCameraDistance||n<this.sortCameraCoorient}requestSort(e,t){var n;this.assembler.totalPoints<=0||this.shouldSort(e)&&(performance.now()-this.sortLastTime<this.sortMinIntervalMs||((this.sortInputsDirty||!this.sortDataUploaded)&&this.postSortData(),(n=this.sortWorker)==null||n.postMessage({viewProj:t}),this.prevSortCameraMatrix||(this.prevSortCameraMatrix=new l.Matrix4),this.prevSortCameraMatrix.copy(e.matrixWorld),this.sortLastTime=performance.now()))}syncMaterialTextures(){this.material.transformsTexture=this.transformStore.texture;let e=this.shStore.appliedDegree;this.material.maxShDegree!==e&&(this.material.maxShDegree=e,this.material.needsUpdate=!0),e>0&&this.shStore.texture?(this.material.shTexture=this.shStore.texture,this.material.shTextureSize.copy(this.shStore.textureSize)):this.material.shTexture=null,this.material.dataTexture=this.assembler.dataTexture,this.material.numPoints=this.assembler.totalPoints,this.material.transformIndicesTexture=null,this.material.layerIndicesTexture=null}dispose(){this.assembler.dispose(),this.transformStore.dispose(),this.shStore.dispose(),this.orderData=null,this.snapshotByGen.clear(),this.sortWorker&&(this.sortWorker.terminate(),this.sortWorker=null),this.geometry.dispose(),this.material.dispose()}},Nr=class extends l.MeshBasicMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`baisc`,this.type=`PBMMeshBasicMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Pr=class extends l.MeshBasicMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`panoOnly`,this.type=`PBMPanoOnlyMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Fr=class extends l.MeshPhongMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`phong`,this.type=`PBMMeshPhongMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}},Ir=class extends l.MeshPhysicalMaterial{constructor(e){super(e),this.isPBMMaterial=!0,this.shaderType=`standard`,this.type=`PBMMeshPhysicalMaterial`,Object.assign(this,Wt())}copy(e){return super.copy(e),Gt(this,e),this}};function Lr(e){switch(typeof e==`object`?e==null?void 0:e.shaderType:e){case`basic`:return new Nr;case`panoOnly`:return new Pr;case`phong`:return new Fr;default:return new Ir}}l.Material;var{materialReference:Rr,attribute:zr,float:Br,vec3:Vr,vec4:Hr,mat4:Ur}=l.TSL;function Wr(e,t=0){let n=`float`,r=zr(e,n),i=r.generate.bind(r);return r.generate=function(r){return r.hasGeometryAttribute(e)?i(r):r.generateConst(n,t)},Br(r)}function W(e){return Br(Rr(e,`float`)).toVar(e)}function Gr(e){return Vr(Rr(e,`vec3`)).toVar(e)}function Kr(e){return Hr(Rr(e,`vec4`)).toVar(e)}function qr(e){return Ur(Rr(e,`mat4`)).toVar(e)}function Jr(e,t){let n=Rr(e,`cubeTexture`),r=n.setup;return n.setup=function(n){let i=r.call(this,n);return i&&(t&&(i.uvNode=t),i.getUniformHash=function(){return[e,this.value.uuid].join(`-`)}),i},Hr(n).toVar(e)}function Yr(e,t){let n=Rr(e,`texture`),r=n.setup;return n.setup=function(n){let i=r.call(this,n);return i&&(t&&(i.uvNode=t),i.getUniformHash=function(){return[e,this.value.uuid].join(`-`)}),i},Hr(n).toVar(e)}var{Fn:Xr,vec3:Zr,vec4:Qr,float:$r,abs:ei,clamp:ti,min:ni,mix:ri,step:ii,fract:ai,dot:oi,log2:si,exp2:ci,pow:li,normalize:ui}=l.TSL,di=Xr(([e])=>{let t=Zr(e).toVar(),n=Qr(0,-1/3,2/3,-1),r=ri(Qr(t.b,t.g,n.w,n.z),Qr(t.g,t.b,n.x,n.y),ii(t.b,t.g)).toVar(),i=ri(Qr(r.x,r.y,r.w,t.r),Qr(t.r,r.y,r.z,r.x),ii(r.x,t.r)).toVar(),a=i.x.sub(ni(i.w,i.y)),o=$r(1e-10);return Zr(ei(i.z.add(i.w.sub(i.y).div(a.mul(6).add(o)))),a.div(i.x.add(o)),i.x)}).setLayout({name:`FN_rgb2hsv`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),fi=Xr(([e])=>{let t=Zr(e).toVar(),n=Qr(1,2/3,1/3,3),r=ei(ai(Zr(t.x,t.x,t.x).add(Zr(n.x,n.y,n.z))).mul(6).sub(Zr(n.w,n.w,n.w)));return t.z.mul(ri(Zr(n.x,n.x,n.x),ti(r.sub(Zr(n.x,n.x,n.x)),0,1),t.y))}).setLayout({name:`FN_hsv2rgb`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),pi=Xr(([e])=>oi(e,Qr(1/(256*256*256),1/(256*256),1/256,1))).setLayout({name:`FN_hsv2rgb`,type:`float`,inputs:[{name:`color`,type:`vec4`}]}),mi=Xr(([e,t,n,r,i,a,o])=>{let s=ti(si(t).sub(si(i)).div(si(a).sub(si(i))),$r(0),$r(1)),c=Zr(li(e.r,o),li(e.g,o),li(e.b,o)),l=si(r),u=si(n),d=Zr(l).add(c.mul(Zr(u.sub(l)))).mul(s);return Zr(ci(d.x),ci(d.y),ci(d.z))}).setLayout({name:`FN_hdrBoost`,type:`vec3`,inputs:[{name:`gainRGB`,type:`vec3`},{name:`maxDisplayBoost`,type:`float`},{name:`maxContentBoost`,type:`float`},{name:`minContentBoost`,type:`float`},{name:`capacityMin`,type:`float`},{name:`capacityMax`,type:`float`},{name:`gamma`,type:`float`}]}),hi=Xr(([e,t,n])=>{let r=oi(e,t),i=e.mul(r),a=t.sub(i).div(n);return ui(i.add(a))}).setLayout({name:`FN_zoomVector`,type:`vec3`,inputs:[{name:`direction`,type:`vec3`},{name:`vector`,type:`vec3`},{name:`zoom`,type:`float`}]}),gi=Xr(([e,t,n,r])=>{let i=e.mul(Qr(0,0,0,1)).xyz,a=hi(n,ui(r.sub(i)),t);return e.toMat3().transpose().mul(a)}).setLayout({name:`FN_sampleDirection`,type:`vec3`,inputs:[{name:`direction`,type:`mat4`},{name:`vector`,type:`float`},{name:`zoom`,type:`vec3`},{name:`positionWorld`,type:`vec3`}]}),_i=Math.PI*2;function vi(e){return e>=0&&e<_i?e:(e%_i+_i)%_i}function yi(e,t){let n=Math.abs(Math.cos(e.latitude)),r=-Math.sin(e.longitude)*n,i=-Math.sin(e.latitude),a=-Math.cos(e.longitude)*n;return t?t.set(r,i,a):new l.Vector3(r,i,a)}function bi(e){return{longitude:vi(-Math.atan2(e.x,-e.z)),latitude:-Math.asin(e.y/1)}}function xi(e){return(-e/Math.PI*180-90)/360+.25}function Si(e){return-((e-.25)*360+90)/180*Math.PI}var Ci=Date.now();typeof performance<`u`&&(typeof performance.timeOrigin==`number`?Ci=performance.timeOrigin:performance.timing!==void 0&&(Ci=performance.timing.navigationStart));var G=typeof performance<`u`?(()=>Ci+performance.now()):(()=>Date.now());function wi(e){return e-Ci}var Ti=1,Ei=.1,Di=2e3,Oi=Math.PI*2,ki=Math.PI/2;function Ai(e){return e>0&&e<=Oi?e:(e%Oi+Oi)%Oi}function ji(e,t,n,r){n=Math.pow(n,4);for(var i=0;i<16;i++)r.elements[i]=e.elements[i]+(t.elements[i]-e.elements[i])*n;return r}var Mi=class extends l.Camera{constructor(e,t=Ti,n=Ei,r=Di,i=new l.Vector2,a=new l.Vector2(512,512),o=1){super(),this.fov=e,this.aspect=t,this.near=n,this.far=r,this.perspToOrtho=i,this.resolution=a,this.pixelRatio=o,this.time=0,this.controllerMode=null,this.needsRender=!0,this.refineModel=!0,this.pose={longitude:0,latitude:0,fov:e,distance:0,offset:new l.Vector3},this.computePose(),this.perspectiveCamera=new l.PerspectiveCamera(this.fov,this.aspect,.001,this.far);let s=Math.max(this.orthoDistance,.01)*Math.tan(.5*this.fov/180*Math.PI),c=-.5*this.aspect*2*s;this.orthographicCamera=new l.OrthographicCamera(c,-c,s,-s,.001,this.far),this.computeProjectionMatrix(),this.lastValues={position:this.position.clone(),quaternion:this.quaternion.clone(),scale:this.scale.clone(),fov:this.fov,aspect:this.aspect,near:this.near,far:this.far,orthoDistance:this.orthoDistance,perspToOrtho:this.perspToOrtho.clone()},this.type=this.perspToOrtho.x<1?`PerspectiveCamera`:`OrthographicCamera`,this.autoNearFar=!0}get orthoDistance(){return this.pose.distance>1?this.pose.distance:1+(this.pose.distance-1)*this.perspToOrtho.x}get zoom(){return this.type===`OrthographicCamera`?this.orthographicCamera.zoom:this.type===`PerspectiveCamera`?this.perspectiveCamera.zoom:1}get top(){return this.type===`OrthographicCamera`?this.orthographicCamera.top:0}get bottom(){return this.type===`OrthographicCamera`?this.orthographicCamera.bottom:0}get left(){return this.type===`OrthographicCamera`?this.orthographicCamera.left:0}get right(){return this.type===`OrthographicCamera`?this.orthographicCamera.right:0}getDirection(e){return yi(this.pose,e)}computePose(e=0){this.updateMatrix();let t=this.matrix.elements;return this.pose.latitude=Math.asin(H(t[9],-1,1)),Math.abs(t[9])<.9999999?this.pose.longitude=Ai(Math.atan2(t[8],t[10])):this.pose.longitude=Ai(Math.atan2(-t[2],t[0])),this.pose.fov=this.fov,this.pose.distance=e,this.pose.offset=new l.Vector3(-t[8],-t[9],-t[10]).setLength(this.pose.distance).add(this.position),this}setFromPose(e){var t,n,r,i,a;let o=Ai((t=e.longitude)==null?this.pose.longitude:t),s=Math.max(-ki+1e-4,Math.min(ki-1e-4,(n=e.latitude)==null?this.pose.latitude:n)),c=(r=e.fov)==null?this.pose.fov:r,l=(i=e.distance)==null?this.pose.distance:i,u=(a=e.offset)==null?this.pose.offset:a,d=yi({longitude:o,latitude:s}).normalize();return this.position.set(0,0,0),this.lookAt(d),this.position.add(u).sub(d.clone().setLength(l)),this.fov!==c&&(this.fov=c,this.perspectiveCamera.fov=c,this.updateProjectionMatrix()),this.updateMatrixWorld(!0),this.pose.longitude=o,this.pose.latitude=s,this.pose.fov=c,this.pose.distance=l,this.pose.offset.copy(u),this.needsRender=!0,this}copyPose(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,distance:this.pose.distance,offset:this.pose.offset.clone()}}computeProjectionMatrix(){ji(this.orthographicCamera.projectionMatrix,this.perspectiveCamera.projectionMatrix,1-this.perspToOrtho.x,this.projectionMatrix),this.projectionMatrixInverse.copy(this.projectionMatrix).invert(),this.needsRender=!0}setViewOffset(e,t,n,r,i,a){this.perspectiveCamera.setViewOffset(e,t,n,r,i,a),this.orthographicCamera.setViewOffset(e,t,n,r,i,a),this.computeProjectionMatrix()}get view(){return this.perspectiveCamera.view?Object.assign({},this.perspectiveCamera.view):null}clearViewOffset(){this.perspectiveCamera.clearViewOffset(),this.orthographicCamera.clearViewOffset(),this.computeProjectionMatrix()}updateProjectionMatrix(){this.perspectiveCamera.coordinateSystem=this.coordinateSystem,this.orthographicCamera.coordinateSystem=this.coordinateSystem,this.perspectiveCamera.updateProjectionMatrix(),this.orthographicCamera.updateProjectionMatrix(),this.computeProjectionMatrix()}get perspectiveProjectionMatrix(){return this.perspectiveCamera.projectionMatrix}get perspectiveProjectionMatrixInverse(){return this.perspectiveCamera.projectionMatrixInverse}get orthographicProjectionMatrix(){return this.orthographicCamera.projectionMatrix}get orthographicProjectionMatrixInverse(){return this.orthographicCamera.projectionMatrixInverse}updateTime(e){this.time=e;let t=!1;if((this.lastValues.fov!==this.fov||this.lastValues.near!==this.near||this.lastValues.far!==this.far||this.lastValues.aspect!==this.aspect)&&(this.perspectiveCamera.coordinateSystem=this.coordinateSystem,this.perspectiveCamera.fov=this.fov,this.perspectiveCamera.near=this.near,this.perspectiveCamera.far=this.far,this.perspectiveCamera.aspect=this.aspect,this.perspectiveCamera.updateProjectionMatrix(),t=!0),!this.lastValues.position.equals(this.position)||!this.lastValues.quaternion.equals(this.quaternion)||!this.lastValues.scale.equals(this.scale)||!this.lastValues.perspToOrtho.equals(this.perspToOrtho)||this.lastValues.fov!==this.fov||this.lastValues.near!==this.near||this.lastValues.far!==this.far||this.lastValues.orthoDistance!==this.orthoDistance||this.lastValues.aspect!==this.aspect){let e=Math.max(this.orthoDistance,.01)*Math.tan(.5*this.fov/180*Math.PI),n=-.5*this.aspect*2*e;this.orthographicCamera.coordinateSystem=this.coordinateSystem,this.orthographicCamera.left=n,this.orthographicCamera.right=-n,this.orthographicCamera.top=e,this.orthographicCamera.bottom=-e,this.orthographicCamera.near=this.near,this.orthographicCamera.far=this.far,this.orthographicCamera.updateProjectionMatrix(),t=!0}t&&this.computeProjectionMatrix(),this.lastValues.position.copy(this.position),this.lastValues.quaternion.copy(this.quaternion),this.lastValues.scale.copy(this.scale),this.lastValues.fov=this.fov,this.lastValues.aspect=this.aspect,this.lastValues.near=this.near,this.lastValues.far=this.far,this.lastValues.orthoDistance=this.orthoDistance,this.lastValues.perspToOrtho.copy(this.perspToOrtho),this.type=this.perspToOrtho.x<1?`PerspectiveCamera`:`OrthographicCamera`}get isPerspectiveCamera(){return this.perspToOrtho.x<1}get isOrthographicCamera(){return this.perspToOrtho.x>=1}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.aspect=e.aspect,this.near=e.near,this.far=e.far,this.perspToOrtho.copy(e.perspToOrtho),this.updateTime(G()),this}},{vec2:Ni,vec3:Pi,vec4:Fi,float:Ii,int:Li,bool:Ri,normalize:zi,mix:Bi,min:Vi,step:Hi,abs:Ui,clamp:Wi,length:Gi,smoothstep:Ki,pow:qi,uniform:Ji,property:Yi,cameraViewMatrix:Xi,positionWorld:Zi,Fn:Qi}=l.TSL,$i=Fi(0,0,0,0),ea=new l.Vector4,ta=Ji(new l.Vector2(512,512)).onFrameUpdate(function(e){let t=e.camera;t instanceof Mi?this.value.copy(t.resolution):e.renderer&&(e.renderer.getViewport(ea),this.value.set(ea.width,ea.height))}),na=Ji(1).onFrameUpdate(function(e){let t=e.camera;t instanceof Mi?this.value=t.pixelRatio:e.renderer&&(this.value=e.renderer.getPixelRatio())}),ra=Pi(Xi.element(Li(0)).element(Li(2)),Xi.element(Li(1)).element(Li(2)),Xi.element(Li(2)).element(Li(2))).negate().normalize().toVarying(`v_cameraDirection`),ia=Ki(Ii(0),Ii(1),Wr(`_feature_id_rsmask`,0)).toVarying(`v_roofMark`),aa=W(`progress`),oa=W(`maxDisplayBoost`),sa=W(`modelAlpha`),ca=qr(`pano0Matrix`),la=W(`pano0Zoom`),ua=Kr(`pano0Histogram`),da=W(`pano0HdrMaxContentBoost`),fa=W(`pano0HdrMinContentBoost`),pa=W(`pano0HdrCapacityMin`),ma=W(`pano0HdrCapacityMax`),ha=W(`pano0HdrGamma`),ga=W(`pano0DepthMaxDepth`),_a=qr(`pano1Matrix`),va=W(`pano1Zoom`),ya=Kr(`pano1Histogram`),ba=W(`pano1HdrMaxContentBoost`),xa=W(`pano1HdrMinContentBoost`),Sa=W(`pano1HdrCapacityMin`),Ca=W(`pano1HdrCapacityMax`),wa=W(`pano1HdrGamma`),Ta=W(`pano1DepthMaxDepth`),Ea=W(`panoFilterSaturationBias`),Da=W(`panoFilterContrastBias`),Oa=W(`panoFilterTemperatureBias`),ka=W(`panoFilterTintBias`),Aa=qr(`refinedScreenProjectionMatrix`),ja=qr(`refinedScreenMatrixInverse`),Ma=W(`refinedScreenOpacity`),Na=W(`refinedScreenPano`),Pa=W(`colorAlpha`);W(`brightness`);var Fa=W(`floorIndex`),Ia=W(`shownFloorIndex`),La=Gr(`modelBoundingMin`),Ra=Gr(`modelBoundingMax`),za=Gr(`constantColor`),Ba=W(`pointScale`),Va=W(`pointMinPixel`),Ha=W(`pointMaxPixel`),Ua=W(`colorSaturation`),Wa=W(`colorBrightness`),Ga=Ia.lessThan(-.01).or(Ui(Fa.sub(Ia)).lessThan(.99)).toVar(`isCurrentFloor`),Ka=ia.greaterThan(.001).toVar(`isRoof`),qa=Qi(()=>{let e=Ri().toVar(`isRoofCut`),t=qi(Wi(ra.y.negate(),0,1),3),n=Ra.y.sub(t.mul(Ra.y.sub(La.y)));return e.assign(Ka.and(Zi.y.greaterThan(n))),e})(),Ja=ca.mul(Fi(0,0,0,1)).xyz.toVar(`pano0Origin`),Ya=gi(ca,la,ra,Zi).toVar(`pano0SampleDirection`),Xa=_a.mul(Fi(0,0,0,1)).xyz.toVar(`pano1Origin`),Za=gi(_a,va,ra,Zi).toVar(`pano1SampleDirection`),Qa=Jr(`pano0Map`,Ya).rgb.toVar(`pano0SdrColor`),$a=Jr(`pano1Map`,Za).rgb.toVar(`pano1SdrColor`),eo=Jr(`pano0GainMap`,Ya).rgb.toVar(`pano0GainColor`),to=Jr(`pano1GainMap`,Za).rgb.toVar(`pano1GainColor`),no=Qi(()=>{let e=Pi().toVar(`pano0HdrColor`),t=mi(eo,oa,da,fa,pa,ma,ha);return e.assign(Qa.mul(t)),e})(),ro=Qi(()=>{let e=Pi().toVar(`pano1HdrColor`),t=mi(to,oa,ba,xa,Sa,Ca,wa);return e.assign($a.mul(t)),e})(),io=Qi(()=>{let e=Fi().toVar(`refinedScreenColor`),t=ja.mul(Fi(Zi,1)).toVar(),n=Bi(la,va,Na),r=hi(Pi(0,0,1),zi(t.xyz),n),i=Aa.mul(Fi(r,1)).toVar();i.divAssign(i.w);let a=Pi(i.x,i.y.negate(),0).add(1).div(2);e.assign(Yr(`refinedScreenMap`,a.xy)),e.a.mulAssign(Ma);let o=Hi(Ui(i.x),1).mul(Hi(Ui(i.y),1)).mul(Hi(t.z,0));return e.assign(Bi($i,e,o)),e})(),ao=Bi(io,$i,Na).toVar(`refinedScreenPano0Color`),oo=Bi(io,$i,Ii(1).sub(Na)).toVar(`refinedScreenPano1Color`),so=.03,co=Qi(()=>{let e=Ii().toVar(`pano0DepthTrust`),t=Wi(Gi(Zi.sub(Ja)),0,Ii(ga)).toVar(),n=Ui(pi(Fi(Jr(`pano0DepthMap`,Ya))).mul(ga).sub(t)),r=Ii(so).mul(t);return e.assign(Hi(r,n)),e})(),lo=Qi(()=>{let e=Ii().toVar(`pano1DepthTrust`),t=Wi(Gi(Zi.sub(Xa)),0,Ii(Ta)).toVar(),n=Ui(pi(Fi(Jr(`pano1DepthMap`,Za))).mul(Ta).sub(t)),r=Ii(so).mul(t);return e.assign(Hi(r,n)),e})(),uo=Qi(()=>{let e=Pi().toVar(`gradientColor`),t=Ii(Zi.y.sub(La.y)).div(Ra.y.sub(La.y));return e.assign(Yr(`gradientTexture`,Ni(t,.5)).rgb),e})(),fo=Bi(Wi(Ii(.2).mul(Vi(Ii(1).add(ra.y),1)),0,1),Ii(1),Ii(Ga)).toVar(`floorOpacity`),po=Yi(`vec3`).toVar(`pano0Color`),mo=Yi(`vec3`).toVar(`pano1Color`),{Fn:ho,vec2:go,vec3:_o,vec4:vo,float:yo,clamp:bo,max:xo,mix:So,step:Co}=l.TSL,wo=ho(([e,t])=>{let n=_o(e).toVar(),r=bo(t,-100,100);return n.r.assign(n.r.mul(yo(1).add(r.div(300)))),n.b.assign(n.b.mul(yo(1).sub(r.div(300)))),bo(n,0,1)}).setLayout({name:`FN_filterColorTemperature`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`temperatureBias`,type:`float`}]}),To=ho(([e,t])=>{let n=_o(e).toVar(),r=bo(t,-100,100),i=yo(1).add(r.mul(-.5).div(200).mul(Co(r,0))),a=yo(1).sub(So(r.mul(.5).div(200),r.div(200),Co(yo(0),r))),o=yo(1).add(r.mul(-.5).div(200).mul(Co(r,0)));return n.r.assign(n.r.mul(i)),n.g.assign(n.g.mul(a)),n.b.assign(n.b.mul(o)),bo(n,0,1)}).setLayout({name:`FN_filterColorTint`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`tintBias`,type:`float`}]}),Eo=ho(([e,t,n])=>{let r=_o(e).toVar(),i=t.y,a=t.z,o=t.w,s=bo(n,-1,1).toVar(),c=s.add(1).toVar(),l=s.mul(s).div(2).toVar(),u=c.sub(1).div(i).toVar(),d=yo(1).sub(c).div(yo(1).sub(i)).toVar(),f=c.sub(i).div(yo(1).sub(i)).toVar(),p=yo(1).div(o.sub(a)).toVar(),m=r.toVar(),h=xo(xo(r.r,r.g),r.b).toVar();m.assign(So(m,m.mul(yo(1).sub(l)).add(h.mul(l)),Co(s,0)));let g=So(d.mul(m.r).add(f),u.mul(m.r).add(1),Co(m.r,i)),_=So(d.mul(m.g).add(f),u.mul(m.g).add(1),Co(m.g,i)),v=So(d.mul(m.b).add(f),u.mul(m.b).add(1),Co(m.b,i));return r.assign(m.sub(i).mul(_o(g,_,v).mul(p)).add(i)),bo(r,0,1)}).setLayout({name:`FN_filterContrast`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`histogram`,type:`vec4`},{name:`contrastBias`,type:`float`}]}),Do=ho(([e,t])=>{let n=_o(e).toVar(),r=yo(1).add(t),i=yo(.299).mul(n.r).add(yo(.587).mul(n.g)).add(yo(.114).mul(n.b));return n.assign(n.sub(i).mul(r).add(i)),bo(n,0,1)}).setLayout({name:`FN_filterSaturation`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`saturationBias`,type:`float`}]});function Oo(e,t,n,r,i){return ho(([a,o])=>{let s=_o(a).toVar(),c=di(s).toVar();return c.z.assign(vo(i(go(c.z,0))).r),s.assign(fi(c)),s.assign(bo(s,0,1)),s.assign(wo(s,n)),s.assign(To(s,r)),s.assign(Eo(s,o,t)),s.assign(Do(s,e)),s})}var{Fn:ko,vec3:Ao,vec4:jo,float:Mo,acos:No,max:Po,min:Fo,mix:Io,length:Lo,distance:Ro,smoothstep:zo,screenCoordinate:Bo}=l.TSL;function Vo(e){return ko(([t,n,r])=>{let i=Ao().toVar();if(e.transition===`BLACK`){let e=jo(.086,.106,.149,1),a=No(Mo(-2).mul(r).add(1)).toVar();i.assign(Io(t,e,Fo(Mo(1),a))),i.assign(Io(i,n,Po(Mo(0),a.sub(Math.PI).add(1))))}else if(e.transition===`SPREAD`){let e=ta.mul(na).div(2).toVar(),a=Lo(e).mul(1.2),o=Ro(Bo.xy,e).div(a);i.assign(Io(t,n,zo(0,.2,r.sub(o))))}else i.assign(Io(t,n,r));return i})}var{vec3:Ho,vec4:Uo,float:Wo,clamp:Go,mix:Ko,Fn:qo}=l.TSL;function Jo(e){return qo(([t])=>{if(e.useHDR?(po.assign(no),mo.assign(ro)):(po.assign(Qa),mo.assign($a)),e.useRefinedScreen&&(po.assign(Ko(po,ao.rgb,ao.a)),mo.assign(Ko(mo,oo.rgb,oo.a))),!e.useHDR&&e.usePanoFilter){let e=Oo(Ea,Da,Oa,ka,e=>Yr(`panoFilterLutMap`,e));po.assign(e(po,ua)),mo.assign(e(mo,ya))}if(e.usePanoDepth){let e=Uo(t).toVar(`depthFallback`),n=Go(aa.mul(10),0,1),r=Go(Wo(1).sub(aa).mul(10),0,1);po.assign(Ko(po,Ko(po,e,n),co)),mo.assign(Ko(mo,Ko(mo,e,r),lo))}let n=Ho(0).toVar(`panoColor`),r=Vo(e);return n.assign(r(po,mo,aa)),n})}var{Fn:Yo,vec3:Xo,vec4:Zo,float:Qo,int:$o,varyingProperty:es,attribute:ts,positionGeometry:ns,positionWorld:rs,positionView:is,modelWorldMatrix:as,cameraProjectionMatrix:os,cameraPosition:ss,normalize:cs,clamp:ls,length:us,dot:ds,mix:fs,min:ps,max:ms,Discard:hs,colorSpaceToWorking:gs,output:_s}=l.TSL;function vs(e,t){let n=e.pano0Map!=null&&e.pano1Map!=null,r=e.vertexMarks,i=e.roofStyle,a=e.floorStyle===`VISIBILITY`,o=e.gradientTexture!=null,s=e.refinedScreenMap!=null,c=e.panoFilterLutMap!=null,l=e.useHDR,u=e.colorStyle,d=e.transition;e.outputNode=Yo(()=>{a&&Ga.not().discard(),r&&(i===`HIDE`?Ka.discard():qa.discard());let e=Zo(0).toVar(`result`);if(e.assign(_s),u===`ALTITUDE`&&o?e.rgb.assign(uo):u===`CONSTANT`&&e.rgb.assign(za),e.a.mulAssign(fo.mul(Pa)),n){let t=Jo({transition:d,usePanoFilter:c,useRefinedScreen:s,useHDR:l,usePanoDepth:!1});e.assign(fs(Zo(t(_s),1),e,sa))}return e})()}function ys(e,t){let n=e.pano0Map!=null&&e.pano1Map!=null,r=e.refinedScreenMap!=null,i=e.panoFilterLutMap!=null,a=e.useHDR,o=e.transition;e.outputNode=Yo(()=>{let e=Zo(0).toVar(`result`);if(n){let t=Jo({transition:o,usePanoFilter:i,useRefinedScreen:r,useHDR:a,usePanoDepth:!1});e.rgb.assign(t(_s))}return e.a.assign(Qo(1).sub(ls(sa.mul(30),0,1))),e})()}function bs(e,t){e.positionNode=ts(`instancePosition`,`vec3`);let n=t;n.addStack(),e.setupPosition(t),n.context.position=n.removeStack();let r=is.z.negate(),i=os.element($o(1)).element($o(1)),a=os.element($o(2)).element($o(3)),o=Qo(0).sub(a),s=fs(Qo(1),r,o),c;if(e.pointSize===`ATTENUATION`){let e=Qo(1).div(i).mul(s).mul(2);c=ta.y.mul(Ba).mul(na).div(e)}else c=Ba.mul(na);c=ls(c,Va.mul(na),Ha.mul(na));let l=Ha.mul(na);if(c=ms(c,ps(Qo(1),l)),c=ps(c,l),e.pointBack===`HIDDEN`&&!e.flatShading){let e=ts(`instanceNormal`,`vec3`),t=cs(as.mul(Zo(e,0)).xyz),n=ds(cs(ss.sub(rs)),t);c=fs(Qo(0),c,Qo(n.greaterThan(0)))}es(`float`,`v_pointSize`).assign(c);let u=ta.y.mul(na),d=c.mul(Qo(2)).mul(s).div(i.mul(u)),f=ns.xy,p=is,m=Xo(f.x.mul(d),f.y.mul(d),Qo(0));return os.mul(Zo(p.add(m),Qo(1)))}function xs(e,t){let n=e.gradientTexture!=null,r=e.colorStyle,i=e.pointBack,a=e.pointShape,o=e.flatShading;e.colorNode=Yo(()=>{let e;return e=r===`ALTITUDE`&&n?uo:r===`CONSTANT`?za:gs(ts(`instanceColor`,`vec3`),l.SRGBColorSpace),i===`DARK`&&!o&&(e=Yo(([e])=>{let t=Xo(e).toVar(),n=ts(`instanceNormal`,`vec3`),r=cs(as.mul(Zo(n,0)).xyz),i=ds(cs(ss.sub(rs)),r);return t.assign(fs(t.mul(.8),t,Qo(i.greaterThan(0)))),t})(e)),e=Yo(([e])=>{let t=Xo(e).toVar(),n=di(t).toVar();return n.y.assign(n.y.add(Ua)),n.z.assign(n.z.add(Wa)),t.assign(ms(fi(n),Qo(0))),t})(e),e})(),e.outputNode=Yo(([e])=>{let t=es(`float`,`v_pointSize`);if(hs(t.lessThan(.001)),a===`CIRCLE`){let e=ns.xy,n=us(e);hs(t.greaterThan(Qo(3)).and(n.greaterThan(.5)))}let n=Zo(e).toVar(`result`);return n.a.assign(fo.mul(sa)),n})(_s)}var Ss=new Nr,Cs=class extends l.MeshBasicNodeMaterial{static get type(){return`PBMMeshBasicNodeMaterial`}constructor(e){super(e),this.isPBMMeshBasicNodeMaterial=!0,this.setDefaultValues(Ss),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},ws=new Fr,Ts=class extends l.MeshPhongNodeMaterial{static get type(){return`PBMMeshPhongNodeMaterial`}constructor(e){super(e),this.isPBMMeshPhongNodeMaterial=!0,this.setDefaultValues(ws),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},Es=new Ir,Ds=class extends l.MeshPhysicalNodeMaterial{static get type(){return`PBMMeshPhysicalNodeMaterial`}constructor(e){super(e),this.isPBMMeshPhysicalNodeMaterial=!0,this.setDefaultValues(Es),this.setValues(e)}setup(e){vs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},Os=new Pr,ks=class extends l.MeshBasicNodeMaterial{static get type(){return`PBMPanoOnlyNodeMaterial`}constructor(e){super(e),this.isPBMPanoOnlyNodeMaterial=!0,this.setDefaultValues(Os),this.setValues(e)}setup(e){ys(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}},As=new $t,js=class extends l.NodeMaterial{static get type(){return`PBMPointCloudNodeMaterial`}constructor(){super(),this.isPBMPointCloudNodeMaterial=!0,this.setDefaultValues(As),this.lights=!1,this.side=l.DoubleSide}customProgramCacheKey(){return super.customProgramCacheKey()+`,`+[this.pointSize,this.pointShape,this.pointBack,this.colorStyle,this.floorStyle,this.vertexMarks,this.flatShading,!!this.gradientTexture].join(`,`)}setupVertex(e){return bs(this,e)}setup(e){xs(this,e),super.setup(e)}setupObserver(e){let t=super.setupObserver(e);return t.refreshUniforms.push(...Ut),t}};function Ms(e){e.library.addMaterial(Cs,`PBMMeshBasicMaterial`),e.library.addMaterial(Ts,`PBMMeshPhongMaterial`),e.library.addMaterial(Ds,`PBMMeshPhysicalMaterial`),e.library.addMaterial(ks,`PBMPanoOnlyMaterial`),e.library.addMaterial(js,`PBMPointCloudMaterial`)}var Ns=new l.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),Ps=new l.Matrix4().copy(Ns).invert();function K(...e){}var Fs=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i],Is=typeof location<`u`?location.href:``,Ls=/^https\:/.test(Is),Rs=class extends Error{constructor(e,t,n){super(`[NETWORK]: request proxy error(type: ${t}, reason: ${n}): ${e}`)}},zs=class extends Error{constructor(e,t,n){super(`[NETWORK]: response error(type: ${t}, status: ${n}): ${e}`),this.httpStatus=n}},Bs=class extends Error{constructor(e,t,n){super(`[NETWORK]: request timeout(type: ${t}, timeout: ${n}ms): ${e}`)}};function Vs(e){if(!e)return{};let t={},n=e.trim().split(`
346
346
  `);for(let e=0;e<n.length;e++){let r=n[e],i=r.indexOf(`:`),a=r.slice(0,i).trim().toLowerCase(),o=r.slice(i+1).trim();o&&(t[a]?t[a]+=`, `+o:t[a]=o)}return t}function Hs(e){for(let t of Fs){let n=e.match(t);if(n)return`jsonp_`+n[1]}return null}function Us(e){return Hs(e)!==null}var Ws=class extends Bt{};function Gs(e,t={},n=K,r=K,i=K){let a=G(),o=e;return Promise.resolve().then(()=>t.requestProxy?t.requestProxy(e):e).then(e=>Ls&&/^http\:/.test(e)?(console.warn(`The page at '${Is}' was loaded over HTTPS, but requested an insecure element '${e}'. This request was automatically upgraded to HTTPS`),e.replace(/^http\:/,`https:`)):e).catch(n=>{var r;Hs(e);let i=new Rs(o,`XMLHttpRequest`,n&&n.message?String(n.message):String(n));return(r=t.networkSubscribe)==null||r.emit(`network`,e,`XMLHttpRequest`,`forbidden`,i.message),Promise.reject(i)}).then(e=>new Promise((s,c)=>{let l=Hs(e);if(l){let i=window,u=null,d=!1,f=document.createElement(`script`);i[l]=p=>{var m,h;let g=G(),_=g-a;if(delete i[l],f.parentNode&&f.parentNode.removeChild(f),u!==null&&(window.clearTimeout(u),u=null),d===!0)return;if(p.indexOf(`data:`)!==0){let n=new zs(e,`XMLHttpRequest`,500);r(n),c(n),(m=t.networkSubscribe)==null||m.emit(`network`,e,`XMLHttpRequest`,`error`,n.message);return}let v=p.split(`,`),y=(v[0].match(/:(.*?);/)||[])[1],b=v[1];if(t.responseType===`arraybuffer`||t.responseType===`blob`){let e=atob(v[1]),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);b=t.responseType===`arraybuffer`?r.buffer:new Blob([r],{type:y})}let x={body:b,meta:{origin:o,source:e,requestTime:a,responseTime:g,costs:_,headers:{}}};n(x),s(x),(h=t.networkSubscribe)==null||h.emit(`network`,e,`XMLHttpRequest`,`ok`,JSON.stringify(x.meta)),d=!0},f.src=e,document.body.appendChild(f),typeof t.timeout==`number`&&(u=window.setTimeout(()=>{var n;if(u=null,d!==!0){d=!0;let i=new Bs(e,`XMLHttpRequest`,t.timeout||NaN);r(i),c(i),(n=t.networkSubscribe)==null||n.emit(`network`,e,`XMLHttpRequest`,`timeout`,i.message)}},t.timeout))}else{let l=!1,u=new XMLHttpRequest,d=()=>{u&&(u.removeEventListener(`timeout`,f,!1),u.removeEventListener(`progress`,p,!1),u.removeEventListener(`load`,m,!1),u.removeEventListener(`error`,h,!1)),u=null,d=K},f=function(){var n;if(l===!0)return;l=!0,d();let i=new Bs(e,`XMLHttpRequest`,t.timeout||NaN);r(i),c(i),(n=t.networkSubscribe)==null||n.emit(`network`,e,`XMLHttpRequest`,`timeout`,i.message)},p=function(e){l!==!0&&e.lengthComputable&&(e.total<=0||i(e.loaded/e.total,e.loaded,e.total))},m=function(r){var i;if(l===!0)return;let c=this.status;if(c===0||c>=200&&c<400){l=!0,d();let c=G(),u=c-a,f=Vs(this.getAllResponseHeaders()),p=r.total,m={body:this.response,meta:{origin:o,source:e,requestTime:a,responseTime:c,costs:u,headers:f,size:p}};n(m),s(m),(i=t.networkSubscribe)==null||i.emit(`network`,e,`XMLHttpRequest`,`ok`,JSON.stringify(m.meta))}else h.call(this)},h=function(){var n;if(l===!0)return;l=!0,d();let i=new zs(e,`XMLHttpRequest`,this.status);r(i),c(i),(n=t.networkSubscribe)==null||n.emit(`network`,e,`XMLHttpRequest`,`error`,i.message)};u.addEventListener(`timeout`,f,!1),u.addEventListener(`progress`,p,!1),u.addEventListener(`load`,m,!1),u.addEventListener(`error`,h,!1),t.responseType&&(u.responseType=t.responseType),typeof t.timeout==`number`&&(u.timeout=t.timeout),u.open(`GET`,e,!0),u.send(null)}}))}var Ks={};function qs(e,t={}){let n=G(),r=e;return Promise.resolve().then(()=>t.requestProxy?t.requestProxy(e):e).then(e=>Ls&&/^http\:/.test(e)?(console.warn(`The page at '${Is}' was loaded over HTTPS, but requested an insecure element '${e}'. This request was automatically upgraded to HTTPS`),e.replace(/^http\:/,`https:`)):e).catch(n=>{var i;let a=new Rs(r,`Link`,n&&n.message?String(n.message):String(n));return(i=t.networkSubscribe)==null||i.emit(`network`,e,`Link`,`forbidden`,a.message),Promise.reject(a)}).then(e=>e in Ks?Ks[e]:Ks[e]=new Promise((i,a)=>{let o=document.head||document.getElementsByTagName(`head`)[0],s=document.createElement(`link`),c=!1,l=null;s.onload=a=>{var o;if(l!==null&&(clearTimeout(l),l=null),c===!0)return;c=!0,i(),s.onerror=K,s.onload=K;let u=G(),d={origin:r,source:e,requestTime:n,responseTime:u,costs:u-n,headers:{}};(o=t.networkSubscribe)==null||o.emit(`network`,e,`Link`,`preload`,JSON.stringify(d))},s.onerror=n=>{var r;if(l!==null&&(clearTimeout(l),l=null),c===!0)return;c=!0,delete Ks[e],o&&s.parentNode===o&&o.removeChild(s);let i=new zs(e,`Link`,0);a(i),s.onerror=K,s.onload=K,(r=t.networkSubscribe)==null||r.emit(`network`,e,`Link`,`error`,i.message)},typeof t.timeout==`number`&&(l=window.setTimeout(()=>{var a;if(l=null,c===!0)return;c=!0,i(),s.onerror=K,s.onload=K;let o=G(),u={origin:r,source:e,requestTime:n,responseTime:o,costs:o-n,headers:{}};(a=t.networkSubscribe)==null||a.emit(`network`,e,`Link`,`timeout`,JSON.stringify(u))},t.timeout)),s.rel=s.relList&&s.relList.supports(`prefetch`)?`prefetch`:`preload`,s.as=`fetch`,s.crossOrigin=``,s.fetchPriority=`high`,s.href=e,o&&o.appendChild(s)}))}function Js(e,t={},n=K,r=K,i=K,a){let o=G(),s=e;return Promise.resolve().then(()=>t.requestProxy?t.requestProxy(e):e).then(e=>Ls&&/^http\:/.test(e)?(console.warn(`The page at '${Is}' was loaded over HTTPS, but requested an insecure element '${e}'. This request was automatically upgraded to HTTPS`),e.replace(/^http\:/,`https:`)):e).catch(n=>{var r;let i=new Rs(s,`Image`,n&&n.message?String(n.message):String(n));return(r=t.networkSubscribe)==null||r.emit(`network`,e,`Image`,`forbidden`,i.message),Promise.reject(i)}).then(e=>Us(e)?Gs(e,{responseType:`blob`,networkSubscribe:t.networkSubscribe}).then(e=>URL.createObjectURL(e.body)):e).then(e=>new Promise((c,l)=>{let u=a==null?new Image:a,d=!1,f=null;typeof t.timeout==`number`&&(f=window.setTimeout(()=>{var n;if(u.onload=K,u.onerror=K,f=null,d===!0)return;d=!0;let i=new Bs(e,`Image`,t.timeout);r(i),l(i),(n=t.networkSubscribe)==null||n.emit(`network`,e,`Image`,`timeout`,i.message)},t.timeout)),u.onload=()=>{var r;if(u.onload=K,u.onerror=K,f!==null&&(clearTimeout(f),f=null),d===!0)return;let a=G(),l={headers:{},origin:s,source:e,requestTime:o,responseTime:a,costs:a-o};d=!0;let p={body:u,meta:l};i(1),n(p),c(p),(r=t.networkSubscribe)==null||r.emit(`network`,e,`Image`,`ok`,JSON.stringify(p.meta))},u.onerror=()=>{var n;if(u.onload=K,u.onerror=K,f!==null&&(clearTimeout(f),f=null),d===!0)return;d=!0;let i=new zs(e,`Image`,0);r(i),l(i),(n=t.networkSubscribe)==null||n.emit(`network`,e,`Image`,`ok`,i.message)},i(0),u.src=e}))}var Ys=class{constructor(e={}){this.options=e}ajax(e,t={},n=K,r=K,i=K){var a;let o=this.options;return Gs(e,{responseType:t.responseType,timeout:(a=t.timeout)==null?o.timeout:a,get requestProxy(){var e;return(e=t.requestProxy)==null?o.requestProxy:e},get networkSubscribe(){var e;return(e=t.networkSubscribe)==null?o.networkSubscribe:e}},n,r,i)}loadImage(e,t={},n=K,r=K,i=K,a){var o;let s=this.options;return Js(e,{timeout:(o=t.timeout)==null?s.timeout:o,get requestProxy(){var e;return(e=t.requestProxy)==null?s.requestProxy:e},get networkSubscribe(){var e;return(e=t.networkSubscribe)==null?s.networkSubscribe:e}},n,r,i,a)}preload(e,t={}){var n;let r=this.options;return qs(e,{timeout:(n=t.timeout)==null?r.timeout:n,get requestProxy(){var e;return(e=t.requestProxy)==null?r.requestProxy:e},get networkSubscribe(){var e;return(e=t.networkSubscribe)==null?r.networkSubscribe:e}})}},Xs=new Ys;function Zs(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Qs(e,t){let n={},r=new Set(t);for(let t of Object.keys(e))r.has(t)||(n[t]=e[t]);return n}function $s(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}return t}var ec=typeof document<`u`?document.createElement(`a`):{href:``};function tc(e){return e.indexOf(`/`)===0||/^[0-9a-z]+\:/i.test(e)}function nc(e){if(typeof URL<`u`&&typeof location<`u`)return new URL(e,location.href).href;{ec.href=e;let t=ec.href;return ec.href=``,t}}function rc(...e){let t=[];e=e.map(e=>(e==null?``:e).trim()).filter(e=>e.length>0&&!/^\/+$/.test(e));for(let n=0;n<e.length;n++){let r=n===0,i=n===e.length-1,a=e[n];r||(a=a.replace(/^\.\//,``).replace(/^\/+/,``)),i||(a=a.replace(/\/+$/,``)),t.push(a)}return t.join(`/`)}function ic(e,t=``){if((t[0]===`?`||t[0]===`&`)&&(t=t.slice(1)),!t)return e;let n=e.indexOf(`#`),r=``;return n>=0&&(r=e.slice(n),e=e.slice(0,n)),(e[e.length-1]===`?`||e[e.length-1]===`&`)&&(e=e.slice(0,-1)),e.indexOf(`?`)>=0?`${e}&${t}${r}`:`${e}?${t}${r}`}function ac(e){var t;let n=/^(http\:|https\:|file\:)?\/\/[^/]/.exec(e);if(!n)return e;let r=n[1]||``,i=e.slice(r.length+2),a=i.indexOf(`#`);a>=0&&(e.slice(a),i=e.slice(0,a));let o=i.indexOf(`?`);o>=0&&(e.slice(o),i=e.slice(0,o));let s=i.split(`/`),c=s.shift(),l=(t=s.pop())==null?``:t,u=[];for(let e of s)if(!(e===``||e===`.`)){if(e===`..`){u.pop();continue}u.push(e)}return r+`//`+c+`/`+u.join(`/`)+`/`+l}function oc(e){let t=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(e);if(t){let e=String(t[1]).trim().split(`.`).slice(1).reverse()[0];if(e)return`.`+e}return``}var sc=`data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoCAAIAAUAmJaQAA3AA/vz0AAA=`,cc=`data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAAGhbWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAsaWxvYwAAAABEAAACAAEAAAABAAAB3gAAABkAAgAAAAEAAAHJAAAAFQAAAEJpaW5mAAAAAAACAAAAGmluZmUCAAAAAAEAAGF2MDFDb2xvcgAAAAAaaW5mZQIAAAAAAgAAYXYwMUFscGhhAAAAABppcmVmAAAAAAAAAA5hdXhsAAIAAQABAAAA12lwcnAAAACxaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIAAoAAAAAUaXNwZQAAAAAAAAACAAAAAgAAAA5waXhpAAAAAAEIAAAADGF2MUOBABwAAAAAOGF1eEMAAAAAdXJuOm1wZWc6bXBlZ0I6Y2ljcDpzeXN0ZW1zOmF1eGlsaWFyeTphbHBoYQAAAAAeaXBtYQAAAAAAAAACAAEEAQKDBAACBAUGhwgAAAA2bWRhdBIACgQYADLVMgsWQBhhIAQqrNj/+BIACgUYADLEoDIOFkADDDDCQAACDaqCCb4=`,lc=`data:image/heif;base64,AAAAGGZ0eXBoZWljAAAAAG1pZjFoZWljAAABL21ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAHBpY3QAAAAAAAAAAAAAAAAAAAAADnBpdG0AAAAAAAEAAAAjaWluZgAAAAAAAQAAABVpbmZlAgAAAAABAABodmMxAAAAAK9pcHJwAAAAkmlwY28AAAB2aHZjQwEBYAAAAAAAAAAAAADwAPz9+PgAACcDoAABAB5AAQwG//8BYAAAAwAAAwAAAwAAAwAAAwAAreTLgSChAAEAI0IBBwFgAAADAAADAAADAAADAAADAAChInJJlreTLySZNdggogABAAdEAcA98DMkAAAAFGlzcGUAAAAAAAAAAgAAAAIAAAAVaXBtYQAAAAAAAAABAAECgQIAAAAiaWxvYwAAAABEQAABAAEAAAAAAU8AAQAAAAAAAAAOAAAAFm1kYXQAAAAKJgGvLvkQwuWM4A==`;function uc(e){return new Promise(t=>{if(typeof Image>`u`){t(!1);return}let n=new Image,r=setTimeout(()=>{n.onload=n.onerror=()=>{},clearTimeout(r),t(!1)},100);n.onload=n.onerror=()=>{n.onload=n.onerror=()=>{},clearTimeout(r),t(n.height===2)},n.src=e})}var dc=null;function fc(){return dc||(dc=Promise.all([uc(sc),uc(cc),uc(lc)]).then(e=>({webp:e[0],avif:e[1],heif:e[2]})))}var pc,mc=!1,hc=!1,gc=!1;fc().then(e=>{mc=e.avif,hc=e.webp,gc=e.heif});var _c=[`jpg`,`jpeg`,`png`,`heif`,`heic`,`webp`,`avif`];function vc(e){return _c.indexOf(e)>=0}var yc={"vrlab-public.ljcdn.com":{type:`tencentCloud`,pano:[`vrlab-image1.ljcdn.com`,`vrlab-image2.ljcdn.com`],texture:[`vrlab-image3.ljcdn.com`],tile:[`vr-tile-1.realsee-cdn.cn`,`vr-tile-2.realsee-cdn.cn`],model:[`vr-model-1.realsee-cdn.cn`,`vr-model-2.realsee-cdn.cn`],default:[`vrlab-image4.ljcdn.com`]},"vr-public.realsee-cdn.cn":{type:`tencentCloud`,pano:[`vr-image-1.realsee-cdn.cn`,`vr-image-2.realsee-cdn.cn`],texture:[`vr-image-3.realsee-cdn.cn`],tile:[`vr-tile-1.realsee-cdn.cn`,`vr-tile-2.realsee-cdn.cn`],model:[`vr-model-1.realsee-cdn.cn`,`vr-model-2.realsee-cdn.cn`],default:[`vr-image-4.realsee-cdn.cn`]},"vr-public.rscdn.cn":{type:`tencentCloud`,pano:[`vr-image-1.rscdn.cn`,`vr-image-2.rscdn.cn`],texture:[`vr-image-3.rscdn.cn`],tile:[`vr-tile-1.rscdn.cn`,`vr-tile-2.rscdn.cn`],model:[`vr-model-1.rscdn.cn`,`vr-model-2.rscdn.cn`],default:[`vr-image-4.rscdn.cn`]},"mars-public.realsee-cdn.cn":{type:`aliyun`,pano:[`mars-image-1.realsee-cdn.cn`,`mars-image-2.realsee-cdn.cn`],texture:[`mars-image-3.realsee-cdn.cn`],tile:[`mars-tile-1.realsee-cdn.cn`,`mars-tile-2.realsee-cdn.cn`],model:[`mars-model-1.realsee-cdn.cn`,`mars-model-2.realsee-cdn.cn`],default:[`mars-image-4.realsee-cdn.cn`]},"global-public.realsee-cdn.com":{type:`tencentCloud`,pano:[`global-image-1.realsee-cdn.com`,`global-image-2.realsee-cdn.com`],texture:[`global-image-3.realsee-cdn.com`],tile:[`global-tile-1.realsee-cdn.com`,`global-tile-2.realsee-cdn.com`],model:[`global-model-1.realsee-cdn.com`,`global-model-2.realsee-cdn.com`],default:[`global-image-4.realsee-cdn.com`]},"earth-ga-public.realsee-cdn.cn":{type:`tencentCloud`,pano:[`earth-ga-image-1.realsee-cdn.cn`,`earth-ga-image-2.realsee-cdn.cn`],texture:[`earth-ga-image-3.realsee-cdn.cn`],tile:[`earth-ga-tile-1.realsee-cdn.cn`,`earth-ga-tile-2.realsee-cdn.cn`],model:[`earth-ga-model-1.realsee-cdn.cn`,`earth-ga-model-2.realsee-cdn.cn`],default:[`earth-ga-image-4.realsee-cdn.cn`]},"test-vr-public.realsee-cdn.com":{type:`tencentCloud`,pano:[`test-vr-image.realsee-cdn.com`,`test-vr-image.realsee-cdn.com`],texture:[`test-vr-image.realsee-cdn.com`],tile:[`test-vr-image.realsee-cdn.com`,`test-vr-image.realsee-cdn.com`],model:[`test-vr-image.realsee-cdn.com`,`test-vr-image.realsee-cdn.com`],default:[`test-vr-image.realsee-cdn.com`]},"test-vr-public.realsee-cdn.cn":{type:`tencentCloud`,pano:[`test-vr-image.realsee-cdn.cn`,`test-vr-image.realsee-cdn.cn`],texture:[`test-vr-image.realsee-cdn.cn`],tile:[`test-vr-image.realsee-cdn.cn`,`test-vr-image.realsee-cdn.cn`],model:[`test-vr-image.realsee-cdn.cn`,`test-vr-image.realsee-cdn.cn`],default:[`test-vr-image.realsee-cdn.cn`]}},bc=/^https?\:\/\/?([^\/]+)/;function xc(e){let t=e.match(bc);return t===null?null:t[1]}function Sc(e,t,n){var r,i;let a=(i=(r=t[n])==null?t[t.length-1]:r)==null?e:i;return e.replace(bc,(e,t)=>e.slice(0,e.length-t.length)+a)}function Cc(e,t,n){let[r,...i]=t.split(`.`);if(r===`texture`)return Sc(e,n.texture,0);if(r===`pano`){let[t,r]=i;switch(r){case`front`:case`left`:case`up`:return Sc(e,n.pano,0);case`down`:case`right`:case`back`:return Sc(e,n.pano,1);default:break}}else if(r===`pano_tile`){let[t,r,a,o,s]=i,c=Math.pow(2,Number(a))*Number(o)+Number(s);if(!isNaN(c))return Sc(e,n.tile,c%2)}else if(r===`model`){let[t]=i,r=Number(t);if(!isNaN(r))return Sc(e,n.model,r%2)}return Sc(e,n.default,0)}var wc=(e,t)=>{let n=e.split(`?`)[0],r=n.split(`.`).pop();if(r===`jpeg`&&(r=`jpg`),r===`heif`&&(r=`heic`),r&&!vc(r))return e;let i=[],{format:a,cut:o,quality:s,size:c,sharpen:l,forceUseExifOrientation:u}=t;if(a===`jpeg`&&(a=`jpg`),a===`heif`&&(a=`heic`),(!mc&&(a==null?r:a)===`avif`||!hc&&(a==null?r:a)===`webp`||!gc&&(a==null?r:a)===`heic`)&&(a=`jpg`),a!==void 0&&a!==r&&i.push(`format/${a}`),o!==void 0&&i.push(`cut/${o[2]}x${o[3]}x${o[0]}x${o[1]}`),s!==void 0){let e=a==null?r:a;e&&[`jpg`,`webp`,`heic`,`avif`].indexOf(e)>=0&&i.push(`quality/${s}`)}if(c!==void 0){let t=e.match(/\/cube_(\d+)\//);(t?Number(t[1]):NaN)!==Number(c)&&i.push(`thumbnail/${c}x`)}l!==void 0&&i.push(`sharpen/${l}`),u===!0&&i.push(`auto-orient`);let d=``;return i.length&&(d=`?imageMogr2/`+i.join(`/`)),n+d},Tc=(e,t)=>{let n=e.split(`?`)[0],r=n.split(`.`).pop();if(r===`jpeg`&&(r=`jpg`),r===`heif`&&(r=`heic`),r&&!vc(r))return e;let i=[],{format:a,cut:o,quality:s,size:c,sharpen:l}=t;if(a===`jpeg`&&(a=`jpg`),a===`heif`&&(a=`heic`),(!mc&&(a==null?r:a)===`avif`||!hc&&(a==null?r:a)===`webp`||!gc&&(a==null?r:a)===`heic`)&&(a=`jpg`),a!==void 0&&a!==r&&i.push(`format,${a}`),o!==void 0){let[e,t,n,r]=o;i.push(`crop,x_${e},y_${t},w_${n},h_${r},g_nw`)}if(s!==void 0&&s!==100){let e=a==null?r:a;e&&[`jpg`,`webp`,`heic`,`avif`].indexOf(e)>=0&&i.push(`quality,Q_${s}`)}c&&c!==2048&&i.push(`resize,w_${c}`),l!==void 0&&i.push(`sharpen,${l}`);let u=``;return i.length&&(u=`?x-oss-process=image/`+i.join(`/`)),n+u},Ec=9007199254740991;function Dc(e){let t=Math.round(e);return Math.abs(t-e)<.001?t:Math.floor(e)}function Oc(e){return e=Object.assign({},e),e.size!==void 0&&(e.size=Dc(H(e.size,0,Ec))),e.quality!==void 0&&(e.quality=Dc(H(e.quality,0,100))),e.cut!==void 0&&(e.cut=[Dc(H(e.cut[0],0,Ec)),Dc(H(e.cut[1],0,Ec)),Dc(H(e.cut[2],0,Ec)),Dc(H(e.cut[3],0,Ec))]),e.sharpen!==void 0&&(e.sharpen=Dc(H(e.sharpen,0,Ec))),e}function kc(e,t){let n=Object.assign(Object.assign({},yc),t.mappings),r=xc(e);if(r===null)return e;t=Oc(t);let i=n[r];return i?(e=Cc(e,t.key,i),/\.basis(\?|$)/.test(e)&&(e=e.replace(/\.basis(\?|$)/,`.jpg$1`)),i.type===`tencentCloud`?wc(e,t):i.type===`aliyun`?Tc(e,t):e):e}function Ac(e,t=kc,n){let r=t(e,n);if(r===e&&n.cut)throw Error(`ImageURL: cut option not applied.`);return r}var jc=/\/cube_(\d+)\//;function Mc(e){let t=e.match(jc);return t?Number(t[1]):null}function Nc(e,t){return e.replace(jc,`/cube_${t}/`)}var Pc=(pc=Math.log2)==null?(e=>Math.log(e)*Math.LOG2E):pc;function Fc(e){return Math.floor(Math.max(Pc(e/512),0))}var Ic=(()=>{let e=G();return{requestAnimationFrame(t){let n=G(),r=H(16+(n-e),16,33),i=setTimeout(function(){t(wi(n+r))},r);return e=n+r,i},cancelAnimationFrame:e=>clearTimeout(e)}})(),Lc=typeof requestAnimationFrame==`function`&&typeof cancelAnimationFrame==`function`?{requestAnimationFrame:e=>requestAnimationFrame(e),cancelAnimationFrame:e=>cancelAnimationFrame(e)}:Ic,Rc=5,zc=16,Bc=class e{static get shared(){return this.sharedInstance||(this.sharedInstance=new e),this.sharedInstance}static getFrameTime(){return zc}constructor(){this.loopType=`raf`,this.frames=[],this.isAnimating=!1,this.context=null;let e=G();this.loop=(...t)=>{if(this.isAnimating===!1)return;let n=G(),r=Math.max(n-e,0);e=n,zc=r;let i=this.frames.slice();for(let e=0;e<i.length;e++){let a=i[e];if(a.delay>0){--a.delay;continue}try{a.callback(n,r,...t)}catch(e){console.error(e)}a.calls++}for(let e=this.frames.length-1;e>=0;e--){let t=this.frames[e];t.once&&t.calls>0&&this.frames.splice(e,1)}this.requestId=this.requestAnimationFrame(this.loop)},this.start()}start(){this.isAnimating!==!0&&(this.isAnimating=!0,this.requestId=this.requestAnimationFrame(this.loop))}stop(){this.isAnimating=!1,this.cancelAnimationFrame(this.requestId)}setContext(e){e!==this.context&&(this.stop(),this.context=e,this.start())}getContext(){return this.context}setLoopType(e){e!==this.loopType&&(this.stop(),this.loopType=e,this.start())}getLoopType(){return this.loopType}requestAnimationFrame(e){let t;if(this.context?t=this.context:this.loopType===`raf`?t=Lc:this.loopType===`sto`&&(t=Ic),t)return t.requestAnimationFrame(e)}cancelAnimationFrame(e){let t;this.context?t=this.context:this.loopType===`raf`?t=Lc:this.loopType===`sto`&&(t=Ic),t&&t.cancelAnimationFrame(e)}remove(e){let t=this.frames.indexOf(e);t>=0&&this.frames.splice(t,1)}add(e,t=!1,n=0,r=Rc){let i={callback:e,once:t,delay:n,order:r,calls:0},a=this.frames.length;for(;--a>=0;)if(this.frames[a].order<=r){this.frames.splice(a+1,0,i);break}return a<0&&this.frames.unshift(i),()=>this.remove(i)}clear(){this.frames.length=0}},Vc=typeof createImageBitmap<`u`&&typeof ImageBitmap<`u`,Hc=!1;function Uc(e){Hc=e}function Wc(){return Hc===!1?!1:Vc}function Gc(e={}){let t=e.onClose;return Object.assign(document.createElementNS(`http://www.w3.org/1999/xhtml`,`img`),{crossOrigin:``,close(){t&&t.call(this),this.onerror=this.onload=this.close=K,this.removeAttribute(`src`),t=void 0}})}function Kc(e){if(Wc())return createImageBitmap(e);{let t=URL.createObjectURL(e),n=function(){this.src===t&&URL.revokeObjectURL(t)};return new Promise((e,r)=>{let i=Gc({onClose:n});i.onload=()=>{i.src===t&&URL.revokeObjectURL(t),i.onload=i.onerror=K,Bc.shared.add(()=>{e(i)},!0)},i.onerror=()=>{let e=i.src;i.onload=i.onerror=K,i.close(),r(Error(`image load error: ${e}`))},i.decoding=`async`,i.src=t})}}var qc=[];function Jc(e,t){let n=qc.pop();if(n)return n.width=e,n.height=t,n;let r=Object.assign(document.createElementNS(`http://www.w3.org/1999/xhtml`,`canvas`),{close:()=>{r.close=K,qc.push(r)}});return r}function Yc(e,t){if(t&&(e.width>t.width||e.height>t.height)){let n=Jc(Math.min(e.width,t.width),Math.min(e.height,t.height)),r=n.getContext(`2d`);r.clearRect(0,0,n.width,n.height),r.drawImage(e,0,0,n.width,n.height),e.close();let i=new l.Texture(n);i.needsUpdate=!0,i.flipY=!0;let a=i.dispose;return i.dispose=function(){n.close(),a.call(i),i.dispose=a},i}else{let t=new l.Texture(e);t.needsUpdate=!0,typeof ImageBitmap<`u`&&e instanceof ImageBitmap?t.flipY=!1:t.flipY=!0,t.flipY===!1&&(t.repeat.y*=-1,t.offset.y+=1,t.updateMatrix());let n=t.dispose;return t.dispose=function(){this.image&&this.image.close(),n.call(t),t.dispose=n},t}}function Xc(e){let t=new l.CubeTexture(e);t.needsUpdate=!0,t.flipY=!1;let n=t.dispose;return t.dispose=function(){if(Array.isArray(this.images))for(let e of this.images)e.close();n.call(t),t.dispose=n},t}var Zc=[`right`,`left`,`up`,`down`,`front`,`back`],Qc=class{loadTexture(e,t,n=K,r=K,i=K,a){var o,s,c,u,d,f,p;let m={};if(t.flipY!==void 0&&(m.flipY=t.flipY),t.format!==void 0)m.format=t.format;else{let t=oc(e);(t===`.jpg`||t===`.jpeg`)&&(m.format=l.RGBAFormat)}t.colorSpace!==void 0&&(m.colorSpace=t.colorSpace),m.generateMipmaps=(o=t.generateMipmaps)==null?!1:o,m.minFilter=(s=t.minFilter)==null?l.LinearFilter:s,m.magFilter=(c=t.magFilter)==null?l.LinearFilter:c,t.wrapS&&(m.wrapS=t.wrapS),t.wrapT&&(m.wrapT=t.wrapT);let h=(d=(u=t.imageURL)==null?void 0:u.options)==null?{key:`unknown`}:d;if(e=Ac(e,(f=t.imageURL)==null?void 0:f.transform,h),(p=t.viaAjax)==null?Wc:p)return t.fetcher.ajax(e,{timeout:t.timeout,responseType:`blob`},void 0,void 0,i).then(e=>Kc(e.body)).then(e=>Yc(e,t.maxSize)).then(e=>(Object.assign(e,m),e)).then(e=>{let t={meta:null,body:e};return n(t),t}).catch(e=>(r(e),Promise.reject(e)));{let a=null,o;return Promise.resolve().then(()=>Gc()).then(n=>(o=n,t.fetcher.loadImage(e,{timeout:t.timeout},void 0,void 0,i,n))).then(e=>(a=e.meta,Yc(e.body,t.maxSize))).then(e=>(Object.assign(e,m),e)).then(e=>{let t={meta:a,body:e};return n(t),t}).catch(e=>(o&&o.close(),r(e),Promise.reject(e)))}}loadCubeTexture(e,t,n=K,r=K,i=K,a){var o,s,c,u,d,f,p;let m={};if(t.format!==void 0)m.format=t.format;else{let t=!0;for(let n of Zc){let r=oc(e[n]);if(r!==`.jpg`&&r!==`.jpeg`){t=!1;break}}t&&(m.format=l.RGBAFormat)}m.generateMipmaps=(o=t.generateMipmaps)==null?!1:o,m.minFilter=(s=t.minFilter)==null?l.LinearFilter:s,m.magFilter=(c=t.magFilter)==null?l.LinearFilter:c,t.wrapS&&(m.wrapS=t.wrapS),t.wrapT&&(m.wrapT=t.wrapT);let h=[e[Zc[0]],e[Zc[1]],e[Zc[2]],e[Zc[3]],e[Zc[4]],e[Zc[5]]],g=[],_=[0,0,0,0,0,0],v=[];for(let e=0;e<6;e++){let n=(d=(u=t.imageURL)==null?void 0:u.options)==null?{key:`unknown`}:d,r=Ac(h[e],(f=t.imageURL)==null?void 0:f.transform,Object.assign(Object.assign({},n),{key:n.key+`.`+Zc[e]})),a=t=>{_[e]=t,i(_.reduce((e,t)=>e+t,0)/6)};if((p=t.viaAjax)!=null&&p){let n=t.fetcher.ajax(r,{timeout:t.timeout,responseType:`blob`},void 0,void 0,a).then(t=>(v[e]=t.meta,Kc(t.body)));g.push(n)}else{let n,i=Promise.resolve().then(()=>Gc()).then(e=>(n=e,t.fetcher.loadImage(r,{timeout:t.timeout},void 0,void 0,a,e))).then(t=>(v[e]=t.meta,t.body)).catch(e=>(n&&n.close(),Promise.reject(e)));g.push(i)}}return Promise.all(g).then(e=>Xc(e)).then(e=>(Object.assign(e,Object.assign({colorSpace:l.SRGBColorSpace},m)),e)).then(e=>{let t={body:e,meta:v};return n(t),t}).catch(e=>{for(let e of g)e.then(e=>e.close()).catch(K);return r(e),Promise.reject(e)})}},$c=u.Reader,el=u.util,tl=u.roots[`@REALSEE/FIVE:five/model/loaders/protobuf/pbm.proto`]||(u.roots[`@REALSEE/FIVE:five/model/loaders/protobuf/pbm.proto`]={}),nl=tl.Model=(()=>{function e(e){if(this.chunks=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return e.prototype.chunks=el.emptyArray,e.prototype.createAt=el.Long?el.Long.fromBits(0,0,!0):0,e.prototype.description=``,e.decode=function(e,t,n){e instanceof $c||(e=$c.create(e));let r=t===void 0?e.len:e.pos+t,i=new tl.Model;for(;e.pos<r;){let t=e.uint32();if(t===n)break;switch(t>>>3){case 1:i.chunks&&i.chunks.length||(i.chunks=[]),i.chunks.push(tl.Chunk.decode(e,e.uint32()));break;case 2:i.createAt=e.uint64();break;case 3:i.description=e.string();break;default:e.skipType(t&7);break}}return i},e.getTypeUrl=function(e){return e===void 0&&(e=`type.googleapis.com`),e+`/Model`},e})();tl.Chunk=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return e.prototype.vertices=null,e.prototype.faces=null,e.prototype.name=``,e.prototype.texture=``,e.decode=function(e,t,n){e instanceof $c||(e=$c.create(e));let r=t===void 0?e.len:e.pos+t,i=new tl.Chunk;for(;e.pos<r;){let t=e.uint32();if(t===n)break;switch(t>>>3){case 1:i.vertices=tl.Vertices.decode(e,e.uint32());break;case 2:i.faces=tl.Faces.decode(e,e.uint32());break;case 3:i.name=e.string();break;case 4:i.texture=e.string();break;default:e.skipType(t&7);break}}if(!i.hasOwnProperty(`vertices`))throw el.ProtocolError(`missing required 'vertices'`,{instance:i});if(!i.hasOwnProperty(`faces`))throw el.ProtocolError(`missing required 'faces'`,{instance:i});if(!i.hasOwnProperty(`name`))throw el.ProtocolError(`missing required 'name'`,{instance:i});return i},e.getTypeUrl=function(e){return e===void 0&&(e=`type.googleapis.com`),e+`/Chunk`},e})(),tl.Vertices=(()=>{function e(e){if(this.xyz=[],this.uvs=[],this.marks=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return e.prototype.xyz=el.emptyArray,e.prototype.uvs=el.emptyArray,e.prototype.marks=el.emptyArray,e.decode=function(e,t,n){e instanceof $c||(e=$c.create(e));let r=t===void 0?e.len:e.pos+t,i=new tl.Vertices;for(;e.pos<r;){let t=e.uint32();if(t===n)break;switch(t>>>3){case 1:if(i.xyz&&i.xyz.length||(i.xyz=[]),(t&7)==2){let t=e.uint32()+e.pos;for(;e.pos<t;)i.xyz.push(e.float())}else i.xyz.push(e.float());break;case 2:if(i.uvs&&i.uvs.length||(i.uvs=[]),(t&7)==2){let t=e.uint32()+e.pos;for(;e.pos<t;)i.uvs.push(e.float())}else i.uvs.push(e.float());break;case 3:if(i.marks&&i.marks.length||(i.marks=[]),(t&7)==2){let t=e.uint32()+e.pos;for(;e.pos<t;)i.marks.push(e.int32())}else i.marks.push(e.int32());break;default:e.skipType(t&7);break}}return i},e.getTypeUrl=function(e){return e===void 0&&(e=`type.googleapis.com`),e+`/Vertices`},e})(),tl.Faces=(()=>{function e(e){if(this.indices=[],this.normals=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return e.prototype.indices=el.emptyArray,e.prototype.normals=el.emptyArray,e.decode=function(e,t,n){e instanceof $c||(e=$c.create(e));let r=t===void 0?e.len:e.pos+t,i=new tl.Faces;for(;e.pos<r;){let t=e.uint32();if(t===n)break;switch(t>>>3){case 1:if(i.indices&&i.indices.length||(i.indices=[]),(t&7)==2){let t=e.uint32()+e.pos;for(;e.pos<t;)i.indices.push(e.uint32())}else i.indices.push(e.uint32());break;case 2:if(i.normals&&i.normals.length||(i.normals=[]),(t&7)==2){let t=e.uint32()+e.pos;for(;e.pos<t;)i.normals.push(e.float())}else i.normals.push(e.float());break;default:e.skipType(t&7);break}}return i},e.getTypeUrl=function(e){return e===void 0&&(e=`type.googleapis.com`),e+`/Faces`},e})(),tl.VertexMark=(()=>{let e={},t=Object.create(e);return t[e[0]=`VERTEX_MARK_UNSPECIFIED`]=0,t[e[1]=`VERTEX_MARK_ROOF`]=1,t})();function rl(e){return isNaN(e)||!isFinite(e)?0:e}function il(e){let t=0;if(e instanceof d.BufferGeometry){for(let n in e.attributes){let r=e.getAttribute(n),i=4;`BYTES_PER_ELEMENT`in r.array&&typeof r.array.BYTES_PER_ELEMENT==`number`&&(i=r.array.BYTES_PER_ELEMENT),t+=rl(r.count*r.itemSize*i)}let n=e.getIndex();if(n){let e=4;`BYTES_PER_ELEMENT`in n.array&&typeof n.array.BYTES_PER_ELEMENT==`number`&&(e=n.array.BYTES_PER_ELEMENT),t+=rl(n.count*n.itemSize*e)}}return t}function al(e){let t=[e.positions,e.colors,e.normals],n=0;for(let e of t){if(!e)continue;let t=4;`BYTES_PER_ELEMENT`in e&&typeof e.BYTES_PER_ELEMENT==`number`&&(t=e.BYTES_PER_ELEMENT);let r=e.length*t;isNaN(r)||!isFinite(r)||(n+=r)}return n}function ol(e){let t=[e.positions,e.rotations,e.scales,e.colors,e.sh1,e.sh2,e.sh3],n=0;for(let e of t){if(!e)continue;let t=4;`BYTES_PER_ELEMENT`in e&&typeof e.BYTES_PER_ELEMENT==`number`&&(t=e.BYTES_PER_ELEMENT);let r=e.length*t;isNaN(r)||!isFinite(r)||(n+=r)}return n}function sl(e,t,n){return function(r,i,a){return((r+e-1)/e|0)*((i+t-1)/t|0)*n*a}}function cl(e,t,n){return function(r,i,a){return(Math.max(r,e)*Math.max(i,t)/n|0)*a}}var ll=new Map([[d.RGB_S3TC_DXT1_Format,sl(4,4,8)],[d.RGBA_S3TC_DXT1_Format,sl(4,4,8)],[d.RGBA_S3TC_DXT3_Format,sl(4,4,16)],[d.RGBA_S3TC_DXT5_Format,sl(4,4,16)],[d.RGB_ETC1_Format,sl(4,4,8)],[d.RGB_PVRTC_4BPPV1_Format,cl(8,8,2)],[d.RGBA_PVRTC_4BPPV1_Format,cl(8,8,2)],[d.RGB_PVRTC_2BPPV1_Format,cl(16,8,4)],[d.RGBA_PVRTC_2BPPV1_Format,cl(16,8,4)],[d.RGB_ETC2_Format,sl(4,4,8)],[d.RGBA_ETC2_EAC_Format,sl(4,4,16)],[d.RGBA_ASTC_4x4_Format,sl(4,4,16)],[d.RGBA_ASTC_5x4_Format,sl(5,4,16)],[d.RGBA_ASTC_5x5_Format,sl(5,5,16)],[d.RGBA_ASTC_6x5_Format,sl(6,5,16)],[d.RGBA_ASTC_6x6_Format,sl(6,6,16)],[d.RGBA_ASTC_8x5_Format,sl(8,5,16)],[d.RGBA_ASTC_8x6_Format,sl(8,6,16)],[d.RGBA_ASTC_8x8_Format,sl(8,8,16)],[d.RGBA_ASTC_10x5_Format,sl(10,5,16)],[d.RGBA_ASTC_10x6_Format,sl(10,6,16)],[d.RGBA_ASTC_10x8_Format,sl(10,8,16)],[d.RGBA_ASTC_10x10_Format,sl(10,10,16)],[d.RGBA_ASTC_12x10_Format,sl(12,10,16)],[d.RGBA_ASTC_12x12_Format,sl(12,12,16)],[d.RGBA_BPTC_Format,sl(4,4,16)]]);function ul(e){let t=0,n=1;(e.generateMipmaps===!0||e.mipmaps&&e.mipmaps.length>1)&&(n=1.33);let r=e instanceof d.CompressedTexture?ll.get(e.format):void 0,i=[].concat(e.image);for(let e of i)if(e)if(e instanceof d.Texture)t+=ul(e);else{let{width:i=1,height:a=1,depth:o=1}=e;r?t+=rl(r(i,a,o)*n):t+=rl(i*a*o*4*n)}return t}var dl=new Set,fl=`map.alphaMap.bumpMap.normalMap.displacementMap.emissiveMap.specularMap.envMap.flipEnvMap.lightMap.aoMap.gradientMap.metalnessMap.roughnessMap.sheenColorMap.sheenRoughnessMap.clearcoatMap.clearcoatRoughnessMap.clearcoatNormalMap.iridescenceMap.iridescenceThicknessMap.transmissionMap.thicknessMap.anisotropyMap.specularColorMap.specularIntensityMap`.split(`.`);function pl(e){let t=0;if(dl.clear(),e instanceof d.ShaderMaterial)for(let n in e.uniforms){let r=e.uniforms[n],i=r&&r.value&&r.value instanceof d.Texture?r.value:void 0;i instanceof d.Texture&&(dl.has(i)||(t=ul(i),dl.add(i)))}else for(let n of fl){let r=e[n];r instanceof d.Texture&&(dl.has(r)||(t=ul(r),dl.add(r)))}return dl.clear(),t}var ml=new Set;function hl(e){let t=0;return ml.clear(),e.traverse(e=>{if(e instanceof Mt){t+=ol(e);return}if(e instanceof on){t+=al(e);return}if(e instanceof d.Mesh||e instanceof d.Line||e instanceof d.Points){let n=e.geometry;n instanceof d.BufferGeometry&&(ml.has(n)||(t+=il(n),ml.add(n)));let r=[].concat(e.material);for(let e of r)e instanceof d.Material&&(ml.has(e)||(t+=pl(e),ml.add(e)))}}),ml.clear(),t}function gl(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t+1).replace(/\/(model)(\/|$)/,(e,t,n)=>`/materials`+n):``}function _l(e,t={}){var n,r,i,a,o,s,c;let u=(n=t.upAxis)==null?`Z`:n,d=(r=t.light)==null?!1:r,f=(i=t.fetcher)==null?Xs:i,p=(a=t.onDownloadProgress)==null?K:a,m=(o=t.textureBaseUri)==null?gl(e):o,h=t.textureBaseUri===void 0?[]:((s=t.textureArray)==null?[]:s).slice(),g=Tl((c=t.textureOptions)==null?{}:c,h.length),_=new Map;for(let e of h){let t=tc(e)?e:rc(m,e);_.set(t,Cl(t,g,f))}let v={byteLength:0};return Promise.resolve().then(()=>f.ajax(e,{responseType:`arraybuffer`},void 0,void 0,p)).then(e=>{v.byteLength=e.body.byteLength;let t=new Uint8Array(e.body);return nl.decode(t)}).then(e=>wl(e,d,m,h,g,_,f)).then(t=>{_.clear();let n=new l.Group;n.name=e;for(let e of t.objects)n.add(e);return u===`Y`&&n.applyMatrix4(Ps),{type:`pbm`,modelUpAxis:`Z`,upAxis:u,uri:e,byteLength:v.byteLength,memoryUsage:hl(n),scene:n,textures:t.textures,animations:[],dispose:()=>t.dispose()}})}function vl(e){let t=e.match(/(group|floor)-?(\d+)/);return t?parseInt(t[2],10):0}function yl(e){let t=e.match(/(chunk)-?(\d+)/);return t?parseInt(t[2],10):0}function bl(e){let t=e.match(/(sub)-?(\d+)/);return t?parseInt(t[2],10):0}function xl(e){let t=vl(e.name),n=yl(e.name),r=bl(e.name);return t*1e6+n*1e3+r}function Sl(e){var t,n,r;let i=typeof e.createAt==`number`?e.createAt:0,a=(t=e.description)==null?``:t,o=[],s=!0,c=!0;for(let t of e.chunks)if(!t.vertices.marks||t.vertices.marks.length===0){c=!1;break}for(let t of e.chunks)if(!t.faces.normals||t.faces.normals.length===0){s=!1;break}let l=e.chunks.sort((e,t)=>xl(e)-xl(t)),u=[];for(let e of l){let t=vl(e.name);u[t]||(u[t]=[]),u[t].push(e)}for(let e=0;e<u.length;e++){let t=u[e];if(t)if(s){let r=0;for(let e=0;e<t.length;e++){let n=t[e];r+=n.faces.indices.length}let s=new Float32Array(r*3),l=new Float32Array(r*2),u=new Float32Array(r*3),d=c?new Float32Array(r):void 0,f=[],p=[1/0,1/0,1/0,-1/0,-1/0,-1/0],m=0;for(let e=0;e<t.length;e++){let r=[1/0,1/0,1/0,-1/0,-1/0,-1/0],i=t[e],a=i.vertices.xyz,o=i.vertices.uvs,c=i.faces.indices,h=i.faces.normals,g=i.vertices.marks,_=c.length;for(let e=0;e<_;e++){let t=c[e],n=s[m*3+e*3]=a[t*3],i=s[m*3+e*3+1]=a[t*3+1],f=s[m*3+e*3+2]=a[t*3+2];d&&(d[m+e]=g[t]),l[m*2+e*2]=o[t*2],l[m*2+e*2+1]=o[t*2+1];let p=Math.floor(e/3)*3;u[m*3+e*3]=h[p],u[m*3+e*3+1]=h[p+1],u[m*3+e*3+2]=h[p+2],n<r[0]&&(r[0]=n),i<r[1]&&(r[1]=i),f<r[2]&&(r[2]=f),n>r[3]&&(r[3]=n),i>r[4]&&(r[4]=i),f>r[5]&&(r[5]=f)}r[0]<p[0]&&(p[0]=r[0]),r[1]<p[1]&&(p[1]=r[1]),r[2]<p[2]&&(p[2]=r[2]),r[3]>p[3]&&(p[3]=r[3]),r[4]>p[4]&&(p[4]=r[4]),r[5]>p[5]&&(p[5]=r[5]),f.push({materialIndex:e,name:i.name,chunkName:yl(i.name),start:m,count:i.faces.indices.length,texture:(n=i.texture)==null?void 0:n}),m+=_}let h={createAt:i,description:a,vertices:s,uvs:l,normals:u,masks:d,indices:null,floorIndex:e,groups:f,extents:p};o.push(h)}else{let n=0,s=0;for(let e=0;e<t.length;e++){let r=t[e];s+=r.vertices.xyz.length/3,n+=r.faces.indices.length}let l=new Float32Array(s*3),u=new Float32Array(s*2),d=new Float32Array(s),f=new Uint32Array(n),p=c?new Float32Array(n):void 0,m=[],h=[1/0,1/0,1/0,-1/0,-1/0,-1/0],g=0,_=0;for(let n=0;n<t.length;n++){let i=[1/0,1/0,1/0,-1/0,-1/0,-1/0],a=t[n],o=a.vertices.xyz,s=a.vertices.marks,c=a.vertices.uvs,v=a.faces.indices,y=o.length/3,b=v.length;for(let t=0;t<y;t++){let n=l[_*3+t*3]=o[t*3],r=l[_*3+t*3+1]=o[t*3+1],a=l[_*3+t*3+2]=o[t*3+2];p&&(p[_+t]=s[t]),u[_*2+t*2]=c[t*2],u[_*2+t*2+1]=c[t*2+1],d[_+t]=e,n<i[0]&&(i[0]=n),r<i[1]&&(i[1]=r),a<i[2]&&(i[2]=a),n>i[3]&&(i[3]=n),r>i[4]&&(i[4]=r),a>i[5]&&(i[5]=a)}i[0]<h[0]&&(h[0]=i[0]),i[1]<h[1]&&(h[1]=i[1]),i[2]<h[2]&&(h[2]=i[2]),i[3]>h[3]&&(h[3]=i[3]),i[4]>h[4]&&(h[4]=i[4]),i[5]>h[5]&&(h[5]=i[5]);for(let e=0;e<b;e++)f[g+e]=_+v[e];m.push({materialIndex:n,name:a.name,chunkName:yl(a.name),start:g,count:a.faces.indices.length,texture:(r=a.texture)==null?void 0:r}),_+=y,g+=b}let v={createAt:i,description:a,vertices:l,uvs:u,normals:void 0,masks:p,indices:f,floorIndex:e,groups:m,extents:h};o.push(v)}}return o}function Cl(e,t,n){let r=Object.assign({key:`texture.pbm`},Zs(t,[`format`,`quality`,`size`,`sharpen`,`forceUseExifOrientation`,`mappings`]));return new Qc().loadTexture(e,{imageURL:{transform:t.transform,options:r},colorSpace:l.SRGBColorSpace,wrapS:l.ClampToEdgeWrapping,wrapT:l.ClampToEdgeWrapping,minFilter:l.LinearFilter,maxSize:typeof r.size==`number`?new l.Vector2(r.size,r.size):void 0,fetcher:n}).then(e=>{let t=e.body;return t.needsUpdate=!0,t})}function wl(e,t,n,r,i,a,o){let s=Sl(e),c=0,u=``,d=[],f={},p=new Set,m=0;for(let{createAt:e,description:t,vertices:i,masks:a,uvs:o,normals:h,indices:g,floorIndex:_,groups:v,extents:y}of s){let s=new l.Box3;s.min.x=y[0],s.min.y=y[1],s.min.z=y[2],s.max.x=y[3],s.max.y=y[4],s.max.z=y[5];let b=new l.BufferGeometry;b.setAttribute(`position`,new l.BufferAttribute(i,3)),b.setAttribute(`uv`,new l.BufferAttribute(o,2)),h&&b.setAttribute(`normal`,new l.BufferAttribute(h,3)),a&&b.setAttribute(`_feature_id_rsmask`,new l.BufferAttribute(a,1)),g&&b.setIndex(new l.BufferAttribute(g,1)),b.boundingBox=s,b.boundingSphere=s.getBoundingSphere(new l.Sphere);for(let e of v)b.addGroup(e.start,e.count,e.materialIndex);p.add(b);let x=[];for(let e of v){let t;if(e.texture){if(t=e.texture,r.length>0&&r.indexOf(e.texture)===-1){for(let i of r)if((tc(i)?i:rc(n,i)).slice(e.texture.length*-1)===e.texture){t=i;break}console.warn(`At3d/Pbm texture not matched. Use ends-guessing mode. ${e.texture} -> ${t}`)}tc(t)||(t=rc(n,t))}let i=new Nr;i.floorIndex=_,b.attributes.normal===void 0&&(i.flatShading=!0),b.attributes._feature_id_rsmask,x.push(i),t?(m++,f[t]?f[t].push(i):f[t]=[i]):i.color=new l.Color(16777215),p.add(i)}let S=new kt(b,x);S.name=`model_floor_`+_,S.userData.createAt=e,S.userData.description=t,S.matrix.compose(S.position,S.quaternion,S.scale),S.matrixAutoUpdate=!1,S.frustumCulled=!1,c=e,u=t,d.push(S)}i=Tl(i,m);let h=[];for(let e of Object.keys(f)){let t;a&&(t=a.get(e)),t||(t=Cl(e,i,o),a&&a.set(e,t)),h.push(t.then(t=>{for(let n of f[e])n.map&&(p.delete(n.map),n.map.dispose()),n.map=t,p.add(t);return t}).catch(()=>{for(let t of f[e])t.map&&(p.delete(t.map),t.map.dispose()),t.map=null,t.color=new l.Color(16777215);return null}))}return Promise.all(h).then(e=>{let t=e.filter(e=>e instanceof l.Texture);return{createAt:c,description:u,objects:d,textures:t,dispose:()=>{p.forEach(e=>{e.dispose()}),p.clear()}}})}function Tl(e,t){return e=Object.assign({},e),e.autoResize!==!1&&(t>96?e.size=Math.min(e.size||1/0,100):t>48?e.size=Math.min(e.size||1/0,200):t>24?e.size=Math.min(e.size||1/0,400):t>22?e.size=Math.min(e.size||1/0,800):t>5&&(e.size=Math.min(e.size||1/0,1024))),e}function El(){var e={};return e.OutWindow=function(){this._windowSize=0},e.OutWindow.prototype.create=function(e){(!this._buffer||this._windowSize!==e)&&(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},e.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(e!==0){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},e.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},e.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},e.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},e.OutWindow.prototype.copyBlock=function(e,t){var n=this._pos-e-1;for(n<0&&(n+=this._windowSize);t--;)n>=this._windowSize&&(n=0),this._buffer[this._pos++]=this._buffer[n++],this._pos>=this._windowSize&&this.flush()},e.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},e.OutWindow.prototype.getByte=function(e){var t=this._pos-e-1;return t<0&&(t+=this._windowSize),this._buffer[t]},e.RangeDecoder=function(){},e.RangeDecoder.prototype.setStream=function(e){this._stream=e},e.RangeDecoder.prototype.releaseStream=function(){this._stream=null},e.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},e.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t=0,n=e,r;n--;)this._range>>>=1,r=this._code-this._range>>>31,this._code-=this._range&r-1,t=t<<1|1-r,this._range&4278190080||(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return t},e.RangeDecoder.prototype.decodeBit=function(e,t){var n=e[t],r=(this._range>>>11)*n;return(this._code^2147483648)<(r^2147483648)?(this._range=r,e[t]+=2048-n>>>5,this._range&4278190080||(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=r,this._code-=r,e[t]-=n>>>5,this._range&4278190080||(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},e.initBitModels=function(e,t){for(;t--;)e[t]=1024},e.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},e.BitTreeDecoder.prototype.init=function(){e.initBitModels(this._models,1<<this._numBitLevels)},e.BitTreeDecoder.prototype.decode=function(e){for(var t=1,n=this._numBitLevels;n--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},e.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t=1,n=0,r=0,i;r<this._numBitLevels;++r)i=e.decodeBit(this._models,t),t=t<<1|i,n|=i<<r;return n},e.reverseDecode2=function(e,t,n,r){for(var i=1,a=0,o=0,s;o<r;++o)s=n.decodeBit(e,t+i),i=i<<1|s,a|=s<<o;return a},e.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new e.BitTreeDecoder(8),this._numPosStates=0},e.LenDecoder.prototype.create=function(t){for(;this._numPosStates<t;++this._numPosStates)this._lowCoder[this._numPosStates]=new e.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new e.BitTreeDecoder(3)},e.LenDecoder.prototype.init=function(){var t=this._numPosStates;for(e.initBitModels(this._choice,2);t--;)this._lowCoder[t].init(),this._midCoder[t].init();this._highCoder.init()},e.LenDecoder.prototype.decode=function(e,t){return e.decodeBit(this._choice,0)===0?this._lowCoder[t].decode(e):e.decodeBit(this._choice,1)===0?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},e.Decoder2=function(){this._decoders=[]},e.Decoder2.prototype.init=function(){e.initBitModels(this._decoders,768)},e.Decoder2.prototype.decodeNormal=function(e){var t=1;do t=t<<1|e.decodeBit(this._decoders,t);while(t<256);return t&255},e.Decoder2.prototype.decodeWithMatchByte=function(e,t){var n=1,r,i;do if(r=t>>7&1,t<<=1,i=e.decodeBit(this._decoders,(1+r<<8)+n),n=n<<1|i,r!==i){for(;n<256;)n=n<<1|e.decodeBit(this._decoders,n);break}while(n<256);return n&255},e.LiteralDecoder=function(){},e.LiteralDecoder.prototype.create=function(t,n){var r;if(!(this._coders&&this._numPrevBits===n&&this._numPosBits===t))for(this._numPosBits=t,this._posMask=(1<<t)-1,this._numPrevBits=n,this._coders=[],r=1<<this._numPrevBits+this._numPosBits;r--;)this._coders[r]=new e.Decoder2},e.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},e.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((t&255)>>>8-this._numPrevBits)]},e.Decoder=function(){this._outWindow=new e.OutWindow,this._rangeDecoder=new e.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new e.BitTreeDecoder(4),this._lenDecoder=new e.LenDecoder,this._repLenDecoder=new e.LenDecoder,this._literalDecoder=new e.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new e.BitTreeDecoder(6),this._posSlotDecoder[1]=new e.BitTreeDecoder(6),this._posSlotDecoder[2]=new e.BitTreeDecoder(6),this._posSlotDecoder[3]=new e.BitTreeDecoder(6)},e.Decoder.prototype.setDictionarySize=function(e){return e<0?!1:(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},e.Decoder.prototype.setLcLpPb=function(e,t,n){var r=1<<n;return e>8||t>4||n>4?!1:(this._literalDecoder.create(t,e),this._lenDecoder.create(r),this._repLenDecoder.create(r),this._posStateMask=r-1,!0)},e.Decoder.prototype.init=function(){var t=4;for(this._outWindow.init(!1),e.initBitModels(this._isMatchDecoders,192),e.initBitModels(this._isRep0LongDecoders,192),e.initBitModels(this._isRepDecoders,12),e.initBitModels(this._isRepG0Decoders,12),e.initBitModels(this._isRepG1Decoders,12),e.initBitModels(this._isRepG2Decoders,12),e.initBitModels(this._posDecoders,114),this._literalDecoder.init();t--;)this._posSlotDecoder[t].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},e.Decoder.prototype.decode=function(t,n,r){var i=0,a=0,o=0,s=0,c=0,l=0,u=0,d,f,p,m,h,g;for(this._rangeDecoder.setStream(t),this._outWindow.setStream(n),this.init();r<0||l<r;)if(d=l&this._posStateMask,this._rangeDecoder.decodeBit(this._isMatchDecoders,(i<<4)+d)===0)f=this._literalDecoder.getDecoder(l++,u),u=i>=7?f.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(a)):f.decodeNormal(this._rangeDecoder),this._outWindow.putByte(u),i=i<4?0:i-(i<10?3:6);else{if(this._rangeDecoder.decodeBit(this._isRepDecoders,i)===1)p=0,this._rangeDecoder.decodeBit(this._isRepG0Decoders,i)===0?this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(i<<4)+d)===0&&(i=i<7?9:11,p=1):(this._rangeDecoder.decodeBit(this._isRepG1Decoders,i)===0?m=o:(this._rangeDecoder.decodeBit(this._isRepG2Decoders,i)===0?m=s:(m=c,c=s),s=o),o=a,a=m),p===0&&(p=2+this._repLenDecoder.decode(this._rangeDecoder,d),i=i<7?8:11);else if(c=s,s=o,o=a,p=2+this._lenDecoder.decode(this._rangeDecoder,d),i=i<7?7:10,h=this._posSlotDecoder[p<=5?p-2:3].decode(this._rangeDecoder),h>=4){if(g=(h>>1)-1,a=(2|h&1)<<g,h<14)a+=e.reverseDecode2(this._posDecoders,a-h-1,this._rangeDecoder,g);else if(a+=this._rangeDecoder.decodeDirectBits(g-4)<<4,a+=this._posAlignDecoder.reverseDecode(this._rangeDecoder),a<0){if(a===-1)break;return!1}}else a=h;if(a>=l||a>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(a,p),l+=p,u=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},e.Decoder.prototype.setDecoderProperties=function(e){var t,n,r,i,a;return e.size<5||(t=e.readByte(),n=t%9,t=~~(t/9),r=t%5,i=~~(t/5),!this.setLcLpPb(n,r,i))?!1:(a=e.readByte(),a|=e.readByte()<<8,a|=e.readByte()<<16,a+=e.readByte()*16777216,this.setDictionarySize(a))},e.decompress=function(t,n,r,i){var a=new e.Decoder;if(!a.setDecoderProperties(t))throw`Incorrect stream properties`;if(!a.decode(n,r,i))throw`Error in data stream`;return!0},e.decompressFile=function(t,n){var r=new e.Decoder,i;if(!r.setDecoderProperties(t))throw`Incorrect stream properties`;if(i=t.readByte(),i|=t.readByte()<<8,i|=t.readByte()<<16,i+=t.readByte()*16777216,t.readByte(),t.readByte(),t.readByte(),t.readByte(),!r.decode(t,n,i))throw`Error in data stream`;return!0},e}var Dl=El();function Ol(){function e(e){let t=new Uint8Array(256);for(let e=0;e<64;e++)t[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charCodeAt(e)]=e;let n=e.length*.75,r=e.length,i,a=0,o,s,c,l;e[e.length-1]===`=`&&(n--,e[e.length-2]===`=`&&n--);let u=new ArrayBuffer(n),d=new Uint8Array(u);for(i=0;i<r;i+=4)o=t[e.charCodeAt(i)],s=t[e.charCodeAt(i+1)],c=t[e.charCodeAt(i+2)],l=t[e.charCodeAt(i+3)],d[a++]=o<<2|s>>4,d[a++]=(s&15)<<4|c>>2,d[a++]=(c&3)<<6|l&63;return u}return e(`AGFzbQEAAAABSg1gAABgAX8Bf2ACf38Bf2AEf39/fwBgA39/fwBgAX8AYAJ/fwBgA39/fwF/YAR/f39/AX9gAn9/AGABfwF/YAABf2AEf39/fwF/AhsCA2VudgVhYm9ydAADA2VudgZtZW1vcnkCAAEDJiUBAQkKAgoKCwsLCwsAAgoBAgQKAQYFCAoFBQQEBwgCBwwCAQAABAQBcAABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwc9BgZtZW1vcnkCAAV0YWJsZQEABXJlc2V0AA0KbmV3VThBcnJheQAQCnVucGFja1NpemUAFAZkZWNvZGUAIwgBJAkHAQBBAAsBJQqAViVoAQN/IABBgICAgARLBEAACyMBIgEgAEEBIABBAUsbakEHakF4cSICPwAiA0EQdEsEQCADIAIgAWtB//8DakGAgHxxQRB2IgAgAyAAShtAAEEASARAIABAAEEASARAAAsLCyACJAEgAQsbAQF/QQFBICAAQQdqZ2t0EAEiASAANgIAIAELkQMBAX8gAUUEQA8LIABBADoAACAAIAFqQQFrQQA6AAAgAUECTQRADwsgAEEBakEAOgAAIABBAmpBADoAACAAIAFqIgJBAmtBADoAACACQQNrQQA6AAAgAUEGTQRADwsgAEEDakEAOgAAIAAgAWpBBGtBADoAACABQQhNBEAPC0EAIABrQQNxIgIgAGoiAEEANgIAIAEgAmtBfHEiASAAakEEa0EANgIAIAFBCE0EQA8LIABBBGpBADYCACAAQQhqQQA2AgAgACABaiICQQxrQQA2AgAgAkEIa0EANgIAIAFBGE0EQA8LIABBDGpBADYCACAAQRBqQQA2AgAgAEEUakEANgIAIABBGGpBADYCACAAIAFqIgJBHGtBADYCACACQRhrQQA2AgAgAkEUa0EANgIAIAJBEGtBADYCACAAQQRxQRhqIgIgAGohACABIAJrIQEDQCABQSBPBEAgAEIANwMAIABBCGpCADcDACAAQRBqQgA3AwAgAEEYakIANwMAIAFBIGshASAAQSBqIQAMAQsLC1EBA38gAEH+////AEsEQEEAQSBBLUEnEAAACyAAQQJ0IgMQAiECQQgQASIBQQA2AgAgAUEANgIEIAEgAjYCACABIAA2AgQgAkEIaiADEAMgAQtmAQF/IAFB/P///wFLBEBBAEHAAEEXQSIQAAALIAFBAXQiARACIgJBCGogARADIABFBEBBDBABIQALIABBADYCACAAQQA2AgQgAEEANgIIIAAgAjYCACAAQQA2AgQgACABNgIIIAALCgBBDBABIAAQBQsuAQF/QQgQASIBQQA2AgAgAUEANgIEIAEgADYCBCABQQEgASgCBHQQBjYCACABC6EBAQR/QRAQASIBQQA2AgAgAUEANgIEIAFBADYCCCABQQA2AgxBEBAEIQIDQCAAQRBIBEBBAxAHIQMgAigCACAAQQJ0aiADNgIIIABBAWohAAwBCwsgASACNgIEQRAQBCECQQAhAANAIABBEEgEQEEDEAchAyACKAIAIABBAnRqIAM2AgggAEEBaiEADAELCyABIAI2AgggAUEIEAc2AgwgAQs0AQF/QRQQASIAQQA2AgAgAEEAOgAEIABBADYCCCAAQQA2AgwgAEEANgIQIABBDTYCCCAAC0IBAX9BGRABIgBBADYCACAAQQA2AgQgAEEANgIIIABBADYCDCAAQQA2AhAgAEEANgIUIABBADoAGCAAQQA2AhAgAAu1AgEEf0HQABABIgBBADoAACAAQQA2AgQgAEEANgIIIABBADYCDCAAQQA2AhAgAEEAOgAUIABBADYCGCAAQQA2AhwgAEEANgIgIABBADYCJCAAQQA2AiggAEEANgIsIABBADYCMCAAQQA2AjQgAEEANgI4IABBADYCPCAAQQA2AkAgAEEANgJEIABBADYCSCAAQQA2AkxBBBAEIQIDQCABQQRIBEBBBhAHIQMgAigCACABQQJ0aiADNgIIIAFBAWohAQwBCwsgACACNgIkIABBBBAHNgIoIABB8wAQBjYCLCAAQcABEAY2AjAgAEEMEAY2AjQgAEEMEAY2AjggAEEMEAY2AjwgAEEMEAY2AkAgAEHAARAGNgJEIAAQCDYCSCAAEAg2AkwgABAJNgIEIAAQCjYCCCAACx8BAX9BCBABIgBBADYCACAAQQA2AgQgABALNgIAIAALCgAjACQBEAwkAwthAQF/IAFB+P///wNLBEBBAEHAAEEXQSIQAAALIAEQAiICQQhqIAEQAyAARQRAQQwQASEACyAAQQA2AgAgAEEANgIEIABBADYCCCAAIAI2AgAgAEEANgIEIAAgATYCCCAACwoAQQwQASAAEA4LBgAgABAPCyoAIAEgACgCCE8EQEEAQcAAQSdBPxAAAAsgACgCBCABIAAoAgBqai0ACAssACABIAAoAghPBEBBAEHAAEEyQT8QAAALIAAoAgQgASAAKAIAamogAjoACAtkAQJ/QQ0QDyECA0AgAUENSARAIAIgASAAIAEQEUH/AXEQEiABQQFqIQEMAQsLQQAhAEEAIQEDQCABQQhIBEAgAiABQQVqEBFB/wFxIAFBA3R0IAByIQAgAUEBaiEBDAELCyAACwYAIAAQEwsnACAAIAEQDzYCCCAAQQA2AgwgACABNgIUIABBADoAGCAAQQA2AgALJAAgACgCCCAAKAIYEBUgAEGABiAAKAIMIAAtABRqdBAGNgIgC5UBAQR/IAEhBSAAIgYoAgAhASAAKAIEIQcgACgCCEEBdiEEIAJBAEgEfyACIARqIgBBACAAQQBKGwUgAiIAIAQgACAESBsLIQIgA0EASAR/IAMgBGoiAEEAIABBAEobBSADIgAgBCAAIARIGwshAwNAIAIgA05FBEAgAkEBdCABaiAHaiAFOwEIIAJBAWohAgwBCwsgBgssAQF/AkACQAJAIwRBAWsOAwEBAgALAAtB/////wchAQsgAEGACEEAIAEQFwvBAQECfyAAQQIQBjYCACAAKAIAIgEoAgAgASgCBGpBgAg7AQggACgCACICKAIAIQEgAigCBCABQQJqakGACDsBCCAAKAIMKAIAQQEkBBAYGkEAIQIDQCACQRBIBEAgAiAAKAIEKAIAIgEoAgBBAnZJBH8gAkECdCABaigCCAUACygCAEEBJAQQGBogAiAAKAIIKAIAIgEoAgBBAnZJBH8gAkECdCABaigCCAUACygCAEEBJAQQGBogAkEBaiECDAELCwuHAgEFfyAAIQJBgAYgACgCDCAALQAUanQhAQNAIAMgAUgEQCACKAIgIgQoAgAhBSAEKAIEIANBAXQgBWpqQYAIOwEIIANBAWohAwwBCwsgAiEBQQAhAgNAIAJBBEkEQCACIAEoAiQoAgAiAygCAEECdkkEfyACQQJ0IANqKAIIBQALKAIAQQEkBBAYGiACQQFqIQIMAQsLIAEoAigoAgBBASQEEBgaIAEoAixBASQEEBgaIAAoAjBBASQEEBgaIAAoAjRBASQEEBgaIAAoAjhBASQEEBgaIAAoAjxBASQEEBgaIAAoAkBBASQEEBgaIAAoAkRBASQEEBgaIAAoAkgQGSAAKAJMEBkLyAwBA38DQCABQQNxIAIgAhsEQCAAIgRBAWohACABIgNBAWohASAEIAMtAAA6AAAgAkEBayECDAELCyAAQQNxRQRAA0AgAkEQTwRAIAAgASgCADYCACAAQQRqIAFBBGooAgA2AgAgAEEIaiABQQhqKAIANgIAIABBDGogAUEMaigCADYCACABQRBqIQEgAEEQaiEAIAJBEGshAgwBCwsgAkEIcQRAIAAgASgCADYCACAAQQRqIAFBBGooAgA2AgAgAUEIaiEBIABBCGohAAsgAkEEcQRAIAAgASgCADYCACABQQRqIQEgAEEEaiEACyACQQJxBEAgACABLwEAOwEAIAFBAmohASAAQQJqIQALIAJBAXEEQCAAIAEtAAA6AAALDwsgAkEgTwRAAkACQAJAIABBA3EiA0EBRwRAIANBAkYNASADQQNGDQIMAwsgASgCACEFIAAgASIDLQAAOgAAIABBAWoiASABIANBAWoiAS0AADoAAEEBaiIEQQFqIQAgAUEBaiIDQQFqIQEgBCADLQAAOgAAIAJBA2shAgNAIAJBEU8EQCAAIAFBAWooAgAiA0EIdCAFQRh2cjYCACAAQQRqIAFBBWooAgAiBUEIdCADQRh2cjYCACAAQQhqIAFBCWooAgAiA0EIdCAFQRh2cjYCACAAQQxqIAFBDWooAgAiBUEIdCADQRh2cjYCACABQRBqIQEgAEEQaiEAIAJBEGshAgwBCwsMAgsgASgCACEFIAAgAS0AADoAACAAQQFqIgRBAWohACABQQFqIgNBAWohASAEIAMtAAA6AAAgAkECayECA0AgAkESTwRAIAAgAUECaigCACIDQRB0IAVBEHZyNgIAIABBBGogAUEGaigCACIFQRB0IANBEHZyNgIAIABBCGogAUEKaigCACIDQRB0IAVBEHZyNgIAIABBDGogAUEOaigCACIFQRB0IANBEHZyNgIAIAFBEGohASAAQRBqIQAgAkEQayECDAELCwwBCyABKAIAIQUgACIEQQFqIQAgASIDQQFqIQEgBCADLQAAOgAAIAJBAWshAgNAIAJBE08EQCAAIAFBA2ooAgAiA0EYdCAFQQh2cjYCACAAQQRqIAFBB2ooAgAiBUEYdCADQQh2cjYCACAAQQhqIAFBC2ooAgAiA0EYdCAFQQh2cjYCACAAQQxqIAFBD2ooAgAiBUEYdCADQQh2cjYCACABQRBqIQEgAEEQaiEAIAJBEGshAgwBCwsLCyACQRBxBEAgACABIgMtAAA6AAAgAEEBaiIBIAEgA0EBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiAyADIAFBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiAyADIAFBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiAyADIAFBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiAyADIAFBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiBEEBaiEAIAFBAWoiA0EBaiEBIAQgAy0AADoAAAsgAkEIcQRAIAAgASIDLQAAOgAAIABBAWoiASABIANBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiAyADIAFBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgMgAyABQQFqIgEtAAA6AABBAWoiBEEBaiEAIAFBAWoiA0EBaiEBIAQgAy0AADoAAAsgAkEEcQRAIAAgASIDLQAAOgAAIABBAWoiASABIANBAWoiAS0AADoAAEEBaiIDIAMgAUEBaiIBLQAAOgAAQQFqIgRBAWohACABQQFqIgNBAWohASAEIAMtAAA6AAALIAJBAnEEQCAAIAEtAAA6AAAgAEEBaiIEQQFqIQAgAUEBaiIDQQFqIQEgBCADLQAAOgAACyACQQFxBEAgACABLQAAOgAACwvVAgECfyAAIAFGBEAPCyABIAJqIABNIgNFBEAgACACaiABTSEDCyADBEAgACABIAIQGw8LIAAgAUkEQCABQQdxIABBB3FGBEADQCAAQQdxBEAgAkUEQA8LIAJBAWshAiAAIgRBAWohACABIgNBAWohASAEIAMtAAA6AAAMAQsLA0AgAkEITwRAIAAgASkDADcDACACQQhrIQIgAEEIaiEAIAFBCGohAQwBCwsLA0AgAgRAIAAiBEEBaiEAIAEiA0EBaiEBIAQgAy0AADoAACACQQFrIQIMAQsLBSABQQdxIABBB3FGBEADQCAAIAJqQQdxBEAgAkUEQA8LIAJBAWsiAiAAaiABIAJqLQAAOgAADAELCwNAIAJBCE8EQCACQQhrIgIgAGogASACaikDADcDAAwBCwsLA0AgAgRAIAJBAWsiAiAAaiABIAJqLQAAOgAADAELCwsL4AoBCH8gACgCACIGIgQoAgAgBCgCBGovAQgiCCABIgcoAgxBC3ZsIQQgBygCECAESQR/QYAQIAhrQf//A3FBBXYgCGohCCAHIAQ2AgxBAAUgCCAIQf//A3FBBXZrIQggByAHKAIQIARrNgIQIAcgBygCDCAEazYCDEEBCyAGKAIEIAYoAgBqIAg7AQggByIFKAIMIwJJBEAgBSAFKAIMQQh0NgIMIAUoAhBBCHQhByAFKAIAIQYgBSAFKAIIIglBAWo2AgggBSAGIAkQEUH/AXEgB3I2AhALQf//A3FFBEAgAiAAKAIEKAIAIgAoAgBBAnZJBH8gAkECdCAAaigCCAUACyEDIAEhBEEBIQgDQCAKIAMoAgRJBEAgAygCACIHKAIAIQEgBCgCECAHKAIEIAgiBUEBdCIIIAFqai8BCCIGIAQoAgxBC3ZsIglJBH9BgBAgBmtB//8DcUEFdiAGaiEGIAQgCTYCDEEABSAGIAZB//8DcUEFdmshBiAEIAQoAhAgCWs2AhAgBCAEKAIMIAlrNgIMQQELIAcoAgQgBygCACAFQQF0amogBjsBCCAEKAIMIwJJBEAgBCAEKAIMQQh0NgIMIAQoAhBBCHQhACAEKAIAIQUgBCAEKAIIIgFBAWo2AgggBCAFIAEQEUH/AXEgAHI2AhALQf//A3EgCGohCCAKQQFqIQoMAQsLIAhBASADKAIEdGsPCyAAKAIAIgooAgAhCCAFKAIQIAooAgQgCEECamovAQgiBCABKAIMQQt2bCIDSQR/IAUgAzYCDEEAIQlBgBAgBGtB//8DcUEFdiAEagUgBSAFKAIQIANrNgIQIAUgBSgCDCADazYCDEEBIQkgBCAEQf//A3FBBXZrCyEEIAoiBygCBCAHKAIAQQJqaiAEOwEIIAUiBigCDCMCSQRAIAYgBigCDEEIdDYCDCAGKAIQQQh0IQUgBigCACEHIAYgBigCCCIIQQFqNgIIIAYgByAIEBFB/wFxIAVyNgIQCyAJQf//A3FFBEAgAiAAKAIIKAIAIgAoAgBBAnZJBH8gAkECdCAAaigCCAUACyEJIAEhA0EBIQRBACECA0AgAiAJKAIESQRAIAMoAhAgCSgCACIFKAIEIAQiBkEBdCIEIAUoAgBqai8BCCIHIAMoAgxBC3ZsIghJBH9BgBAgB2tB//8DcUEFdiAHaiEHIAMgCDYCDEEABSAHIAdB//8DcUEFdmshByADIAMoAhAgCGs2AhAgAyADKAIMIAhrNgIMQQELIAUoAgQgBSgCACAGQQF0amogBzsBCCADKAIMIwJJBEAgAyADKAIMQQh0NgIMIAMoAhBBCHQhBSADKAIAIQcgAyADKAIIIgZBAWo2AgggAyAHIAYQEUH/AXEgBXI2AhALQf//A3EgBGohBCACQQFqIQIMAQsLIARBASAJKAIEdGtBCGoPCyAAKAIMIQQgASEDQQEhCUEAIQIDQCACIAQoAgRJBEAgBCgCACIIKAIAIQogAygCECAIKAIEIAogCSIHQQF0IgFqai8BCCIFIAMoAgxBC3ZsIgZJBH8gAyAGNgIMQQAhBkGAECAFa0H//wNxQQV2IAVqBSADIAMoAhAgBms2AhAgAyADKAIMIAZrNgIMQQEhBiAFIAVB//8DcUEFdmsLIQUgCCgCBCAIKAIAIAdBAXRqaiAFOwEIIAMoAgwjAkkEQCADIAMoAgxBCHQ2AgwgAygCEEEIdCEAIAMoAgAhBSADIAMoAggiCkEBajYCCCADIAUgChARQf8BcSAAcjYCEAsgBkH//wNxIAFqIQkgAkEBaiECDAELCyAJQQEgBCgCBHRrQRBqC5YCAQh/QQEhBwNAAkAgBiABTg0AIAIoAhAgACgCBCAAKAIAIAMgB2oiCUEBdGpqLwEIIgQgAigCDEELdmwiBUkEfyACIAU2AgxBACEFQYAQIARrQf//A3FBBXYgBGoFIAIgAigCECAFazYCECACIAIoAgwgBWs2AgxBASEFIAQgBEH//wNxQQV2awshBCAAKAIEIAAoAgAgCUEBdGpqIAQ7AQggAiIEKAIMIwJJBEAgBCAEKAIMQQh0NgIMIAQoAhBBCHQhCiAEKAIAIQsgBCAEKAIIIglBAWo2AgggBCALIAkQEUH/AXEgCnI2AhALIAVB//8DcSIEIAdBAXRqIQcgBCAGdCAIciEIIAZBAWohBgwBCwsgCAvwBAEIf0EDIAEgAUEDSxsiAiAAKAIkKAIAIgEoAgBBAnZJBH8gAkECdCABaigCCAUACyEEIAAoAgQhAkEBIQEDQCAHIAQoAgRJBEAgBCgCACIFKAIAIQMgAigCECAFKAIEIAFBAXQiCSADamovAQgiAyACKAIMQQt2bCIGSQR/IAIgBjYCDEEAIQhBgBAgA2tB//8DcUEFdiADagUgAiACKAIQIAZrNgIQIAIgAigCDCAGazYCDEEBIQggAyADQf//A3FBBXZrCyEDIAUoAgQgBSgCACABQQF0amogAzsBCCACKAIMIwJJBEAgAiACKAIMQQh0NgIMIAIoAhBBCHQhBiACKAIAIQUgAiACKAIIIgNBAWo2AgggAiAFIAMQEUH/AXEgBnI2AhALIAhB//8DcSAJaiEBIAdBAWohBwwBCwsgAUEBIAQoAgR0ayIBQQRJBEAgAQ8LIAFBAXFBAnIgAUEBdkEBayICdCEDIAFBDkkEfyAAKAIsIAIgACgCBCADIAFrEB4gA2oFIAAoAgQhASACQQRrIQJBACEEA0AgASABKAIMQQF2NgIMIAEgASgCECABKAIMazYCECABIAEoAhBBACABKAIQQR92ayIHIAEoAgxxajYCECABKAIQIAEoAgxGBEAgAUEBOgAECyABKAIMIwJJBEAgASABKAIMQQh0NgIMIAEoAhBBCHQhBSABKAIAIQggASABKAIIIgZBAWo2AgggASAIIAYQEUH/AXEgBXI2AhALIAdBAWogBEEBdGohBCACQQFrIgINAAsgBEEEdCADaiAAKAIoIgQoAgAgBCgCBCAAKAIEQQAQHmoLC9AcAQ9/IAAQGiAAKAIEIgdBADoABCAHKAIAIAcgBygCCCIDQQFqNgIIIAMQEUH/AXEEQCAHQQE6AAQLIAdBfzYCDCAHQQA2AhBBACEDA0AgA0EESARAIAcoAhBBCHQhBSAHKAIAIQwgByAHKAIIIghBAWo2AgggByAMIAgQEUH/AXEgBXI2AhAgA0EBaiEDDAELCyAHKAIQIAcoAgxGBEAgB0EBOgAECyABBEAgACgCCCACEA82AgQFIAAoAghBBBAPNgIEC0EAIQwDQAJAIAJFIAEgARsiBwR/IAAtAABFBSAHCwRAIAAoAgQoAhBFBEBBAw8LCyAAKAIwIgUoAgAhByAFKAIEIAAoAggoAgBBASAAKAIQdEEBa3EiCyAMQQR0Qf8BcWoiBkEBdCAHamovAQghAyAGIQcgACgCBCIEKAIMQQt2IANsIQggBCgCECAISQR/IAQgCDYCDEEAIQlBgBAgA2tB//8DcUEFdiADagUgBCAEKAIQIAhrNgIQIAQgBCgCDCAIazYCDEEBIQkgAyADQf//A3FBBXZrCyEIIAUiAygCBCADKAIAIAdBAXRqaiAIOwEIIAQiBigCDCMCSQRAIAYgBigCDEEIdDYCDCAGKAIQQQh0IQggBigCACEDIAYgBigCCCIHQQFqNgIIIAYgAyAHEBFB/wFxIAhyNgIQCyAJQf//A3FFBEAgAkUgASABGw0BIAwhCEEAIQYgACgCCCIFKAIMRSIEBH8gBS0AGEUFIAQLRQRAIAAoAggiBSgCCCIGKAIEQQEgBSgCDEwEfyAFKAIMQQFrBSAFKAIMIAUoAhRBAWtqCyAGKAIAamotAAghBgtBASEEIAAoAggoAgBBASAALQAUdEEBa3EgACgCDHQgBkEIIAAoAgxrdmpBgAZsIQcgCEEHTwRAIAAoAggiBigCCCIJKAIEIA5BAWoiDSAGKAIMTAR/IAYoAgwgDWsFIAYoAgwgBigCFCANa2oLIAkoAgBqai0ACCENA0ACQCANQf8BcUEHdiEGIA1BAXQhDSAAKAIgIgkoAgAhCyAJKAIEIAZBAWpBCHQgB2ogBGoiDEEBdCALamovAQgiCyAAKAIEIgMoAgxBC3ZsIQogAygCECAKSQR/QYAQIAtrQf//A3FBBXYgC2ohCyADIAo2AgxBAAUgCyALQf//A3FBBXZrIQsgAyADKAIQIAprNgIQIAMgAygCDCAKazYCDEEBCyEFIAkoAgQgCSgCACAMQQF0amogCzsBCCADIgooAgwjAkkEQCAKIAooAgxBCHQ2AgwgCigCEEEIdCEDIAooAgAhDCAKIAooAggiC0EBajYCCCAKIAwgCxARQf8BcSADcjYCEAsgBEEBdCAFciEEIAVB//8DcSAGRw0AIARB//8DcUGAAkkNAQsLCwNAIARBgAJJBEAgBEEBdCEJIAAoAiAiBSgCACEMIAUoAgQgBCAHaiIGQQF0IAxqai8BCCILIAAoAgQiDSgCDEELdmwhCiANKAIQIApJBH9BgBAgC2tB//8DcUEFdiALaiELIA0gCjYCDEEABSALIAtB//8DcUEFdmshCyANIA0oAhAgCms2AhAgDSANKAIMIAprNgIMQQELIAUoAgQgBSgCACAGQQF0amogCzsBCCANIgooAgwjAkkEQCAKIAooAgxBCHQ2AgwgCigCEEEIdCEGIAooAgAhBSAKIAooAggiDEEBajYCCCAKIAUgDBARQf8BcSAGcjYCEAsgCXIhBAwBCwsgACgCCCIDIAMoAgBBAWo2AgAgAygCCCELIAMgAygCDCIGQQFqNgIMIAsoAgQgCygCACAGamogBEGAAmsiCjoACCADKAIMIAMoAhRGBEAgA0EANgIMIANBAToAGAsgAygCBCgCCCADKAIQRgRAIAMgAygCBCIGKAIIQQF0EA82AgQgAygCBCgCACADKAIEKAIEakEIaiAGKAIAIAYoAgRqQQhqIAYoAggQHCAGKAIAGgsgAygCBCEJIAMgAygCECIMQQFqNgIQIAkoAgQgCSgCACAMamogCjoACCAIIgVBBEkEf0EABSAFQQNrIAVBBmsgBUEKSRsLIQwgAkEBayECDAILIAAoAjQiBigCACEFIAYoAgQgDCIDQQF0IAVqai8BCCIHIAAoAgQiCigCDEELdmwhBCAKKAIQIARJBH9BgBAgB2tB//8DcUEFdiAHaiEHIAogBDYCDEEABSAHIAdB//8DcUEFdmshByAKIAooAhAgBGs2AhAgCiAKKAIMIARrNgIMQQELIAMhBSAGIgMoAgAhDSADKAIEIAVBAXQgDWpqIAc7AQggCiIJKAIMIwJJBEAgCSAJKAIMQQh0NgIMIAkoAhBBCHQhBiAJKAIAIQMgCSAJKAIIIgVBAWo2AgggCSADIAUQEUH/AXEgBnI2AhALQf//A3EEQCACRSABIAEbDQEgACgCCCIIKAIMRSIEBH8gCC0AGEUFIAQLDQEgACgCOCIDKAIAIQggAygCBCAMQQF0IAhqai8BCCIEIAAoAgQiBSgCDEELdmwhByAFKAIQIAdJBH9BgBAgBGtB//8DcUEFdiAEaiEEIAUgBzYCDEEABSAEIARB//8DcUEFdmshBCAFIAUoAhAgB2s2AhAgBSAFKAIMIAdrNgIMQQELIAMoAgQgAygCACAMQQF0amogBDsBCCAFIgkoAgwjAkkEQCAJIAkoAgxBCHQ2AgwgCSgCEEEIdCEFIAkoAgAhAyAJIAkoAggiCEEBajYCCCAJIAMgCBARQf8BcSAFcjYCEAtB//8DcQRAIAAoAjwiCCgCACEHIAgoAgQgDEEBdCAHamovAQgiBCAAKAIEIgUoAgxBC3ZsIQYgBSgCECAGSQR/QYAQIARrQf//A3FBBXYgBGohBCAFIAY2AgxBAAUgBCAEQf//A3FBBXZrIQQgBSAFKAIQIAZrNgIQIAUgBSgCDCAGazYCDEEBCyAIIgMoAgQgAygCACAMQQF0amogBDsBCCAFIgkoAgwjAkkEQCAJIAkoAgxBCHQ2AgwgCSgCEEEIdCEIIAkoAgAhAyAJIAkoAggiB0EBajYCCCAJIAMgBxARQf8BcSAIcjYCEAtB//8DcQRAIAAoAkAiAygCACEKIAMoAgQgDEEBdCAKamovAQgiBiAAKAIEIgcoAgxBC3ZsIQQgBygCECAESQR/QYAQIAZrQf//A3FBBXYgBmohBiAHIAQ2AgxBAAUgBiAGQf//A3FBBXZrIQYgByAHKAIQIARrNgIQIAcgBygCDCAEazYCDEEBCyADKAIEIAMoAgAgDEEBdGpqIAY7AQggByIJKAIMIwJJBEAgCSAJKAIMQQh0NgIMIAkoAhBBCHQhCCAJKAIAIQMgCSAJKAIIIgpBAWo2AgggCSADIAoQEUH/AXEgCHI2AhALQf//A3EEQCARIQMgDyERBSAPIQMLIBAhDwUgECEDCyAOIRAgAyEOBSAAKAJEIgYoAgAhCiAGKAIEIAxBBHRB/wFxIAtqIgNBAXQgCmpqLwEIIgcgACgCBCIIKAIMQQt2bCEEIAgoAhAgBEkEf0GAECAHa0H//wNxQQV2IAdqIQcgCCAENgIMQQAFIAcgB0H//wNxQQV2ayEHIAggCCgCECAEazYCECAIIAgoAgwgBGs2AgxBAQsgAyEKIAYiAygCACENIAMoAgQgCkEBdCANamogBzsBCCAIIgkoAgwjAkkEQCAJIAkoAgxBCHQ2AgwgCSgCEEEIdCEIIAkoAgAhAyAJIAkoAggiCkEBajYCCCAJIAMgChARQf8BcSAIcjYCEAtB//8DcUUEQEEJQQsgDEEHSRshDCAAKAIIIQQgACgCCCIFKAIIIgMoAgQgDkEBaiIHIAUoAgxMBH8gBSgCDCAHawUgBSgCDCAFKAIUIAdragsgAygCAGpqLQAIIQcgBCAEKAIAQQFqNgIAIAQoAgghBSAEIAQoAgwiBkEBajYCDCAFKAIEIAUoAgAgBmpqIAc6AAggBCgCDCAEKAIURgRAIARBADYCDCAEQQE6ABgLIAQoAgQoAgggBCgCEEYEQCAEIAQoAgQiBigCCEEBdBAPNgIEIAQoAgQoAgAgBCgCBCgCBGpBCGogBigCACAGKAIEakEIaiAGKAIIEBwgBigCABoLIAQoAgQhAyAEIAQoAhAiCEEBajYCECADKAIEIAMoAgAgCGpqIAc6AAggAkEBayECDAQLCyAAKAJMIAAoAgQgCxAdIQtBCEELIAxBB0kbIQwFIA8hESAQIQ8gDiEQQQdBCiAMQQdJGyEMIAAgACgCSCAAKAIEIAsQHSILEB8iDkF/RgRAIAAoAgQoAhAEf0EBBUECCw8LIAJFIAEgARsNASAOIAAoAhhPIgUEfyAFBSAOIAAoAggiBCgCDEwiBgR/IAYFIAQtABgLRQsNAQtBACENIAAoAgghBSAOQQFqIQQgAiALQQJqIgtIIAEgARsEQEEBIQ0gAiELCyALIQYDQCAGQQBKBEAgBSIIKAIIIgkoAgQgBCAFKAIMTAR/IAUoAgwgBGsFIAUoAgwgBSgCFCAEa2oLIAkoAgBqai0ACCEHIAggCCgCAEEBajYCACAIKAIIIQMgCCAIKAIMIgpBAWo2AgwgAygCBCADKAIAIApqaiAHOgAIIAgoAgwgCCgCFEYEQCAIQQA2AgwgCEEBOgAYCyAIKAIEKAIIIAgoAhBGBEAgCCAIKAIEIgMoAghBAXQQDzYCBCAIKAIEKAIAIAgoAgQoAgRqQQhqIAMoAgAgAygCBGpBCGogAygCCBAcIAMoAgAaCyAIKAIEIQkgCCAIKAIQIgNBAWo2AhAgCSgCBCAJKAIAIANqaiAHOgAIIAZBAWshBgwBCwsgAiALayECIA1FDQELC0EBCyYBAX9BEBABIgQgADYCACAEIAE2AgQgBCACNgIIIAQgAzYCDCAEC7YEAQZ/IAAgATYCBEENEA8hAgNAAkAgA0ENTg0AIAIgAyABIAMQEUH/AXEQEiADQQFqIQMMAQsLIAAoAgAhBCACIQZBBBAPIgIoAgQgAigCAGogBigCBCAGKAIAai0ACCIDOgAIIANB/wFxQeEBTwRAQQBBgAFBoQFBDBAAAAsgAigCBCACKAIAQQFqaiADQf8BcUEJcCIHOgAIIAIoAgQgAigCAGogA0H/AXFBCW4iAzoACCADQQVwIQUgAigCBCACKAIAQQJqaiADQQVuIgM6AAggAigCBCACKAIAQQNqaiAFOgAIIAQgBzYCDCAEIAM2AhAgBCAFOgAUIARBADYCHEEAIQIDQAJAIAJBBE8NACAEIAQoAhwgBigCBCAGKAIAIAJBAWpqai0ACCACQQN0dHI2AhwgAkEBaiECDAELCyAEIAQoAhw2AhggBCgCGEGAIEkEQCAEQYAgNgIYC0EAIQJBACEFQQAhAwNAAkAgA0EITg0AIAYgA0EFahARQf8BcSIEQf8BRwRAQQEhBQsgBCADQQN0dCACciECIANBAWohAwwBCwsgACgCACAFRToAACAAKAIAKAIEIAE2AgAgACgCABAWAkAgACgCACAFIAIQICIBQQFGDQAgAUEDRwRAIAFBAkYEQCAFBEAgACgCACgCCCgCECACRw0DCwUMAgsLIAAoAgAoAgQtAAQaQQFBACAAKAIAKAIIKAIQIAAoAgAoAggoAgQQIQ8LQQBBAUEAQQAQIQsIACMDIAAQIgsWAEG4ASQAIwAkAUGAgIAIJAIQDCQDCwMAAQsLtwEEAEEICxcKAAAAdQBzAGUAIABzAHQAcgBpAGMAdABBIAsdDQAAAH4AbABpAGIALwBhAHIAcgBhAHkALgB0AHMAQcAACzkbAAAAfgBsAGkAYgAvAGkAbgB0AGUAcgBuAGEAbAAvAHQAeQBwAGUAZABhAHIAcgBhAHkALgB0AHMAQYABCzMYAAAAcwByAGMALwBsAHoAbQBhAC8AbAB6AG0AYQAtAGQAZQBjAG8AZABlAHIALgB0AHM=`)}function kl(e,t,n){try{let r={data:t,offset:0,readByte(){return this.data[this.offset++]}},i=r.data.length,a={data:[],offset:0,writeByte(e){let t=Math.floor(this.offset/i);this.data[t]||(this.data[t]=new Uint8Array(i)),this.data[t][this.offset%i]=e,this.offset++}};e.decompressFile(r,a);let o=new Uint8Array(a.offset);for(let e=0;e<a.offset;e++)o[e]=a.data[Math.floor(e/i)][e%i];n(null,o)}catch(e){n(e)}}function Al(e,t,n){try{let r=new WebAssembly.Memory({initial:16}),i=new WebAssembly.Module(e),a=new WebAssembly.Instance(i,{env:{memory:r,abort(){n(Error(`webAssembly abort`))}}}).exports,o=a.newU8Array(t.length);new Uint8Array(r.buffer,o+24,t.length).set(t);let s=a.decode(o),c=new Uint32Array(r.buffer,s,4),l=c[0],u=c[2],d=c[3];l?n(null,new Uint8Array(r.buffer,d+24,u).slice(0,u)):n(Error(`lzma deocder error`))}catch(e){n(e)}}var jl=`
347
347
  var decodeLZMA = (function() {
348
348
  var LZMA = (${El.toString()})();
@@ -586,8 +586,8 @@ self.onmessage = function(event) {
586
586
  }
587
587
 
588
588
  }
589
- `,Uu=`KHR_draco_mesh_compression`,Wu=class extends Fu{loadGeometry(e,t){return e.extensions&&e.extensions[Uu]?this.decodePrimitive(e,t).then(n=>t.addGeometryPrimitiveAttributes(n,e)):null}decodePrimitive(e,t){let n=t.json,r=e.extensions[Uu].bufferView,i=e.extensions[Uu].attributes,a={},o={},s={};for(let e in i){let t=Su[e]||e.toLowerCase();a[t]=i[e]}for(let t in e.attributes){let r=Su[t]||t.toLowerCase();if(i[t]!==void 0){let i=n.accessors[e.attributes[t]];s[r]=vu[i.componentType],o[r]=i.normalized===!0}}return t.loadBufferView(r).then(e=>new Promise(t=>{Vu.decodeDracoFile(e,e=>{for(let t in e.attributes){let n=e.attributes[t],r=o[t];r!==void 0&&(n.normalized=r)}t(e)},a,s)}))}},Gu=class{constructor(e,t){this.disposed=!1,this.pool=t,this.workerCreator=e,this.queue=[],this.workers=[],this.workerResolvers=[],this.workerStatus=0}setWorkerCreator(e){this.workerCreator=e}initWorker(e){if(!this.workerCreator)throw Error(`workerCreator is not defined`);if(!this.workers[e]){let t=this.workerCreator(e);t.addEventListener(`message`,this.onMessage.bind(this,e)),this.workers[e]=t}}getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}onMessage(e,t){let n=this.workerResolvers[e];if(t.data&&`$$error`in t.data?n==null||n.reject(t.data.$$error):n==null||n.resolve(t.data),this.workerResolvers[e]=void 0,this.queue.length){let{resolve:t,reject:n,input:r,transfer:i}=this.queue.shift();this.workerResolvers[e]={resolve:t,reject:n},this.workers[e].postMessage(r,i)}else this.workerStatus^=1<<e}postMessage(e,t=[]){return new Promise((n,r)=>{if(this.disposed){r(Error(`disposed`));return}let i=this.getIdleWorker();i===-1?this.queue.push({resolve:n,reject:r,input:e,transfer:t}):(this.initWorker(i),this.workerStatus|=1<<i,this.workerResolvers[i]={resolve:n,reject:r},this.workers[i].postMessage(e,t))})}dispose(){this.disposed=!0,this.workers.forEach(e=>{e.terminate()}),this.workers.length=0,this.workerResolvers.forEach(e=>{e==null||e.reject(Error(`disposed`))}),this.workerResolvers.length=0,this.queue.forEach(e=>{e.reject(Error(`disposed`))}),this.queue.length=0,this.workerStatus=0}},Ku=`https://vr-public.realsee-cdn.cn/release/static/image/release/five/resource/basis/1.16/`,qu=2,Ju=1,Yu=new class{constructor(){this.transcoderPath=Ku,this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Gu(null,4),this.workerSourceURL=``,this.workerConfig=null}setTranscoderPath(e){this.transcoderPath=e}detectSupport(e){var t;let n=e;return n.isWebGPURenderer===!0&&(t=n.backend)!=null&&t.device?this.workerConfig={astcSupported:n.hasFeature(`texture-compression-astc`),etc1Supported:n.hasFeature(`texture-compression-etc2`),etc2Supported:n.hasFeature(`texture-compression-etc2`),dxtSupported:n.hasFeature(`texture-compression-bc`),bptcSupported:n.hasFeature(`texture-compression-bc`),pvrtcSupported:!1}:n.extensions?this.workerConfig={astcSupported:!!n.extensions.get(`WEBGL_compressed_texture_astc`),etc1Supported:!!n.extensions.get(`WEBGL_compressed_texture_etc1`),etc2Supported:!!n.extensions.get(`WEBGL_compressed_texture_etc`),dxtSupported:!!n.extensions.get(`WEBGL_compressed_texture_s3tc`),bptcSupported:!!n.extensions.get(`EXT_texture_compression_bptc`),pvrtcSupported:!!n.extensions.get(`WEBGL_compressed_texture_pvrtc`)||!!n.extensions.get(`WEBKIT_WEBGL_compressed_texture_pvrtc`)}:this.workerConfig||(this.workerConfig={astcSupported:!1,etc1Supported:!1,etc2Supported:!1,dxtSupported:!1,bptcSupported:!1,pvrtcSupported:!1}),this}init(){if(!this.transcoderPending){let e=Xs.ajax(this.transcoderPath+`basis_transcoder.js`,{responseType:`text`}).then(e=>e.body),t=Xs.ajax(this.transcoderPath+`basis_transcoder.wasm`,{responseType:`arraybuffer`}).then(e=>e.body);this.transcoderPending=Promise.all([e,t]).then(([e,t])=>{let n=[`/* constants */`,`let _EngineFormat = `+JSON.stringify(Qu),`let _TranscoderFormat = `+JSON.stringify(Zu),`let _BasisFormat = `+JSON.stringify(Xu),`/* basis_transcoder.js */`,e,`/* worker */`,$u].join(`
590
- `);this.workerSourceURL=URL.createObjectURL(new Blob([n])),this.transcoderBinary=t,this.workerPool.setWorkerCreator(()=>{let e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:`init`,config:this.workerConfig,transcoderBinary:t},[t]),e})})}return this.transcoderPending}parse(e){return this._createTexture([e])}_createTextureFrom(e){let{mipmaps:t,width:n,height:r,format:i,type:a,error:o,dfdTransferFn:s,dfdFlags:c}=e;if(a===`error`)return Promise.reject(o);let u=new l.CompressedTexture(t,n,r,i,l.UnsignedByteType);return u.minFilter=t.length===1?l.LinearFilter:l.LinearMipmapLinearFilter,u.magFilter=l.LinearFilter,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=s===qu?l.SRGBColorSpace:l.LinearSRGBColorSpace,u.premultiplyAlpha=!!(c&Ju),Promise.resolve(u)}_createTexture(e){return this.init().then(()=>this.workerPool.postMessage({type:`transcode`,buffers:e},e)).then(e=>this._createTextureFrom(e))}dispose(){return URL.revokeObjectURL(this.workerSourceURL),this.workerPool.dispose(),this}},Xu={ETC1S:0,UASTC_4x4:1},Zu={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},Qu={RGBAFormat:l.RGBAFormat,RGBA_ASTC_4x4_Format:l.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:l.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:l.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:l.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:l.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:l.RGB_ETC1_Format,RGB_ETC2_Format:l.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:l.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:l.RGB_S3TC_DXT1_Format},$u=`
589
+ `,Uu=`KHR_draco_mesh_compression`,Wu=class extends Fu{loadGeometry(e,t){return e.extensions&&e.extensions[Uu]?this.decodePrimitive(e,t).then(n=>t.addGeometryPrimitiveAttributes(n,e)):null}decodePrimitive(e,t){let n=t.json,r=e.extensions[Uu].bufferView,i=e.extensions[Uu].attributes,a={},o={},s={};for(let e in i){let t=Su[e]||e.toLowerCase();a[t]=i[e]}for(let t in e.attributes){let r=Su[t]||t.toLowerCase();if(i[t]!==void 0){let i=n.accessors[e.attributes[t]];s[r]=vu[i.componentType],o[r]=i.normalized===!0}}return t.loadBufferView(r).then(e=>new Promise(t=>{Vu.decodeDracoFile(e,e=>{for(let t in e.attributes){let n=e.attributes[t],r=o[t];r!==void 0&&(n.normalized=r)}t(e)},a,s)}))}},Gu=class{constructor(e,t){this.disposed=!1,this.pool=t,this.workerCreator=e,this.queue=[],this.workers=[],this.workerResolvers=[],this.workerStatus=0}setWorkerCreator(e){this.workerCreator=e}initWorker(e){if(!this.workerCreator)throw Error(`workerCreator is not defined`);if(!this.workers[e]){let t=this.workerCreator(e);t.addEventListener(`message`,this.onMessage.bind(this,e)),this.workers[e]=t}}getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}onMessage(e,t){let n=this.workerResolvers[e];if(t.data&&`$$error`in t.data?n==null||n.reject(t.data.$$error):n==null||n.resolve(t.data),this.workerResolvers[e]=void 0,this.queue.length){let{resolve:t,reject:n,input:r,transfer:i}=this.queue.shift();this.workerResolvers[e]={resolve:t,reject:n},this.workers[e].postMessage(r,i)}else this.workerStatus^=1<<e}postMessage(e,t=[]){return new Promise((n,r)=>{if(this.disposed){r(Error(`disposed`));return}let i=this.getIdleWorker();i===-1?this.queue.push({resolve:n,reject:r,input:e,transfer:t}):(this.initWorker(i),this.workerStatus|=1<<i,this.workerResolvers[i]={resolve:n,reject:r},this.workers[i].postMessage(e,t))})}dispose(){this.disposed=!0,this.workers.forEach(e=>{e.terminate()}),this.workers.length=0,this.workerResolvers.forEach(e=>{e==null||e.reject(Error(`disposed`))}),this.workerResolvers.length=0,this.queue.forEach(e=>{e.reject(Error(`disposed`))}),this.queue.length=0,this.workerStatus=0}},Ku=`https://vr-public.realsee-cdn.cn/release/static/image/release/five/resource/basis/1.16/`,qu=2,Ju=1,Yu=new class{constructor(){this.transcoderPath=Ku,this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Gu(null,4),this.workerSourceURL=``,this.workerConfig=null}setTranscoderPath(e){this.transcoderPath=e}detectSupport(e){var t,n;let r=e;if(r.isWebGPURenderer===!0&&(t=r.backend)!=null&&t.device)this.workerConfig={astcSupported:r.hasFeature(`texture-compression-astc`),etc1Supported:r.hasFeature(`texture-compression-etc2`),etc2Supported:r.hasFeature(`texture-compression-etc2`),dxtSupported:r.hasFeature(`texture-compression-bc`),bptcSupported:r.hasFeature(`texture-compression-bc`),pvrtcSupported:!1};else if(r.isWebGPURenderer===!0&&(n=r.backend)!=null&&n.gl){let e=r.backend.gl,t=t=>e.getExtension(t)!=null;this.workerConfig={astcSupported:t(`WEBGL_compressed_texture_astc`),etc1Supported:t(`WEBGL_compressed_texture_etc1`),etc2Supported:t(`WEBGL_compressed_texture_etc`),dxtSupported:t(`WEBGL_compressed_texture_s3tc`),bptcSupported:t(`EXT_texture_compression_bptc`),pvrtcSupported:t(`WEBGL_compressed_texture_pvrtc`)||t(`WEBKIT_WEBGL_compressed_texture_pvrtc`)}}else r.extensions?this.workerConfig={astcSupported:!!r.extensions.get(`WEBGL_compressed_texture_astc`),etc1Supported:!!r.extensions.get(`WEBGL_compressed_texture_etc1`),etc2Supported:!!r.extensions.get(`WEBGL_compressed_texture_etc`),dxtSupported:!!r.extensions.get(`WEBGL_compressed_texture_s3tc`),bptcSupported:!!r.extensions.get(`EXT_texture_compression_bptc`),pvrtcSupported:!!r.extensions.get(`WEBGL_compressed_texture_pvrtc`)||!!r.extensions.get(`WEBKIT_WEBGL_compressed_texture_pvrtc`)}:this.workerConfig||(this.workerConfig={astcSupported:!1,etc1Supported:!1,etc2Supported:!1,dxtSupported:!1,bptcSupported:!1,pvrtcSupported:!1});return this}init(){if(!this.transcoderPending){let e=Xs.ajax(this.transcoderPath+`basis_transcoder.js`,{responseType:`text`}).then(e=>e.body),t=Xs.ajax(this.transcoderPath+`basis_transcoder.wasm`,{responseType:`arraybuffer`}).then(e=>e.body);this.transcoderPending=Promise.all([e,t]).then(([e,t])=>{let n=[`/* constants */`,`let _EngineFormat = `+JSON.stringify(Qu),`let _TranscoderFormat = `+JSON.stringify(Zu),`let _BasisFormat = `+JSON.stringify(Xu),`/* basis_transcoder.js */`,e,`/* worker */`,$u].join(`
590
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([n])),this.transcoderBinary=t,this.workerPool.setWorkerCreator(()=>{let e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:`init`,config:this.workerConfig,transcoderBinary:t},[t]),e})})}return this.transcoderPending}parse(e){return this._createTexture([e])}_createTextureFrom(e){let{mipmaps:t,width:n,height:r,format:i,type:a,error:o,dfdTransferFn:s,dfdFlags:c}=e;if(a===`error`)return Promise.reject(o);let u;return i===l.RGBAFormat?(u=new l.DataTexture(t[0].data,n,r,l.RGBAFormat,l.UnsignedByteType),u.mipmaps=t):u=new l.CompressedTexture(t,n,r,i,l.UnsignedByteType),u.minFilter=t.length===1?l.LinearFilter:l.LinearMipmapLinearFilter,u.magFilter=l.LinearFilter,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=s===qu?l.SRGBColorSpace:l.LinearSRGBColorSpace,u.premultiplyAlpha=!!(c&Ju),Promise.resolve(u)}_createTexture(e){return this.init().then(()=>this.workerPool.postMessage({type:`transcode`,buffers:e},e)).then(e=>this._createTextureFrom(e))}dispose(){return URL.revokeObjectURL(this.workerSourceURL),this.workerPool.dispose(),this}},Xu={ETC1S:0,UASTC_4x4:1},Zu={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},Qu={RGBAFormat:l.RGBAFormat,RGBA_ASTC_4x4_Format:l.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:l.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:l.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:l.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:l.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:l.RGB_ETC1_Format,RGB_ETC2_Format:l.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:l.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:l.RGB_S3TC_DXT1_Format},$u=`
591
591
 
592
592
  let config;
593
593
  let transcoderPending;
@@ -886,7 +886,7 @@ j  j"'*\x008\0
886
886
  `)),e.indexOf(`\\
887
887
  `)!==-1&&(e=e.replace(/\\\n/g,``));let n=e.split(`
888
888
  `),r=[];for(let e=0,i=n.length;e<i;e++){let i=n[e].trimStart();if(i.length===0)continue;let a=i.charAt(0);if(a!==`#`){if(a===`v`){let e=i.split(_h);switch(e[0]){case`v`:t.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?(vh.setRGB(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])),vh.convertSRGBToLinear(),t.colors.push(vh.r,vh.g,vh.b)):t.colors.push(void 0,void 0,void 0);break;case`vn`:t.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:t.uvs.push(parseFloat(e[1]),parseFloat(e[2]));break}}else if(a===`f`){let e=i.slice(1).trim().split(_h),n=[];for(let t=0,r=e.length;t<r;t++){let r=e[t];if(r.length>0){let e=r.split(`/`);n.push(e)}}let r=n[0];for(let e=1,i=n.length-1;e<i;e++){let i=n[e],a=n[e+1];t.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a!==`l`&&a!==`p`)if((r=ph.exec(i))!==null){let e=(` `+r[0].slice(1).trim()).slice(1);t.startObject(e)}else if(hh.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(mh.test(i))t.materialLibraries.push(i.substring(7).trim());else if(gh.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(r=i.split(` `),r.length>1){let e=r[1].trim().toLowerCase();t.object.smooth=e!==`0`&&e!==`off`}else t.object.smooth=!0;let e=t.object.currentMaterial();e&&(e.smooth=t.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}}return t.finalize(),t}function xh(e,t,n){let r=new Qc,i=t.split(`
889
- `),a={name:``},o=/\s+/,s={};for(let e=0;e<i.length;e++){let t=i[e];if(t=t.trim(),t.length===0||t.charAt(0)===`#`)continue;let n=t.indexOf(` `),r=n>=0?t.substring(0,n):t;r=r.toLowerCase();let c=n>=0?t.substring(n+1):``;if(c=c.trim(),r===`newmtl`)a={name:c},s[c]=a;else if(r===`ka`||r===`kd`||r===`ks`||r===`ke`){let e=c.split(o,3);a[r]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else(r===`map_kd`||r===`map_ks`||r===`map_ke`||r===`norm`||r===`map_bump`||r===`bump`||r===`map_d`||r===`ns`||r===`d`||r===`tr`)&&(a[r]=c)}function c(e){let t={url:``,scale:new l.Vector2(1,1),offset:new l.Vector2(0,0),bumpScale:1},n=e.split(/\s+/),r;return r=n.indexOf(`-bm`),r>=0&&(t.bumpScale=parseFloat(n[r+1]),n.splice(r,2)),r=n.indexOf(`-s`),r>=0&&(t.scale.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),r=n.indexOf(`-o`),r>=0&&(t.offset.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),t.url=n.join(` `).trim(),t}function u(e,t,i){let a=c(i),o=rc(n.path,a.url);return r.loadTexture(o,{fetcher:n.fetcher,colorSpace:t===`map`||t===`emissiveMap`?l.SRGBColorSpace:l.LinearSRGBColorSpace,minFilter:l.LinearFilter,magFilter:l.LinearFilter,wrapS:l.RepeatWrapping,wrapT:l.RepeatWrapping}).then(n=>{let r=n.body;return r.repeat.copy(a.scale),r.offset.copy(a.offset),e.bumpScale=a.bumpScale,e[t]=r,r})}return{name:e,create:e=>{let t=Lr(n.light?`phong`:`basic`),r=[],i=s[e];if(i){if(i.kd!==void 0&&t.color.fromArray(i.kd),i.ks!==void 0&&t.specular.fromArray(i.ks),i.ke!==void 0&&t.emissive.fromArray(i.ke),i.map_kd!==void 0&&r.push(u(t,`map`,i.map_kd)),i.map_ks!==void 0&&r.push(u(t,`specularMap`,i.map_ks)),i.map_ke!==void 0&&r.push(u(t,`emissiveMap`,i.map_ke)),i.norm!==void 0&&r.push(u(t,`normalMap`,i.norm)),i.map_bump!==void 0&&r.push(u(t,`bumpMap`,i.map_bump)),i.bump!==void 0&&r.push(u(t,`bumpMap`,i.bump)),i.map_d!==void 0&&r.push(u(t,`alphaMap`,i.map_d)),i.ns!==void 0&&(t.shininess=parseFloat(i.ns)),i.d!==void 0){let e=parseFloat(i.d);e<1&&(t.opacity=e,t.transparent=!0)}if(i.tr!==void 0){let e=parseFloat(i.tr);e>0&&(t.opacity=1-e,t.transparent=!0)}}return[t,Promise.all(r).then(e=>e)]}}}function Sh(e,t){var n;let r=[],i=[],a=new l.Group;for(let o=0,s=e.objects.length;o<s;o++){let s=e.objects[o],c=s.geometry,u=s.materials,d=!1;if(c.vertices.length===0)continue;let f=new l.BufferGeometry;i.push(()=>f.dispose()),f.setAttribute(`position`,new l.BufferAttribute(new Float32Array(c.vertices),3)),c.normals.length>0&&f.setAttribute(`normal`,new l.BufferAttribute(new Float32Array(c.normals),3)),c.colors.length>0&&(d=!0,f.setAttribute(`color`,new l.BufferAttribute(new Float32Array(c.colors),3))),c.uvs.length>0&&f.setAttribute(`uv`,new l.BufferAttribute(new Float32Array(c.uvs),2)),c.index.length>0&&f.setIndex(new l.BufferAttribute(new Uint32Array(c.index),1)),f.computeBoundingBox(),f.computeBoundingSphere();let p=[];for(let n=0,a=u.length;n<a;n++){let a=u[n],o=a.name+`_`+a.smooth+`_`+d,s=e.materials[o];if(!s){let n=null;for(let{name:e,create:r}of t)e===a.mtllib&&(n=r(a.name));n||(n=[Lr(),Promise.resolve([])]),s=n[0],s.name=a.name,s.flatShading=!(a.smooth||f.attributes.normal),s.vertexColors=d,e.materials[o]=s;let c=n[1];r.push(c),i.push(()=>s.dispose())}p.push(s)}f.clearGroups();for(let e=0,t=u.length;e<t;e++){let t=u[e];t.groupCount&&f.addGroup((n=t.groupStart)==null?0:n,t.groupCount,e)}(!f.groups||f.groups.length===0)&&f.addGroup(0,f.index?f.index.count:f.attributes.position.count,0);let m=new kt(f,p);m.name=s.name,a.add(m)}return Promise.all(r).then(e=>{let t=[];for(let n of e)t=t.concat(n);return{scene:a,textures:t,dispose:()=>i.forEach(e=>e())}})}function Ch(e,t={}){var n,r,i,a;let o=(n=t.modelUpAxis)==null?`Z`:n,s=(r=t.upAxis)==null?`Z`:r,c=(i=t.fetcher)==null?Xs:i,l=(a=t.onDownloadProgress)==null?K:a,u=e.slice(0,e.lastIndexOf(`/`)+1),d=0,f;return Promise.resolve().then(()=>c.ajax(e,{responseType:`arraybuffer`},void 0,void 0,l)).then(e=>(d=e.body.byteLength,new TextDecoder().decode(e.body))).then(e=>(f=bh(e),Promise.all(f.materialLibraries.map(e=>{let n=rc(u,e),r=n.slice(0,n.lastIndexOf(`/`)+1);return c.ajax(n,{responseType:`text`}).then(n=>{var i;return xh(e,n.body,{path:r,light:(i=t.light)==null?!1:i,fetcher:c})})})))).then(e=>Sh(f,e)).then(t=>(o===`Y`&&t.scene.applyMatrix4(Ns),s===`Y`&&t.scene.applyMatrix4(Ps),{type:`obj`,modelUpAxis:o,upAxis:s,uri:e,byteLength:d,memoryUsage:hl(t.scene),scene:t.scene,textures:t.textures,animations:[],dispose:()=>t.dispose()}))}var wh=Uint8Array,Th=Uint16Array,Eh=Int32Array,Dh=new wh([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]),Oh=new wh([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]),kh=new wh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ah=function(e,t){for(var n=new Th(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Eh(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},jh=Ah(Dh,2),Mh=jh.b,Nh=jh.r;Mh[28]=258,Nh[258]=28;var Ph=Ah(Oh,0),Fh=Ph.b;Ph.r;for(var Ih=new Th(32768),Lh=0;Lh<32768;++Lh){var Rh=(Lh&43690)>>1|(Lh&21845)<<1;Rh=(Rh&52428)>>2|(Rh&13107)<<2,Rh=(Rh&61680)>>4|(Rh&3855)<<4,Ih[Lh]=((Rh&65280)>>8|(Rh&255)<<8)>>1}for(var zh=(function(e,t,n){for(var r=e.length,i=0,a=new Th(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Th(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Th(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ih[d]>>c]=l}else for(s=new Th(r),i=0;i<r;++i)e[i]&&(s[i]=Ih[o[e[i]-1]++]>>15-e[i]);return s}),Bh=new wh(288),Lh=0;Lh<144;++Lh)Bh[Lh]=8;for(var Lh=144;Lh<256;++Lh)Bh[Lh]=9;for(var Lh=256;Lh<280;++Lh)Bh[Lh]=7;for(var Lh=280;Lh<288;++Lh)Bh[Lh]=8;for(var Vh=new wh(32),Lh=0;Lh<32;++Lh)Vh[Lh]=5;var Hh=zh(Bh,9,1),Uh=zh(Vh,5,1),Wh=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Gh=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Kh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qh=function(e){return(e+7)/8|0},Jh=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new wh(e.subarray(t,n))},Yh=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Xh=function(e,t,n){var r=Error(t||Yh[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Xh),!n)throw r;return r},Zh=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new wh(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new wh(i*3));var l=function(e){var t=n.length;if(e>t){var r=new wh(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=Gh(e,d,1);var v=Gh(e,d+1,3);if(d+=3,!v){var y=qh(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Xh(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=Hh,m=Uh,h=9,g=5;else if(v==2){var S=Gh(e,d,31)+257,C=Gh(e,d+10,15)+4,w=S+Gh(e,d+5,31)+1;d+=14;for(var T=new wh(w),E=new wh(19),D=0;D<C;++D)E[kh[D]]=Gh(e,d+D*3,7);d+=C*3;for(var O=Wh(E),k=(1<<O)-1,A=zh(E,O,1),D=0;D<w;){var j=A[Gh(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+Gh(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+Gh(e,d,7),d+=3):y==18&&(N=11+Gh(e,d,127),d+=7);N--;)T[D++]=M}}var ee=T.subarray(0,S),P=T.subarray(S);h=Wh(ee),g=Wh(P),p=zh(ee,h,1),m=zh(P,g,1)}else Xh(1);if(d>_){c&&Xh(0);break}}s&&l(f+131072);for(var te=(1<<h)-1,F=(1<<g)-1,ne=d;;ne=d){var M=p[Kh(e,d)&te],re=M>>4;if(d+=M&15,d>_){c&&Xh(0);break}if(M||Xh(2),re<256)n[f++]=re;else if(re==256){ne=d,p=null;break}else{var ie=re-254;if(re>264){var D=re-257,ae=Dh[D];ie=Gh(e,d,(1<<ae)-1)+Mh[D],d+=ae}var I=m[Kh(e,d)&F],L=I>>4;I||Xh(3),d+=I&15;var P=Fh[L];if(L>3){var ae=Oh[L];P+=Kh(e,d)&(1<<ae)-1,d+=ae}if(d>_){c&&Xh(0);break}s&&l(f+131072);var R=f+ie;if(f<P){var oe=a-P,se=Math.min(P,R);for(oe+f<0&&Xh(3);f<se;++f)n[f]=r[oe+f]}for(;f<R;++f)n[f]=n[f-P]}}t.l=p,t.p=ne,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Jh(n,0,f):n.subarray(0,f)},Qh=new wh(0),$h=function(e,t){return e[t]|e[t+1]<<8},eg=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},tg=function(e,t){return eg(e,t)+eg(e,t+4)*4294967296},ng=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Xh(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Xh(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function rg(e,t){return Zh(e,{i:2},t&&t.out,t&&t.dictionary)}function ig(e,t){return Zh(e.subarray(ng(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var ag=typeof TextDecoder<`u`&&new TextDecoder;try{ag.decode(Qh,{stream:!0})}catch(e){}var og=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Jh(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function sg(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else if(ag)return ag.decode(e);else{var i=og(e),a=i.s,n=i.r;return n.length&&Xh(8),a}}var cg=function(e,t){return t+30+$h(e,t+26)+$h(e,t+28)},lg=function(e,t,n){var r=$h(e,t+28),i=sg(e.subarray(t+46,t+46+r),!($h(e,t+8)&2048)),a=t+46+r,o=eg(e,t+20),s=n&&o==4294967295?ug(e,a):[o,eg(e,t+24),eg(e,t+42)],c=s[0],l=s[1],u=s[2];return[$h(e,t+10),c,l,i,a+$h(e,t+30)+$h(e,t+32),u]},ug=function(e,t){for(;$h(e,t)!=1;t+=4+$h(e,t+2));return[tg(e,t+12),tg(e,t+4),tg(e,t+20)]};function dg(e,t){for(var n={},r=e.length-22;eg(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Xh(13);var i=$h(e,r+8);if(!i)return{};var a=eg(e,r+16),o=a==4294967295||i==65535;if(o){var s=eg(e,r-12);o=eg(e,s)==101075792,o&&(i=eg(e,s+32),a=eg(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=lg(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=cg(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=rg(e.subarray(_,_+f),{out:new wh(p)}):Xh(14,`unknown compression type `+d):n[m]=Jh(e,_,_+f))}return n}function fg(e,t={}){var n,r,i;let a=(n=t.upAxis)==null?`Z`:n,o=(r=t.fetcher)==null?Xs:r,s=(i=t.onDownloadProgress)==null?K:i,c=0;return Promise.resolve().then(()=>o.ajax(e,{responseType:`arraybuffer`},void 0,void 0,s).then(e=>(c=e.body.byteLength,e.body))).then(n=>{var r;return pg(n,{light:t.light,resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(r=e.split(`?`)[1])==null?``:r,fetcher:o})}).then(t=>{let n=t.scene,r=t.unitScale/100,i=new l.Matrix4;if(i.makeScale(r,r,r),t.upAxis===`X`)throw Error(`Cannot load fbx x upAxis`);return t.upAxis===`Y`&&i.premultiply(Ns),a===`Y`&&i.premultiply(Ps),n.applyMatrix4(i),{type:`fbx`,modelUpAxis:t.upAxis,upAxis:a,uri:e,byteLength:c,memoryUsage:hl(n),scene:n,textures:t.textures,animations:t.animations,dispose:()=>t.dispose()}})}function pg(e,t){let n;if(xg(e))n=new vg().parse(e);else{let t=Mg(e);if(!Sg(t))throw Error(`THREE.FBXLoader: Unknown format.`);if(Cg(t)<7e3)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+Cg(t));n=new _g().parse(t)}return new mg(t).parse(n)}var mg=class{constructor(e){var t,n,r;this.light=(t=e.light)==null?!0:t,this.resourcePath=(n=e.resourcePath)==null?``:n,this.search=(r=e.search)==null?``:r,this.fetcher=e.fetcher}parse(e){var t,n,r,i,a,o;let s=this.parseConnections(e),c=Object.assign(new l.Group,{animations:[]}),u=[],d=this.parseImages(e),f=this.parseTextures(e,d,s,u),p=this.parseMaterials(e,f,s),m=this.parseDeformers(e,s),h=new hg().parse(e,m,s);this.parseScene(e,m,h,p,s,c);let g=(n=(t=e.GlobalSettings.UpAxis)==null?void 0:t.value)==null?1:n,_=(i=(r=e.GlobalSettings.FrontAxis)==null?void 0:r.value)==null?2:i,v=(o=(a=e.GlobalSettings.UnitScaleFactor)==null?void 0:a.value)==null?1:o,y;if(e.GlobalSettings.AmbientColor){let t=e.GlobalSettings.AmbientColor.value,n=t[0],r=t[1],i=t[2];if(n!==0||r!==0||i!==0){let e=new l.Color().setRGB(n,r,i);y=new l.AmbientLight(e,1)}}return Promise.all(u).then(e=>{var t;return{scene:c,textures:e,ambientLight:y,upAxis:[`X`,`Y`,`Z`][g],frontAxis:[`X`,`Y`,`Z`][_],unitScale:v,animations:(t=c.animations)==null?[]:t,dispose:()=>{e.forEach(e=>e.dispose()),p.forEach(e=>e.dispose()),h.forEach(e=>e.dispose())}}})}parseConnections(e){let t=new Map;return`Connections`in e&&e.Connections.connections.forEach(function(e){let n=e[0],r=e[1],i=e[2];t.has(n)||t.set(n,{parents:[],children:[]});let a={ID:r,relationship:i};t.get(n).parents.push(a),t.has(r)||t.set(r,{parents:[],children:[]});let o={ID:n,relationship:i};t.get(r).children.push(o)}),t}parseImages(e){let t={},n={};if(`Video`in e.Objects){let r=e.Objects.Video;for(let e in r){let i=r[e],a=parseInt(e);if(t[a]=i.RelativeFilename||i.Filename,`Content`in i){let t=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content==`string`&&i.Content!==``;if(t||a){let t=this.parseImage(r[e]);n[i.RelativeFilename||i.Filename]=t}}}}for(let e in t){let r=t[e];n[r]===void 0?t[e]=t[e].split(`\\`).pop():t[e]=n[r]}return t}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(`.`)+1).toLowerCase(),i;switch(r){case`bmp`:i=`image/bmp`;break;case`jpg`:case`jpeg`:i=`image/jpeg`;break;case`png`:i=`image/png`;break;case`tif`:i=`image/tiff`;break;case`tga`:i=`image/tga`;break;default:return}if(typeof t==`string`)return`data:`+i+`;base64,`+t;{let e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e,t,n,r){let i=new Map;if(`Texture`in e.Objects){let a=e.Objects.Texture;for(let e in a){let o=this.parseTexture(a[e],t,n,r);i.set(parseInt(e),o)}}return i}parseTexture(e,t,n,r){let i=this.loadTexture(e,t,n,r);i.ID=e.id,i.name=e.attrName;let a=e.WrapModeU,o=e.WrapModeV,s=a===void 0?0:a.value,c=o===void 0?0:o.value;if(i.wrapS=s===0?l.RepeatWrapping:l.ClampToEdgeWrapping,i.wrapT=c===0?l.RepeatWrapping:l.ClampToEdgeWrapping,e.Scaling){let t=e.Scaling.value;i.repeat.x=t[0],i.repeat.y=t[1]}if(e.Translation){let t=e.Translation.value;i.offset.x=t[0],i.offset.y=t[1]}return i}loadTexture(e,t,n,r){let i=n.get(e.id).children,a=``;i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(a=t[i[0].ID]),a=rc(this.resourcePath,ic(a,this.search));let o=Object.assign(new l.Texture,{ID:0}),s;s=Wc()?this.fetcher.ajax(a,{responseType:`blob`}).then(e=>{let t=e.body;return Kc(t)}):this.fetcher.loadImage(a,{},void 0,void 0,void 0,Gc()).then(e=>e.body);let c=s.then(e=>(o.image=e,o.needsUpdate=!0,o)).catch(e=>(console.warn(e),o));return r.push(c),o}parseMaterials(e,t,n){let r=new Map;if(`Material`in e.Objects){let i=e.Objects.Material;for(let a in i){let o=this.parseMaterial(e,i[a],t,n);o!==null&&r.set(parseInt(a),o)}}return r}parseMaterial(e,t,n,r){let i=t.id,a=t.attrName,o=t.ShadingModel;if(typeof o==`object`&&(o=o.value),o=o.toLowerCase(),!r.has(i))return null;let s=Lr(this.light?`phong`:`basic`);s.name=a,t.BumpFactor&&(s.bumpScale=t.BumpFactor.value),t.Diffuse?s.color=new l.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type===`Color`||t.DiffuseColor.type===`ColorRGB`)&&(s.color=new l.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(s.displacementScale=t.DisplacementFactor.value),t.Emissive?s.emissive=new l.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type===`Color`||t.EmissiveColor.type===`ColorRGB`)&&(s.emissive=new l.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(s.emissiveIntensity=parseFloat(t.EmissiveFactor.value));let c=1-(t.TransparencyFactor?parseFloat(t.TransparencyFactor.value):0);(c===1||c===0)&&(c=t.Opacity?parseFloat(t.Opacity.value):null,c===null&&(c=1-(t.TransparentColor?parseFloat(t.TransparentColor.value[0]):0))),s.opacity=c,s.opacity<1&&(s.transparent=!0),t.ReflectionFactor&&(s.reflectivity=t.ReflectionFactor.value),t.Shininess&&(s.shininess=t.Shininess.value),t.Specular?s.specular=new l.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type===`Color`&&(s.specular=new l.Color().fromArray(t.SpecularColor.value));let u=this;return r.get(i).children.forEach(function(t){let i=t.relationship;switch(i){case`Bump`:s.bumpMap=u.getTexture(e,n,t.ID,r);break;case`Maya|TEX_ao_map`:s.aoMap=u.getTexture(e,n,t.ID,r);break;case`DiffuseColor`:case`Maya|TEX_color_map`:s.map=u.getTexture(e,n,t.ID,r),s.map!==void 0&&(s.map.colorSpace=l.SRGBColorSpace);break;case`DisplacementColor`:s.displacementMap=u.getTexture(e,n,t.ID,r);break;case`EmissiveColor`:s.emissiveMap=u.getTexture(e,n,t.ID,r),s.emissiveMap!==void 0&&(s.emissiveMap.colorSpace=l.SRGBColorSpace);break;case`NormalMap`:case`Maya|TEX_normal_map`:s.normalMap=u.getTexture(e,n,t.ID,r);break;case`ReflectionColor`:s.envMap=u.getTexture(e,n,t.ID,r),s.envMap!==void 0&&(s.envMap.mapping=l.EquirectangularReflectionMapping,s.envMap.colorSpace=l.SRGBColorSpace);break;case`SpecularColor`:s.specularMap=u.getTexture(e,n,t.ID,r),s.specularMap!==void 0&&(s.specularMap.colorSpace=l.SRGBColorSpace);break;case`TransparentColor`:case`TransparencyFactor`:s.alphaMap=u.getTexture(e,n,t.ID,r),s.transparent=!0;break;default:console.warn(`THREE.FBXLoader: %s map is not supported in three.js, skipping texture.`,i);break}}),s}getTexture(e,t,n,r){return e.Objects.LayeredTexture&&n in e.Objects.LayeredTexture&&(console.warn(`THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.`),n=r.get(n).children[0].ID),t.get(n)}parseDeformers(e,t){let n={},r={};if(`Deformer`in e.Objects){let i=e.Objects.Deformer;for(let e in i){let a=i[e],o=t.get(parseInt(e));if(a.attrType===`Skin`){let t=this.parseSkeleton(o,i);t.ID=e,o.parents.length>1&&console.warn(`THREE.FBXLoader: skeleton attached to more than one geometry is not supported.`),t.geometryID=o.parents[0].ID,n[e]=t}else if(a.attrType===`BlendShape`){let n={id:e};n.rawTargets=this.parseMorphTargets(o,i,t),n.id=e,o.parents.length>1&&console.warn(`THREE.FBXLoader: morph target attached to more than one geometry is not supported.`),r[e]=n}}}return{skeletons:n,morphTargets:r}}parseSkeleton(e,t){let n=[];return e.children.forEach(function(e){let r=t[e.ID];if(r.attrType!==`Cluster`)return;let i={ID:e.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(r.TransformLink.a)};r.Indexes&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)}),{ID:``,geometryID:0,rawBones:n,bones:[]}}parseMorphTargets(e,t,n){let r=[];for(let i=0;i<e.children.length;i++){let a=e.children[i],o=t[a.ID],s={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a,geoID:0};if(o.attrType!==`BlendShapeChannel`)return;s.geoID=n.get(parseInt(a.ID)).children.filter(function(e){return e.relationship===void 0})[0].ID,r.push(s)}return r}parseScene(e,t,n,r,i,a){let o=this.parseModels(e,t.skeletons,n,r,i),s=e.Objects.Model,c=this;o.forEach(function(t){let n=s[t.ID];c.setLookAtProperties(e,t,n,i,a),i.get(t.ID).parents.forEach(function(e){let n=o.get(e.ID);n!==void 0&&n.add(t)}),t.parent===null&&a.add(t)}),this.bindSkeleton(e,t.skeletons,n,o,i),a.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);let t=kg(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix(!0,!0)}});let u=new gg().parse(e,i,a);a.children.length===1&&a.children[0]instanceof l.Group&&(a=a.children[0]),a.animations=u}parseModels(e,t,n,r,i){let a=new Map,o=e.Objects.Model;for(let s in o){let c=parseInt(s),u=o[s],d=i.get(c),f=this.buildSkeleton(d,t,c,u.attrName);if(!f){switch(u.attrType){case`Camera`:f=this.createCamera(e,d);break;case`Light`:f=this.createLight(e,d);break;case`Mesh`:f=this.createMesh(d,n,r);break;case`NurbsCurve`:case`LimbNode`:case`Root`:f=new l.Bone;break;default:f=new l.Group;break}f.name=u.attrName?l.PropertyBinding.sanitizeNodeName(u.attrName):``,f.userData.originalName=u.attrName,f.ID=c}this.getTransformData(f,u),a.set(c,f)}return a}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach(function(e){for(let a in t){let o=t[a];o.rawBones.forEach(function(t,a){if(t.ID===e.ID){let e=i;i=new l.Bone,i.matrixWorld.copy(t.transformLink),i.name=r?l.PropertyBinding.sanitizeNodeName(r):``,i.userData.originalName=r,i.ID=n,o.bones[a]=i,e!==null&&i.add(e)}})}}),i}createCamera(e,t){let n,r;if(t.children.forEach(function(t){let n=e.Objects.NodeAttribute[t.ID];n!==void 0&&(r=n)}),r===void 0)n=new l.Object3D;else{let e=0;r.CameraProjectionType!==void 0&&r.CameraProjectionType.value===1&&(e=1);let t=1;r.NearPlane!==void 0&&(t=r.NearPlane.value/1e3);let i=1e3;r.FarPlane!==void 0&&(i=r.FarPlane.value/1e3);let a=window.innerWidth,o=window.innerHeight;r.AspectWidth!==void 0&&r.AspectHeight!==void 0&&(a=r.AspectWidth.value,o=r.AspectHeight.value);let s=a/o,c=45;r.FieldOfView!==void 0&&(c=r.FieldOfView.value);let u=r.FocalLength?r.FocalLength.value:null;switch(e){case 0:n=new l.PerspectiveCamera(c,s,t,i),u!==null&&n.setFocalLength(u);break;case 1:console.warn(`THREE.FBXLoader: Orthographic cameras not supported yet.`),n=new l.Object3D;break;default:console.warn(`THREE.FBXLoader: Unknown camera type `+e+`.`),n=new l.Object3D;break}}return n}createLight(e,t){let n,r;if(t.children.forEach(function(t){let n=e.Objects.NodeAttribute[t.ID];n!==void 0&&(r=n)}),r===void 0)n=new l.Object3D;else{let e;e=r.LightType===void 0?0:r.LightType.value;let t=new l.Color(16777215);r.Color!==void 0&&(t=new l.Color().fromArray(r.Color.value));let i=r.Intensity===void 0?1:r.Intensity.value/100;r.CastLightOnObject!==void 0&&r.CastLightOnObject.value===0&&(i=0);let a=0;switch(r.FarAttenuationEnd!==void 0&&(a=r.EnableFarAttenuation!==void 0&&r.EnableFarAttenuation.value===0?0:r.FarAttenuationEnd.value),e){case 0:n=new l.PointLight(t,i,a,1);break;case 1:n=new l.DirectionalLight(t,i);break;case 2:let e=Math.PI/3;r.InnerAngle!==void 0&&(e=l.MathUtils.degToRad(r.InnerAngle.value));let o=0;r.OuterAngle!==void 0&&(o=l.MathUtils.degToRad(r.OuterAngle.value),o=Math.max(o,1)),n=new l.SpotLight(t,i,a,e,o,1);break;default:console.warn(`THREE.FBXLoader: Unknown light type `+r.LightType.value+`, defaulting to a PointLight.`),n=new l.PointLight(t,i);break}r.CastShadows!==void 0&&r.CastShadows.value===1&&(n.castShadow=!0)}return n}createMesh(e,t,n){let r,i=null,a=[];if(e.children.forEach(function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&a.push(n.get(e.ID))}),a.length===0){let e=Lr(this.light?`phong`:`basic`);e.color=new l.Color(13421772),a.push(e)}return`color`in i.attributes&&a.forEach(function(e){e.vertexColors=!0}),(!i.groups||i.groups.length===0)&&i.addGroup(0,i.index?i.index.count:i.attributes.position.count,0),i.FBX_Deformer?(a.forEach(function(e){e.skinning=!0}),r=new At(i,a),r.normalizeSkinWeights()):r=new kt(i,a),r}createCurve(e,t){let n=e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),r=new l.LineBasicMaterial({name:``,color:3342591,linewidth:1});return new l.Line(n,r)}getTransformData(e,t){let n={};t.InheritType&&(n.inheritType=parseInt(t.InheritType.value)),t.RotationOrder?n.eulerOrder=Ag(t.RotationOrder.value):n.eulerOrder=Ag(0),t.Lcl_Translation&&(n.translation=t.Lcl_Translation.value),t.PreRotation&&(n.preRotation=t.PreRotation.value),t.Lcl_Rotation&&(n.rotation=t.Lcl_Rotation.value),t.PostRotation&&(n.postRotation=t.PostRotation.value),t.Lcl_Scaling&&(n.scale=t.Lcl_Scaling.value),t.ScalingOffset&&(n.scalingOffset=t.ScalingOffset.value),t.ScalingPivot&&(n.scalingPivot=t.ScalingPivot.value),t.RotationOffset&&(n.rotationOffset=t.RotationOffset.value),t.RotationPivot&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t,n,r,i){`LookAtProperty`in n&&r.get(t.ID).children.forEach(function(n){if(n.relationship===`LookAtProperty`){let r=e.Objects.Model[n.ID];if(r.Lcl_Translation){let e=r.Lcl_Translation.value;`target`in t&&t.target instanceof l.Object3D?(t.target.position.fromArray(e),i.add(t.target)):t.lookAt(new l.Vector3().fromArray(e))}}})}bindSkeleton(e,t,n,r,i){let a=this.parsePoseNodes(e);for(let e in t){let o=t[e];i.get(parseInt(o.ID)).parents.forEach(function(e){if(n.has(e.ID)){let t=e.ID;i.get(t).parents.forEach(function(e){if(r.has(e.ID)){let t=r.get(e.ID);t instanceof l.SkinnedMesh&&t.bind(new l.Skeleton(o.bones),a[e.ID])}})}})}}parsePoseNodes(e){let t={};if(e.Objects.Pose){let n=e.Objects.Pose;for(let e in n)if(n[e].attrType===`BindPose`&&n[e].NbPoseNodes>0){let r=n[e].PoseNode;Array.isArray(r)?r.forEach(function(e){t[e.Node]=new l.Matrix4().fromArray(e.Matrix.a)}):t[r.Node]=new l.Matrix4().fromArray(r.Matrix.a)}}return t}},hg=class{constructor(){this.negativeMaterialIndices=!1}parse(e,t,n){let r=new Map;if(`Geometry`in e.Objects){let i=e.Objects.Geometry;for(let a in i){let o=n.get(parseInt(a)),s=this.parseGeometry(e,o,i[a],t);r.set(parseInt(a),s)}}return this.negativeMaterialIndices===!0&&console.warn(`THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.`),r}parseGeometry(e,t,n,r){switch(n.attrType){case`Mesh`:return this.parseMeshGeometry(e,t,n,r);case`NurbsCurve`:return this.parseNurbsGeometry(n)}}parseMeshGeometry(e,t,n,r){let i=r.skeletons,a=[],o=t.parents.map(function(t){return e.Objects.Model[t.ID]});if(o.length===0)return;let s=t.children.reduce(function(e,t){return i[t.ID]!==void 0&&(e=i[t.ID]),e},null);t.children.forEach(function(e){r.morphTargets[e.ID]!==void 0&&a.push(r.morphTargets[e.ID])});let c=o[0],l={};c.RotationOrder&&(l.eulerOrder=Ag(c.RotationOrder.value)),c.InheritType&&(l.inheritType=parseInt(c.InheritType.value)),c.GeometricTranslation&&(l.translation=c.GeometricTranslation.value),c.GeometricRotation&&(l.rotation=c.GeometricRotation.value),c.GeometricScaling&&(l.scale=c.GeometricScaling.value);let u=kg(l);return this.genGeometry(e,n,s,a,u)}genGeometry(e,t,n,r,i){let a=new l.BufferGeometry;t.attrName&&(a.name=t.attrName);let o=this.parseGeoNode(t,n),s=this.genBuffers(o),c=new l.Float32BufferAttribute(s.vertex,3);if(c.applyMatrix4(i),a.setAttribute(`position`,c),s.colors.length>0&&a.setAttribute(`color`,new l.Float32BufferAttribute(s.colors,3)),n&&(a.setAttribute(`skinIndex`,new l.Uint16BufferAttribute(s.weightsIndices,4)),a.setAttribute(`skinWeight`,new l.Float32BufferAttribute(s.vertexWeights,4)),a.FBX_Deformer=n),s.normal.length>0){let e=new l.Matrix3().getNormalMatrix(i),t=new l.Float32BufferAttribute(s.normal,3);t.applyNormalMatrix(e),a.setAttribute(`normal`,t)}if(s.uvs.forEach(function(e,t){let n=t===0?`uv`:`uv${t}`;a.setAttribute(n,new l.Float32BufferAttribute(s.uvs[t],2))}),o.material&&o.material.mappingType!==`AllSame`){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach(function(n,r){n!==e&&(a.addGroup(t,r-t,e),e=n,t=r)}),a.groups.length>0){let t=a.groups[a.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&a.addGroup(n,s.materialIndex.length-n,e)}a.groups.length===0&&a.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(e,a,t,r,i),a}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices===void 0?[]:e.Vertices.a,n.vertexIndices=e.PolygonVertexIndex===void 0?[]:e.PolygonVertexIndex.a,e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,i){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,r=0,i=!1,a=[],o=[],s=[],c=[],l=[],u=[],d=this;return e.vertexIndices.forEach(function(f,p){let m=0,h=!1;f<0&&(f^=-1,h=!0);let g=[],_=[];if(a.push(f*3,f*3+1,f*3+2),e.color){let t=Eg(p,n,f,e.color);s.push(t[0],t[1],t[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(e){_.push(e.weight),g.push(e.id)}),_.length>4){i||(console.warn(`THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.`),i=!0);let e=[0,0,0,0],t=[0,0,0,0];_.forEach(function(n,r){let i=n,a=g[r];t.forEach(function(t,n,r){if(i>t){r[n]=i,i=t;let o=e[n];e[n]=a,a=o}})}),g=e,_=t}for(;_.length<4;)_.push(0),g.push(0);for(let e=0;e<4;++e)l.push(_[e]),u.push(g[e])}if(e.normal){let t=Eg(p,n,f,e.normal);o.push(t[0],t[1],t[2])}e.material&&e.material.mappingType!==`AllSame`&&(m=Eg(p,n,f,e.material)[0],m<0&&(d.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){let r=Eg(p,n,f,e);c[t]===void 0&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,h&&(d.genFace(t,e,a,m,o,s,c,l,u,r),n++,r=0,a=[],o=[],s=[],c=[],l=[],u=[])}),t}getNormalNewell(e){let t=new l.Vector3(0,0,0);for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t.x+=(r.y-i.y)*(r.z+i.z),t.y+=(r.z-i.z)*(r.x+i.x),t.z+=(r.x-i.x)*(r.y+i.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){let t=this.getNormalNewell(e),n=(Math.abs(t.z)>.5?new l.Vector3(0,1,0):new l.Vector3(0,0,1)).cross(t).normalize();return{normal:t,tangent:n,bitangent:t.clone().cross(n).normalize()}}flattenVertex(e,t,n){return new l.Vector2(e.dot(t),e.dot(n))}genFace(e,t,n,r,i,a,o,s,c,u){let d;if(u>3){let e=[],r=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<n.length;t+=3)e.push(new l.Vector3(r[n[t]],r[n[t+1]],r[n[t+2]]));let{tangent:i,bitangent:a}=this.getNormalTangentAndBitangent(e),o=[];for(let t of e)o.push(this.flattenVertex(t,i,a));d=l.ShapeUtils.triangulateShape(o,[])}else d=[[0,1,2]];for(let[l,u,f]of d)e.vertex.push(t.vertexPositions[n[l*3]]),e.vertex.push(t.vertexPositions[n[l*3+1]]),e.vertex.push(t.vertexPositions[n[l*3+2]]),e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(s[l*4]),e.vertexWeights.push(s[l*4+1]),e.vertexWeights.push(s[l*4+2]),e.vertexWeights.push(s[l*4+3]),e.vertexWeights.push(s[u*4]),e.vertexWeights.push(s[u*4+1]),e.vertexWeights.push(s[u*4+2]),e.vertexWeights.push(s[u*4+3]),e.vertexWeights.push(s[f*4]),e.vertexWeights.push(s[f*4+1]),e.vertexWeights.push(s[f*4+2]),e.vertexWeights.push(s[f*4+3]),e.weightsIndices.push(c[l*4]),e.weightsIndices.push(c[l*4+1]),e.weightsIndices.push(c[l*4+2]),e.weightsIndices.push(c[l*4+3]),e.weightsIndices.push(c[u*4]),e.weightsIndices.push(c[u*4+1]),e.weightsIndices.push(c[u*4+2]),e.weightsIndices.push(c[u*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3])),t.color&&(e.colors.push(a[l*3]),e.colors.push(a[l*3+1]),e.colors.push(a[l*3+2]),e.colors.push(a[u*3]),e.colors.push(a[u*3+1]),e.colors.push(a[u*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2])),t.material&&t.material.mappingType!==`AllSame`&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[l*3]),e.normal.push(i[l*3+1]),e.normal.push(i[l*3+2]),e.normal.push(i[u*3]),e.normal.push(i[u*3+1]),e.normal.push(i[u*3+2]),e.normal.push(i[f*3]),e.normal.push(i[f*3+1]),e.normal.push(i[f*3+2])),t.uv&&t.uv.forEach(function(t,n){e.uvs[n]===void 0&&(e.uvs[n]=[]),e.uvs[n].push(o[n][l*2]),e.uvs[n].push(o[n][l*2+1]),e.uvs[n].push(o[n][u*2]),e.uvs[n].push(o[n][u*2+1]),e.uvs[n].push(o[n][f*2]),e.uvs[n].push(o[n][f*2+1])})}addMorphTargets(e,t,n,r,i){if(r.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];let a=this;r.forEach(function(r){r.rawTargets.forEach(function(r){let o=e.Objects.Geometry[r.geoID];o!==void 0&&a.genMorphGeometry(t,n,o,i,r.name)})})}genMorphGeometry(e,t,n,r,i){var a;let o=t.Vertices===void 0?[]:t.Vertices.a,s=t.PolygonVertexIndex===void 0?[]:t.PolygonVertexIndex.a,c=n.Vertices===void 0?[]:n.Vertices.a,u=n.Indexes?n.Indexes.a:[],d=e.attributes.position.count*3,f=new Float32Array(d);for(let e=0;e<u.length;e++){let t=u[e]*3;f[t]=c[e*3],f[t+1]=c[e*3+1],f[t+2]=c[e*3+2]}let p={vertexIndices:s,vertexPositions:f,baseVertexPositions:o},m=this.genBuffers(p),h=new l.Float32BufferAttribute(m.vertex,3);h.name=i||n.attrName,h.applyMatrix4(r),(a=e.morphAttributes.position)==null||a.push(h)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a,i=[];return n===`IndexToDirect`&&(e.NormalIndex?i=e.NormalIndex.a:e.NormalsIndex&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a,i=[];return n===`IndexToDirect`&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a,i=[];n===`IndexToDirect`&&(i=e.ColorIndex.a);for(let e=0,t=new l.Color;e<r.length;e+=4)t.fromArray(r,e),t.toArray(r,e);return{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t===`NoMappingInformation`)return{dataSize:1,buffer:[0],indices:[0],mappingType:`AllSame`,referenceType:n};let r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let 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 l.BufferGeometry;let n=t-1,r=e.KnotVector.a,i=[],a=e.Points.a;for(let e=0,t=a.length;e<t;e+=4)i.push(new l.Vector4().fromArray(a,e));let o,s;if(e.Form===`Closed`)i.push(i[0]);else if(e.Form===`Periodic`){o=n,s=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}let c=new Fg(n,r,i,o,s).getPoints(i.length*12);return new l.BufferGeometry().setFromPoints(c)}},gg=class{parse(e,t,n){let r=[],i=this.parseClips(e,t,n);if(i!==void 0)for(let e in i){let t=i[e],a=this.addClip(t,n);r.push(a)}return r}parseClips(e,t,n){if(e.Objects.AnimationCurve===void 0)return;let r=this.parseAnimationCurveNodes(e);this.parseAnimationCurves(e,r,t);let i=this.parseAnimationLayers(e,r,t,n);return this.parseAnimStacks(e,i,t)}parseAnimationCurveNodes(e){let t=e.Objects.AnimationCurveNode,n=new Map;for(let e in t){let r=t[e];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){let e={id:r.id,attr:r.attrName,curves:{}};n.set(e.id,e)}}return n}parseAnimationCurves(e,t,n){let r=e.Objects.AnimationCurve;for(let e in r){let i={id:r[e].id,times:r[e].KeyTime.a.map(wg),values:r[e].KeyValueFloat.a},a=n.get(i.id);if(a!==void 0){let e=a.parents[0].ID,n=a.parents[0].relationship,r=t.get(e);r&&(n.match(/X/)?r.curves.x=i:n.match(/Y/)?r.curves.y=i:n.match(/Z/)?r.curves.z=i:n.match(/DeformPercent/)&&t.has(e)&&(r.curves.morph=i))}}}parseAnimationLayers(e,t,n,r){let i=e.Objects.AnimationLayer,a=new Map;for(let o in i){let i=[],s=n.get(parseInt(o));s!==void 0&&(s.children.forEach((a,o)=>{if(t.has(a.ID)){let s=t.get(a.ID);if(s.curves.x!==void 0||s.curves.y!==void 0||s.curves.z!==void 0){if(i[o]===void 0){let t=n.get(a.ID).parents.filter(function(e){return e.relationship!==void 0})[0].ID;if(t!==void 0){let n=e.Objects.Model[t.toString()];if(n===void 0){console.warn(`THREE.FBXLoader: Encountered a unused curve.`,a);return}let s={modelName:n.attrName?l.PropertyBinding.sanitizeNodeName(n.attrName):``,ID:n.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1],transform:new l.Matrix4,eulerOrder:``,preRotation:[0,0,0],postRotation:[0,0,0]};r.traverse(function(e){e.ID===n.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))}),s.transform||(s.transform=new l.Matrix4),n.PreRotation&&(s.preRotation=n.PreRotation.value),n.PostRotation&&(s.postRotation=n.PostRotation.value),i[o]=s}}i[o]&&(i[o][s.attr]=s)}else if(s.curves.morph!==void 0){if(i[o]===void 0){let t=n.get(a.ID).parents.filter(function(e){return e.relationship!==void 0})[0].ID,r=n.get(t).parents[0].ID,s=n.get(r).parents[0].ID,c=n.get(s).parents[0].ID,u=e.Objects.Model[c];i[o]={modelName:u.attrName?l.PropertyBinding.sanitizeNodeName(u.attrName):``,morphName:e.Objects.Deformer[t].attrName}}i[o][s.attr]=s}}}),a.set(parseInt(o),i))}return a}parseAnimStacks(e,t,n){let r=e.Objects.AnimationStack,i={};for(let e in r){let a=n.get(parseInt(e)).children;a.length>1&&console.warn(`THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.`);let o=t.get(a[0].ID);i[e]={name:r[e].attrName,layer:o}}return i}addClip(e,t){let n=[],r=this;return e.layer.forEach(function(e){n=n.concat(r.generateTracks(e,t))}),new l.AnimationClip(e.name,-1,n)}generateTracks(e,t){let n=[],r=new l.Vector3,i=new l.Vector3;e.transform&&e.transform.decompose(r,new l.Quaternion,i);let a=r.toArray(),o=i.toArray();if(e.T!==void 0&&Object.keys(e.T.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.T.curves,a,`position`);t!==void 0&&n.push(t)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let t=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);t!==void 0&&n.push(t)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.S.curves,o,`scale`);t!==void 0&&n.push(t)}if(e.DeformPercent!==void 0){let r=this.generateMorphTrack(e,t);r!==void 0&&n.push(r)}return n}generateVectorTrack(e,t,n,r){let i=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(i,t,n);return new l.VectorKeyframeTrack(e+`.`+r,i,a)}generateRotationTrack(e,t,n,r,i){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){let e=this.interpolateRotations(t.x,t.y,t.z,i);a=e[0],o=e[1]}let s=Ag(0),c=new l.Quaternion,u=new l.Quaternion;n!==void 0&&(n=n.map(l.MathUtils.degToRad),n.push(s),c.setFromEuler(new l.Euler().fromArray(n))),r!==void 0&&(r=r.map(l.MathUtils.degToRad),r.push(s),u.setFromEuler(new l.Euler().fromArray(r)),u.invert());let d=new l.Quaternion,f=new l.Euler,p=[];if(!o||!a)return new l.QuaternionKeyframeTrack(e+`.quaternion`,[0],[0]);for(let e=0;e<o.length;e+=3)f.set(o[e],o[e+1],o[e+2],i),d.setFromEuler(f),d.premultiply(c),d.multiply(u),e>2&&new l.Quaternion().fromArray(p,(e-3)/3*4).dot(d)<0&&d.set(-d.x,-d.y,-d.z,-d.w),d.toArray(p,e/3*4);return new l.QuaternionKeyframeTrack(e+`.quaternion`,a,p)}generateMorphTrack(e,t){let n=e.DeformPercent.curves.morph,r=n.values.map(function(e){return e/100}),i=t.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+`.morphTargetInfluences[`+i+`]`,n.times,r)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){let i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){let r=n,i=[],a=-1,o=-1,s=-1;return e.forEach(function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),a!==-1){let e=t.x.values[a];i.push(e),r[0]=e}else i.push(r[0]);if(o!==-1){let e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(s!==-1){let e=t.z.values[s];i.push(e),r[2]=e}else i.push(r[2])}),i}interpolateRotations(e,t,n,r){let i=[],a=[];i.push(e.times[0]),a.push(l.MathUtils.degToRad(e.values[0])),a.push(l.MathUtils.degToRad(t.values[0])),a.push(l.MathUtils.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){let s=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(s[0])||isNaN(s[1])||isNaN(s[2]))continue;let c=s.map(l.MathUtils.degToRad),u=[e.values[o],t.values[o],n.values[o]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;u.map(l.MathUtils.degToRad);let d=[u[0]-s[0],u[1]-s[1],u[2]-s[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){let t=Math.max(...f)/180,n=new l.Euler(c[0],c[1],c[2],r),s=new l.Euler(c[0],c[1],c[2],r),u=new l.Quaternion().setFromEuler(n),d=new l.Quaternion().setFromEuler(s);u.dot(d)&&d.set(-d.x,-d.y,-d.z,-d.w);let p=e.times[o-1],m=e.times[o]-p,h=new l.Quaternion,g=new l.Euler;for(let e=0;e<1;e+=1/t)h.copy(u.clone().slerp(d.clone(),e)),i.push(p+e*m),g.setFromQuaternion(h,r),a.push(g.x),a.push(g.y),a.push(g.z)}else i.push(e.times[o]),a.push(l.MathUtils.degToRad(e.values[o])),a.push(l.MathUtils.degToRad(t.values[o])),a.push(l.MathUtils.degToRad(n.values[o]))}return[i,a]}},_g=class{constructor(){this.allNodes=new bg,this.nodeStack=[],this.currentIndent=0,this.currentPropName=``}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 bg,this.nodeStack=[],this.currentProp=[],this.currentPropName=``;let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){let i=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(i||a)return;let o=e.match(`^\\t{`+t.currentIndent+`}(\\w+):(.*){`),s=e.match(`^\\t{`+t.currentIndent+`}(\\w+):[\\s\\t\\r\\n](.*)`),c=e.match(`^\\t{`+(t.currentIndent-1)+`}}`);o?t.parseNodeBegin(e,o):s?t.parseNodeProperty(e,s,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,``).replace(/"$/,``),r=t[2].split(`,`).map(function(e){return e.trim().replace(/^"/,``).replace(/"$/,``)}),i={name:n},a=this.parseNodeAttr(r),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,i):n in o?(n===`PoseNode`?o.PoseNode.push(i):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==``&&(o[n][a.id]=i)):typeof a.id==`number`?(o[n]={},o[n][a.id]=i):n!==`Properties70`&&(n===`PoseNode`?o[n]=[i]:o[n]=i),typeof a.id==`number`&&(i.id=a.id),a.name!==``&&(i.attrName=a.name),a.type!==``&&(i.attrType=a.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==``&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n=``,r=``;return e.length>1&&(n=e[1].replace(/^(\w+)::/,``),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,``).replace(/"$/,``).trim(),i=t[2].replace(/^"/,``).replace(/"$/,``).trim();r===`Content`&&i===`,`&&(i=n.replace(/"/g,``).replace(/,$/,``).trim());let a=this.getCurrentNode();if(a.name===`Properties70`){this.parseNodeSpecialProperty(e,r,i);return}if(r===`C`){let e=i.split(`,`).slice(1),t=parseInt(e[0]),n=parseInt(e[1]),o=i.split(`,`).slice(3);o=o.map(function(e){return e.trim().replace(/^"/,``)}),r=`connections`,i=[t,n],Ng(i,o),a[r]===void 0&&(a[r]=[])}r===`Node`&&(a.id=i),r in a&&Array.isArray(a[r])?a[r].push(i):r===`a`?a.a=i:a[r]=i,this.setCurrentProp(a,r),r===`a`&&i.slice(-1)!==`,`&&(a.a=jg(i))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==`,`&&(t.a=jg(t.a))}parseNodeSpecialProperty(e,t,n){let r=n.split(`",`).map(function(e){return e.trim().replace(/^\"/,``).replace(/\s/,`_`)}),i=r[0],a=r[1],o=r[2],s=r[3],c=r[4];switch(a){case`int`:case`enum`:case`bool`:case`ULongLong`:case`double`:case`Number`:case`FieldOfView`:c=parseFloat(c);break;case`Color`:case`ColorRGB`:case`Vector3D`:case`Lcl_Translation`:case`Lcl_Rotation`:case`Lcl_Scaling`:c=jg(c);break}this.getPrevNode()[i]={type:a,type2:o,flag:s,value:c},this.setCurrentProp(this.getPrevNode(),i)}},vg=class{parse(e){let t=new yg(e);t.skip(23);let n=t.getUint32();if(n<6400)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+n);let r=new bg;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);e!==null&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),o=e.getString(a);if(r===0)return null;let s=[];for(let t=0;t<i;t++)s.push(this.parseProperty(e));let c=s.length>0?s[0]:``,l=s.length>1?s[1]:``,u=s.length>2?s[2]:``;for(n.singleProperty=i===1&&e.getOffset()===r;r>e.getOffset();){let r=this.parseNode(e,t);r!==null&&this.parseSubNode(o,n,r)}return n.propertyList=s,typeof c==`number`&&(n.id=c),l!==``&&(n.attrName=l),u!==``&&(n.attrType=u),o!==``&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if(e===`Connections`&&n.name===`C`){let e=[];n.propertyList.forEach(function(t,n){n!==0&&e.push(t)}),t.connections===void 0&&(t.connections=[]),t.connections.push(e)}else if(n.name===`Properties70`)Object.keys(n).forEach(function(e){t[e]=n[e]});else if(e===`Properties70`&&n.name===`P`){let e=n.propertyList[0],r=n.propertyList[1],i=n.propertyList[2],a=n.propertyList[3],o;e.indexOf(`Lcl `)===0&&(e=e.replace(`Lcl `,`Lcl_`)),r.indexOf(`Lcl `)===0&&(r=r.replace(`Lcl `,`Lcl_`)),o=r===`Color`||r===`ColorRGB`||r===`Vector`||r===`Vector3D`||r.indexOf(`Lcl_`)===0?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:a,value:o}}else t[n.name]===void 0?typeof n.id==`number`?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name===`PoseNode`?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),n;switch(t){case`C`:return e.getBoolean();case`D`:return e.getFloat64();case`F`:return e.getFloat32();case`I`:return e.getInt32();case`L`:return e.getInt64();case`R`:return n=e.getUint32(),e.getArrayBuffer(n);case`S`:return n=e.getUint32(),e.getString(n);case`Y`:return e.getInt16();case`b`:case`c`:case`d`:case`f`:case`i`:case`l`:let r=e.getUint32(),i=e.getUint32(),a=e.getUint32();if(i===0)switch(t){case`b`:case`c`:return e.getBooleanArray(r);case`d`:return e.getFloat64Array(r);case`f`:return e.getFloat32Array(r);case`i`:return e.getInt32Array(r);case`l`:return e.getInt64Array(r)}let o=new yg(ig(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case`b`:case`c`:return o.getBooleanArray(r);case`d`:return o.getFloat64Array(r);case`f`:return o.getFloat32Array(r);case`i`:return o.getInt32Array(r);case`l`:return o.getInt64Array(r)}break;default:throw Error(`THREE.FBXLoader: Unknown property type `+t)}}},yg=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t===void 0?!0:t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)==1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let 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()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)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()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}},bg=class{constructor(){this.Connections={connections:[]},this.Objects={Model:{},NodeAttribute:{},Geometry:{}},this.GlobalSettings={}}add(e,t){this[e]=t}};function xg(e){return e.byteLength>=21&&Mg(e,0,21)===`Kaydara FBX Binary \0`}function Sg(e){let t=[`K`,`a`,`y`,`d`,`a`,`r`,`a`,`\\`,`F`,`B`,`X`,`\\`,`B`,`i`,`n`,`a`,`r`,`y`,`\\`,`\\`],n=0;function r(t){let r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e)if(r(1)===t[e])return!1;return!0}function Cg(e){let t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw Error(`THREE.FBXLoader: Cannot find the version number for the file given.`)}function wg(e){return e/46186158e3}var Tg=[];function Eg(e,t,n,r){let i;switch(r.mappingType){case`ByPolygonVertex`:i=e;break;case`ByPolygon`:i=t;break;case`ByVertice`:i=n;break;case`AllSame`:i=r.indices[0];break;default:console.warn(`THREE.FBXLoader: unknown attribute mapping type `+r.mappingType),i=0}r.referenceType===`IndexToDirect`&&(i=r.indices[i]);let a=i*r.dataSize,o=a+r.dataSize;return Pg(Tg,r.buffer,a,o)}var Dg=new l.Euler,Og=new l.Vector3;function kg(e){let t=new l.Matrix4,n=new l.Matrix4,r=new l.Matrix4,i=new l.Matrix4,a=new l.Matrix4,o=new l.Matrix4,s=new l.Matrix4,c=new l.Matrix4,u=new l.Matrix4,d=new l.Matrix4,f=new l.Matrix4,p=new l.Matrix4,m=e.inheritType?e.inheritType:0;e.translation&&t.setPosition(Og.fromArray(e.translation));let h=Ag(0);if(e.preRotation){let t=e.preRotation.map(l.MathUtils.degToRad);t.push(h),n.makeRotationFromEuler(Dg.fromArray(t))}if(e.rotation){let t=e.rotation.map(l.MathUtils.degToRad);t.push(e.eulerOrder||h),r.makeRotationFromEuler(Dg.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(l.MathUtils.degToRad);t.push(h),i.makeRotationFromEuler(Dg.fromArray(t)),i.copy(i.clone().invert())}e.scale&&a.scale(Og.fromArray(e.scale)),e.scalingOffset&&s.setPosition(Og.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(Og.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(Og.fromArray(e.rotationOffset)),e.rotationPivot&&u.setPosition(Og.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(f.copy(e.parentMatrix),d.copy(e.parentMatrixWorld));let g=n.clone().multiply(r).multiply(i),_=new l.Matrix4;_.extractRotation(d);let v=new l.Matrix4;v.copyPosition(d);let y=v.clone().invert().multiply(d),b=_.clone().invert().multiply(y),x=a,S=new l.Matrix4;if(m===0)S.copy(_).multiply(g).multiply(b).multiply(x);else if(m===1)S.copy(_).multiply(b).multiply(g).multiply(x);else{let e=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(f)).clone().invert(),t=b.clone().multiply(e);S.copy(_).multiply(g).multiply(t).multiply(x)}let C=u.clone().invert(),w=o.clone().invert(),T=t.clone().multiply(c).multiply(u).multiply(n).multiply(r).multiply(i).multiply(C).multiply(s).multiply(o).multiply(a).multiply(w),E=new l.Matrix4().copyPosition(T),D=d.clone().multiply(E);return p.copyPosition(D),T=p.clone().multiply(S),T.premultiply(d.clone().invert()),T}function Ag(e){e=e||0;let t=[`ZYX`,`YZX`,`XZY`,`ZXY`,`YXZ`,`XYZ`];return e===6?(console.warn(`THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.`),t[0]):t[e]}function jg(e){return e.split(`,`).map(function(e){return parseFloat(e)})}function Mg(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=e.byteLength),new TextDecoder().decode(new Uint8Array(e,t,n))}function Ng(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}function Pg(e,t,n,r){for(let i=n,a=0;i<r;i++,a++)e[a]=t[i];return e}var Fg=class extends l.Curve{constructor(e,t,n,r,i){super();let a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||a;for(let e=0;e<o;++e){let t=n[e];this.controlPoints[e]=new l.Vector4(t.x,t.y,t.z,t.w)}}getPoint(e,t=new l.Vector3){let n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=Rg(this.degree,this.knots,this.controlPoints,r);return i.w!==1&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new l.Vector3){let n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Ug(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}toJSON(){let e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new l.Vector4(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}};function Ig(e,t,n){let r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,a=r,o=Math.floor((i+a)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?a=o:i=o,o=Math.floor((i+a)/2);return o}function Lg(e,t,n,r){let i=[],a=[],o=[];i[0]=1;for(let s=1;s<=n;++s){a[s]=t-r[e+1-s],o[s]=r[e+s]-t;let n=0;for(let e=0;e<s;++e){let t=o[e+1],r=a[s-e],c=i[e]/(t+r);i[e]=n+t*c,n=r*c}i[s]=n}return i}function Rg(e,t,n,r){let i=Ig(e,r,t),a=Lg(i,r,e,t),o=new l.Vector4(0,0,0,0);for(let t=0;t<=e;++t){let r=n[i-e+t],s=a[t],c=r.w*s;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*s}return o}function zg(e,t,n,r,i){let a=[];for(let e=0;e<=n;++e)a[e]=0;let o=[];for(let e=0;e<=r;++e)o[e]=a.slice(0);let s=[];for(let e=0;e<=n;++e)s[e]=a.slice(0);s[0][0]=1;let c=a.slice(0),l=a.slice(0);for(let r=1;r<=n;++r){c[r]=t-i[e+1-r],l[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){let t=l[e+1],i=c[r-e];s[r][e]=t+i;let a=s[e][r-1]/s[r][e];s[e][r]=n+t*a,n=i*a}s[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=s[e][n];for(let e=0;e<=n;++e){let t=0,i=1,c=[];for(let e=0;e<=n;++e)c[e]=a.slice(0);c[0][0]=1;for(let a=1;a<=r;++a){let r=0,l=e-a,u=n-a;e>=a&&(c[i][0]=c[t][0]/s[u+1][l],r=c[i][0]*s[l][u]);let d=l>=-1?1:-l,f=e-1<=u?a-1:n-e;for(let e=d;e<=f;++e)c[i][e]=(c[t][e]-c[t][e-1])/s[u+1][l+e],r+=c[i][e]*s[l+e][u];e<=u&&(c[i][a]=-c[t][a-1]/s[u+1][e],r+=c[i][a]*s[e][u]),o[a][e]=r;let p=t;t=i,i=p}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}function Bg(e,t,n,r,i){let a=i<e?i:e,o=[],s=Ig(e,r,t),c=zg(s,r,e,a,t),u=[];for(let e=0;e<n.length;++e){let t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,u[e]=t}for(let t=0;t<=a;++t){let n=u[s-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(u[s-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=a+1;e<=i+1;++e)o[e]=new l.Vector4(0,0,0);return o}function Vg(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Hg(e){let t=e.length,n=[],r=[];for(let i=0;i<t;++i){let t=e[i];n[i]=new l.Vector3(t.x,t.y,t.z),r[i]=t.w}let i=[];for(let e=0;e<t;++e){let t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Vg(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}function Ug(e,t,n,r,i){return Hg(Bg(e,t,n,r,i))}var Wg=new l.Vector3;function Gg(e,t){switch(t){case`D`:return new Float64Array(e);case`F`:return new Float32Array(e);case`L`:return new Int32Array(e);case`I`:return new Int16Array(e);default:return new Uint8Array(e)}}function Kg(e,t={}){var n,r,i;let a=(n=t.upAxis)==null?`Z`:n,o=(r=t.fetcher)==null?Xs:r,s=(i=t.onDownloadProgress)==null?K:i,c={byteLength:0};return Promise.resolve().then(()=>o.ajax(e,{responseType:`arraybuffer`},void 0,void 0,s)).then(n=>{var r,i;return c.byteLength=n.body.byteLength,qg(new Uint8Array(n.body),{light:(r=t.light)==null?!0:r,color:t.color,resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(i=e.split(`?`)[1])==null?``:i,fetcher:o})}).then(t=>{let n=new l.Group;return n.name=e,n.add(t.object),a===`Y`&&n.applyMatrix4(Ps),{type:`x3p`,modelUpAxis:`Z`,upAxis:a,uri:e,byteLength:c.byteLength,memoryUsage:hl(n),scene:n,textures:[],animations:[],dispose:()=>t.dispose()}})}function qg(e,t){var n,r,i,a,o,s,c,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,ee,P,te,F,ne,re,ie,ae,I,L,R,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e;let ve=dg(e),ye=``,be=null;for(let e of Object.keys(ve))/(^|\/)main\.xml$/i.test(e)&&(be=ve[e],ye=e.slice(0,e.lastIndexOf(`/`)+1));if(!be)throw Error(`X3p: main.xml not found.`);if(typeof DOMParser>`u`)throw Error(`X3p: DOMParser not found.`);let xe=(n=t.color)==null?new l.Color(10066329):n,Se=new DOMParser,Ce=gu(be),we=Se.parseFromString(Ce,`text/xml`),Te=we.querySelector(`Record1 Axes`),Ee={x:{type:(a=(i=(r=Te==null?void 0:Te.querySelector(`CX AxisType`))==null?void 0:r.textContent)==null?void 0:i.toUpperCase())==null?`I`:a,dataType:(c=(s=(o=Te==null?void 0:Te.querySelector(`CX DataType`))==null?void 0:o.textContent)==null?void 0:s.toUpperCase())==null?`D`:c,increment:Number((d=(u=Te==null?void 0:Te.querySelector(`CX Increment`))==null?void 0:u.textContent)==null?`1`:d),offset:Number((p=(f=Te==null?void 0:Te.querySelector(`CX Offset`))==null?void 0:f.textContent)==null?`0`:p)},y:{type:(g=(h=(m=Te==null?void 0:Te.querySelector(`CY AxisType`))==null?void 0:m.textContent)==null?void 0:h.toUpperCase())==null?`I`:g,dataType:(y=(v=(_=Te==null?void 0:Te.querySelector(`CY DataType`))==null?void 0:_.textContent)==null?void 0:v.toUpperCase())==null?`D`:y,increment:Number((x=(b=Te==null?void 0:Te.querySelector(`CY Increment`))==null?void 0:b.textContent)==null?`1`:x),offset:Number((C=(S=Te==null?void 0:Te.querySelector(`CY Offset`))==null?void 0:S.textContent)==null?`0`:C)},z:{type:(E=(T=(w=Te==null?void 0:Te.querySelector(`CZ AxisType`))==null?void 0:w.textContent)==null?void 0:T.toUpperCase())==null?`A`:E,dataType:(k=(O=(D=Te==null?void 0:Te.querySelector(`CZ DataType`))==null?void 0:D.textContent)==null?void 0:O.toUpperCase())==null?`D`:k,increment:Number((j=(A=Te==null?void 0:Te.querySelector(`CZ Increment`))==null?void 0:A.textContent)==null?`1`:j),offset:Number((N=(M=Te==null?void 0:Te.querySelector(`CZ Offset`))==null?void 0:M.textContent)==null?`0`:N)}},De=null,Oe=we.querySelector(`Record1 Axes Rotation`);Oe&&(De=new l.Matrix3,De.set(Number((P=(ee=Oe.querySelector(`r11`))==null?void 0:ee.textContent)==null?0:P),Number((F=(te=Oe.querySelector(`r12`))==null?void 0:te.textContent)==null?0:F),Number((re=(ne=Oe.querySelector(`r13`))==null?void 0:ne.textContent)==null?0:re),Number((ae=(ie=Oe.querySelector(`r21`))==null?void 0:ie.textContent)==null?0:ae),Number((L=(I=Oe.querySelector(`r22`))==null?void 0:I.textContent)==null?0:L),Number((oe=(R=Oe.querySelector(`r23`))==null?void 0:R.textContent)==null?0:oe),Number((ce=(se=Oe.querySelector(`r31`))==null?void 0:se.textContent)==null?0:ce),Number((ue=(le=Oe.querySelector(`r32`))==null?void 0:le.textContent)==null?0:ue),Number((fe=(de=Oe.querySelector(`r33`))==null?void 0:de.textContent)==null?0:fe)));let ke=(pe=we.querySelector(`Record3 DataLink PointDataLink`))==null?void 0:pe.textContent;if(typeof ke!=`string`)throw Error(`X3p: PointDataLink not found.`);ke=rc(ye,ke);let Ae=ve[ke];if(!Ae)throw Error(`X3p: ${ke} not found.`);let je=Gg(Ae.buffer,Ee.z.dataType),Me=Number((he=(me=we.querySelector(`Record3 MatrixDimension SizeX`))==null?void 0:me.textContent)==null?`0`:he),Ne=Number((_e=(ge=we.querySelector(`Record3 MatrixDimension SizeY`))==null?void 0:ge.textContent)==null?`0`:_e),Pe=Math.floor(Me-1),Fe=Math.floor(Ne-1),Ie=Pe+1,Le=Fe+1,z=new Float32Array(Ie*Le*3),Re=new Float32Array(Ie*Le*2),ze=new Uint32Array(Pe*Fe*6),Be=new l.Box3;for(let e=0;e<Le;e++){let t=e*Ee.y.increment+Ee.y.offset;for(let n=0;n<Ie;n++){let r=e*Ie+n,i=n*Ee.x.increment+Ee.x.offset,a=je[r],o=!isNaN(a),s=o?a:NaN;Wg.set(i,-t,s),De&&Wg.applyMatrix3(De),o&&Be.expandByPoint(Wg),z[r*3+0]=Wg.x,z[r*3+1]=Wg.y,z[r*3+2]=Wg.z,Re[r*2+0]=n/Pe,Re[r*2+1]=1-e/Fe}}for(let e=0;e<Fe;e++)for(let t=0;t<Pe;t++){let n=t+Ie*e,r=t+Ie*(e+1),i=t+1+Ie*(e+1),a=t+1+Ie*e,o=(e*Pe+t)*6;ze[o+0]=n,ze[o+1]=r,ze[o+2]=a,ze[o+3]=r,ze[o+4]=i,ze[o+5]=a}let Ve=new l.BufferGeometry;Ve.setAttribute(`position`,new l.BufferAttribute(z,3)),Ve.setAttribute(`uv`,new l.BufferAttribute(Re,2)),Ve.setIndex(new l.BufferAttribute(ze,1)),(!Ve.groups||Ve.groups.length===0)&&Ve.addGroup(0,Ve.index?Ve.index.count:Ve.attributes.position.count,0),Ve.boundingBox=Be;let He=Lr(t.light?`phong`:`basic`);return He.flatShading=!0,He.color.copy(xe),{object:new kt(Ve,[He]),dispose:()=>{Ve.dispose(),He.dispose()}}}function Jg(e){let t=e.length/32;if(e.length%32!=0)throw Error(`Invalid splat file: data length ${e.length} is not a multiple of 32`);let n=new Float32Array(3*t),r=new Float32Array(4*t),i=new Float32Array(3*t),a=new Uint8Array(4*t),o=new Float32Array(e.buffer),s=new Uint8Array(e.buffer);for(let e=0;e<t;e++)n[3*e+0]=o[8*e+0],n[3*e+1]=o[8*e+1],n[3*e+2]=o[8*e+2],i[3*e+0]=o[8*e+3+0],i[3*e+1]=o[8*e+3+1],i[3*e+2]=o[8*e+3+2],a[4*e+0]=s[32*e+24+0],a[4*e+1]=s[32*e+24+1],a[4*e+2]=s[32*e+24+2],a[4*e+3]=s[32*e+24+3],r[4*e+0]=(s[32*e+28+0]-128)/128,r[4*e+1]=(s[32*e+28+1]-128)/128,r[4*e+2]=(s[32*e+28+2]-128)/128,r[4*e+3]=(s[32*e+28+3]-128)/128;return{numPoints:t,positions:n,scales:i,rotations:r,colors:a}}function Yg(e,t={}){var n,r,i,a;let o=(n=t.modelUpAxis)==null?`Y`:n,s=(r=t.upAxis)==null?`Z`:r,c=(i=t.fetcher)==null?Xs:i,l=(a=t.onDownloadProgress)==null?K:a,u=0;return Promise.resolve().then(()=>c.ajax(e,{responseType:`arraybuffer`},void 0,void 0,l)).then(e=>(u=e.body.byteLength,e.body)).then(e=>Jg(new Uint8Array(e))).then(t=>{let n=new Mt({positions:t.positions,scales:t.scales,rotations:t.rotations,colors:t.colors,numPoints:t.numPoints});return o===`Y`&&n.applyMatrix4(Ns),{type:`splat`,modelUpAxis:o,upAxis:s,uri:e,byteLength:u,memoryUsage:hl(n),scene:n,textures:[],animations:[],dispose:()=>n.dispose()}})}var Xg=new l.Matrix4,Zg=5e3,Qg=1e3;function $g(e,t){e.name=t.id;let n=t.tileset.properties.floorInfo;e.traverse(e=>{if(`floor`in t.extras){if(e instanceof on&&(e.floorIndex=t.extras.floor),e instanceof l.Mesh||e instanceof l.Points){let n=Array.isArray(e.material)?e.material:e.material?[e.material]:[];for(let e of n)Kt(e)&&(e.floorIndex=t.extras.floor),e.isPBMPointCloudMaterial&&(e.floorIndex=t.extras.floor)}}else if((e instanceof kt||e instanceof At)&&n){let r=new l.Box3().expandByObject(e).getCenter(new l.Vector3),i=0;for(let e=0;e<n.length;e++){let{ground:t,height:a}=n[e];if(r.y<t+a){i=e;break}}t.floor=i,t.tileset.floorLength=Math.max(t.tileset.floorLength,t.floor+1),e.material.forEach(e=>e.floorIndex=i)}})}function e_(e,t){if(!e.content)return Promise.resolve(e);let n=e.content,r=ic(n.uri,t.search);if(e.type===`TILESET`){let i=kc(r,{key:`model.${e.siblingIndex}`});return n.loadState=`LOADING`,n.loadStateUpdateTime=G(),t.fetcher.ajax(i,{responseType:`text`},void 0,void 0,(e,t,r)=>{n.loadState===`LOADING`&&(n.loadProgress=e)}).then(e=>e.body).then(e=>{let t=r.slice(0,r.lastIndexOf(`/`)+1);return Am(JSON.parse(e),t)}).then(t=>{n.loadState=`READY`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=0,e.children.length===0&&(e.children=[new Rf(`${e.id}.0`,t.root,e.tileset,e)])}).then(()=>e).catch(e=>(n.loadState=`FAILED`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=Math.min(n.loadfailRetryDelay+1e3,5e3),Promise.reject(e)))}if(e.type===`SCENEGRAPH`){n.loadState=`LOADING`,n.loadStateUpdateTime=G();let i=(e,t,r)=>{n.loadState===`LOADING`&&(n.loadProgress=e,r&&(n.byteLength=r))};return Promise.resolve().then(()=>{var n,a,o,s,c,u,d,f,p,m,h,g;let _=``,[v,y]=r.split(`#`),b=(y||v).split(`?`)[0].match(/\.([0-9a-zA-Z]+)$/);if(b&&(_=b[1]),_===`b3dm`)return nh(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:e.tileset.asset.gltfUpAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,$g(t.scene,e),t));if(_===`pnts`)return dh(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,computeBoundingBox:!1,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>{if(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,e.boundingVolume){let n=e.boundingVolume;t.scene.traverse(e=>{if(e instanceof on){Xg.copy(e.matrixWorld).invert();let t=new l.Box3;n.getBoundingBox(t),t.applyMatrix4(Xg),e.setLocalBoundingBox(t)}})}return $g(t.scene,e),t});if(_===`glb`||_===`gltf`)return sf(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:e.tileset.asset.gltfUpAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,$g(t.scene,e),t));if(_===`at3d`)return zl(e.extras.at3d?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(n=e.extras.at3d)==null?void 0:n.textureBaseUri,textureArray:(a=e.extras.at3d)==null?void 0:a.textureArray,textureOptions:(o=e.extras.at3d)==null?void 0:o.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`ply`)return eu(e.extras.ply?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:(s=e.extras.ply)==null?void 0:s.upAxis,type:`pbmPointCloud`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`pbm`)return _l(e.extras.pbm?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(c=e.extras.pbm)==null?void 0:c.textureBaseUri,textureArray:(u=e.extras.pbm)==null?void 0:u.textureArray,textureOptions:(d=e.extras.pbm)==null?void 0:d.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`dome`)return Ul(e.extras.dome?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(f=e.extras.dome)==null?void 0:f.textureBaseUri,textureOptions:(p=e.extras.dome)==null?void 0:p.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`domez`)return Xl(e.extras.domez?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(m=e.extras.domez)==null?void 0:m.textureBaseUri,textureOptions:(h=e.extras.domez)==null?void 0:h.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`obj`)return Ch(e.extras.obj?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:(g=e.extras.obj)==null?void 0:g.upAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`fbx`)return fg(e.extras.fbx?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`x3p`)return Kg(e.extras.x3p?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`spz`)return Jd(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:`Z`,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t.scene.transformChanged=!0,t));if(_===`splat`)return Yg(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));throw Error(`Invalid Tile content: ${r}`)}).then(r=>{let i={type:r.type,uri:r.uri,byteLength:r.byteLength,memoryUsage:r.memoryUsage,object:new dm(e.id,r.scene,r.animations,r.dispose)};return Promise.resolve().then(()=>{i.object.traverse(e=>{e.matrix.compose(e.position,e.quaternion,e.scale),e.matrixAutoUpdate=!1})}).then(()=>Promise.all([i.object.generateBvhTree(),t.renderer?Im(r.textures,t.renderer):null])).then(()=>(n.loadState=`READY`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=0,n.byteLength=i.byteLength,n.memoryUsage=i.memoryUsage,n.data=i,e)).catch(t=>(t_(e),Promise.reject(t)))}).catch(e=>(n.loadState=`FAILED`,n.loadStateUpdateTime=G(),e instanceof zs&&e.httpStatus===0||e instanceof Bs||e instanceof Rs?n.loadfailRetryDelay=H(n.loadfailRetryDelay+Qg,Qg,Zg):n.loadfailRetryDelay=1/0,Promise.reject(e)))}throw Error(`Invalid Tile type: ${e.type}`)}function t_(e){e.content&&(e.content.data&&e.content.data.object.dispose(),e.content.data=void 0,e.content.loadState=`UNLOADED`,e.content.loadStateUpdateTime=G(),e.content.byteLength=0,e.content.memoryUsage=0)}var n_=new l.Vector3,r_=new l.Matrix3,i_=new l.Matrix4,a_=6378137,o_=298.257223563;function s_(e){let t=a_-a_/o_,n=(a_*a_-t*t)/(a_*a_),r=Math.sqrt(e.x*e.x+e.y*e.y),i=0,a=Math.atan2(e.z,r),o=0;for(;i++<1e3;){let t=Math.sin(a),i=a_/Math.sqrt(1-n*t*t);o=r/Math.cos(a)-i;let s=Math.atan2(e.z/(i*(1-n)+o),r/(i+o));if(isNaN(s)||Math.abs(s-a)<1e-12)break;a=s}return e.set(a,Math.atan2(e.y,e.x),o)}function c_(e){let{x:t,y:n,z:r}=e,i=a_-a_/o_,a=(a_*a_-i*i)/(a_*a_),o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=a_/Math.sqrt(1-a*o*o),d=(u+r)*s*l,f=(u+r)*s*c,p=(i*i/(a_*a_)*u+r)*o;return e.set(d,f,p)}function l_(e,t){let{x:n,y:r,z:i}=s_(n_.copy(e)),a=Math.sin(n),o=Math.sin(r),s=Math.cos(n),c=Math.cos(r);t.fromArray([-o,-a*c,s*c,0,+c,-a*o,s*o,0,0,s,a,0,0,0,0,1]);let l=r_.setFromMatrix4(t),u=n_.copy(e).applyMatrix3(l).multiplyScalar(-1);t.setPosition(u);let d=i_.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,i,1]);return t.premultiply(d),t}var u_=new l.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),d_=new l.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),f_=new l.Matrix4().copy(u_),p_=new l.Matrix4().copy(d_);function m_(e,t={}){var n,r,i;let a,o,s;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){s=4,t.powerPreference===`high`&&(s=2),a=s/1.6;let c=0;if(((n=e.tileset.rootMeta.taskParameters)==null?void 0:n.point_homogenization)===`1`&&(r=e.tileset.rootMeta.taskParameters)!=null&&r.homo_point_density){let t=Number((i=e.tileset.rootMeta.taskParameters)==null?void 0:i.homo_point_density);isFinite(t)&&!isNaN(t)&&(c=t)}c<=0&&(c=.02),o=c*1.4}else s=5,t.powerPreference===`high`&&(s=4),a=0,o=.03;else s=6,a=0,o=.03,e.name===`aerophoto`?(s=12,t.powerPreference===`high`&&(s=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(s=5,t.powerPreference===`high`&&(s=4));return{pointScale:o,pointMinPixel:a,maxScreenSpaceError:s}}var h_=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAABCAYAAACouxZ2AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACAKADAAQAAAABAAAAAQAAAAB7UD0+AAACA0lEQVRIDXWUW3YjIQxEwdnV/GT/q8kO3FO3pAJst3PSAaR6Cbszf//9XeMxxpjXmI+pVXudp2s6PC4dqHff9e6D7/PZLy46xQvG+sZvrfK8xgXUeq85yINe9bdmtOK1+kun5vjgq58a+eZPna9jvmjiserqG/+Whathvo3L3WhV89L9sXI/m18z2uene9ap/ftsuT9WZxoHXzW56/fpj8l7+tTw7P011NdpqnY19sRsfuHMA9u8oZWfDz4+fra/dfG1V60ydZ7qba1g7UNAeK0JP7ydD7/OqH6wO2f7HTq+B/lbL9qsB3/N1/UzR81XfPzw4tp5OPvRneacteq8Xo0xR3vuv/kPz0KtX0Nhg0eHuaNXdWI3X/ld427h++vzyp99V6VPrzWFhbv4ayay4oFecm198MmUXN/mL+x7npq/uJXBGb/MTw4+t+SvbLoTZnUW5uHhz7nWcTxT73OwXV7cxT9wbBf/0LnDBgcnHmtPLYba32Hp808sMy1u88yhr58n70/v4xX92GSN19l/2UsqGmiH94Hpxjcs+DO/ccpIVNVp62PUWXu//ur1GQy1Cf+GZ13rtNYN1po3/NI79fGXibHkq4z25xvV2pW3szpneXsW8SsreTe/NIPrtXMnH7wPf+LEN6tqhUVHj3XKD/72p9eafCeYB3zuonnbv7yqP8d/o4K6gRb1wbYAAAAASUVORK5CYII=`;function g_(e){return Object.keys(e)}function Y(e,t){return e==t}function __(e,t){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function v_(e,t){return e instanceof l.Vector3&&t instanceof l.Vector3?e.equals(t):e===t}function y_(e,t){return e instanceof l.Box3&&t instanceof l.Box3?e.equals(t):e===t}var b_={castShadow:Y,receiveShadow:Y,vertexMarks:Y,pano0:Y,pano1:Y,pano0Depth:Y,pano1Depth:Y,panoFilter:Y,refinedScreen:Y,modelAlpha:Y,progress:Y,transition:Y,opacity:Y,floorStyle:Y,colorStyle:Y,constantColor:v_,shownFloorIndex:Y,clippers:__,brightness:Y,useHDR:Y,maxDisplayBoost:Y,pointShape:Y,pointSize:Y,pointBack:Y,pointScale:Y,pointMinPixel:Y,pointMaxPixel:Y,pointAppearAnimation:Y,colorSaturation:Y,colorBrightness:Y,useAddBlend:Y,outlineGain:Y,distanceGain:Y,gradientTexture:Y,boundingBox:y_,gaussianSplattingSHDegree:Y,minLevelOfDetail:Y,maxLevelOfDetail:Y,minGeometricError:Y,maxGeometricError:Y,panoramaMinGeometricError:Y,skipLevelOfDetail:Y,mostDetail:Y,loadSiblings:Y,cameraCulling:Y,maxMemoryUsage:Y,maxRequests:Y,requestOrder:Y,maxScreenSpaceError:Y,memoryAdjustedScreenSpaceError:Y,cacheCameras:__},x_=(()=>{let e;return e=typeof document<`u`?new l.TextureLoader().load(h_):new l.Texture,e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.wrapS=l.RepeatWrapping,e.wrapT=l.RepeatWrapping,e})(),S_=Object.freeze(new l.Vector3(.6,.6,.6)),C_=Object.freeze([]),w_=Object.freeze(new l.Box3),T_=Object.freeze([]);function E_(){return{castShadow:void 0,receiveShadow:void 0,vertexMarks:void 0,pano0:void 0,pano1:void 0,pano0Depth:void 0,pano1Depth:void 0,panoFilter:void 0,refinedScreen:void 0,floorStyle:void 0,colorStyle:void 0,constantColor:void 0,shownFloorIndex:void 0,modelAlpha:void 0,opacity:void 0,progress:void 0,transition:void 0,clippers:void 0,brightness:void 0,useHDR:void 0,maxDisplayBoost:void 0,pointSize:void 0,pointBack:void 0,pointShape:void 0,pointScale:void 0,pointMaxPixel:void 0,pointMinPixel:void 0,pointAppearAnimation:void 0,gradientTexture:void 0,colorSaturation:void 0,colorBrightness:void 0,outlineGain:void 0,distanceGain:void 0,useAddBlend:void 0,boundingBox:void 0,gaussianSplattingSHDegree:void 0,minLevelOfDetail:void 0,maxLevelOfDetail:void 0,minGeometricError:void 0,maxGeometricError:void 0,panoramaMinGeometricError:void 0,skipLevelOfDetail:void 0,mostDetail:void 0,loadSiblings:void 0,cameraCulling:void 0,maxMemoryUsage:void 0,maxRequests:void 0,requestOrder:void 0,maxScreenSpaceError:void 0,memoryAdjustedScreenSpaceError:void 0,cacheCameras:void 0}}var D_={versionNumber:0,castShadow:!1,receiveShadow:!1,vertexMarks:!0,pano0:null,pano1:null,pano0Depth:null,pano1Depth:null,panoFilter:null,refinedScreen:null,floorStyle:`OPACITY`,colorStyle:`RGB`,constantColor:S_,shownFloorIndex:-1,modelAlpha:1,opacity:1,progress:0,transition:`FADE`,clippers:C_,brightness:1,useHDR:!1,maxDisplayBoost:1,pointSize:`ATTENUATION`,pointBack:`DARK`,pointShape:`CIRCLE`,pointScale:.02,pointMaxPixel:40,pointMinPixel:0,pointAppearAnimation:!0,gradientTexture:x_,colorSaturation:0,colorBrightness:0,outlineGain:0,distanceGain:0,useAddBlend:!1,boundingBox:w_,gaussianSplattingSHDegree:0,minLevelOfDetail:0,maxLevelOfDetail:20,minGeometricError:0,maxGeometricError:1e4,panoramaMinGeometricError:.04,skipLevelOfDetail:!1,mostDetail:!1,loadSiblings:!1,cameraCulling:!0,maxMemoryUsage:64,maxRequests:6,requestOrder:`SCREEN_SPACE_ERROR`,maxScreenSpaceError:4,memoryAdjustedScreenSpaceError:!1,cacheCameras:T_},O_=D_.versionNumber;function k_(e={}){return Object.assign(e,D_)}var A_=g_(E_());function j_(e,t,n){let r=b_[t];if(!r)return!1;Array.isArray(n)&&(n=n.slice());let i=e[t];return r(i,n)?!1:(e[t]=n,!0)}var X=class e{static createDefault(){return k_()}static resolveValueTo(t,...n){let r=k_(t);for(let t of n){let n=t instanceof e?t.versionNumber:++O_;r.versionNumber=r.versionNumber*31+n|0;for(let e of A_)t[e]!==void 0&&j_(r,e,t[e])}return r}static resolveValue(...t){if(typeof t[0]==`string`){let e=t.shift(),n=t,r=D_[e];for(let t of n)t[e]!==void 0&&(r=t[e]);return r}else{let n=t;return e.resolveValueTo({},...n)}}constructor(e){this.id=Ft(),this.versionNumber=++O_,this.unbind=new Map,this.value=E_(),e&&this.copy(e);for(let e of A_)Object.defineProperty(this,e,{get(){return this.value[e]}});Ot(this)}resolveValue(...t){return e.resolveValue(...t,this)}assignValue(e,t){let n=this.unbind.get(e);n&&(this.unbind.delete(e),n());let r=j_(this.value,e,t),i=this.value[e];if(i instanceof Vt){let t=i.on(`update`,()=>this.versionNumber=++O_);this.unbind.set(e,t)}return r}set(e,t){let n=!1;if(typeof e==`string`)t!==void 0&&this.assignValue(e,t)&&(n=!0);else{let t=e;for(let e of A_)t[e]!==void 0&&this.assignValue(e,t[e])&&(n=!0)}return n&&(this.versionNumber=++O_),this}reset(...e){let t=!1;for(let n of e)this.assignValue(n,void 0)&&(t=!0);return t&&(this.versionNumber=++O_),this}resetAll(){return this.reset(...A_)}copy(e){let t=!0;for(let n of A_)this.assignValue(n,e[n])&&(t=!0);return t&&(this.versionNumber=++O_),this}},M_=new l.Vector3,N_=new Ef,P_=new Tf,F_=new WeakMap,I_=new WeakMap,L_=new WeakMap,R_={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},z_=(()=>{let e=new l.MeshBasicMaterial;return e.side=l.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=R_.TILE_MASK,e.stencilFunc=l.AlwaysStencilFunc,e.stencilFuncMask=R_.TILE_MASK,e.stencilZPass=l.ReplaceStencilOp,e.stencilWriteMask=R_.TILE_MASK,e})(),B_=(()=>{let e=new l.MeshBasicMaterial;return e.visible=!1,e})(),V_=new l.BufferGeometry,H_=new l.MeshBasicMaterial;function U_(e){let t;t=e instanceof l.Mesh?new l.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?B_:z_):e.material&&e.material.transparent?B_:z_):e instanceof l.Group?new l.Group:new l.Object3D,t.position.copy(e.position),t.quaternion.copy(e.quaternion),t.scale.copy(e.scale),t.matrix.compose(e.position,e.quaternion,e.scale),t.matrixAutoUpdate=!1,t.frustumCulled=e.frustumCulled,t.visible=e.visible;for(let n of e.children)t.add(U_(n));return t}var W_=class extends l.Object3D{constructor(e,t){var n,r;super(),this.parameter=new X,this.renderObjects=[],this.backfaceObjects=[],this.tileObjects=[],this.frameNumber=0,this.error=(n=t.error)==null?null:n,this.name=t.name,this.type=t.type,this.upAxis=t.upAxis,this.light=t.light,this.fetcher=t.fetcher,this.search=(r=t.search)==null?``:r,this.groundHeight=t.groundHeight,this.coordinateSystem=t.coordinateSystem,this.boundingBox=new l.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new l.Mesh(V_,H_),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new Om(e,{tileLoader:e=>this.loadContent(e),tileUnloader:e=>this.unloadContent(e),onTileLoad:e=>{this.onTileLoad&&this.onTileLoad(e)},onTileUnload:e=>{this.onTileUnload&&this.onTileUnload(e)},onTileError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{tile:e})),console.error(`Tile error`,e.id,t)}}),this.tileset.root.boundingVolume&&this.tileset.root.boundingVolume.getBoundingBox(this.boundingBox),this.currentResolvedParameterValue=X.resolveValueTo({},this.parameter)}get viewerRequestVolume(){return this.tileset.root.viewerRequestVolume}set viewerRequestVolume(e){this.tileset.root.viewerRequestVolume=e}get tiles(){return this.tileset.selectedTiles}get trajectories(){return this.tileset.trajectories}getRecommendProps(e={}){return m_(this,e)}loadContent(e){return e_(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)t_(e);else if(e.content.data)if(e.content.data.type===`spz`){let t=e.content.data.object.children[0].boundingBox;this.boundingBox.union(t)}else this.boundingBox.expandByObject(e.content.data.object)}})}unloadContent(e){return t_(e),Promise.resolve()}loadAllTilesets(){let e=t=>{let n=[];return this.tileset.root.traverse(e=>{var t;e.type===`TILESET`&&((t=e.content)==null?void 0:t.loadState)!==`READY`&&n.push(e)}),Promise.all(n.map(t=>this.loadContent(t).then(()=>e(t)))).then(()=>{})};return e(this.tileset.root)}intersectRaycaster(e,t){var n,r;let i=t==null?[]:t,a=[this.tileset.root],o=this.tileset.transform,s=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,c=e.sortByDistance;e.sortByDistance=!1;let l,u=1/0;for(;l=a.pop();){let t;if(l.boundingVolume){let n;n=l.boundingVolume instanceof Tf?P_.copy(l.boundingVolume):l.boundingVolume instanceof Ef?N_.copy(l.boundingVolume):l.boundingVolume.clone(),n.applyMatrix4(o),t=n.intersectRay(e.ray,s,u)}else t=!0;if(t){for(let e=0,t=l.children.length;e<t;e++)a.push(l.children[e]);if(l.selected&&l.content&&l.content.data&&l.content.data.object.visible){let t=e.hitFilter;if(e.hitFilter=n=>{var r;return Object.assign(n,{model:(r=this.parent)==null?void 0:r,viewLayer:this,tile:l}),t?t.call(e,n):!0},l.content.data.object.intersectRaycaster(e,i),e.hitFilter=t,e.firstHitOnly){let e=i[0];e&&u>e.distance&&(u=e.distance)}}}}return e.sortByDistance=c,Kf(i,e.sortByDistance,e.firstHitOnly),i}update(e,t,n,r){var i,a,o;this.renderer=e,this.frameNumber++;let s=!1,c=X.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);F_.get(this)!==c.versionNumber&&(F_.set(this,c.versionNumber),s=!0);let u=this.visible&&r.visible&&n.visible,d=c.maxLevelOfDetail;d=Math.max(d,0);let f=Math.min(c.minLevelOfDetail,d);(!u||!this.loaded||!n.loaded)&&(d=Math.max(f,0));let p=c.maxMemoryUsage;u||(p=Math.min(0,p));let m=c.minGeometricError,h=c.maxRequests,g=c.memoryAdjustedScreenSpaceError;u||(g=!1),t.controllerMode===`Panorama`&&(c.modelAlpha<.1&&(m=c.panoramaMinGeometricError,g=!1),c.progress>=.01&&c.progress<=.99&&(h=0));let _=c.maxGeometricError;_=Math.max(m,_);let v={time:t.time,camera:{type:t.type,position:new l.Vector3().copy(t.position),direction:t.getDirection(new l.Vector3),up:new l.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:u&&t.visible,refine:t.refineModel},height:t.resolution.height,pixelRatio:t.pixelRatio,frameNumber:this.frameNumber,sseDenominator:2*Math.tan(.5*t.fov/180*Math.PI),cullingVolume:new wf().setFromCamera(t),minLevelOfDetail:f,maxLevelOfDetail:d,minGeometricError:m,maxGeometricError:_,skipLevelOfDetail:c.skipLevelOfDetail,mostDetail:c.mostDetail,loadSiblings:c.loadSiblings,cameraCulling:c.cameraCulling,maxMemoryUsage:p,maxRequests:h,requestOrder:c.requestOrder,maxScreenSpaceError:c.maxScreenSpaceError,memoryAdjustedScreenSpaceError:g},y=c.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},v),{camera:{type:t.type,position:new l.Vector3().copy(e.position),direction:e.getWorldDirection(new l.Vector3),up:new l.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new wf().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),s=!0);let b=!this.autoRefine;if(b===!1&&c.progress>=.01&&c.progress<=.99){let e=new l.Vector3;c.pano0&&e.setFromMatrixPosition(c.pano0.matrix);let t=e.clone();c.pano1&&t.setFromMatrixPosition(c.pano1.matrix),e.distanceTo(t)<10&&(b=!0)}if(b||this.tileset.update(v,y),this.refined=!0,this.refineProgress[0]=0,this.refineProgress[1]=0,this.tileset.needsRefinedTiles.forEach(e=>{if(this.refineProgress[1]++,e.content){let t=e.content.loadState;if(t===`UNLOADED`||t===`LOADING`){this.refined=!1;return}}this.refineProgress[0]++}),this.loaded===!1&&this.autoRefine){this.loaded=!0;let e=!1;this.tileset.needsRefinedTiles.forEach(t=>{if(this.loaded!==!1&&t.content&&(t.state.visible&&(e=!0),c.minLevelOfDetail>=0)){if(v.skipLevelOfDetail){if(t.state.finalResolution){let e=t.state.ancestorWithContentAvailable,n=(e&&e.content?e.content:t.content).loadState;(n===`UNLOADED`||n===`LOADING`)&&(this.loaded=!1)}}else if(t.state.visible&&t.levelOfContent<=0){let e=t.content.loadState;(e===`UNLOADED`||e===`LOADING`)&&(this.loaded=!1)}}}),e&&this.tileset.selectedTiles.length===0&&this.tileset.frameNumber<500&&(this.loaded=!1),this.loaded===!0&&(this.refined=!1,this.refineProgress[1]++)}this.renderObjects.length=0,this.backfaceObjects.length=0,this.tileObjects.length=0;for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);v.skipLevelOfDetail||this.tileset.selectedTiles.sort((e,t)=>e.floor===t.floor?e.levelOfContent===t.levelOfContent?e.state.distanceToCamera===t.state.distanceToCamera?e.state.centerZDepth-t.state.centerZDepth:e.state.distanceToCamera-t.state.distanceToCamera:t.levelOfContent-e.levelOfContent:e.floor-t.floor);let x=[];for(let r of this.tileset.selectedTiles){let o=(a=(i=r.content)==null?void 0:i.data)==null?void 0:a.object;if(!o)continue;let u=o.update(e,t,n,this,r,c);if(x.push(r.id),u&&(s=!0),this.tileset.hasMixedContent&&v.skipLevelOfDetail){if(!r.state.finalResolution){let e=U_(o);e.name=`skipBackface:`+o.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=R_.TILE_MASK|e<<R_.SKIP_LOD_BIT_SHIFT,n=l.GreaterEqualStencilFunc,i=R_.SKIP_LOD_MASK,a=l.ReplaceStencilOp,s=R_.TILE_MASK|R_.SKIP_LOD_MASK;for(let e of o.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=i,e.stencilZPass=a,e.stencilWriteMask=s}else for(let e of o.materials)e.stencilWrite=!1,e.stencilRef=R_.TILE_MASK,e.stencilFunc=l.AlwaysStencilFunc,e.stencilFuncMask=R_.TILE_MASK,e.stencilZPass=l.ReplaceStencilOp,e.stencilWriteMask=R_.TILE_MASK;this.tileObjects.push(o)}let S=x.toString();if(I_.get(this)!==S&&(I_.set(this,S),s=!0),v.skipLevelOfDetail&&this.backfaceObjects.length)for(let e=0;e<this.backfaceObjects.length;e++)this.renderObjects.push(this.backfaceObjects[e]);if(this.tileObjects.length)for(let e=0;e<this.tileObjects.length;e++)this.renderObjects.push(this.tileObjects[e]);v.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let C=[];for(let r of this.tileset.selectedTrajectories){let i=(o=r.content.data)==null?void 0:o.object;if(!i)continue;let a=i.update(e,t,n,this,r,c);C.push(r.id),a&&(s=!0),this.renderObjects.push(i)}let w=C.toString();if(L_.get(this)!==w&&(L_.set(this,w),s=!0),this.parent){let e=this.parent.children.length+1,t=(Math.min(0,this.parent.children.indexOf(this))-e)*1e4+1;for(let e=0;e<this.renderObjects.length;e++){let n=this.renderObjects[e],r=e+t;n.traverse(e=>{(e instanceof l.Mesh||e instanceof l.Line||e instanceof l.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return s}dispose(){this.disposed=!0,this.tileset.reset(),this.tileset.root.children.length=0,/^blob\:/.test(this.tileset.id)&&URL.revokeObjectURL(this.tileset.id);for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);this.refined=!1,this.loaded=!1,this.refineProgress[0]=this.refineProgress[1]=0,this.error=null,this.onError=void 0,this.renderer=void 0}get model(){return this.parent}get scene(){return this}get viewLayer(){return this}localToEnu(e){return e.applyMatrix4(p_)}enuToLocal(e){return e.applyMatrix4(f_)}enuToEcef(e){return e.applyMatrix4(this.coordinateSystem.enuToEcefMatrix)}ecefToEnu(e){return e.applyMatrix4(this.coordinateSystem.ecefToEnuMatrix)}localToEcef(e){return this.enuToEcef(this.localToEnu(e))}ecefToLocal(e){return this.enuToLocal(this.ecefToEnu(e))}localToLla(e){return s_(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(c_(e)))}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}worldToEcef(e){return this.localToEcef(this.worldToLocal(e))}ecefToWorld(e){return this.localToWorld(this.ecefToLocal(e))}worldToLla(e){return this.localToLla(this.worldToLocal(e))}llaToWorld(e){return this.localToWorld(this.llaToLocal(e))}get coordinates(){M_.setScalar(0);let{x:e,y:t}=this.localToLla(M_);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new l.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(f_),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new l.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return M_.copy(e),this.worldToLla(M_),{latitude:M_.x,longitude:M_.y,altitude:M_.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minLevelOfDetail`,...e)}set minLevelOfDetail(e){this.parameter.set(`minLevelOfDetail`,e)}get maxLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxLevelOfDetail`,...e)}set maxLevelOfDetail(e){this.parameter.set(`maxLevelOfDetail`,e)}get minGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minGeometricError`,...e)}set minGeometricError(e){this.parameter.set(`minGeometricError`,e)}get maxGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxGeometricError`,...e)}set maxGeometricError(e){this.parameter.set(`maxGeometricError`,e)}get panoramaMinGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`panoramaMinGeometricError`,...e)}set panoramaMinGeometricError(e){this.parameter.set(`panoramaMinGeometricError`,e)}get skipLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`skipLevelOfDetail`,...e)}set skipLevelOfDetail(e){this.parameter.set(`skipLevelOfDetail`,e)}get mostDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`mostDetail`,...e)}set mostDetail(e){this.parameter.set(`mostDetail`,e)}get loadSiblings(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`loadSiblings`,...e)}set loadSiblings(e){this.parameter.set(`loadSiblings`,e)}get maxMemoryUsage(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxMemoryUsage`,...e)}set maxMemoryUsage(e){this.parameter.set(`maxMemoryUsage`,e)}get maxRequests(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxRequests`,...e)}set maxRequests(e){this.parameter.set(`maxRequests`,e)}get requestOrder(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`requestOrder`,...e)}set requestOrder(e){this.parameter.set(`requestOrder`,e)}get maxScreenSpaceError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},G_={};function K_(e,t){let n=G_[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function q_(e,t,n){let r=G_[e];r||(r=G_[e]=new WeakMap),r.has(t)||r.set(t,n)}var J_=new l.Matrix4,Y_=new l.Vector3,X_=new l.Matrix4;function Z_(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:l_(t,n);break;default:n.identity();break}return n}function Q_(e){var t;let[n,r]=e.tilesetUrl.split(`#`),i=(t=(r||n).split(`?`)[1])==null?``:t;return e.fetcher.ajax(e.tilesetUrl,{responseType:`text`}).catch(e=>({error:e,body:JSON.stringify({asset:{version:`0.0`},geometricError:0,root:{geometricError:0}})})).then(t=>{var n;let r=`error`in t?t.error:null,a=Am(JSON.parse(t.body),e.tilesetUrl),{root:o,rootMeta:s={}}=a,c=e.upAxis;s.upAxis&&s.upAxis!==c&&(c=s.upAxis),`lodVersion`in a&&(c=`-Y`,`floorInfo`in a&&(a.properties=a.properties||{},a.properties.floorInfo=a.floorInfo.map(e=>({ground:-e.ground,height:e.height})),a.floorInfo=void 0),a.asset.tilesetVersion=String(a.lodVersion),a.lodVersion=void 0);let u=c,d=new l.Matrix4;u===`Y`?(u=`Z`,d.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):u===`-Y`&&(u=`Z`,d.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let f=o.boundingVolume?kf(o.boundingVolume):void 0;f&&o.transform&&f.applyMatrix4(X_.fromArray(o.transform));let p=null,m=new l.Matrix4,h=new l.Matrix4;return s.coordinate?(p=s.coordinate.ground_height,m.fromArray(s.coordinate.pose_ecef_to_enu),h.fromArray(s.coordinate.pose_enu_to_ecef)):(f?f.getCenter(Y_):Y_.setScalar(0),Y_.applyMatrix4(d),Z_(u,Y_,m),h.copy(m).invert()),a.root={refine:(n=o.refine)==null?`REPLACE`:n,geometricError:o.geometricError,transform:X_.copy(d).premultiply(u===`Z`?J_:m).premultiply(f_).toArray(),boundingVolume:f?f.toJson():void 0,children:[o]},new W_(a,{name:e.name,type:e.type,upAxis:c,light:e.light,fetcher:e.fetcher,search:i,groundHeight:p,coordinateSystem:{enuToEcefMatrix:h,ecefToEnuMatrix:m},error:r})})}function $_(e,t){var n;let r=e.layers.map(e=>({tilesetUrl:e.work.getURL(e.tileset),name:e.name,type:e.type,upAxis:e.upAxis,light:t.light,fetcher:t.fetcher}));if(e.file){let i=!1;for(let e of r)if(e.type===`mesh`){i=!0;break}if(i===!1){let i=oc(e.file)||`.at3d`,a=JSON.stringify({tilesetUrl:``,asset:{version:`0.0`},geometricError:0,root:{refine:`REPLACE`,geometricError:0,transform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],content:{uri:e.work.getURL(e.file)},extras:{[i.slice(1)]:{upAxis:e.upAxis,textureBaseUri:typeof e.textureBase==`string`?e.work.getURL(e.textureBase):void 0,textureArray:e.textures,textureOptions:(n=t.textureOptions)==null?{}:n}}},rootMeta:{coordinate:e.coordinate}});r.push({name:`fallback`,type:`mesh`,upAxis:`Z`,tilesetUrl:URL.createObjectURL(new Blob([a],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let i=r.map(e=>Q_(e).then(e=>e));return Promise.all(i)}function ev(e=1,t=1,n=1){let r=e/2,i=t/2,a=n/2,o=new Float32Array([-r,+i,+a,+r,+i,+a,+r,+i,-a,-r,+i,-a,-r,-i,+a,+r,-i,+a,+r,-i,-a,-r,-i,-a]),s=new Uint32Array([0,4,1,1,4,5,1,5,2,2,5,6,2,6,3,3,6,7,3,7,0,0,7,4,3,0,2,2,0,1,4,7,5,5,7,6]),c=new l.BufferGeometry;return c.setAttribute(`position`,new l.BufferAttribute(o,3)),c.setIndex(new l.BufferAttribute(s,1)),c.addGroup(0,c.index.count,0),c.computeBoundingBox(),c.computeBoundingSphere(),c}function tv(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=new l.BufferGeometry,c=0,u=0;u<e.length;++u){var d=e[u];if(n!==(d.index!==null))return null;for(var f in d.attributes){if(!r.has(f))return null;a[f]===void 0&&(a[f]=[]),a[f].push(d.attributes[f])}for(var f in d.morphAttributes){if(!i.has(f))return null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(s.userData.mergedUserData=s.userData.mergedUserData||[],s.userData.mergedUserData.push(d.userData),t){var p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return null;s.addGroup(c,p,u),c+=p}}if(n){for(var m=0,h=[],u=0;u<e.length;++u){for(var g=e[u].index,_=0;_<g.count;++_)h.push(g.getX(_)+m);m+=e[u].attributes.position.count}s.setIndex(h)}for(var f in a){var v=nv(a[f]);if(!v)return null;s.setAttribute(f,v)}for(var f in o){var y=o[f][0].length;if(y===0)break;s.morphAttributes=s.morphAttributes||{},s.morphAttributes[f]=[];for(var u=0;u<y;++u){for(var b=[],_=0;_<o[f].length;++_)b.push(o[f][_][u]);var x=nv(b);if(!x)return null;s.morphAttributes[f].push(x)}}return s}function nv(e){for(var t,n,r,i=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute||(t===void 0&&(t=o.array.constructor),t!==o.array.constructor)||(n===void 0&&(n=o.itemSize),n!==o.itemSize)||(r===void 0&&(r=o.normalized),r!==o.normalized))return null;i+=o.array.length}for(var s=new t(i),c=0,a=0;a<e.length;++a)s.set(e[a].array,c),c+=e[a].array.length;return new l.BufferAttribute(s,n,r)}function rv(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},u={},d=[],f=[`getX`,`getY`,`getZ`,`getW`],p=0,m=s.length;p<m;p++){var h=s[p];c[h]=[];var g=e.morphAttributes[h];g&&(u[h]=Array(g.length).fill().map(()=>[]))}for(var _=Math.log10(1/t),v=Math.pow(10,_),p=0;p<a;p++){for(var y=r?r.getX(p):p,b=``,x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),C=S.itemSize,w=0;w<C;w++)b+=`${~~(S[f[w]](y)*v)},`;if(b in n)d.push(n[b]);else{for(var x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),g=e.morphAttributes[h],C=S.itemSize,T=c[h],E=u[h],w=0;w<C;w++){var D=f[w];if(T.push(S[D](y)),g)for(var O=0,k=g.length;O<k;O++)E[O].push(g[O][D](y))}n[b]=o,d.push(o),o++}}let A=e.clone();for(var p=0,m=s.length;p<m;p++){var h=s[p],j=e.getAttribute(h),M=new j.array.constructor(c[h]),S=new l.BufferAttribute(M,j.itemSize,j.normalized);if(A.setAttribute(h,S),h in u)for(var x=0;x<u[h].length;x++){var N=e.morphAttributes[h][x],M=new N.array.constructor(u[h][x]),ee=new l.BufferAttribute(M,N.itemSize,N.normalized);A.morphAttributes[h][x]=ee}}return A.setIndex(d),A}var iv=new l.Sphere,av=new l.Matrix4,ov=new l.Matrix4;function sv(e,t,n=30/180*Math.PI){let r=Math.cos(n),i=[];for(let n of e.children)n instanceof W_&&n.tileset.selectedTiles.forEach(e=>{var n,a,o;let s=(a=(n=e.content)==null?void 0:n.data)==null?void 0:a.object;if(s&&s.visible){let e=[];if(s.traverseVisible(n=>{if(n instanceof l.Mesh){let r=Pp(n);if(r){av.copy(n.matrixWorld),ov.copy(av).invert(),iv.copy(t).applyMatrix4(ov);let i=r.trianglesInSphere(iv.center,iv.radius),a=new l.BufferGeometry;a.setAttribute(`position`,new l.BufferAttribute(i,3)),a.applyMatrix4(n.matrixWorld),a=rv(a,.01),e.push(a)}}}),e.length===0)return;let n=[`a`,`b`,`c`],a=tv(e,!1),c=a.getAttribute(`position`).array,u=((o=a.getIndex())==null?void 0:o.array)||[],d=[],f=[];for(let e=0,t=c.length;e<t;e+=3){let t=new l.Vector3(c[e],c[e+1],c[e+2]);d.push(t)}for(let e=0,t=u.length;e<t;e+=3){let t=u[e],n=u[e+1],r=u[e+2],i=new l.Vector3().crossVectors(d[n].clone().sub(d[t]),d[r].clone().sub(d[t])).normalize();f.push({a:t,b:n,c:r,normal:i})}let p={};for(let e=0,t=f.length;e<t;e++){let t=f[e];for(let r=0;r<3;r++){let i=t[n[r]],a=t[n[(r+1)%3]],o=[Math.min(i,a),Math.max(i,a)],s=o[0]+`-`+o[1];p[s]===void 0?p[s]={index1:o[0],index2:o[1],face1:e}:p[s].face2=e}}for(let e in p){let t=p[e];if(t.face2===void 0||f[t.face1].normal.dot(f[t.face2].normal)<=r){let e=d[t.index1],n=d[t.index2];i.push(new l.Line3(e,n))}}d.length=0,f.length=0}});return i}var cv=new l.Box3,lv=new l.Box3,uv=new l.Box3,dv=class extends l.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new X,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new l.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let i=0;for(let e of t.observers)i=Math.max(i,e.floorIndex);if(this.floorLength=i+1,t.model){this.metaPending=!0;let e=$_(t.model,{fetcher:K_(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),i=e=>this.dispatchEvent({type:`error`,error:e}),a=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),o=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,s=null;for(let t of e){if(t.visible=!1,t.onError=i,t.onTileLoad=a,t.onTileUnload=o,t.error){i(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):s===null&&(s=t)}let c=(t=n==null?r:n)==null?s:t;if(c&&(c.visible=!0),e.length)if(this.disposed)for(let t of e)t.dispose();else this.add(...e);return this}),this.loadedReady=new Promise(e=>{let t=()=>{e(this),this.removeEventListener(`load`,t),this.removeEventListener(`dispose`,t)};this.addEventListener(`load`,t),this.addEventListener(`dispose`,t)})}else this.refined=!0,this.loaded=!0,this.initReady=Promise.resolve(this),this.loadedReady=Promise.resolve(this);this.parameter.set(`boundingBox`,this.boundingBox.clone())}dispose(){this.disposed=!0;let e;for(;e=this.children[0];)typeof e.dispose==`function`&&e.dispose(),e.onError=void 0,e.onTileLoad=void 0,e.onTileUnload=void 0,this.remove(e);this.dispatchEvent({type:`dispose`})}get empty(){return this.children.length===0}get viewLayers(){return this.children}getEdgesBySphere(e,t=30/180*Math.PI){return sv(this,e,t)}intersectRaycaster(e,t){let n=t==null?[]:t,r=e.sortByDistance;e.sortByDistance=!1;for(let t=0,r=this.children.length;t<r;t++){let r=this.children[t];r.visible&&typeof r.intersectRaycaster==`function`&&r.intersectRaycaster(e,n)}return e.sortByDistance=r,Kf(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let i=this.loaded;this.refined=!this.metaPending,this.loaded=!this.metaPending,this.refineProgress[0]=this.refineProgress[1]=0,this.work.transform.equals(this.matrix)||(this.matrix.copy(this.work.transform),this.matrix.decompose(this.position,this.quaternion,this.scale),this.matrixAutoUpdate=!1,r=!0);for(let i of this.children)i.autoRefine=this.autoRefine,i.update(e,t,n,this)&&(r=!0),i.refined===!1&&(this.refined=!1),i.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=i.refineProgress[0],this.refineProgress[1]+=i.refineProgress[1];cv.makeEmpty(),uv.copy(this.work.observerBox),uv.isEmpty()||(uv.max.x+=1,uv.max.z+=1,uv.max.y+=1,--uv.min.x,--uv.min.z,cv.union(uv));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(lv.copy(e.boundingBox),cv.union(lv));return cv.applyMatrix4(this.matrix),cv.equals(this.boundingBox)||(this.boundingBox.copy(cv),this.parameter.set(`boundingBox`,cv.clone())),i===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(p_)}enuToLocal(e){return e.applyMatrix4(f_)}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}get shownFloor(){return this.shownFloorIndex===-1?null:this.shownFloorIndex}set shownFloor(e){this.shownFloorIndex=e===null?-1:e}show(e){this.shownFloor=e==null?null:e,this.dispatchEvent({type:`changeShownFloor`,floorIndex:e==null?null:e})}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).shownFloorIndex}set shownFloorIndex(e){this.parameter.set(`shownFloorIndex`,e)}get brightness(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).brightness}set brightness(e){this.parameter.set(`brightness`,e)}get clippers(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).clippers}set clippers(e){this.parameter.set(`clippers`,e)}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.viewLayers)e.resetBrightness()}};function Z(e,t,n){return Object.defineProperty(e,t,n)}var fv=ev(1,1,1);fv.applyMatrix4(new l.Matrix4().makeScale(-1,1,1));var pv=new WeakMap,mv=new l.Vector3(1,1,1),hv=new l.Box3,gv=new l.Vector3,_v=new l.Box3,vv=new l.Vector3,yv=new l.Vector3,bv=class extends kt{constructor(e={}){var t;let n=new Pr;n.colorAlpha=0,n.alphaMode=`BLEND`,n.depthWrite=!1,n.transparent=!1,n.blending=l.CustomBlending,n.blendSrc=l.SrcAlphaFactor,n.blendDst=l.OneMinusSrcAlphaFactor,n.blendSrcAlpha=l.OneFactor,n.blendDstAlpha=l.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(fv,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999}update(e,t,n){let r=!1,i=X.resolveValue(n.parameter);hv.copy(i.boundingBox),hv.getSize(gv);let a=Math.min(gv.x/2,500);hv.min.x-=a,hv.max.x+=a;let o=Math.min(gv.y/2,500);hv.min.z-=o,hv.max.z+=o;let s=gv.length()/2;if(hv.max.y=Math.max(hv.max.y,s),hv.union(_v.setFromCenterAndSize(t.position,mv)),hv.expandByScalar(1),hv.getCenter(vv),hv.getSize(yv),vv.equals(this.position)||(this.position.copy(vv),r=!0),yv.equals(this.scale)||(this.scale.copy(yv),r=!0),pv.get(this)!==i.versionNumber){pv.set(this,i.versionNumber),r=!0;let e=this.material;for(let t of e)Qt(t,i),t.visible=t.opacity!==0}return r}dispose(){for(let e of this.material)e.dispose()}},xv=new l.Box3,Sv=class extends l.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new l.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new X,this.fiveId=e.fiveId,this.boundingMesh=new bv({name:`bounding`}),this.add(this.boundingMesh);let t=this.models=[];this.shownModels=[],this.updateModelMap=new Map,this.parameter.set(`boundingBox`,this.boundingBox.clone());let n=this;Z(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),Z(t,`bounding`,{get(){return n.boundingBox}}),Z(t,`loaded`,{get(){return n.loaded}}),Z(t,`refined`,{get(){return n.refined}}),Z(t,`refineProgress`,{get(){return n.refineProgress}}),Z(t,`cacheCameras`,{get(){return n.parameter.resolveValue().cacheCameras},set(e){n.parameter.set(`cacheCameras`,e)}}),Z(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),Z(t,`setMaterial`,{value:e=>n.setMaterial(e)}),Z(t,`getMaterial`,{value:()=>n.getMaterial()}),Z(t,`resetBrightness`,{value:()=>n.resetBrightness()})}setModels(e,t){let n=e.map(e=>{let n=this.shownModels.filter(t=>t.work.workCode===e.workCode)[0];if(n||(n=this.models.filter(t=>t.work.workCode===e.workCode)[0],n))return n.work=e,n;n=new dv(this.fiveId,e,{light:t.light,textureOptions:t.textureOptions});let r=t[`3d-tiles`];return n.initReady.then(()=>{if(r)if(typeof r==`function`)for(let e of n.viewLayers){let t=r(e,n);t&&(t.viewerRequestVolume&&(e.viewerRequestVolume=kf(t.viewerRequestVolume)),e.parameter.set(Qs(t,[`showLayers`])),t.showLayers===!1?e.visible=!1:Array.isArray(t.showLayers)&&(e.visible=t.showLayers.includes(e.name)))}else for(let e of n.viewLayers)r.viewerRequestVolume&&(e.viewerRequestVolume=kf(r.viewerRequestVolume)),e.parameter.set(Qs(r,[`showLayers`])),r.showLayers===!1?e.visible=!1:Array.isArray(r.showLayers)&&(e.visible=r.showLayers.includes(e.name))}),this.dispatchEvent({type:`model.create`,model:n}),n});for(let e=0;e<this.models.length;e++){let t=this.models[e];n.indexOf(t)===-1&&this.shownModels.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.models.length=0;for(let e=0;e<n.length;e++){let t=n[e];this.models.push(t)}if(t.forceReplaceImmediately&&!Vf(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e])}return this.loaded=!1,this.refined=!1,this.models}get empty(){return this.boundingBox.isEmpty()}intersectRaycaster(e,t){let n=t==null?[]:t,r=this.shownModels.filter(e=>e.visible);if(r.length===1)r[0].intersectRaycaster(e,n);else{let t=e.sortByDistance;e.sortByDistance=!1;for(let t of r)t.intersectRaycaster(e,n);e.sortByDistance=t,Kf(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;xv.makeEmpty(),this.loaded=this.models.length>0,this.refined=this.models.length>0,this.refineProgress[0]=this.refineProgress[1]=0,this.updateModelMap.clear();for(let n=0;n<this.models.length;n++){let r=this.models[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;this.autoRefine===!1&&(r.autoRefine=!1);let i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}r.loaded===!1&&(this.loaded=!1),r.refined===!1&&(this.refined=!1),this.refineProgress[0]+=r.refineProgress[0],this.refineProgress[1]+=r.refineProgress[1]}if((this.loaded===!0||this.models.length===0)&&!Vf(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e]);n=!0}for(let n=0;n<this.shownModels.length;n++){let r=this.shownModels[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;(this.autoRefine===!1||this.models.indexOf(r)<0)&&(r.autoRefine=!1);let i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof dv&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),xv.union(t.boundingBox),this.add(t)}for(let e=0;e<this.models.length;e++){let t=this.models[e];this.shownModels.indexOf(t)===-1&&xv.union(t.boundingBox)}return xv.equals(this.boundingBox)||(this.boundingBox.copy(xv),this.parameter.set(`boundingBox`,this.boundingBox.clone()),n=!0),this.boundingMesh.update(e,t,this)&&(n=!0),this.updateModelMap.clear(),this.needsRender=n,n}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){return this.parameter.resolveValue()}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.models)e.resetBrightness()}dispose(){this.remove(this.boundingMesh),this.boundingMesh.dispose();for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof dv&&this.remove(t)}let e=Uf(this.models.concat(this.shownModels));for(let t=0;t<this.shownModels.length;t++)e[t].dispose();this.models.length=0,this.shownModels.length=0}};function Cv(e){let t={};return e.mode!==void 0&&(t.mode=e.mode),e.panoIndex!==void 0&&(t.pano_index=e.panoIndex),e.longitude!==void 0&&(t.longitude=e.longitude),e.latitude!==void 0&&(t.latitude=e.latitude),e.fov!==void 0&&(t.fov=e.fov),e.distance!==void 0&&(t.distance=e.distance),e.offset!==void 0&&(t.offset=e.offset.toArray()),t}function wv(e){var t;if(e)return{file_url:e.file,material_base_url:e.textureBase,material_textures:(t=e.textures)==null?void 0:t.slice(),up_axis:e.upAxis,layers:e.layers.map(e=>({tileset_url:e.tileset,up_axis:e.upAxis,name:e.name,type:e.type}))}}function Tv(e){return{index:e.index,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,floor_index:e.floorIndex,position:e.position.toArray(),standing_position:e.standingPosition.toArray(),quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w},visible_nodes:e.accessibleNodes.slice(),accessible_nodes:e.accessibleNodes.slice()}}function Ev(e){return{index:e.index,active:e.active,loadable:e.loadable,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,size_list:e.images.sizeList.slice(),up:e.images.up,down:e.images.down,right:e.images.right,left:e.images.left,front:e.images.front,back:e.images.back,video:e.images.video?{matrix:e.images.video.matrix.toArray(),size:e.images.video.size.toArray(),source:e.images.video.source}:void 0}}function Dv(e){return{allow_hosts:e.allowHosts.slice(),expire_at:e.expire.getTime().toString(),project_id:e.projectId,code:e.workCode,name:e.name,base_url:e.baseURL,initial:Cv(e.initial),model:wv(e.model),observers:e.observers.map(e=>Tv(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>Ev(e))}}}function Ov(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t),s=i*a,c=r,u=i*o,d=Math.abs(s),f=Math.abs(c),p=Math.abs(u),m,h;if(d>=f&&d>=p){let e=1/d;s>0?(m=`right`,h=new l.Vector2(-u*e,c*e)):(m=`left`,h=new l.Vector2(u*e,c*e))}else if(f>=d&&f>=p){let e=1/f;c>0?(m=`up`,h=new l.Vector2(s*e,-u*e)):(m=`down`,h=new l.Vector2(s*e,u*e))}else{let e=1/p;u>0?(m=`front`,h=new l.Vector2(s*e,c*e)):(m=`back`,h=new l.Vector2(-s*e,c*e))}return h.x=(h.x+1)/2,h.y=1-(h.y+1)/2,[m,h]}function kv(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,i=0,a=0,o=0;switch(e){case`right`:i=1,a=r,o=-n;break;case`left`:i=-1,a=r,o=n;break;case`up`:i=n,a=1,o=-r;break;case`down`:i=n,a=-1,o=r;break;case`front`:i=n,a=r,o=1;break;case`back`:i=-n,a=r,o=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let s=Math.sqrt(i*i+a*a+o*o);if(s===0)return new l.Vector2(.5,.5);i/=s,a/=s,o/=s;let c=Math.atan2(i,o),u=Math.asin(Math.max(-1,Math.min(1,a))),d=(c+Math.PI)/(2*Math.PI),f=(Math.PI/2-u)/Math.PI;return d%=1,d=d<0?d+1:d,f=Math.max(0,Math.min(1,f)),new l.Vector2(d,f)}function Av(e,t=`top-left`){let n=new l.Quaternion().setFromRotationMatrix(this.work.transform).invert(),r=new l.Quaternion().copy(this.quaternion).invert(),i=new l.Quaternion(0,1,0,0).invert(),a=new l.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(i),o=Math.atan2(a.x,-a.z),s=Math.asin(-a.y);if(t===`top-left`)return new l.Vector2(o/(Math.PI*2)+.5,s/Math.PI+.5);if(t===`bottom-left`)return new l.Vector2(o/(Math.PI*2)+.5,.5-s/Math.PI);throw Error(`Invalid uvOrigin ${t}`)}function jv(e,t=`top-left`){let n=0;if(t===`top-left`)n=1;else if(t===`bottom-left`)n=-1;else throw Error(`Invalid uvOrigin ${t}`);let r=new l.Quaternion().setFromRotationMatrix(this.work.transform),i=new l.Quaternion().copy(this.quaternion),a=new l.Quaternion(0,1,0,0),o=Math.PI*2*(e.x+.5),s=Math.PI*(e.y-.5),c=Math.abs(Math.cos(s)),u=Math.sin(o)*c,d=-Math.sin(s)*n,f=-Math.cos(o)*c;return new l.Vector3(u,d,f).applyQuaternion(a).applyQuaternion(i).applyQuaternion(r)}function Mv(e,t=`top-left`){let n=Ov(this.vectorToEquirectangularUv(e,`top-left`));if(t===`top-left`)return n;if(t===`bottom-left`){let[e,t]=n;return t.y=1-t.y,n}else throw Error(`Invalid uvOrigin ${t}`)}function Nv(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new l.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let i=kv(e,r);return this.equirectangularUvToVector(i)}function Pv(){return new l.Vector3().copy(this.position).applyMatrix4(this.work.transform)}function Fv(){return new l.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}function Iv(e){return typeof e==`number`}function Lv(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:Lv(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:Lv(r)}return t}}function Rv(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function zv(e,t){let n=Rv(e),r=Rv(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return Lv(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=zv(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=zv(e[n],t[n]);return e}function Bv(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=Bv(e[r],!1)+`,`;return n>-1&&(t+=Bv(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return Bv(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=Bv(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:return JSON.stringify(e.toString());case`undefined`:return t?void 0:null;case`number`:return e;default:return isFinite(e)?e:null}}function Vv(e){return Bv(e,!1)}function Hv(e){return`hash::${_t(Vv(e))}`}var Uv=/^(.*)\[(\d+)\]$/;function Wv(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function Gv(e){let t=e.match(Uv);if(t){let[e,n,r]=t,i=Math.floor(Number(r));if(!isNaN(i)&&isFinite(i))return{workCode:n,panoIndex:i}}throw Error(`Invalid PanoId`)}function Kv(e,t){return Wv(e)===Wv(t)}function qv(e){return typeof e==`string`&&Uv.test(e)}var Jv=`\\{([^\\}]+)\\}`;function Yv(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Xv(e){return RegExp(`^`+e.map(e=>Yv(e)).join(`(.+)`)+`$`)}var Zv=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(Jv,`g`),n,r=0;for(;(n=t.exec(e))!==null;)this.strings.push(e.slice(r,n.index)),this.keys.push(n[1]),r=n.index+n[0].length;this.strings.push(e.slice(r))}stringify(e){let t=[this.strings[0]];for(let n=0;n<this.keys.length;n++){let r=e[this.keys[n]];t.push(String(r),this.strings[n+1])}return t.join(``)}match(e){var t;this.matchRegexp=(t=this.matchRegexp)==null?Xv(this.strings):t;let n=e.match(this.matchRegexp);if(!n)return null;let r={};for(let e=0;e<this.keys.length;e++){let t=this.keys[e],i=n[e+1];if(r[t]!==i){if(r[t]!==void 0)return null;r[t]=i}}return r}};function Qv(e){Object.freeze(e);let t=typeof e==`function`,n=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach(function(r){n.call(e,r)&&(!t||r!==`caller`&&r!==`callee`&&r!==`arguments`)&&e[r]!==null&&(typeof e[r]==`object`||typeof e[r]==`function`)&&!Object.isFrozen(e[r])&&Qv(e[r])}),e}var $v=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,ey=Qv(JSON.parse(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/rnyrr;p{/9/rnyrr;p|z/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/rnyrr;nv/9/;p{/9/pq{;p{/9/pnyp{|qr;vr/j`))),ty=/^([^.]+)(\.([^.]+))*$/,ny=typeof location<`u`?location.hostname:`localhost`;function ry(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function iy(e,t){if(!ty.test(e)||!ty.test(t))return!1;if(e===`*`)return!0;let n=e.split(`.`).reverse(),r=t.split(`.`).reverse();if(n.length<=1)return e===t;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function ay(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return ny;let t=e.match($v);return t?t[2]:ny}var oy=()=>Error(`Invalid input.`),sy=()=>Error(`Invalid certificate.`),cy=()=>Error(`Invalid signature.`),ly=e=>Error(`Date(${e.toString()}) expired.`),uy=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function dy(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function fy(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=fy(e[r],!1)+`,`;return n>-1&&(t+=fy(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return fy(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=fy(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function py(e){return String(fy(e,!1))}function my(e){var t,n,r;let i={};try{i=typeof e==`string`?JSON.parse(e):e}catch(e){return oy()}if(typeof i!=`object`)return oy();let a=ny,o=Date.now(),s=new Date(typeof i.expire_at==`string`&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at),c=Array.isArray(i.allow_hosts)?i.allow_hosts:[];if(a.length===0||ry(a)||ey.filter(e=>iy(e,a)).length>0){let e=String((t=i.certificate)==null?``:t);if(e)try{let t=new V;return t.readCertPEM(e),Qv({issuer:t.getSubjectString(),expire:s,allowHosts:c})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return Qv({issuer:`none`,expire:s,allowHosts:c})}let l=String((n=i.certificate)==null?``:n);if(!l)return sy();let u=new V;u.readCertPEM(l);let d=String((r=i._signature)==null?``:r);return!d||Ct(py(dy(i,[`_signature`])),d,u)===!1?cy():o<s.getTime()?ey.concat(c).filter(e=>iy(e,a)).length===0?uy(a):Qv({issuer:u.getSubjectString(),expire:s,allowHosts:c}):ly(s)}function hy(e,t){let n=ay(e);return ny.length!==0&&!ry(ny)&&ey.filter(e=>iy(e,ny)).length===0&&!ry(n)&&ey.concat(t).filter(e=>iy(e,n)).length===0?uy(n):e}var gy=new Set,_y=new l.Vector3(1,1,1),vy=[`right`,`left`,`up`,`down`,`front`,`back`],yy=[`gainmap_right`,`gainmap_left`,`gainmap_up`,`gainmap_down`,`gainmap_front`,`gainmap_back`],by={vectorToEquirectangularUv:Av,vectorToCubemapUv:Mv,equirectangularUvToVector:jv,cubemapUvToVector:Nv,getWorldPosition:Pv,getWorldStandingPosition:Fv};function xy(e,t){if(!tc(e))return e;if(e.indexOf(t)===0)return e.slice(t.length);let n=t.replace(/^https\:/,`http:`);if(e.indexOf(n)===0)return e.slice(n.length);let r=t.replace(/^http\:/,`https:`);return e.indexOf(r)===0?e.slice(r.length):(console.warn(`${e} is not start with base_url(${t}).`),e)}function Sy(e,t,n){return!tc(e)&&typeof t==`string`&&t.length>0&&(e=rc(t,String(n),e)),e}function Cy(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function wy(e){e=e.slice().sort((e,t)=>e.level-t.level);let t=[];for(let n of e){if(t.length===0){t.push(n);continue}let e=t[t.length-1];if(n.level>e.level){t.push(n);continue}if(n.size>e.size){t[t.length-1]=n;continue}}return t}function Ty(e){let{manifest:t,baseURL:n}=e,r=[];return t.forEach((e,t)=>{let i={index:t,derived_id:e.derived_id,size_list:e.size_list,hdr_config:rc(n,e.cfg)};vy.forEach(t=>{i[t]=rc(n,e[t])}),yy.forEach(t=>{i[t]=rc(n,e[t])}),r.push(i)}),r}function Ey(e,t){var n,r,i,a,o,s,c,u,d,f,p,m,h,g,_,v,y,b,x;let S=[],C=null;for(let t of[].concat(e))if(`getURL`in t)C={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},S.push(Dv(t));else{let e=typeof t==`string`?JSON.parse(t):Lv(t),n=my(e);if(n instanceof Error)return n;C===null&&(C=n),S.push(e)}if(C===null)return Error(`Empty`);Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:C.issuer}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.expire)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.allowHosts)});let w=S.reduce((e,t)=>zv(e,t));Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=w.name)==null?`Unknown`:n)}),Z(t,`workCode`,{enumerable:!0,writable:!0,value:String(w.resource_code||w.basic_code||w.vr_code||w.code||w.project_id||w.work_code||w.workCode||Ft())}),Z(t,`projectId`,{enumerable:!0,writable:!0,value:w.project_id}),Z(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=w.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let T;typeof w.model==`object`&&(T={},Z(T,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(T,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.file_url;if(e)return xy(e,t.baseURL)})()}),Z(T,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.material_base_url;return e&&(e=xy(e,t.baseURL)),e})()}),Z(T,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(w.model.material_textures)&&(e=w.model.material_textures.slice(),Object.freeze(e)),e})()}),Z(T,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:w.model.up_axis}),Z(T,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:Lv(w.model.coordinate)}),Z(T,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let i=[];if(Array.isArray(w.model.layers)){for(let a of w.model.layers)if(a&&a.tileset_url){let o={};Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=a.name)==null?``:e}),Z(o,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=a.type)==null?`mesh`:n}),Z(o,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=a.up_axis)==null?`Z`:r}),Z(o,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:xy(a.tileset_url,t.baseURL)}),i.push(o)}}if(typeof w.model.tiles==`object`){let e=w.model.tiles;if(e&&e.tileset_url){let n={};Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),Z(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),Z(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),Z(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:xy(e.tileset_url,t.baseURL)}),i.push(n)}}return Object.freeze(i)})()})),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:T});let E=[];if(Array.isArray(w.observers)&&w.panorama&&Array.isArray(w.panorama.list||w.panorama.info)){let e=w.observers,n=t.panoHDR?Ty(t.panoHDR):(r=w.panorama.list||w.panorama.info)==null?[]:r,S=(u=(s=(a=(i=w.panorama)==null?void 0:i.pano_high_cube_base_url)==null?(o=w.panorama)==null?void 0:o.pano_cube_base_url:a)==null?(c=w.panorama)==null?void 0:c.base_url:s)==null?``:u,C=Math.min(e.length,n.length),T={};for(let e of Object.keys((d=w.panorama.pattern)==null?{}:d)){let t=e,n=w.panorama.pattern[t];if(typeof n==`string`){let e=new Zv(n);T[t]=t=>e.stringify(t)}else T[t]=()=>n}let D=(e,t)=>{var n;let r=T[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<C;r++){let i=e[r],a=n[r],o=Object.create(by);Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),Z(o,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),Z(o,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Wv({workCode:t.workCode,panoIndex:r})}),Z(o,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(f=i.floor_index)==null?i.floor:f}),Z(o,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(m=(p=i.derived_id)==null?D(a,`derived_id`):p)==null?0:m}),Z(o,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(g=(h=i.derived_id_str)==null?D(a,`derived_id_str`):h)==null?String(o.derivedId):g}),Z(o,`active`,{enumerable:!0,configurable:!1,writable:!1,value:i.active!==!1&&D(a,`active`)!==!1}),Z(o,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(v=(_=i.loadable)==null?D(a,`loadable`):_)==null?!1:v}),Z(o,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Vector3().fromArray((y=i.position)==null?[0,0,0]:y))}),Z(o,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Vector3().fromArray((x=(b=i.standing_position)==null?i.standingPosition:b)==null?[0,0,0]:x))}),Z(o,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Quaternion().fromArray(i.quaternion?[i.quaternion.x,i.quaternion.y,i.quaternion.z,i.quaternion.w]:[0,0,0,1]))}),Z(o,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Matrix4().compose(o.position,o.quaternion,_y))}),Z(o,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(gy.clear(),i.accessible_nodes&&Array.isArray(i.accessible_nodes))for(let e of i.accessible_nodes)e>=C||e===r||gy.add(e);else if(i.accessibleNodes&&Array.isArray(i.accessibleNodes))for(let e of i.accessibleNodes)e>=C||e===r||gy.add(e);else if(i.visible_nodes&&Array.isArray(i.visible_nodes))for(let e of i.visible_nodes)e>=C||e===r||gy.add(e);else if(i.visibleNodes&&Array.isArray(i.visibleNodes))for(let e of i.visibleNodes)e>=C||e===r||gy.add(e);if(gy.size===0)for(let e=0;e<C;e++)e!==r&&gy.add(e);let e=Array.from(gy);return gy.clear(),Object.freeze(e)})()}),Z(o,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:o.accessibleNodes}),Z(o,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of vy)Z(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return xy(Sy((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});if(Z(e,`hdrConfig`,{enumerable:!0,configurable:!1,writable:!1,value:D(a,`hdr_config`)}),e.hdrConfig)for(let n of yy)Z(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return xy(Sy((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});return Z(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=Mc(e[vy[0]]),n=D(a,`size_list`),r=D(a,`tiles`);if(t){if(n){let e=n.slice().sort((e,t)=>e-t);return Object.freeze(e)}else if(r){let e=[t],n=r.slice().sort((e,t)=>e-t);for(let r of n){let n=512*Math.pow(2,r);n>t&&e.push(n)}return Object.freeze(e)}return Object.freeze([t])}return Object.freeze([])})()}),Z(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=Mc(e.front);if(!n)return;let i=e.sizeList.slice();if(i[0]){let e=Cy(i[0]);if(e)for(let t=e-1;t>=0;t--)i.unshift(512*Math.pow(2,t))}if(i.length<=0)return;let o=[];for(let s of i){let i=Cy(s);if(typeof i!=`number`)continue;let c={};if(Z(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:i}),s>n){Z(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),Z(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of vy)Z(c,t,{enumerable:!0,configurable:!1,writable:!1,value:Nc(e[t],s)});if(e.hdrConfig)for(let e of yy)Z(c,e,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var n;return Nc(xy(Sy((n=D(a,e))==null?``:n,S,r),t.baseURL),s)})()})}else{Z(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),Z(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/n});for(let t of vy)Z(c,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});if(e.hdrConfig)for(let e of yy)Z(c,e,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var n;return xy(Sy((n=D(a,e))==null?``:n,S,r),t.baseURL)})()})}o.push(c)}return o=wy(o),Object.freeze(o)})()}),Z(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=D(a,`video`),n;return e&&(n={},Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),Z(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Matrix4().fromArray(e.matrix)}),Z(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector2().fromArray(e.size)})),n})()}),e})()}),E.push(o)}}Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(E)});let D={};if(Z(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),w.initial){if(t.observers.length>0){let e;Iv(w.initial.panoIndex)?e=w.initial.panoIndex:Iv(w.initial.pano_index)?e=w.initial.pano_index:Iv(w.initial.pano)&&(e=w.initial.pano),typeof e==`number`&&(e=H(e,0,t.observers.length-1),Z(D,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(w.initial.mode===`Panorama`&&t.observers.length===0||w.initial.mode===`Floorplan`||w.initial.mode===`Topview`||w.initial.mode===`Model`||w.initial.mode===`Mapview`?Z(D,`mode`,{enumerable:!0,writable:!0,value:w.initial.mode}):typeof D.panoIndex==`number`?Z(D,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):Z(D,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),Iv(w.initial.latitude)&&Z(D,`latitude`,{enumerable:!0,writable:!0,value:w.initial.latitude}),Iv(w.initial.longitude)?Z(D,`longitude`,{enumerable:!0,writable:!0,value:w.initial.longitude}):Iv(w.initial.heading)&&Z(D,`longitude`,{enumerable:!0,writable:!0,value:Si(w.initial.heading)}),Iv(w.initial.fov)&&Z(D,`fov`,{enumerable:!0,writable:!0,value:w.initial.fov}),Iv(w.initial.distance)&&Z(D,`distance`,{enumerable:!0,writable:!0,value:w.initial.distance}),Array.isArray(w.initial.offset)){let e=w.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});Z(D,`offset`,{enumerable:!0,writable:!0,value:new l.Vector3().fromArray(t)})}else typeof w.initial.offset==`object`&&typeof w.initial.offset.x==`number`&&typeof w.initial.offset.y==`number`&&typeof w.initial.offset.z==`number`&&Z(D,`offset`,{enumerable:!0,writable:!0,value:new l.Vector3().fromArray([w.initial.offset.x,w.initial.offset.y,w.initial.offset.z])})}return Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:D}),t}function Dy(e,t){return Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),Z(t,`workCode`,{enumerable:!0,value:`null-`+Ft()}),Z(t,`baseURL`,{enumerable:!0,value:`/`}),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function Oy(e,t){var n,r;return Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),Z(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?Ft():r}),Z(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Wv({workCode:t.workCode,panoIndex:0})}),Z(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),Z(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),Z(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector3(0,1.5,0)}),Z(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector3(0,0,0)}),Z(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Quaternion(0,1,0,0)}),Z(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Matrix4().compose(n.position,n.quaternion,_y)}),Z(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),Z(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),Z(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of vy)Z(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return Z(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),Z(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=Mc(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=Cy(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let i=[];for(let a of r){let r=Cy(a);if(typeof r!=`number`)continue;let o={};if(Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>e){Z(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),Z(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of vy)Z(o,e,{enumerable:!0,configurable:!1,writable:!1,value:Nc(n[e],a)})}else{Z(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),Z(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/e});for(let e of vy)Z(o,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}i.push(o)}return i=wy(i),Object.freeze(i)})()}),Z(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),Z(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var ky=new WeakSet,Ay=class{constructor(e,t){this.observerBox=new l.Box3,this.observerBox=new l.Box3,this.transform=new l.Matrix4,this.shortPath=!1,this.jsonp=!1,t.panoHDR&&(this.panoHDR=t.panoHDR);let n;if(n=e===null?Dy(e,this):typeof e==`object`&&typeof e.size==`number`&&typeof e.up==`string`&&typeof e.down==`string`&&typeof e.right==`string`&&typeof e.left==`string`&&typeof e.front==`string`&&typeof e.back==`string`?Oy(e,this):Ey(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
889
+ `),a={name:``},o=/\s+/,s={};for(let e=0;e<i.length;e++){let t=i[e];if(t=t.trim(),t.length===0||t.charAt(0)===`#`)continue;let n=t.indexOf(` `),r=n>=0?t.substring(0,n):t;r=r.toLowerCase();let c=n>=0?t.substring(n+1):``;if(c=c.trim(),r===`newmtl`)a={name:c},s[c]=a;else if(r===`ka`||r===`kd`||r===`ks`||r===`ke`){let e=c.split(o,3);a[r]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else(r===`map_kd`||r===`map_ks`||r===`map_ke`||r===`norm`||r===`map_bump`||r===`bump`||r===`map_d`||r===`ns`||r===`d`||r===`tr`)&&(a[r]=c)}function c(e){let t={url:``,scale:new l.Vector2(1,1),offset:new l.Vector2(0,0),bumpScale:1},n=e.split(/\s+/),r;return r=n.indexOf(`-bm`),r>=0&&(t.bumpScale=parseFloat(n[r+1]),n.splice(r,2)),r=n.indexOf(`-s`),r>=0&&(t.scale.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),r=n.indexOf(`-o`),r>=0&&(t.offset.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),t.url=n.join(` `).trim(),t}function u(e,t,i){let a=c(i),o=rc(n.path,a.url);return r.loadTexture(o,{fetcher:n.fetcher,colorSpace:t===`map`||t===`emissiveMap`?l.SRGBColorSpace:l.LinearSRGBColorSpace,minFilter:l.LinearFilter,magFilter:l.LinearFilter,wrapS:l.RepeatWrapping,wrapT:l.RepeatWrapping}).then(n=>{let r=n.body;return r.repeat.copy(a.scale),r.offset.copy(a.offset),e.bumpScale=a.bumpScale,e[t]=r,r})}return{name:e,create:e=>{let t=Lr(n.light?`phong`:`basic`),r=[],i=s[e];if(i){if(i.kd!==void 0&&t.color.fromArray(i.kd),i.ks!==void 0&&t.specular.fromArray(i.ks),i.ke!==void 0&&t.emissive.fromArray(i.ke),i.map_kd!==void 0&&r.push(u(t,`map`,i.map_kd)),i.map_ks!==void 0&&r.push(u(t,`specularMap`,i.map_ks)),i.map_ke!==void 0&&r.push(u(t,`emissiveMap`,i.map_ke)),i.norm!==void 0&&r.push(u(t,`normalMap`,i.norm)),i.map_bump!==void 0&&r.push(u(t,`bumpMap`,i.map_bump)),i.bump!==void 0&&r.push(u(t,`bumpMap`,i.bump)),i.map_d!==void 0&&r.push(u(t,`alphaMap`,i.map_d)),i.ns!==void 0&&(t.shininess=parseFloat(i.ns)),i.d!==void 0){let e=parseFloat(i.d);e<1&&(t.opacity=e,t.transparent=!0)}if(i.tr!==void 0){let e=parseFloat(i.tr);e>0&&(t.opacity=1-e,t.transparent=!0)}}return[t,Promise.all(r).then(e=>e)]}}}function Sh(e,t){var n;let r=[],i=[],a=new l.Group;for(let o=0,s=e.objects.length;o<s;o++){let s=e.objects[o],c=s.geometry,u=s.materials,d=!1;if(c.vertices.length===0)continue;let f=new l.BufferGeometry;i.push(()=>f.dispose()),f.setAttribute(`position`,new l.BufferAttribute(new Float32Array(c.vertices),3)),c.normals.length>0&&f.setAttribute(`normal`,new l.BufferAttribute(new Float32Array(c.normals),3)),c.colors.length>0&&(d=!0,f.setAttribute(`color`,new l.BufferAttribute(new Float32Array(c.colors),3))),c.uvs.length>0&&f.setAttribute(`uv`,new l.BufferAttribute(new Float32Array(c.uvs),2)),c.index.length>0&&f.setIndex(new l.BufferAttribute(new Uint32Array(c.index),1)),f.computeBoundingBox(),f.computeBoundingSphere();let p=[];for(let n=0,a=u.length;n<a;n++){let a=u[n],o=a.name+`_`+a.smooth+`_`+d,s=e.materials[o];if(!s){let n=null;for(let{name:e,create:r}of t)e===a.mtllib&&(n=r(a.name));n||(n=[Lr(),Promise.resolve([])]),s=n[0],s.name=a.name,s.flatShading=!(a.smooth||f.attributes.normal),s.vertexColors=d,e.materials[o]=s;let c=n[1];r.push(c),i.push(()=>s.dispose())}p.push(s)}f.clearGroups();for(let e=0,t=u.length;e<t;e++){let t=u[e];t.groupCount&&f.addGroup((n=t.groupStart)==null?0:n,t.groupCount,e)}(!f.groups||f.groups.length===0)&&f.addGroup(0,f.index?f.index.count:f.attributes.position.count,0);let m=new kt(f,p);m.name=s.name,a.add(m)}return Promise.all(r).then(e=>{let t=[];for(let n of e)t=t.concat(n);return{scene:a,textures:t,dispose:()=>i.forEach(e=>e())}})}function Ch(e,t={}){var n,r,i,a;let o=(n=t.modelUpAxis)==null?`Z`:n,s=(r=t.upAxis)==null?`Z`:r,c=(i=t.fetcher)==null?Xs:i,l=(a=t.onDownloadProgress)==null?K:a,u=e.slice(0,e.lastIndexOf(`/`)+1),d=0,f;return Promise.resolve().then(()=>c.ajax(e,{responseType:`arraybuffer`},void 0,void 0,l)).then(e=>(d=e.body.byteLength,new TextDecoder().decode(e.body))).then(e=>(f=bh(e),Promise.all(f.materialLibraries.map(e=>{let n=rc(u,e),r=n.slice(0,n.lastIndexOf(`/`)+1);return c.ajax(n,{responseType:`text`}).then(n=>{var i;return xh(e,n.body,{path:r,light:(i=t.light)==null?!1:i,fetcher:c})})})))).then(e=>Sh(f,e)).then(t=>(o===`Y`&&t.scene.applyMatrix4(Ns),s===`Y`&&t.scene.applyMatrix4(Ps),{type:`obj`,modelUpAxis:o,upAxis:s,uri:e,byteLength:d,memoryUsage:hl(t.scene),scene:t.scene,textures:t.textures,animations:[],dispose:()=>t.dispose()}))}var wh=Uint8Array,Th=Uint16Array,Eh=Int32Array,Dh=new wh([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]),Oh=new wh([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]),kh=new wh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ah=function(e,t){for(var n=new Th(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Eh(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},jh=Ah(Dh,2),Mh=jh.b,Nh=jh.r;Mh[28]=258,Nh[258]=28;var Ph=Ah(Oh,0),Fh=Ph.b;Ph.r;for(var Ih=new Th(32768),Lh=0;Lh<32768;++Lh){var Rh=(Lh&43690)>>1|(Lh&21845)<<1;Rh=(Rh&52428)>>2|(Rh&13107)<<2,Rh=(Rh&61680)>>4|(Rh&3855)<<4,Ih[Lh]=((Rh&65280)>>8|(Rh&255)<<8)>>1}for(var zh=(function(e,t,n){for(var r=e.length,i=0,a=new Th(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Th(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Th(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ih[d]>>c]=l}else for(s=new Th(r),i=0;i<r;++i)e[i]&&(s[i]=Ih[o[e[i]-1]++]>>15-e[i]);return s}),Bh=new wh(288),Lh=0;Lh<144;++Lh)Bh[Lh]=8;for(var Lh=144;Lh<256;++Lh)Bh[Lh]=9;for(var Lh=256;Lh<280;++Lh)Bh[Lh]=7;for(var Lh=280;Lh<288;++Lh)Bh[Lh]=8;for(var Vh=new wh(32),Lh=0;Lh<32;++Lh)Vh[Lh]=5;var Hh=zh(Bh,9,1),Uh=zh(Vh,5,1),Wh=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Gh=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Kh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qh=function(e){return(e+7)/8|0},Jh=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new wh(e.subarray(t,n))},Yh=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Xh=function(e,t,n){var r=Error(t||Yh[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Xh),!n)throw r;return r},Zh=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new wh(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new wh(i*3));var l=function(e){var t=n.length;if(e>t){var r=new wh(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=Gh(e,d,1);var v=Gh(e,d+1,3);if(d+=3,!v){var y=qh(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Xh(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=Hh,m=Uh,h=9,g=5;else if(v==2){var S=Gh(e,d,31)+257,C=Gh(e,d+10,15)+4,w=S+Gh(e,d+5,31)+1;d+=14;for(var T=new wh(w),E=new wh(19),D=0;D<C;++D)E[kh[D]]=Gh(e,d+D*3,7);d+=C*3;for(var O=Wh(E),k=(1<<O)-1,A=zh(E,O,1),D=0;D<w;){var j=A[Gh(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+Gh(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+Gh(e,d,7),d+=3):y==18&&(N=11+Gh(e,d,127),d+=7);N--;)T[D++]=M}}var ee=T.subarray(0,S),P=T.subarray(S);h=Wh(ee),g=Wh(P),p=zh(ee,h,1),m=zh(P,g,1)}else Xh(1);if(d>_){c&&Xh(0);break}}s&&l(f+131072);for(var te=(1<<h)-1,F=(1<<g)-1,ne=d;;ne=d){var M=p[Kh(e,d)&te],re=M>>4;if(d+=M&15,d>_){c&&Xh(0);break}if(M||Xh(2),re<256)n[f++]=re;else if(re==256){ne=d,p=null;break}else{var ie=re-254;if(re>264){var D=re-257,ae=Dh[D];ie=Gh(e,d,(1<<ae)-1)+Mh[D],d+=ae}var I=m[Kh(e,d)&F],L=I>>4;I||Xh(3),d+=I&15;var P=Fh[L];if(L>3){var ae=Oh[L];P+=Kh(e,d)&(1<<ae)-1,d+=ae}if(d>_){c&&Xh(0);break}s&&l(f+131072);var R=f+ie;if(f<P){var oe=a-P,se=Math.min(P,R);for(oe+f<0&&Xh(3);f<se;++f)n[f]=r[oe+f]}for(;f<R;++f)n[f]=n[f-P]}}t.l=p,t.p=ne,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Jh(n,0,f):n.subarray(0,f)},Qh=new wh(0),$h=function(e,t){return e[t]|e[t+1]<<8},eg=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},tg=function(e,t){return eg(e,t)+eg(e,t+4)*4294967296},ng=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Xh(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Xh(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function rg(e,t){return Zh(e,{i:2},t&&t.out,t&&t.dictionary)}function ig(e,t){return Zh(e.subarray(ng(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var ag=typeof TextDecoder<`u`&&new TextDecoder;try{ag.decode(Qh,{stream:!0})}catch(e){}var og=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Jh(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function sg(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else if(ag)return ag.decode(e);else{var i=og(e),a=i.s,n=i.r;return n.length&&Xh(8),a}}var cg=function(e,t){return t+30+$h(e,t+26)+$h(e,t+28)},lg=function(e,t,n){var r=$h(e,t+28),i=sg(e.subarray(t+46,t+46+r),!($h(e,t+8)&2048)),a=t+46+r,o=eg(e,t+20),s=n&&o==4294967295?ug(e,a):[o,eg(e,t+24),eg(e,t+42)],c=s[0],l=s[1],u=s[2];return[$h(e,t+10),c,l,i,a+$h(e,t+30)+$h(e,t+32),u]},ug=function(e,t){for(;$h(e,t)!=1;t+=4+$h(e,t+2));return[tg(e,t+12),tg(e,t+4),tg(e,t+20)]};function dg(e,t){for(var n={},r=e.length-22;eg(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Xh(13);var i=$h(e,r+8);if(!i)return{};var a=eg(e,r+16),o=a==4294967295||i==65535;if(o){var s=eg(e,r-12);o=eg(e,s)==101075792,o&&(i=eg(e,s+32),a=eg(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=lg(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=cg(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=rg(e.subarray(_,_+f),{out:new wh(p)}):Xh(14,`unknown compression type `+d):n[m]=Jh(e,_,_+f))}return n}function fg(e,t={}){var n,r,i;let a=(n=t.upAxis)==null?`Z`:n,o=(r=t.fetcher)==null?Xs:r,s=(i=t.onDownloadProgress)==null?K:i,c=0;return Promise.resolve().then(()=>o.ajax(e,{responseType:`arraybuffer`},void 0,void 0,s).then(e=>(c=e.body.byteLength,e.body))).then(n=>{var r;return pg(n,{light:t.light,resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(r=e.split(`?`)[1])==null?``:r,fetcher:o})}).then(t=>{let n=t.scene,r=t.unitScale/100,i=new l.Matrix4;if(i.makeScale(r,r,r),t.upAxis===`X`)throw Error(`Cannot load fbx x upAxis`);return t.upAxis===`Y`&&i.premultiply(Ns),a===`Y`&&i.premultiply(Ps),n.applyMatrix4(i),{type:`fbx`,modelUpAxis:t.upAxis,upAxis:a,uri:e,byteLength:c,memoryUsage:hl(n),scene:n,textures:t.textures,animations:t.animations,dispose:()=>t.dispose()}})}function pg(e,t){let n;if(xg(e))n=new vg().parse(e);else{let t=Mg(e);if(!Sg(t))throw Error(`THREE.FBXLoader: Unknown format.`);if(Cg(t)<7e3)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+Cg(t));n=new _g().parse(t)}return new mg(t).parse(n)}var mg=class{constructor(e){var t,n,r;this.light=(t=e.light)==null?!0:t,this.resourcePath=(n=e.resourcePath)==null?``:n,this.search=(r=e.search)==null?``:r,this.fetcher=e.fetcher}parse(e){var t,n,r,i,a,o;let s=this.parseConnections(e),c=Object.assign(new l.Group,{animations:[]}),u=[],d=this.parseImages(e),f=this.parseTextures(e,d,s,u),p=this.parseMaterials(e,f,s),m=this.parseDeformers(e,s),h=new hg().parse(e,m,s);this.parseScene(e,m,h,p,s,c);let g=(n=(t=e.GlobalSettings.UpAxis)==null?void 0:t.value)==null?1:n,_=(i=(r=e.GlobalSettings.FrontAxis)==null?void 0:r.value)==null?2:i,v=(o=(a=e.GlobalSettings.UnitScaleFactor)==null?void 0:a.value)==null?1:o,y;if(e.GlobalSettings.AmbientColor){let t=e.GlobalSettings.AmbientColor.value,n=t[0],r=t[1],i=t[2];if(n!==0||r!==0||i!==0){let e=new l.Color().setRGB(n,r,i);y=new l.AmbientLight(e,1)}}return Promise.all(u).then(e=>{var t;return{scene:c,textures:e,ambientLight:y,upAxis:[`X`,`Y`,`Z`][g],frontAxis:[`X`,`Y`,`Z`][_],unitScale:v,animations:(t=c.animations)==null?[]:t,dispose:()=>{e.forEach(e=>e.dispose()),p.forEach(e=>e.dispose()),h.forEach(e=>e.dispose())}}})}parseConnections(e){let t=new Map;return`Connections`in e&&e.Connections.connections.forEach(function(e){let n=e[0],r=e[1],i=e[2];t.has(n)||t.set(n,{parents:[],children:[]});let a={ID:r,relationship:i};t.get(n).parents.push(a),t.has(r)||t.set(r,{parents:[],children:[]});let o={ID:n,relationship:i};t.get(r).children.push(o)}),t}parseImages(e){let t={},n={};if(`Video`in e.Objects){let r=e.Objects.Video;for(let e in r){let i=r[e],a=parseInt(e);if(t[a]=i.RelativeFilename||i.Filename,`Content`in i){let t=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content==`string`&&i.Content!==``;if(t||a){let t=this.parseImage(r[e]);n[i.RelativeFilename||i.Filename]=t}}}}for(let e in t){let r=t[e];n[r]===void 0?t[e]=t[e].split(`\\`).pop():t[e]=n[r]}return t}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(`.`)+1).toLowerCase(),i;switch(r){case`bmp`:i=`image/bmp`;break;case`jpg`:case`jpeg`:i=`image/jpeg`;break;case`png`:i=`image/png`;break;case`tif`:i=`image/tiff`;break;case`tga`:i=`image/tga`;break;default:return}if(typeof t==`string`)return`data:`+i+`;base64,`+t;{let e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e,t,n,r){let i=new Map;if(`Texture`in e.Objects){let a=e.Objects.Texture;for(let e in a){let o=this.parseTexture(a[e],t,n,r);i.set(parseInt(e),o)}}return i}parseTexture(e,t,n,r){let i=this.loadTexture(e,t,n,r);i.ID=e.id,i.name=e.attrName;let a=e.WrapModeU,o=e.WrapModeV,s=a===void 0?0:a.value,c=o===void 0?0:o.value;if(i.wrapS=s===0?l.RepeatWrapping:l.ClampToEdgeWrapping,i.wrapT=c===0?l.RepeatWrapping:l.ClampToEdgeWrapping,e.Scaling){let t=e.Scaling.value;i.repeat.x=t[0],i.repeat.y=t[1]}if(e.Translation){let t=e.Translation.value;i.offset.x=t[0],i.offset.y=t[1]}return i}loadTexture(e,t,n,r){let i=n.get(e.id).children,a=``;i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(a=t[i[0].ID]),a=rc(this.resourcePath,ic(a,this.search));let o=Object.assign(new l.Texture,{ID:0}),s;s=Wc()?this.fetcher.ajax(a,{responseType:`blob`}).then(e=>{let t=e.body;return Kc(t)}):this.fetcher.loadImage(a,{},void 0,void 0,void 0,Gc()).then(e=>e.body);let c=s.then(e=>(o.image=e,o.needsUpdate=!0,o)).catch(e=>(console.warn(e),o));return r.push(c),o}parseMaterials(e,t,n){let r=new Map;if(`Material`in e.Objects){let i=e.Objects.Material;for(let a in i){let o=this.parseMaterial(e,i[a],t,n);o!==null&&r.set(parseInt(a),o)}}return r}parseMaterial(e,t,n,r){let i=t.id,a=t.attrName,o=t.ShadingModel;if(typeof o==`object`&&(o=o.value),o=o.toLowerCase(),!r.has(i))return null;let s=Lr(this.light?`phong`:`basic`);s.name=a,t.BumpFactor&&(s.bumpScale=t.BumpFactor.value),t.Diffuse?s.color=new l.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type===`Color`||t.DiffuseColor.type===`ColorRGB`)&&(s.color=new l.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(s.displacementScale=t.DisplacementFactor.value),t.Emissive?s.emissive=new l.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type===`Color`||t.EmissiveColor.type===`ColorRGB`)&&(s.emissive=new l.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(s.emissiveIntensity=parseFloat(t.EmissiveFactor.value));let c=1-(t.TransparencyFactor?parseFloat(t.TransparencyFactor.value):0);(c===1||c===0)&&(c=t.Opacity?parseFloat(t.Opacity.value):null,c===null&&(c=1-(t.TransparentColor?parseFloat(t.TransparentColor.value[0]):0))),s.opacity=c,s.opacity<1&&(s.transparent=!0),t.ReflectionFactor&&(s.reflectivity=t.ReflectionFactor.value),t.Shininess&&(s.shininess=t.Shininess.value),t.Specular?s.specular=new l.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type===`Color`&&(s.specular=new l.Color().fromArray(t.SpecularColor.value));let u=this;return r.get(i).children.forEach(function(t){let i=t.relationship;switch(i){case`Bump`:s.bumpMap=u.getTexture(e,n,t.ID,r);break;case`Maya|TEX_ao_map`:s.aoMap=u.getTexture(e,n,t.ID,r);break;case`DiffuseColor`:case`Maya|TEX_color_map`:s.map=u.getTexture(e,n,t.ID,r),s.map!==void 0&&(s.map.colorSpace=l.SRGBColorSpace);break;case`DisplacementColor`:s.displacementMap=u.getTexture(e,n,t.ID,r);break;case`EmissiveColor`:s.emissiveMap=u.getTexture(e,n,t.ID,r),s.emissiveMap!==void 0&&(s.emissiveMap.colorSpace=l.SRGBColorSpace);break;case`NormalMap`:case`Maya|TEX_normal_map`:s.normalMap=u.getTexture(e,n,t.ID,r);break;case`ReflectionColor`:s.envMap=u.getTexture(e,n,t.ID,r),s.envMap!==void 0&&(s.envMap.mapping=l.EquirectangularReflectionMapping,s.envMap.colorSpace=l.SRGBColorSpace);break;case`SpecularColor`:s.specularMap=u.getTexture(e,n,t.ID,r),s.specularMap!==void 0&&(s.specularMap.colorSpace=l.SRGBColorSpace);break;case`TransparentColor`:case`TransparencyFactor`:s.alphaMap=u.getTexture(e,n,t.ID,r),s.transparent=!0;break;default:console.warn(`THREE.FBXLoader: %s map is not supported in three.js, skipping texture.`,i);break}}),s}getTexture(e,t,n,r){return e.Objects.LayeredTexture&&n in e.Objects.LayeredTexture&&(console.warn(`THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.`),n=r.get(n).children[0].ID),t.get(n)}parseDeformers(e,t){let n={},r={};if(`Deformer`in e.Objects){let i=e.Objects.Deformer;for(let e in i){let a=i[e],o=t.get(parseInt(e));if(a.attrType===`Skin`){let t=this.parseSkeleton(o,i);t.ID=e,o.parents.length>1&&console.warn(`THREE.FBXLoader: skeleton attached to more than one geometry is not supported.`),t.geometryID=o.parents[0].ID,n[e]=t}else if(a.attrType===`BlendShape`){let n={id:e};n.rawTargets=this.parseMorphTargets(o,i,t),n.id=e,o.parents.length>1&&console.warn(`THREE.FBXLoader: morph target attached to more than one geometry is not supported.`),r[e]=n}}}return{skeletons:n,morphTargets:r}}parseSkeleton(e,t){let n=[];return e.children.forEach(function(e){let r=t[e.ID];if(r.attrType!==`Cluster`)return;let i={ID:e.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(r.TransformLink.a)};r.Indexes&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)}),{ID:``,geometryID:0,rawBones:n,bones:[]}}parseMorphTargets(e,t,n){let r=[];for(let i=0;i<e.children.length;i++){let a=e.children[i],o=t[a.ID],s={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a,geoID:0};if(o.attrType!==`BlendShapeChannel`)return;s.geoID=n.get(parseInt(a.ID)).children.filter(function(e){return e.relationship===void 0})[0].ID,r.push(s)}return r}parseScene(e,t,n,r,i,a){let o=this.parseModels(e,t.skeletons,n,r,i),s=e.Objects.Model,c=this;o.forEach(function(t){let n=s[t.ID];c.setLookAtProperties(e,t,n,i,a),i.get(t.ID).parents.forEach(function(e){let n=o.get(e.ID);n!==void 0&&n.add(t)}),t.parent===null&&a.add(t)}),this.bindSkeleton(e,t.skeletons,n,o,i),a.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);let t=kg(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix(!0,!0)}});let u=new gg().parse(e,i,a);a.children.length===1&&a.children[0]instanceof l.Group&&(a=a.children[0]),a.animations=u}parseModels(e,t,n,r,i){let a=new Map,o=e.Objects.Model;for(let s in o){let c=parseInt(s),u=o[s],d=i.get(c),f=this.buildSkeleton(d,t,c,u.attrName);if(!f){switch(u.attrType){case`Camera`:f=this.createCamera(e,d);break;case`Light`:f=this.createLight(e,d);break;case`Mesh`:f=this.createMesh(d,n,r);break;case`NurbsCurve`:case`LimbNode`:case`Root`:f=new l.Bone;break;default:f=new l.Group;break}f.name=u.attrName?l.PropertyBinding.sanitizeNodeName(u.attrName):``,f.userData.originalName=u.attrName,f.ID=c}this.getTransformData(f,u),a.set(c,f)}return a}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach(function(e){for(let a in t){let o=t[a];o.rawBones.forEach(function(t,a){if(t.ID===e.ID){let e=i;i=new l.Bone,i.matrixWorld.copy(t.transformLink),i.name=r?l.PropertyBinding.sanitizeNodeName(r):``,i.userData.originalName=r,i.ID=n,o.bones[a]=i,e!==null&&i.add(e)}})}}),i}createCamera(e,t){let n,r;if(t.children.forEach(function(t){let n=e.Objects.NodeAttribute[t.ID];n!==void 0&&(r=n)}),r===void 0)n=new l.Object3D;else{let e=0;r.CameraProjectionType!==void 0&&r.CameraProjectionType.value===1&&(e=1);let t=1;r.NearPlane!==void 0&&(t=r.NearPlane.value/1e3);let i=1e3;r.FarPlane!==void 0&&(i=r.FarPlane.value/1e3);let a=window.innerWidth,o=window.innerHeight;r.AspectWidth!==void 0&&r.AspectHeight!==void 0&&(a=r.AspectWidth.value,o=r.AspectHeight.value);let s=a/o,c=45;r.FieldOfView!==void 0&&(c=r.FieldOfView.value);let u=r.FocalLength?r.FocalLength.value:null;switch(e){case 0:n=new l.PerspectiveCamera(c,s,t,i),u!==null&&n.setFocalLength(u);break;case 1:console.warn(`THREE.FBXLoader: Orthographic cameras not supported yet.`),n=new l.Object3D;break;default:console.warn(`THREE.FBXLoader: Unknown camera type `+e+`.`),n=new l.Object3D;break}}return n}createLight(e,t){let n,r;if(t.children.forEach(function(t){let n=e.Objects.NodeAttribute[t.ID];n!==void 0&&(r=n)}),r===void 0)n=new l.Object3D;else{let e;e=r.LightType===void 0?0:r.LightType.value;let t=new l.Color(16777215);r.Color!==void 0&&(t=new l.Color().fromArray(r.Color.value));let i=r.Intensity===void 0?1:r.Intensity.value/100;r.CastLightOnObject!==void 0&&r.CastLightOnObject.value===0&&(i=0);let a=0;switch(r.FarAttenuationEnd!==void 0&&(a=r.EnableFarAttenuation!==void 0&&r.EnableFarAttenuation.value===0?0:r.FarAttenuationEnd.value),e){case 0:n=new l.PointLight(t,i,a,1);break;case 1:n=new l.DirectionalLight(t,i);break;case 2:let e=Math.PI/3;r.InnerAngle!==void 0&&(e=l.MathUtils.degToRad(r.InnerAngle.value));let o=0;r.OuterAngle!==void 0&&(o=l.MathUtils.degToRad(r.OuterAngle.value),o=Math.max(o,1)),n=new l.SpotLight(t,i,a,e,o,1);break;default:console.warn(`THREE.FBXLoader: Unknown light type `+r.LightType.value+`, defaulting to a PointLight.`),n=new l.PointLight(t,i);break}r.CastShadows!==void 0&&r.CastShadows.value===1&&(n.castShadow=!0)}return n}createMesh(e,t,n){let r,i=null,a=[];if(e.children.forEach(function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&a.push(n.get(e.ID))}),a.length===0){let e=Lr(this.light?`phong`:`basic`);e.color=new l.Color(13421772),a.push(e)}return`color`in i.attributes&&a.forEach(function(e){e.vertexColors=!0}),(!i.groups||i.groups.length===0)&&i.addGroup(0,i.index?i.index.count:i.attributes.position.count,0),i.FBX_Deformer?(a.forEach(function(e){e.skinning=!0}),r=new At(i,a),r.normalizeSkinWeights()):r=new kt(i,a),r}createCurve(e,t){let n=e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),r=new l.LineBasicMaterial({name:``,color:3342591,linewidth:1});return new l.Line(n,r)}getTransformData(e,t){let n={};t.InheritType&&(n.inheritType=parseInt(t.InheritType.value)),t.RotationOrder?n.eulerOrder=Ag(t.RotationOrder.value):n.eulerOrder=Ag(0),t.Lcl_Translation&&(n.translation=t.Lcl_Translation.value),t.PreRotation&&(n.preRotation=t.PreRotation.value),t.Lcl_Rotation&&(n.rotation=t.Lcl_Rotation.value),t.PostRotation&&(n.postRotation=t.PostRotation.value),t.Lcl_Scaling&&(n.scale=t.Lcl_Scaling.value),t.ScalingOffset&&(n.scalingOffset=t.ScalingOffset.value),t.ScalingPivot&&(n.scalingPivot=t.ScalingPivot.value),t.RotationOffset&&(n.rotationOffset=t.RotationOffset.value),t.RotationPivot&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t,n,r,i){`LookAtProperty`in n&&r.get(t.ID).children.forEach(function(n){if(n.relationship===`LookAtProperty`){let r=e.Objects.Model[n.ID];if(r.Lcl_Translation){let e=r.Lcl_Translation.value;`target`in t&&t.target instanceof l.Object3D?(t.target.position.fromArray(e),i.add(t.target)):t.lookAt(new l.Vector3().fromArray(e))}}})}bindSkeleton(e,t,n,r,i){let a=this.parsePoseNodes(e);for(let e in t){let o=t[e];i.get(parseInt(o.ID)).parents.forEach(function(e){if(n.has(e.ID)){let t=e.ID;i.get(t).parents.forEach(function(e){if(r.has(e.ID)){let t=r.get(e.ID);t instanceof l.SkinnedMesh&&t.bind(new l.Skeleton(o.bones),a[e.ID])}})}})}}parsePoseNodes(e){let t={};if(e.Objects.Pose){let n=e.Objects.Pose;for(let e in n)if(n[e].attrType===`BindPose`&&n[e].NbPoseNodes>0){let r=n[e].PoseNode;Array.isArray(r)?r.forEach(function(e){t[e.Node]=new l.Matrix4().fromArray(e.Matrix.a)}):t[r.Node]=new l.Matrix4().fromArray(r.Matrix.a)}}return t}},hg=class{constructor(){this.negativeMaterialIndices=!1}parse(e,t,n){let r=new Map;if(`Geometry`in e.Objects){let i=e.Objects.Geometry;for(let a in i){let o=n.get(parseInt(a)),s=this.parseGeometry(e,o,i[a],t);r.set(parseInt(a),s)}}return this.negativeMaterialIndices===!0&&console.warn(`THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.`),r}parseGeometry(e,t,n,r){switch(n.attrType){case`Mesh`:return this.parseMeshGeometry(e,t,n,r);case`NurbsCurve`:return this.parseNurbsGeometry(n)}}parseMeshGeometry(e,t,n,r){let i=r.skeletons,a=[],o=t.parents.map(function(t){return e.Objects.Model[t.ID]});if(o.length===0)return;let s=t.children.reduce(function(e,t){return i[t.ID]!==void 0&&(e=i[t.ID]),e},null);t.children.forEach(function(e){r.morphTargets[e.ID]!==void 0&&a.push(r.morphTargets[e.ID])});let c=o[0],l={};c.RotationOrder&&(l.eulerOrder=Ag(c.RotationOrder.value)),c.InheritType&&(l.inheritType=parseInt(c.InheritType.value)),c.GeometricTranslation&&(l.translation=c.GeometricTranslation.value),c.GeometricRotation&&(l.rotation=c.GeometricRotation.value),c.GeometricScaling&&(l.scale=c.GeometricScaling.value);let u=kg(l);return this.genGeometry(e,n,s,a,u)}genGeometry(e,t,n,r,i){let a=new l.BufferGeometry;t.attrName&&(a.name=t.attrName);let o=this.parseGeoNode(t,n),s=this.genBuffers(o),c=new l.Float32BufferAttribute(s.vertex,3);if(c.applyMatrix4(i),a.setAttribute(`position`,c),s.colors.length>0&&a.setAttribute(`color`,new l.Float32BufferAttribute(s.colors,3)),n&&(a.setAttribute(`skinIndex`,new l.Uint16BufferAttribute(s.weightsIndices,4)),a.setAttribute(`skinWeight`,new l.Float32BufferAttribute(s.vertexWeights,4)),a.FBX_Deformer=n),s.normal.length>0){let e=new l.Matrix3().getNormalMatrix(i),t=new l.Float32BufferAttribute(s.normal,3);t.applyNormalMatrix(e),a.setAttribute(`normal`,t)}if(s.uvs.forEach(function(e,t){let n=t===0?`uv`:`uv${t}`;a.setAttribute(n,new l.Float32BufferAttribute(s.uvs[t],2))}),o.material&&o.material.mappingType!==`AllSame`){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach(function(n,r){n!==e&&(a.addGroup(t,r-t,e),e=n,t=r)}),a.groups.length>0){let t=a.groups[a.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&a.addGroup(n,s.materialIndex.length-n,e)}a.groups.length===0&&a.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(e,a,t,r,i),a}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices===void 0?[]:e.Vertices.a,n.vertexIndices=e.PolygonVertexIndex===void 0?[]:e.PolygonVertexIndex.a,e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,i){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,r=0,i=!1,a=[],o=[],s=[],c=[],l=[],u=[],d=this;return e.vertexIndices.forEach(function(f,p){let m=0,h=!1;f<0&&(f^=-1,h=!0);let g=[],_=[];if(a.push(f*3,f*3+1,f*3+2),e.color){let t=Eg(p,n,f,e.color);s.push(t[0],t[1],t[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(e){_.push(e.weight),g.push(e.id)}),_.length>4){i||(console.warn(`THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.`),i=!0);let e=[0,0,0,0],t=[0,0,0,0];_.forEach(function(n,r){let i=n,a=g[r];t.forEach(function(t,n,r){if(i>t){r[n]=i,i=t;let o=e[n];e[n]=a,a=o}})}),g=e,_=t}for(;_.length<4;)_.push(0),g.push(0);for(let e=0;e<4;++e)l.push(_[e]),u.push(g[e])}if(e.normal){let t=Eg(p,n,f,e.normal);o.push(t[0],t[1],t[2])}e.material&&e.material.mappingType!==`AllSame`&&(m=Eg(p,n,f,e.material)[0],m<0&&(d.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){let r=Eg(p,n,f,e);c[t]===void 0&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,h&&(d.genFace(t,e,a,m,o,s,c,l,u,r),n++,r=0,a=[],o=[],s=[],c=[],l=[],u=[])}),t}getNormalNewell(e){let t=new l.Vector3(0,0,0);for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t.x+=(r.y-i.y)*(r.z+i.z),t.y+=(r.z-i.z)*(r.x+i.x),t.z+=(r.x-i.x)*(r.y+i.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){let t=this.getNormalNewell(e),n=(Math.abs(t.z)>.5?new l.Vector3(0,1,0):new l.Vector3(0,0,1)).cross(t).normalize();return{normal:t,tangent:n,bitangent:t.clone().cross(n).normalize()}}flattenVertex(e,t,n){return new l.Vector2(e.dot(t),e.dot(n))}genFace(e,t,n,r,i,a,o,s,c,u){let d;if(u>3){let e=[],r=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<n.length;t+=3)e.push(new l.Vector3(r[n[t]],r[n[t+1]],r[n[t+2]]));let{tangent:i,bitangent:a}=this.getNormalTangentAndBitangent(e),o=[];for(let t of e)o.push(this.flattenVertex(t,i,a));d=l.ShapeUtils.triangulateShape(o,[])}else d=[[0,1,2]];for(let[l,u,f]of d)e.vertex.push(t.vertexPositions[n[l*3]]),e.vertex.push(t.vertexPositions[n[l*3+1]]),e.vertex.push(t.vertexPositions[n[l*3+2]]),e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(s[l*4]),e.vertexWeights.push(s[l*4+1]),e.vertexWeights.push(s[l*4+2]),e.vertexWeights.push(s[l*4+3]),e.vertexWeights.push(s[u*4]),e.vertexWeights.push(s[u*4+1]),e.vertexWeights.push(s[u*4+2]),e.vertexWeights.push(s[u*4+3]),e.vertexWeights.push(s[f*4]),e.vertexWeights.push(s[f*4+1]),e.vertexWeights.push(s[f*4+2]),e.vertexWeights.push(s[f*4+3]),e.weightsIndices.push(c[l*4]),e.weightsIndices.push(c[l*4+1]),e.weightsIndices.push(c[l*4+2]),e.weightsIndices.push(c[l*4+3]),e.weightsIndices.push(c[u*4]),e.weightsIndices.push(c[u*4+1]),e.weightsIndices.push(c[u*4+2]),e.weightsIndices.push(c[u*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3])),t.color&&(e.colors.push(a[l*3]),e.colors.push(a[l*3+1]),e.colors.push(a[l*3+2]),e.colors.push(a[u*3]),e.colors.push(a[u*3+1]),e.colors.push(a[u*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2])),t.material&&t.material.mappingType!==`AllSame`&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[l*3]),e.normal.push(i[l*3+1]),e.normal.push(i[l*3+2]),e.normal.push(i[u*3]),e.normal.push(i[u*3+1]),e.normal.push(i[u*3+2]),e.normal.push(i[f*3]),e.normal.push(i[f*3+1]),e.normal.push(i[f*3+2])),t.uv&&t.uv.forEach(function(t,n){e.uvs[n]===void 0&&(e.uvs[n]=[]),e.uvs[n].push(o[n][l*2]),e.uvs[n].push(o[n][l*2+1]),e.uvs[n].push(o[n][u*2]),e.uvs[n].push(o[n][u*2+1]),e.uvs[n].push(o[n][f*2]),e.uvs[n].push(o[n][f*2+1])})}addMorphTargets(e,t,n,r,i){if(r.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];let a=this;r.forEach(function(r){r.rawTargets.forEach(function(r){let o=e.Objects.Geometry[r.geoID];o!==void 0&&a.genMorphGeometry(t,n,o,i,r.name)})})}genMorphGeometry(e,t,n,r,i){var a;let o=t.Vertices===void 0?[]:t.Vertices.a,s=t.PolygonVertexIndex===void 0?[]:t.PolygonVertexIndex.a,c=n.Vertices===void 0?[]:n.Vertices.a,u=n.Indexes?n.Indexes.a:[],d=e.attributes.position.count*3,f=new Float32Array(d);for(let e=0;e<u.length;e++){let t=u[e]*3;f[t]=c[e*3],f[t+1]=c[e*3+1],f[t+2]=c[e*3+2]}let p={vertexIndices:s,vertexPositions:f,baseVertexPositions:o},m=this.genBuffers(p),h=new l.Float32BufferAttribute(m.vertex,3);h.name=i||n.attrName,h.applyMatrix4(r),(a=e.morphAttributes.position)==null||a.push(h)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a,i=[];return n===`IndexToDirect`&&(e.NormalIndex?i=e.NormalIndex.a:e.NormalsIndex&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a,i=[];return n===`IndexToDirect`&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a,i=[];n===`IndexToDirect`&&(i=e.ColorIndex.a);for(let e=0,t=new l.Color;e<r.length;e+=4)t.fromArray(r,e),t.toArray(r,e);return{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t===`NoMappingInformation`)return{dataSize:1,buffer:[0],indices:[0],mappingType:`AllSame`,referenceType:n};let r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let 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 l.BufferGeometry;let n=t-1,r=e.KnotVector.a,i=[],a=e.Points.a;for(let e=0,t=a.length;e<t;e+=4)i.push(new l.Vector4().fromArray(a,e));let o,s;if(e.Form===`Closed`)i.push(i[0]);else if(e.Form===`Periodic`){o=n,s=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}let c=new Fg(n,r,i,o,s).getPoints(i.length*12);return new l.BufferGeometry().setFromPoints(c)}},gg=class{parse(e,t,n){let r=[],i=this.parseClips(e,t,n);if(i!==void 0)for(let e in i){let t=i[e],a=this.addClip(t,n);r.push(a)}return r}parseClips(e,t,n){if(e.Objects.AnimationCurve===void 0)return;let r=this.parseAnimationCurveNodes(e);this.parseAnimationCurves(e,r,t);let i=this.parseAnimationLayers(e,r,t,n);return this.parseAnimStacks(e,i,t)}parseAnimationCurveNodes(e){let t=e.Objects.AnimationCurveNode,n=new Map;for(let e in t){let r=t[e];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){let e={id:r.id,attr:r.attrName,curves:{}};n.set(e.id,e)}}return n}parseAnimationCurves(e,t,n){let r=e.Objects.AnimationCurve;for(let e in r){let i={id:r[e].id,times:r[e].KeyTime.a.map(wg),values:r[e].KeyValueFloat.a},a=n.get(i.id);if(a!==void 0){let e=a.parents[0].ID,n=a.parents[0].relationship,r=t.get(e);r&&(n.match(/X/)?r.curves.x=i:n.match(/Y/)?r.curves.y=i:n.match(/Z/)?r.curves.z=i:n.match(/DeformPercent/)&&t.has(e)&&(r.curves.morph=i))}}}parseAnimationLayers(e,t,n,r){let i=e.Objects.AnimationLayer,a=new Map;for(let o in i){let i=[],s=n.get(parseInt(o));s!==void 0&&(s.children.forEach((a,o)=>{if(t.has(a.ID)){let s=t.get(a.ID);if(s.curves.x!==void 0||s.curves.y!==void 0||s.curves.z!==void 0){if(i[o]===void 0){let t=n.get(a.ID).parents.filter(function(e){return e.relationship!==void 0})[0].ID;if(t!==void 0){let n=e.Objects.Model[t.toString()];if(n===void 0){console.warn(`THREE.FBXLoader: Encountered a unused curve.`,a);return}let s={modelName:n.attrName?l.PropertyBinding.sanitizeNodeName(n.attrName):``,ID:n.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1],transform:new l.Matrix4,eulerOrder:``,preRotation:[0,0,0],postRotation:[0,0,0]};r.traverse(function(e){e.ID===n.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))}),s.transform||(s.transform=new l.Matrix4),n.PreRotation&&(s.preRotation=n.PreRotation.value),n.PostRotation&&(s.postRotation=n.PostRotation.value),i[o]=s}}i[o]&&(i[o][s.attr]=s)}else if(s.curves.morph!==void 0){if(i[o]===void 0){let t=n.get(a.ID).parents.filter(function(e){return e.relationship!==void 0})[0].ID,r=n.get(t).parents[0].ID,s=n.get(r).parents[0].ID,c=n.get(s).parents[0].ID,u=e.Objects.Model[c];i[o]={modelName:u.attrName?l.PropertyBinding.sanitizeNodeName(u.attrName):``,morphName:e.Objects.Deformer[t].attrName}}i[o][s.attr]=s}}}),a.set(parseInt(o),i))}return a}parseAnimStacks(e,t,n){let r=e.Objects.AnimationStack,i={};for(let e in r){let a=n.get(parseInt(e)).children;a.length>1&&console.warn(`THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.`);let o=t.get(a[0].ID);i[e]={name:r[e].attrName,layer:o}}return i}addClip(e,t){let n=[],r=this;return e.layer.forEach(function(e){n=n.concat(r.generateTracks(e,t))}),new l.AnimationClip(e.name,-1,n)}generateTracks(e,t){let n=[],r=new l.Vector3,i=new l.Vector3;e.transform&&e.transform.decompose(r,new l.Quaternion,i);let a=r.toArray(),o=i.toArray();if(e.T!==void 0&&Object.keys(e.T.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.T.curves,a,`position`);t!==void 0&&n.push(t)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let t=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);t!==void 0&&n.push(t)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.S.curves,o,`scale`);t!==void 0&&n.push(t)}if(e.DeformPercent!==void 0){let r=this.generateMorphTrack(e,t);r!==void 0&&n.push(r)}return n}generateVectorTrack(e,t,n,r){let i=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(i,t,n);return new l.VectorKeyframeTrack(e+`.`+r,i,a)}generateRotationTrack(e,t,n,r,i){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){let e=this.interpolateRotations(t.x,t.y,t.z,i);a=e[0],o=e[1]}let s=Ag(0),c=new l.Quaternion,u=new l.Quaternion;n!==void 0&&(n=n.map(l.MathUtils.degToRad),n.push(s),c.setFromEuler(new l.Euler().fromArray(n))),r!==void 0&&(r=r.map(l.MathUtils.degToRad),r.push(s),u.setFromEuler(new l.Euler().fromArray(r)),u.invert());let d=new l.Quaternion,f=new l.Euler,p=[];if(!o||!a)return new l.QuaternionKeyframeTrack(e+`.quaternion`,[0],[0]);for(let e=0;e<o.length;e+=3)f.set(o[e],o[e+1],o[e+2],i),d.setFromEuler(f),d.premultiply(c),d.multiply(u),e>2&&new l.Quaternion().fromArray(p,(e-3)/3*4).dot(d)<0&&d.set(-d.x,-d.y,-d.z,-d.w),d.toArray(p,e/3*4);return new l.QuaternionKeyframeTrack(e+`.quaternion`,a,p)}generateMorphTrack(e,t){let n=e.DeformPercent.curves.morph,r=n.values.map(function(e){return e/100}),i=t.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+`.morphTargetInfluences[`+i+`]`,n.times,r)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){let i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){let r=n,i=[],a=-1,o=-1,s=-1;return e.forEach(function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),a!==-1){let e=t.x.values[a];i.push(e),r[0]=e}else i.push(r[0]);if(o!==-1){let e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(s!==-1){let e=t.z.values[s];i.push(e),r[2]=e}else i.push(r[2])}),i}interpolateRotations(e,t,n,r){let i=[],a=[];i.push(e.times[0]),a.push(l.MathUtils.degToRad(e.values[0])),a.push(l.MathUtils.degToRad(t.values[0])),a.push(l.MathUtils.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){let s=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(s[0])||isNaN(s[1])||isNaN(s[2]))continue;let c=s.map(l.MathUtils.degToRad),u=[e.values[o],t.values[o],n.values[o]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;u.map(l.MathUtils.degToRad);let d=[u[0]-s[0],u[1]-s[1],u[2]-s[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){let t=Math.max(...f)/180,n=new l.Euler(c[0],c[1],c[2],r),s=new l.Euler(c[0],c[1],c[2],r),u=new l.Quaternion().setFromEuler(n),d=new l.Quaternion().setFromEuler(s);u.dot(d)&&d.set(-d.x,-d.y,-d.z,-d.w);let p=e.times[o-1],m=e.times[o]-p,h=new l.Quaternion,g=new l.Euler;for(let e=0;e<1;e+=1/t)h.copy(u.clone().slerp(d.clone(),e)),i.push(p+e*m),g.setFromQuaternion(h,r),a.push(g.x),a.push(g.y),a.push(g.z)}else i.push(e.times[o]),a.push(l.MathUtils.degToRad(e.values[o])),a.push(l.MathUtils.degToRad(t.values[o])),a.push(l.MathUtils.degToRad(n.values[o]))}return[i,a]}},_g=class{constructor(){this.allNodes=new bg,this.nodeStack=[],this.currentIndent=0,this.currentPropName=``}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 bg,this.nodeStack=[],this.currentProp=[],this.currentPropName=``;let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){let i=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(i||a)return;let o=e.match(`^\\t{`+t.currentIndent+`}(\\w+):(.*){`),s=e.match(`^\\t{`+t.currentIndent+`}(\\w+):[\\s\\t\\r\\n](.*)`),c=e.match(`^\\t{`+(t.currentIndent-1)+`}}`);o?t.parseNodeBegin(e,o):s?t.parseNodeProperty(e,s,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,``).replace(/"$/,``),r=t[2].split(`,`).map(function(e){return e.trim().replace(/^"/,``).replace(/"$/,``)}),i={name:n},a=this.parseNodeAttr(r),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,i):n in o?(n===`PoseNode`?o.PoseNode.push(i):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==``&&(o[n][a.id]=i)):typeof a.id==`number`?(o[n]={},o[n][a.id]=i):n!==`Properties70`&&(n===`PoseNode`?o[n]=[i]:o[n]=i),typeof a.id==`number`&&(i.id=a.id),a.name!==``&&(i.attrName=a.name),a.type!==``&&(i.attrType=a.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==``&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n=``,r=``;return e.length>1&&(n=e[1].replace(/^(\w+)::/,``),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,``).replace(/"$/,``).trim(),i=t[2].replace(/^"/,``).replace(/"$/,``).trim();r===`Content`&&i===`,`&&(i=n.replace(/"/g,``).replace(/,$/,``).trim());let a=this.getCurrentNode();if(a.name===`Properties70`){this.parseNodeSpecialProperty(e,r,i);return}if(r===`C`){let e=i.split(`,`).slice(1),t=parseInt(e[0]),n=parseInt(e[1]),o=i.split(`,`).slice(3);o=o.map(function(e){return e.trim().replace(/^"/,``)}),r=`connections`,i=[t,n],Ng(i,o),a[r]===void 0&&(a[r]=[])}r===`Node`&&(a.id=i),r in a&&Array.isArray(a[r])?a[r].push(i):r===`a`?a.a=i:a[r]=i,this.setCurrentProp(a,r),r===`a`&&i.slice(-1)!==`,`&&(a.a=jg(i))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==`,`&&(t.a=jg(t.a))}parseNodeSpecialProperty(e,t,n){let r=n.split(`",`).map(function(e){return e.trim().replace(/^\"/,``).replace(/\s/,`_`)}),i=r[0],a=r[1],o=r[2],s=r[3],c=r[4];switch(a){case`int`:case`enum`:case`bool`:case`ULongLong`:case`double`:case`Number`:case`FieldOfView`:c=parseFloat(c);break;case`Color`:case`ColorRGB`:case`Vector3D`:case`Lcl_Translation`:case`Lcl_Rotation`:case`Lcl_Scaling`:c=jg(c);break}this.getPrevNode()[i]={type:a,type2:o,flag:s,value:c},this.setCurrentProp(this.getPrevNode(),i)}},vg=class{parse(e){let t=new yg(e);t.skip(23);let n=t.getUint32();if(n<6400)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+n);let r=new bg;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);e!==null&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),o=e.getString(a);if(r===0)return null;let s=[];for(let t=0;t<i;t++)s.push(this.parseProperty(e));let c=s.length>0?s[0]:``,l=s.length>1?s[1]:``,u=s.length>2?s[2]:``;for(n.singleProperty=i===1&&e.getOffset()===r;r>e.getOffset();){let r=this.parseNode(e,t);r!==null&&this.parseSubNode(o,n,r)}return n.propertyList=s,typeof c==`number`&&(n.id=c),l!==``&&(n.attrName=l),u!==``&&(n.attrType=u),o!==``&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if(e===`Connections`&&n.name===`C`){let e=[];n.propertyList.forEach(function(t,n){n!==0&&e.push(t)}),t.connections===void 0&&(t.connections=[]),t.connections.push(e)}else if(n.name===`Properties70`)Object.keys(n).forEach(function(e){t[e]=n[e]});else if(e===`Properties70`&&n.name===`P`){let e=n.propertyList[0],r=n.propertyList[1],i=n.propertyList[2],a=n.propertyList[3],o;e.indexOf(`Lcl `)===0&&(e=e.replace(`Lcl `,`Lcl_`)),r.indexOf(`Lcl `)===0&&(r=r.replace(`Lcl `,`Lcl_`)),o=r===`Color`||r===`ColorRGB`||r===`Vector`||r===`Vector3D`||r.indexOf(`Lcl_`)===0?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:a,value:o}}else t[n.name]===void 0?typeof n.id==`number`?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name===`PoseNode`?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),n;switch(t){case`C`:return e.getBoolean();case`D`:return e.getFloat64();case`F`:return e.getFloat32();case`I`:return e.getInt32();case`L`:return e.getInt64();case`R`:return n=e.getUint32(),e.getArrayBuffer(n);case`S`:return n=e.getUint32(),e.getString(n);case`Y`:return e.getInt16();case`b`:case`c`:case`d`:case`f`:case`i`:case`l`:let r=e.getUint32(),i=e.getUint32(),a=e.getUint32();if(i===0)switch(t){case`b`:case`c`:return e.getBooleanArray(r);case`d`:return e.getFloat64Array(r);case`f`:return e.getFloat32Array(r);case`i`:return e.getInt32Array(r);case`l`:return e.getInt64Array(r)}let o=new yg(ig(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case`b`:case`c`:return o.getBooleanArray(r);case`d`:return o.getFloat64Array(r);case`f`:return o.getFloat32Array(r);case`i`:return o.getInt32Array(r);case`l`:return o.getInt64Array(r)}break;default:throw Error(`THREE.FBXLoader: Unknown property type `+t)}}},yg=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t===void 0?!0:t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)==1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let 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()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)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()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}},bg=class{constructor(){this.Connections={connections:[]},this.Objects={Model:{},NodeAttribute:{},Geometry:{}},this.GlobalSettings={}}add(e,t){this[e]=t}};function xg(e){return e.byteLength>=21&&Mg(e,0,21)===`Kaydara FBX Binary \0`}function Sg(e){let t=[`K`,`a`,`y`,`d`,`a`,`r`,`a`,`\\`,`F`,`B`,`X`,`\\`,`B`,`i`,`n`,`a`,`r`,`y`,`\\`,`\\`],n=0;function r(t){let r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e)if(r(1)===t[e])return!1;return!0}function Cg(e){let t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw Error(`THREE.FBXLoader: Cannot find the version number for the file given.`)}function wg(e){return e/46186158e3}var Tg=[];function Eg(e,t,n,r){let i;switch(r.mappingType){case`ByPolygonVertex`:i=e;break;case`ByPolygon`:i=t;break;case`ByVertice`:i=n;break;case`AllSame`:i=r.indices[0];break;default:console.warn(`THREE.FBXLoader: unknown attribute mapping type `+r.mappingType),i=0}r.referenceType===`IndexToDirect`&&(i=r.indices[i]);let a=i*r.dataSize,o=a+r.dataSize;return Pg(Tg,r.buffer,a,o)}var Dg=new l.Euler,Og=new l.Vector3;function kg(e){let t=new l.Matrix4,n=new l.Matrix4,r=new l.Matrix4,i=new l.Matrix4,a=new l.Matrix4,o=new l.Matrix4,s=new l.Matrix4,c=new l.Matrix4,u=new l.Matrix4,d=new l.Matrix4,f=new l.Matrix4,p=new l.Matrix4,m=e.inheritType?e.inheritType:0;e.translation&&t.setPosition(Og.fromArray(e.translation));let h=Ag(0);if(e.preRotation){let t=e.preRotation.map(l.MathUtils.degToRad);t.push(h),n.makeRotationFromEuler(Dg.fromArray(t))}if(e.rotation){let t=e.rotation.map(l.MathUtils.degToRad);t.push(e.eulerOrder||h),r.makeRotationFromEuler(Dg.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(l.MathUtils.degToRad);t.push(h),i.makeRotationFromEuler(Dg.fromArray(t)),i.copy(i.clone().invert())}e.scale&&a.scale(Og.fromArray(e.scale)),e.scalingOffset&&s.setPosition(Og.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(Og.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(Og.fromArray(e.rotationOffset)),e.rotationPivot&&u.setPosition(Og.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(f.copy(e.parentMatrix),d.copy(e.parentMatrixWorld));let g=n.clone().multiply(r).multiply(i),_=new l.Matrix4;_.extractRotation(d);let v=new l.Matrix4;v.copyPosition(d);let y=v.clone().invert().multiply(d),b=_.clone().invert().multiply(y),x=a,S=new l.Matrix4;if(m===0)S.copy(_).multiply(g).multiply(b).multiply(x);else if(m===1)S.copy(_).multiply(b).multiply(g).multiply(x);else{let e=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(f)).clone().invert(),t=b.clone().multiply(e);S.copy(_).multiply(g).multiply(t).multiply(x)}let C=u.clone().invert(),w=o.clone().invert(),T=t.clone().multiply(c).multiply(u).multiply(n).multiply(r).multiply(i).multiply(C).multiply(s).multiply(o).multiply(a).multiply(w),E=new l.Matrix4().copyPosition(T),D=d.clone().multiply(E);return p.copyPosition(D),T=p.clone().multiply(S),T.premultiply(d.clone().invert()),T}function Ag(e){e=e||0;let t=[`ZYX`,`YZX`,`XZY`,`ZXY`,`YXZ`,`XYZ`];return e===6?(console.warn(`THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.`),t[0]):t[e]}function jg(e){return e.split(`,`).map(function(e){return parseFloat(e)})}function Mg(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=e.byteLength),new TextDecoder().decode(new Uint8Array(e,t,n))}function Ng(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}function Pg(e,t,n,r){for(let i=n,a=0;i<r;i++,a++)e[a]=t[i];return e}var Fg=class extends l.Curve{constructor(e,t,n,r,i){super();let a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||a;for(let e=0;e<o;++e){let t=n[e];this.controlPoints[e]=new l.Vector4(t.x,t.y,t.z,t.w)}}getPoint(e,t=new l.Vector3){let n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=Rg(this.degree,this.knots,this.controlPoints,r);return i.w!==1&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new l.Vector3){let n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Ug(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}toJSON(){let e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new l.Vector4(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}};function Ig(e,t,n){let r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,a=r,o=Math.floor((i+a)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?a=o:i=o,o=Math.floor((i+a)/2);return o}function Lg(e,t,n,r){let i=[],a=[],o=[];i[0]=1;for(let s=1;s<=n;++s){a[s]=t-r[e+1-s],o[s]=r[e+s]-t;let n=0;for(let e=0;e<s;++e){let t=o[e+1],r=a[s-e],c=i[e]/(t+r);i[e]=n+t*c,n=r*c}i[s]=n}return i}function Rg(e,t,n,r){let i=Ig(e,r,t),a=Lg(i,r,e,t),o=new l.Vector4(0,0,0,0);for(let t=0;t<=e;++t){let r=n[i-e+t],s=a[t],c=r.w*s;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*s}return o}function zg(e,t,n,r,i){let a=[];for(let e=0;e<=n;++e)a[e]=0;let o=[];for(let e=0;e<=r;++e)o[e]=a.slice(0);let s=[];for(let e=0;e<=n;++e)s[e]=a.slice(0);s[0][0]=1;let c=a.slice(0),l=a.slice(0);for(let r=1;r<=n;++r){c[r]=t-i[e+1-r],l[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){let t=l[e+1],i=c[r-e];s[r][e]=t+i;let a=s[e][r-1]/s[r][e];s[e][r]=n+t*a,n=i*a}s[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=s[e][n];for(let e=0;e<=n;++e){let t=0,i=1,c=[];for(let e=0;e<=n;++e)c[e]=a.slice(0);c[0][0]=1;for(let a=1;a<=r;++a){let r=0,l=e-a,u=n-a;e>=a&&(c[i][0]=c[t][0]/s[u+1][l],r=c[i][0]*s[l][u]);let d=l>=-1?1:-l,f=e-1<=u?a-1:n-e;for(let e=d;e<=f;++e)c[i][e]=(c[t][e]-c[t][e-1])/s[u+1][l+e],r+=c[i][e]*s[l+e][u];e<=u&&(c[i][a]=-c[t][a-1]/s[u+1][e],r+=c[i][a]*s[e][u]),o[a][e]=r;let p=t;t=i,i=p}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}function Bg(e,t,n,r,i){let a=i<e?i:e,o=[],s=Ig(e,r,t),c=zg(s,r,e,a,t),u=[];for(let e=0;e<n.length;++e){let t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,u[e]=t}for(let t=0;t<=a;++t){let n=u[s-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(u[s-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=a+1;e<=i+1;++e)o[e]=new l.Vector4(0,0,0);return o}function Vg(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Hg(e){let t=e.length,n=[],r=[];for(let i=0;i<t;++i){let t=e[i];n[i]=new l.Vector3(t.x,t.y,t.z),r[i]=t.w}let i=[];for(let e=0;e<t;++e){let t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Vg(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}function Ug(e,t,n,r,i){return Hg(Bg(e,t,n,r,i))}var Wg=new l.Vector3;function Gg(e,t){switch(t){case`D`:return new Float64Array(e);case`F`:return new Float32Array(e);case`L`:return new Int32Array(e);case`I`:return new Int16Array(e);default:return new Uint8Array(e)}}function Kg(e,t={}){var n,r,i;let a=(n=t.upAxis)==null?`Z`:n,o=(r=t.fetcher)==null?Xs:r,s=(i=t.onDownloadProgress)==null?K:i,c={byteLength:0};return Promise.resolve().then(()=>o.ajax(e,{responseType:`arraybuffer`},void 0,void 0,s)).then(n=>{var r,i;return c.byteLength=n.body.byteLength,qg(new Uint8Array(n.body),{light:(r=t.light)==null?!0:r,color:t.color,resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(i=e.split(`?`)[1])==null?``:i,fetcher:o})}).then(t=>{let n=new l.Group;return n.name=e,n.add(t.object),a===`Y`&&n.applyMatrix4(Ps),{type:`x3p`,modelUpAxis:`Z`,upAxis:a,uri:e,byteLength:c.byteLength,memoryUsage:hl(n),scene:n,textures:[],animations:[],dispose:()=>t.dispose()}})}function qg(e,t){var n,r,i,a,o,s,c,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,ee,P,te,F,ne,re,ie,ae,I,L,R,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e;let ve=dg(e),ye=``,be=null;for(let e of Object.keys(ve))/(^|\/)main\.xml$/i.test(e)&&(be=ve[e],ye=e.slice(0,e.lastIndexOf(`/`)+1));if(!be)throw Error(`X3p: main.xml not found.`);if(typeof DOMParser>`u`)throw Error(`X3p: DOMParser not found.`);let xe=(n=t.color)==null?new l.Color(10066329):n,Se=new DOMParser,Ce=gu(be),we=Se.parseFromString(Ce,`text/xml`),Te=we.querySelector(`Record1 Axes`),Ee={x:{type:(a=(i=(r=Te==null?void 0:Te.querySelector(`CX AxisType`))==null?void 0:r.textContent)==null?void 0:i.toUpperCase())==null?`I`:a,dataType:(c=(s=(o=Te==null?void 0:Te.querySelector(`CX DataType`))==null?void 0:o.textContent)==null?void 0:s.toUpperCase())==null?`D`:c,increment:Number((d=(u=Te==null?void 0:Te.querySelector(`CX Increment`))==null?void 0:u.textContent)==null?`1`:d),offset:Number((p=(f=Te==null?void 0:Te.querySelector(`CX Offset`))==null?void 0:f.textContent)==null?`0`:p)},y:{type:(g=(h=(m=Te==null?void 0:Te.querySelector(`CY AxisType`))==null?void 0:m.textContent)==null?void 0:h.toUpperCase())==null?`I`:g,dataType:(y=(v=(_=Te==null?void 0:Te.querySelector(`CY DataType`))==null?void 0:_.textContent)==null?void 0:v.toUpperCase())==null?`D`:y,increment:Number((x=(b=Te==null?void 0:Te.querySelector(`CY Increment`))==null?void 0:b.textContent)==null?`1`:x),offset:Number((C=(S=Te==null?void 0:Te.querySelector(`CY Offset`))==null?void 0:S.textContent)==null?`0`:C)},z:{type:(E=(T=(w=Te==null?void 0:Te.querySelector(`CZ AxisType`))==null?void 0:w.textContent)==null?void 0:T.toUpperCase())==null?`A`:E,dataType:(k=(O=(D=Te==null?void 0:Te.querySelector(`CZ DataType`))==null?void 0:D.textContent)==null?void 0:O.toUpperCase())==null?`D`:k,increment:Number((j=(A=Te==null?void 0:Te.querySelector(`CZ Increment`))==null?void 0:A.textContent)==null?`1`:j),offset:Number((N=(M=Te==null?void 0:Te.querySelector(`CZ Offset`))==null?void 0:M.textContent)==null?`0`:N)}},De=null,Oe=we.querySelector(`Record1 Axes Rotation`);Oe&&(De=new l.Matrix3,De.set(Number((P=(ee=Oe.querySelector(`r11`))==null?void 0:ee.textContent)==null?0:P),Number((F=(te=Oe.querySelector(`r12`))==null?void 0:te.textContent)==null?0:F),Number((re=(ne=Oe.querySelector(`r13`))==null?void 0:ne.textContent)==null?0:re),Number((ae=(ie=Oe.querySelector(`r21`))==null?void 0:ie.textContent)==null?0:ae),Number((L=(I=Oe.querySelector(`r22`))==null?void 0:I.textContent)==null?0:L),Number((oe=(R=Oe.querySelector(`r23`))==null?void 0:R.textContent)==null?0:oe),Number((ce=(se=Oe.querySelector(`r31`))==null?void 0:se.textContent)==null?0:ce),Number((ue=(le=Oe.querySelector(`r32`))==null?void 0:le.textContent)==null?0:ue),Number((fe=(de=Oe.querySelector(`r33`))==null?void 0:de.textContent)==null?0:fe)));let ke=(pe=we.querySelector(`Record3 DataLink PointDataLink`))==null?void 0:pe.textContent;if(typeof ke!=`string`)throw Error(`X3p: PointDataLink not found.`);ke=rc(ye,ke);let Ae=ve[ke];if(!Ae)throw Error(`X3p: ${ke} not found.`);let je=Gg(Ae.buffer,Ee.z.dataType),Me=Number((he=(me=we.querySelector(`Record3 MatrixDimension SizeX`))==null?void 0:me.textContent)==null?`0`:he),Ne=Number((_e=(ge=we.querySelector(`Record3 MatrixDimension SizeY`))==null?void 0:ge.textContent)==null?`0`:_e),Pe=Math.floor(Me-1),Fe=Math.floor(Ne-1),Ie=Pe+1,Le=Fe+1,z=new Float32Array(Ie*Le*3),Re=new Float32Array(Ie*Le*2),ze=new Uint32Array(Pe*Fe*6),Be=new l.Box3;for(let e=0;e<Le;e++){let t=e*Ee.y.increment+Ee.y.offset;for(let n=0;n<Ie;n++){let r=e*Ie+n,i=n*Ee.x.increment+Ee.x.offset,a=je[r],o=!isNaN(a),s=o?a:NaN;Wg.set(i,-t,s),De&&Wg.applyMatrix3(De),o&&Be.expandByPoint(Wg),z[r*3+0]=Wg.x,z[r*3+1]=Wg.y,z[r*3+2]=Wg.z,Re[r*2+0]=n/Pe,Re[r*2+1]=1-e/Fe}}for(let e=0;e<Fe;e++)for(let t=0;t<Pe;t++){let n=t+Ie*e,r=t+Ie*(e+1),i=t+1+Ie*(e+1),a=t+1+Ie*e,o=(e*Pe+t)*6;ze[o+0]=n,ze[o+1]=r,ze[o+2]=a,ze[o+3]=r,ze[o+4]=i,ze[o+5]=a}let Ve=new l.BufferGeometry;Ve.setAttribute(`position`,new l.BufferAttribute(z,3)),Ve.setAttribute(`uv`,new l.BufferAttribute(Re,2)),Ve.setIndex(new l.BufferAttribute(ze,1)),(!Ve.groups||Ve.groups.length===0)&&Ve.addGroup(0,Ve.index?Ve.index.count:Ve.attributes.position.count,0),Ve.boundingBox=Be;let He=Lr(t.light?`phong`:`basic`);return He.flatShading=!0,He.color.copy(xe),{object:new kt(Ve,[He]),dispose:()=>{Ve.dispose(),He.dispose()}}}function Jg(e){let t=e.length/32;if(e.length%32!=0)throw Error(`Invalid splat file: data length ${e.length} is not a multiple of 32`);let n=new Float32Array(3*t),r=new Float32Array(4*t),i=new Float32Array(3*t),a=new Uint8Array(4*t),o=new Float32Array(e.buffer),s=new Uint8Array(e.buffer);for(let e=0;e<t;e++)n[3*e+0]=o[8*e+0],n[3*e+1]=o[8*e+1],n[3*e+2]=o[8*e+2],i[3*e+0]=o[8*e+3+0],i[3*e+1]=o[8*e+3+1],i[3*e+2]=o[8*e+3+2],a[4*e+0]=s[32*e+24+0],a[4*e+1]=s[32*e+24+1],a[4*e+2]=s[32*e+24+2],a[4*e+3]=s[32*e+24+3],r[4*e+0]=(s[32*e+28+0]-128)/128,r[4*e+1]=(s[32*e+28+1]-128)/128,r[4*e+2]=(s[32*e+28+2]-128)/128,r[4*e+3]=(s[32*e+28+3]-128)/128;return{numPoints:t,positions:n,scales:i,rotations:r,colors:a}}function Yg(e,t={}){var n,r,i,a;let o=(n=t.modelUpAxis)==null?`Y`:n,s=(r=t.upAxis)==null?`Z`:r,c=(i=t.fetcher)==null?Xs:i,l=(a=t.onDownloadProgress)==null?K:a,u=0;return Promise.resolve().then(()=>c.ajax(e,{responseType:`arraybuffer`},void 0,void 0,l)).then(e=>(u=e.body.byteLength,e.body)).then(e=>Jg(new Uint8Array(e))).then(t=>{let n=new Mt({positions:t.positions,scales:t.scales,rotations:t.rotations,colors:t.colors,numPoints:t.numPoints});return o===`Y`&&n.applyMatrix4(Ns),{type:`splat`,modelUpAxis:o,upAxis:s,uri:e,byteLength:u,memoryUsage:hl(n),scene:n,textures:[],animations:[],dispose:()=>n.dispose()}})}var Xg=new l.Matrix4,Zg=5e3,Qg=1e3;function $g(e,t){e.name=t.id;let n=t.tileset.properties.floorInfo;e.traverse(e=>{if(`floor`in t.extras){if(e instanceof on&&(e.floorIndex=t.extras.floor),e instanceof l.Mesh||e instanceof l.Points){let n=Array.isArray(e.material)?e.material:e.material?[e.material]:[];for(let e of n)Kt(e)&&(e.floorIndex=t.extras.floor),e.isPBMPointCloudMaterial&&(e.floorIndex=t.extras.floor)}}else if((e instanceof kt||e instanceof At)&&n){let r=new l.Box3().expandByObject(e).getCenter(new l.Vector3),i=0;for(let e=0;e<n.length;e++){let{ground:t,height:a}=n[e];if(r.y<t+a){i=e;break}}t.floor=i,t.tileset.floorLength=Math.max(t.tileset.floorLength,t.floor+1),e.material.forEach(e=>e.floorIndex=i)}})}function e_(e,t){if(!e.content)return Promise.resolve(e);let n=e.content,r=ic(n.uri,t.search);if(e.type===`TILESET`){let i=kc(r,{key:`model.${e.siblingIndex}`});return n.loadState=`LOADING`,n.loadStateUpdateTime=G(),t.fetcher.ajax(i,{responseType:`text`},void 0,void 0,(e,t,r)=>{n.loadState===`LOADING`&&(n.loadProgress=e)}).then(e=>e.body).then(e=>{let t=r.slice(0,r.lastIndexOf(`/`)+1);return Am(JSON.parse(e),t)}).then(t=>{n.loadState=`READY`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=0,e.children.length===0&&(e.children=[new Rf(`${e.id}.0`,t.root,e.tileset,e)])}).then(()=>e).catch(e=>(n.loadState=`FAILED`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=Math.min(n.loadfailRetryDelay+1e3,5e3),Promise.reject(e)))}if(e.type===`SCENEGRAPH`){n.loadState=`LOADING`,n.loadStateUpdateTime=G();let i=(e,t,r)=>{n.loadState===`LOADING`&&(n.loadProgress=e,r&&(n.byteLength=r))};return Promise.resolve().then(()=>{var n,a,o,s,c,u,d,f,p,m,h,g;let _=``,[v,y]=r.split(`#`),b=(y||v).split(`?`)[0].match(/\.([0-9a-zA-Z]+)$/);if(b&&(_=b[1]),_===`b3dm`)return nh(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:e.tileset.asset.gltfUpAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,$g(t.scene,e),t));if(_===`pnts`)return dh(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,computeBoundingBox:!1,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>{if(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,e.boundingVolume){let n=e.boundingVolume;t.scene.traverse(e=>{if(e instanceof on){Xg.copy(e.matrixWorld).invert();let t=new l.Box3;n.getBoundingBox(t),t.applyMatrix4(Xg),e.setLocalBoundingBox(t)}})}return $g(t.scene,e),t});if(_===`glb`||_===`gltf`)return sf(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:e.tileset.asset.gltfUpAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,$g(t.scene,e),t));if(_===`at3d`)return zl(e.extras.at3d?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(n=e.extras.at3d)==null?void 0:n.textureBaseUri,textureArray:(a=e.extras.at3d)==null?void 0:a.textureArray,textureOptions:(o=e.extras.at3d)==null?void 0:o.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`ply`)return eu(e.extras.ply?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:(s=e.extras.ply)==null?void 0:s.upAxis,type:`pbmPointCloud`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`pbm`)return _l(e.extras.pbm?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(c=e.extras.pbm)==null?void 0:c.textureBaseUri,textureArray:(u=e.extras.pbm)==null?void 0:u.textureArray,textureOptions:(d=e.extras.pbm)==null?void 0:d.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`dome`)return Ul(e.extras.dome?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(f=e.extras.dome)==null?void 0:f.textureBaseUri,textureOptions:(p=e.extras.dome)==null?void 0:p.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`domez`)return Xl(e.extras.domez?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,textureBaseUri:(m=e.extras.domez)==null?void 0:m.textureBaseUri,textureOptions:(h=e.extras.domez)==null?void 0:h.textureOptions,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`obj`)return Ch(e.extras.obj?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:(g=e.extras.obj)==null?void 0:g.upAxis,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`fbx`)return fg(e.extras.fbx?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`x3p`)return Kg(e.extras.x3p?r:kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,light:t.light,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));if(_===`spz`)return Jd(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,modelUpAxis:`Z`,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t.scene.transformChanged=!0,t));if(_===`splat`)return Yg(kc(r,{key:`model.${e.siblingIndex}`}),{upAxis:`Z`,fetcher:t.fetcher,onDownloadProgress:i}).then(t=>(t.scene.applyMatrix4(e.transform),t.scene.updateWorldMatrix(!1,!0),t.scene.matrixAutoUpdate=!1,t));throw Error(`Invalid Tile content: ${r}`)}).then(r=>{let i={type:r.type,uri:r.uri,byteLength:r.byteLength,memoryUsage:r.memoryUsage,object:new dm(e.id,r.scene,r.animations,r.dispose)};return Promise.resolve().then(()=>{i.object.traverse(e=>{e.matrix.compose(e.position,e.quaternion,e.scale),e.matrixAutoUpdate=!1})}).then(()=>Promise.all([i.object.generateBvhTree(),t.renderer?Im(r.textures,t.renderer):null])).then(()=>(n.loadState=`READY`,n.loadStateUpdateTime=G(),n.loadfailRetryDelay=0,n.byteLength=i.byteLength,n.memoryUsage=i.memoryUsage,n.data=i,e)).catch(t=>(t_(e),Promise.reject(t)))}).catch(e=>(n.loadState=`FAILED`,n.loadStateUpdateTime=G(),e instanceof zs&&e.httpStatus===0||e instanceof Bs||e instanceof Rs?n.loadfailRetryDelay=H(n.loadfailRetryDelay+Qg,Qg,Zg):n.loadfailRetryDelay=1/0,Promise.reject(e)))}throw Error(`Invalid Tile type: ${e.type}`)}function t_(e){e.content&&(e.content.data&&e.content.data.object.dispose(),e.content.data=void 0,e.content.loadState=`UNLOADED`,e.content.loadStateUpdateTime=G(),e.content.byteLength=0,e.content.memoryUsage=0)}var n_=new l.Vector3,r_=new l.Matrix3,i_=new l.Matrix4,a_=6378137,o_=298.257223563;function s_(e){let t=a_-a_/o_,n=(a_*a_-t*t)/(a_*a_),r=Math.sqrt(e.x*e.x+e.y*e.y),i=0,a=Math.atan2(e.z,r),o=0;for(;i++<1e3;){let t=Math.sin(a),i=a_/Math.sqrt(1-n*t*t);o=r/Math.cos(a)-i;let s=Math.atan2(e.z/(i*(1-n)+o),r/(i+o));if(isNaN(s)||Math.abs(s-a)<1e-12)break;a=s}return e.set(a,Math.atan2(e.y,e.x),o)}function c_(e){let{x:t,y:n,z:r}=e,i=a_-a_/o_,a=(a_*a_-i*i)/(a_*a_),o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=a_/Math.sqrt(1-a*o*o),d=(u+r)*s*l,f=(u+r)*s*c,p=(i*i/(a_*a_)*u+r)*o;return e.set(d,f,p)}function l_(e,t){let{x:n,y:r,z:i}=s_(n_.copy(e)),a=Math.sin(n),o=Math.sin(r),s=Math.cos(n),c=Math.cos(r);t.fromArray([-o,-a*c,s*c,0,+c,-a*o,s*o,0,0,s,a,0,0,0,0,1]);let l=r_.setFromMatrix4(t),u=n_.copy(e).applyMatrix3(l).multiplyScalar(-1);t.setPosition(u);let d=i_.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,i,1]);return t.premultiply(d),t}var u_=new l.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),d_=new l.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),f_=new l.Matrix4().copy(u_),p_=new l.Matrix4().copy(d_);function m_(e,t={}){var n,r,i;let a,o,s;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){s=4,t.powerPreference===`high`&&(s=2),a=s/1.6;let c=0;if(((n=e.tileset.rootMeta.taskParameters)==null?void 0:n.point_homogenization)===`1`&&(r=e.tileset.rootMeta.taskParameters)!=null&&r.homo_point_density){let t=Number((i=e.tileset.rootMeta.taskParameters)==null?void 0:i.homo_point_density);isFinite(t)&&!isNaN(t)&&(c=t)}c<=0&&(c=.02),o=c*1.4}else s=5,t.powerPreference===`high`&&(s=4),a=0,o=.03;else s=6,a=0,o=.03,e.name===`aerophoto`?(s=12,t.powerPreference===`high`&&(s=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(s=5,t.powerPreference===`high`&&(s=4));return{pointScale:o,pointMinPixel:a,maxScreenSpaceError:s}}var h_=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAABCAYAAACouxZ2AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACAKADAAQAAAABAAAAAQAAAAB7UD0+AAACA0lEQVRIDXWUW3YjIQxEwdnV/GT/q8kO3FO3pAJst3PSAaR6Cbszf//9XeMxxpjXmI+pVXudp2s6PC4dqHff9e6D7/PZLy46xQvG+sZvrfK8xgXUeq85yINe9bdmtOK1+kun5vjgq58a+eZPna9jvmjiserqG/+Whathvo3L3WhV89L9sXI/m18z2uene9ap/ftsuT9WZxoHXzW56/fpj8l7+tTw7P011NdpqnY19sRsfuHMA9u8oZWfDz4+fra/dfG1V60ydZ7qba1g7UNAeK0JP7ydD7/OqH6wO2f7HTq+B/lbL9qsB3/N1/UzR81XfPzw4tp5OPvRneacteq8Xo0xR3vuv/kPz0KtX0Nhg0eHuaNXdWI3X/ld427h++vzyp99V6VPrzWFhbv4ayay4oFecm198MmUXN/mL+x7npq/uJXBGb/MTw4+t+SvbLoTZnUW5uHhz7nWcTxT73OwXV7cxT9wbBf/0LnDBgcnHmtPLYba32Hp808sMy1u88yhr58n70/v4xX92GSN19l/2UsqGmiH94Hpxjcs+DO/ccpIVNVp62PUWXu//ur1GQy1Cf+GZ13rtNYN1po3/NI79fGXibHkq4z25xvV2pW3szpneXsW8SsreTe/NIPrtXMnH7wPf+LEN6tqhUVHj3XKD/72p9eafCeYB3zuonnbv7yqP8d/o4K6gRb1wbYAAAAASUVORK5CYII=`;function g_(e){return Object.keys(e)}function Y(e,t){return e==t}function __(e,t){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function v_(e,t){return e instanceof l.Vector3&&t instanceof l.Vector3?e.equals(t):e===t}function y_(e,t){return e instanceof l.Box3&&t instanceof l.Box3?e.equals(t):e===t}var b_={castShadow:Y,receiveShadow:Y,vertexMarks:Y,pano0:Y,pano1:Y,pano0Depth:Y,pano1Depth:Y,panoFilter:Y,refinedScreen:Y,modelAlpha:Y,progress:Y,transition:Y,opacity:Y,floorStyle:Y,roofStyle:Y,colorStyle:Y,constantColor:v_,shownFloorIndex:Y,clippers:__,brightness:Y,useHDR:Y,maxDisplayBoost:Y,pointShape:Y,pointSize:Y,pointBack:Y,pointScale:Y,pointMinPixel:Y,pointMaxPixel:Y,pointAppearAnimation:Y,colorSaturation:Y,colorBrightness:Y,useAddBlend:Y,outlineGain:Y,distanceGain:Y,gradientTexture:Y,boundingBox:y_,gaussianSplattingSHDegree:Y,minLevelOfDetail:Y,maxLevelOfDetail:Y,minGeometricError:Y,maxGeometricError:Y,panoramaMinGeometricError:Y,skipLevelOfDetail:Y,mostDetail:Y,loadSiblings:Y,cameraCulling:Y,maxMemoryUsage:Y,maxRequests:Y,requestOrder:Y,maxScreenSpaceError:Y,memoryAdjustedScreenSpaceError:Y,cacheCameras:__},x_=(()=>{let e;return e=typeof document<`u`?new l.TextureLoader().load(h_):new l.Texture,e.minFilter=l.NearestFilter,e.magFilter=l.NearestFilter,e.wrapS=l.RepeatWrapping,e.wrapT=l.RepeatWrapping,e})(),S_=Object.freeze(new l.Vector3(.6,.6,.6)),C_=Object.freeze([]),w_=Object.freeze(new l.Box3),T_=Object.freeze([]);function E_(){return{castShadow:void 0,receiveShadow:void 0,vertexMarks:void 0,pano0:void 0,pano1:void 0,pano0Depth:void 0,pano1Depth:void 0,panoFilter:void 0,refinedScreen:void 0,floorStyle:void 0,roofStyle:void 0,colorStyle:void 0,constantColor:void 0,shownFloorIndex:void 0,modelAlpha:void 0,opacity:void 0,progress:void 0,transition:void 0,clippers:void 0,brightness:void 0,useHDR:void 0,maxDisplayBoost:void 0,pointSize:void 0,pointBack:void 0,pointShape:void 0,pointScale:void 0,pointMaxPixel:void 0,pointMinPixel:void 0,pointAppearAnimation:void 0,gradientTexture:void 0,colorSaturation:void 0,colorBrightness:void 0,outlineGain:void 0,distanceGain:void 0,useAddBlend:void 0,boundingBox:void 0,gaussianSplattingSHDegree:void 0,minLevelOfDetail:void 0,maxLevelOfDetail:void 0,minGeometricError:void 0,maxGeometricError:void 0,panoramaMinGeometricError:void 0,skipLevelOfDetail:void 0,mostDetail:void 0,loadSiblings:void 0,cameraCulling:void 0,maxMemoryUsage:void 0,maxRequests:void 0,requestOrder:void 0,maxScreenSpaceError:void 0,memoryAdjustedScreenSpaceError:void 0,cacheCameras:void 0}}var D_={versionNumber:0,castShadow:!1,receiveShadow:!1,vertexMarks:!0,pano0:null,pano1:null,pano0Depth:null,pano1Depth:null,panoFilter:null,refinedScreen:null,floorStyle:`OPACITY`,roofStyle:`AUTO`,colorStyle:`RGB`,constantColor:S_,shownFloorIndex:-1,modelAlpha:1,opacity:1,progress:0,transition:`FADE`,clippers:C_,brightness:1,useHDR:!1,maxDisplayBoost:1,pointSize:`ATTENUATION`,pointBack:`DARK`,pointShape:`CIRCLE`,pointScale:.02,pointMaxPixel:40,pointMinPixel:0,pointAppearAnimation:!0,gradientTexture:x_,colorSaturation:0,colorBrightness:0,outlineGain:0,distanceGain:0,useAddBlend:!1,boundingBox:w_,gaussianSplattingSHDegree:0,minLevelOfDetail:0,maxLevelOfDetail:20,minGeometricError:0,maxGeometricError:1e4,panoramaMinGeometricError:.04,skipLevelOfDetail:!1,mostDetail:!1,loadSiblings:!1,cameraCulling:!0,maxMemoryUsage:64,maxRequests:6,requestOrder:`SCREEN_SPACE_ERROR`,maxScreenSpaceError:4,memoryAdjustedScreenSpaceError:!1,cacheCameras:T_},O_=D_.versionNumber;function k_(e={}){return Object.assign(e,D_)}var A_=g_(E_());function j_(e,t,n){let r=b_[t];if(!r)return!1;Array.isArray(n)&&(n=n.slice());let i=e[t];return r(i,n)?!1:(e[t]=n,!0)}var X=class e{static createDefault(){return k_()}static resolveValueTo(t,...n){let r=k_(t);for(let t of n){let n=t instanceof e?t.versionNumber:++O_;r.versionNumber=r.versionNumber*31+n|0;for(let e of A_)t[e]!==void 0&&j_(r,e,t[e])}return r}static resolveValue(...t){if(typeof t[0]==`string`){let e=t.shift(),n=t,r=D_[e];for(let t of n)t[e]!==void 0&&(r=t[e]);return r}else{let n=t;return e.resolveValueTo({},...n)}}constructor(e){this.id=Ft(),this.versionNumber=++O_,this.unbind=new Map,this.value=E_(),e&&this.copy(e);for(let e of A_)Object.defineProperty(this,e,{get(){return this.value[e]}});Ot(this)}resolveValue(...t){return e.resolveValue(...t,this)}assignValue(e,t){let n=this.unbind.get(e);n&&(this.unbind.delete(e),n());let r=j_(this.value,e,t),i=this.value[e];if(i instanceof Vt){let t=i.on(`update`,()=>this.versionNumber=++O_);this.unbind.set(e,t)}return r}set(e,t){let n=!1;if(typeof e==`string`)t!==void 0&&this.assignValue(e,t)&&(n=!0);else{let t=e;for(let e of A_)t[e]!==void 0&&this.assignValue(e,t[e])&&(n=!0)}return n&&(this.versionNumber=++O_),this}reset(...e){let t=!1;for(let n of e)this.assignValue(n,void 0)&&(t=!0);return t&&(this.versionNumber=++O_),this}resetAll(){return this.reset(...A_)}copy(e){let t=!0;for(let n of A_)this.assignValue(n,e[n])&&(t=!0);return t&&(this.versionNumber=++O_),this}},M_=new l.Vector3,N_=new Ef,P_=new Tf,F_=new WeakMap,I_=new WeakMap,L_=new WeakMap,R_={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},z_=(()=>{let e=new l.MeshBasicMaterial;return e.side=l.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=R_.TILE_MASK,e.stencilFunc=l.AlwaysStencilFunc,e.stencilFuncMask=R_.TILE_MASK,e.stencilZPass=l.ReplaceStencilOp,e.stencilWriteMask=R_.TILE_MASK,e})(),B_=(()=>{let e=new l.MeshBasicMaterial;return e.visible=!1,e})(),V_=new l.BufferGeometry,H_=new l.MeshBasicMaterial;function U_(e){let t;t=e instanceof l.Mesh?new l.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?B_:z_):e.material&&e.material.transparent?B_:z_):e instanceof l.Group?new l.Group:new l.Object3D,t.position.copy(e.position),t.quaternion.copy(e.quaternion),t.scale.copy(e.scale),t.matrix.compose(e.position,e.quaternion,e.scale),t.matrixAutoUpdate=!1,t.frustumCulled=e.frustumCulled,t.visible=e.visible;for(let n of e.children)t.add(U_(n));return t}var W_=class extends l.Object3D{constructor(e,t){var n,r;super(),this.parameter=new X,this.renderObjects=[],this.backfaceObjects=[],this.tileObjects=[],this.frameNumber=0,this.error=(n=t.error)==null?null:n,this.name=t.name,this.type=t.type,this.upAxis=t.upAxis,this.light=t.light,this.fetcher=t.fetcher,this.search=(r=t.search)==null?``:r,this.groundHeight=t.groundHeight,this.coordinateSystem=t.coordinateSystem,this.boundingBox=new l.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new l.Mesh(V_,H_),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new Om(e,{tileLoader:e=>this.loadContent(e),tileUnloader:e=>this.unloadContent(e),onTileLoad:e=>{this.onTileLoad&&this.onTileLoad(e)},onTileUnload:e=>{this.onTileUnload&&this.onTileUnload(e)},onTileError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{tile:e})),console.error(`Tile error`,e.id,t)}}),this.tileset.root.boundingVolume&&this.tileset.root.boundingVolume.getBoundingBox(this.boundingBox),this.currentResolvedParameterValue=X.resolveValueTo({},this.parameter)}get viewerRequestVolume(){return this.tileset.root.viewerRequestVolume}set viewerRequestVolume(e){this.tileset.root.viewerRequestVolume=e}get tiles(){return this.tileset.selectedTiles}get trajectories(){return this.tileset.trajectories}getRecommendProps(e={}){return m_(this,e)}loadContent(e){return e_(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)t_(e);else if(e.content.data)if(e.content.data.type===`spz`){let t=e.content.data.object.children[0].boundingBox;this.boundingBox.union(t)}else this.boundingBox.expandByObject(e.content.data.object)}})}unloadContent(e){return t_(e),Promise.resolve()}loadAllTilesets(){let e=t=>{let n=[];return this.tileset.root.traverse(e=>{var t;e.type===`TILESET`&&((t=e.content)==null?void 0:t.loadState)!==`READY`&&n.push(e)}),Promise.all(n.map(t=>this.loadContent(t).then(()=>e(t)))).then(()=>{})};return e(this.tileset.root)}intersectRaycaster(e,t){var n,r;let i=t==null?[]:t,a=[this.tileset.root],o=this.tileset.transform,s=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,c=e.sortByDistance;e.sortByDistance=!1;let l,u=1/0;for(;l=a.pop();){let t;if(l.boundingVolume){let n;n=l.boundingVolume instanceof Tf?P_.copy(l.boundingVolume):l.boundingVolume instanceof Ef?N_.copy(l.boundingVolume):l.boundingVolume.clone(),n.applyMatrix4(o),t=n.intersectRay(e.ray,s,u)}else t=!0;if(t){for(let e=0,t=l.children.length;e<t;e++)a.push(l.children[e]);if(l.selected&&l.content&&l.content.data&&l.content.data.object.visible){let t=e.hitFilter;if(e.hitFilter=n=>{var r;return Object.assign(n,{model:(r=this.parent)==null?void 0:r,viewLayer:this,tile:l}),t?t.call(e,n):!0},l.content.data.object.intersectRaycaster(e,i),e.hitFilter=t,e.firstHitOnly){let e=i[0];e&&u>e.distance&&(u=e.distance)}}}}return e.sortByDistance=c,Kf(i,e.sortByDistance,e.firstHitOnly),i}update(e,t,n,r){var i,a,o;this.renderer=e,this.frameNumber++;let s=!1,c=X.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);F_.get(this)!==c.versionNumber&&(F_.set(this,c.versionNumber),s=!0);let u=this.visible&&r.visible&&n.visible,d=c.maxLevelOfDetail;d=Math.max(d,0);let f=Math.min(c.minLevelOfDetail,d);(!u||!this.loaded||!n.loaded)&&(d=Math.max(f,0));let p=c.maxMemoryUsage;u||(p=Math.min(0,p));let m=c.minGeometricError,h=c.maxRequests,g=c.memoryAdjustedScreenSpaceError;u||(g=!1),t.controllerMode===`Panorama`&&(c.modelAlpha<.1&&(m=c.panoramaMinGeometricError,g=!1),c.progress>=.01&&c.progress<=.99&&(h=0));let _=c.maxGeometricError;_=Math.max(m,_);let v={time:t.time,camera:{type:t.type,position:new l.Vector3().copy(t.position),direction:t.getDirection(new l.Vector3),up:new l.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:u&&t.visible,refine:t.refineModel},height:t.resolution.height,pixelRatio:t.pixelRatio,frameNumber:this.frameNumber,sseDenominator:2*Math.tan(.5*t.fov/180*Math.PI),cullingVolume:new wf().setFromCamera(t),minLevelOfDetail:f,maxLevelOfDetail:d,minGeometricError:m,maxGeometricError:_,skipLevelOfDetail:c.skipLevelOfDetail,mostDetail:c.mostDetail,loadSiblings:c.loadSiblings,cameraCulling:c.cameraCulling,maxMemoryUsage:p,maxRequests:h,requestOrder:c.requestOrder,maxScreenSpaceError:c.maxScreenSpaceError,memoryAdjustedScreenSpaceError:g},y=c.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},v),{camera:{type:t.type,position:new l.Vector3().copy(e.position),direction:e.getWorldDirection(new l.Vector3),up:new l.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new wf().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),s=!0);let b=!this.autoRefine;if(b===!1&&c.progress>=.01&&c.progress<=.99){let e=new l.Vector3;c.pano0&&e.setFromMatrixPosition(c.pano0.matrix);let t=e.clone();c.pano1&&t.setFromMatrixPosition(c.pano1.matrix),e.distanceTo(t)<10&&(b=!0)}if(b||this.tileset.update(v,y),this.refined=!0,this.refineProgress[0]=0,this.refineProgress[1]=0,this.tileset.needsRefinedTiles.forEach(e=>{if(this.refineProgress[1]++,e.content){let t=e.content.loadState;if(t===`UNLOADED`||t===`LOADING`){this.refined=!1;return}}this.refineProgress[0]++}),this.loaded===!1&&this.autoRefine){this.loaded=!0;let e=!1;this.tileset.needsRefinedTiles.forEach(t=>{if(this.loaded!==!1&&t.content&&(t.state.visible&&(e=!0),c.minLevelOfDetail>=0)){if(v.skipLevelOfDetail){if(t.state.finalResolution){let e=t.state.ancestorWithContentAvailable,n=(e&&e.content?e.content:t.content).loadState;(n===`UNLOADED`||n===`LOADING`)&&(this.loaded=!1)}}else if(t.state.visible&&t.levelOfContent<=0){let e=t.content.loadState;(e===`UNLOADED`||e===`LOADING`)&&(this.loaded=!1)}}}),e&&this.tileset.selectedTiles.length===0&&this.tileset.frameNumber<500&&(this.loaded=!1),this.loaded===!0&&(this.refined=!1,this.refineProgress[1]++)}this.renderObjects.length=0,this.backfaceObjects.length=0,this.tileObjects.length=0;for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);v.skipLevelOfDetail||this.tileset.selectedTiles.sort((e,t)=>e.floor===t.floor?e.levelOfContent===t.levelOfContent?e.state.distanceToCamera===t.state.distanceToCamera?e.state.centerZDepth-t.state.centerZDepth:e.state.distanceToCamera-t.state.distanceToCamera:t.levelOfContent-e.levelOfContent:e.floor-t.floor);let x=[];for(let r of this.tileset.selectedTiles){let o=(a=(i=r.content)==null?void 0:i.data)==null?void 0:a.object;if(!o)continue;let u=o.update(e,t,n,this,r,c);if(x.push(r.id),u&&(s=!0),this.tileset.hasMixedContent&&v.skipLevelOfDetail){if(!r.state.finalResolution){let e=U_(o);e.name=`skipBackface:`+o.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=R_.TILE_MASK|e<<R_.SKIP_LOD_BIT_SHIFT,n=l.GreaterEqualStencilFunc,i=R_.SKIP_LOD_MASK,a=l.ReplaceStencilOp,s=R_.TILE_MASK|R_.SKIP_LOD_MASK;for(let e of o.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=i,e.stencilZPass=a,e.stencilWriteMask=s}else for(let e of o.materials)e.stencilWrite=!1,e.stencilRef=R_.TILE_MASK,e.stencilFunc=l.AlwaysStencilFunc,e.stencilFuncMask=R_.TILE_MASK,e.stencilZPass=l.ReplaceStencilOp,e.stencilWriteMask=R_.TILE_MASK;this.tileObjects.push(o)}let S=x.toString();if(I_.get(this)!==S&&(I_.set(this,S),s=!0),v.skipLevelOfDetail&&this.backfaceObjects.length)for(let e=0;e<this.backfaceObjects.length;e++)this.renderObjects.push(this.backfaceObjects[e]);if(this.tileObjects.length)for(let e=0;e<this.tileObjects.length;e++)this.renderObjects.push(this.tileObjects[e]);v.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let C=[];for(let r of this.tileset.selectedTrajectories){let i=(o=r.content.data)==null?void 0:o.object;if(!i)continue;let a=i.update(e,t,n,this,r,c);C.push(r.id),a&&(s=!0),this.renderObjects.push(i)}let w=C.toString();if(L_.get(this)!==w&&(L_.set(this,w),s=!0),this.parent){let e=this.parent.children.length+1,t=(Math.min(0,this.parent.children.indexOf(this))-e)*1e4+1;for(let e=0;e<this.renderObjects.length;e++){let n=this.renderObjects[e],r=e+t;n.traverse(e=>{(e instanceof l.Mesh||e instanceof l.Line||e instanceof l.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return s}dispose(){this.disposed=!0,this.tileset.reset(),this.tileset.root.children.length=0,/^blob\:/.test(this.tileset.id)&&URL.revokeObjectURL(this.tileset.id);for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);this.refined=!1,this.loaded=!1,this.refineProgress[0]=this.refineProgress[1]=0,this.error=null,this.onError=void 0,this.renderer=void 0}get model(){return this.parent}get scene(){return this}get viewLayer(){return this}localToEnu(e){return e.applyMatrix4(p_)}enuToLocal(e){return e.applyMatrix4(f_)}enuToEcef(e){return e.applyMatrix4(this.coordinateSystem.enuToEcefMatrix)}ecefToEnu(e){return e.applyMatrix4(this.coordinateSystem.ecefToEnuMatrix)}localToEcef(e){return this.enuToEcef(this.localToEnu(e))}ecefToLocal(e){return this.enuToLocal(this.ecefToEnu(e))}localToLla(e){return s_(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(c_(e)))}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}worldToEcef(e){return this.localToEcef(this.worldToLocal(e))}ecefToWorld(e){return this.localToWorld(this.ecefToLocal(e))}worldToLla(e){return this.localToLla(this.worldToLocal(e))}llaToWorld(e){return this.localToWorld(this.llaToLocal(e))}get coordinates(){M_.setScalar(0);let{x:e,y:t}=this.localToLla(M_);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new l.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(f_),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new l.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return M_.copy(e),this.worldToLla(M_),{latitude:M_.x,longitude:M_.y,altitude:M_.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minLevelOfDetail`,...e)}set minLevelOfDetail(e){this.parameter.set(`minLevelOfDetail`,e)}get maxLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxLevelOfDetail`,...e)}set maxLevelOfDetail(e){this.parameter.set(`maxLevelOfDetail`,e)}get minGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minGeometricError`,...e)}set minGeometricError(e){this.parameter.set(`minGeometricError`,e)}get maxGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxGeometricError`,...e)}set maxGeometricError(e){this.parameter.set(`maxGeometricError`,e)}get panoramaMinGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`panoramaMinGeometricError`,...e)}set panoramaMinGeometricError(e){this.parameter.set(`panoramaMinGeometricError`,e)}get skipLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`skipLevelOfDetail`,...e)}set skipLevelOfDetail(e){this.parameter.set(`skipLevelOfDetail`,e)}get mostDetail(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`mostDetail`,...e)}set mostDetail(e){this.parameter.set(`mostDetail`,e)}get loadSiblings(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`loadSiblings`,...e)}set loadSiblings(e){this.parameter.set(`loadSiblings`,e)}get maxMemoryUsage(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxMemoryUsage`,...e)}set maxMemoryUsage(e){this.parameter.set(`maxMemoryUsage`,e)}get maxRequests(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxRequests`,...e)}set maxRequests(e){this.parameter.set(`maxRequests`,e)}get requestOrder(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`requestOrder`,...e)}set requestOrder(e){this.parameter.set(`requestOrder`,e)}get maxScreenSpaceError(){let e=[];return this.parent&&this.parent.parameter instanceof X&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof X&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},G_={};function K_(e,t){let n=G_[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function q_(e,t,n){let r=G_[e];r||(r=G_[e]=new WeakMap),r.has(t)||r.set(t,n)}var J_=new l.Matrix4,Y_=new l.Vector3,X_=new l.Matrix4;function Z_(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:l_(t,n);break;default:n.identity();break}return n}function Q_(e){var t;let[n,r]=e.tilesetUrl.split(`#`),i=(t=(r||n).split(`?`)[1])==null?``:t;return e.fetcher.ajax(e.tilesetUrl,{responseType:`text`}).catch(e=>({error:e,body:JSON.stringify({asset:{version:`0.0`},geometricError:0,root:{geometricError:0}})})).then(t=>{var n;let r=`error`in t?t.error:null,a=Am(JSON.parse(t.body),e.tilesetUrl),{root:o,rootMeta:s={}}=a,c=e.upAxis;s.upAxis&&s.upAxis!==c&&(c=s.upAxis),`lodVersion`in a&&(c=`-Y`,`floorInfo`in a&&(a.properties=a.properties||{},a.properties.floorInfo=a.floorInfo.map(e=>({ground:-e.ground,height:e.height})),a.floorInfo=void 0),a.asset.tilesetVersion=String(a.lodVersion),a.lodVersion=void 0);let u=c,d=new l.Matrix4;u===`Y`?(u=`Z`,d.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):u===`-Y`&&(u=`Z`,d.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let f=o.boundingVolume?kf(o.boundingVolume):void 0;f&&o.transform&&f.applyMatrix4(X_.fromArray(o.transform));let p=null,m=new l.Matrix4,h=new l.Matrix4;return s.coordinate?(p=s.coordinate.ground_height,m.fromArray(s.coordinate.pose_ecef_to_enu),h.fromArray(s.coordinate.pose_enu_to_ecef)):(f?f.getCenter(Y_):Y_.setScalar(0),Y_.applyMatrix4(d),Z_(u,Y_,m),h.copy(m).invert()),a.root={refine:(n=o.refine)==null?`REPLACE`:n,geometricError:o.geometricError,transform:X_.copy(d).premultiply(u===`Z`?J_:m).premultiply(f_).toArray(),boundingVolume:f?f.toJson():void 0,children:[o]},new W_(a,{name:e.name,type:e.type,upAxis:c,light:e.light,fetcher:e.fetcher,search:i,groundHeight:p,coordinateSystem:{enuToEcefMatrix:h,ecefToEnuMatrix:m},error:r})})}function $_(e,t){var n;let r=e.layers.map(e=>({tilesetUrl:e.work.getURL(e.tileset),name:e.name,type:e.type,upAxis:e.upAxis,light:t.light,fetcher:t.fetcher}));if(e.file){let i=!1;for(let e of r)if(e.type===`mesh`){i=!0;break}if(i===!1){let i=oc(e.file)||`.at3d`,a=JSON.stringify({tilesetUrl:``,asset:{version:`0.0`},geometricError:0,root:{refine:`REPLACE`,geometricError:0,transform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],content:{uri:e.work.getURL(e.file)},extras:{[i.slice(1)]:{upAxis:e.upAxis,textureBaseUri:typeof e.textureBase==`string`?e.work.getURL(e.textureBase):void 0,textureArray:e.textures,textureOptions:(n=t.textureOptions)==null?{}:n}}},rootMeta:{coordinate:e.coordinate}});r.push({name:`fallback`,type:`mesh`,upAxis:`Z`,tilesetUrl:URL.createObjectURL(new Blob([a],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let i=r.map(e=>Q_(e).then(e=>e));return Promise.all(i)}function ev(e=1,t=1,n=1){let r=e/2,i=t/2,a=n/2,o=new Float32Array([-r,+i,+a,+r,+i,+a,+r,+i,-a,-r,+i,-a,-r,-i,+a,+r,-i,+a,+r,-i,-a,-r,-i,-a]),s=new Uint32Array([0,4,1,1,4,5,1,5,2,2,5,6,2,6,3,3,6,7,3,7,0,0,7,4,3,0,2,2,0,1,4,7,5,5,7,6]),c=new l.BufferGeometry;return c.setAttribute(`position`,new l.BufferAttribute(o,3)),c.setIndex(new l.BufferAttribute(s,1)),c.addGroup(0,c.index.count,0),c.computeBoundingBox(),c.computeBoundingSphere(),c}function tv(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=new l.BufferGeometry,c=0,u=0;u<e.length;++u){var d=e[u];if(n!==(d.index!==null))return null;for(var f in d.attributes){if(!r.has(f))return null;a[f]===void 0&&(a[f]=[]),a[f].push(d.attributes[f])}for(var f in d.morphAttributes){if(!i.has(f))return null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(s.userData.mergedUserData=s.userData.mergedUserData||[],s.userData.mergedUserData.push(d.userData),t){var p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return null;s.addGroup(c,p,u),c+=p}}if(n){for(var m=0,h=[],u=0;u<e.length;++u){for(var g=e[u].index,_=0;_<g.count;++_)h.push(g.getX(_)+m);m+=e[u].attributes.position.count}s.setIndex(h)}for(var f in a){var v=nv(a[f]);if(!v)return null;s.setAttribute(f,v)}for(var f in o){var y=o[f][0].length;if(y===0)break;s.morphAttributes=s.morphAttributes||{},s.morphAttributes[f]=[];for(var u=0;u<y;++u){for(var b=[],_=0;_<o[f].length;++_)b.push(o[f][_][u]);var x=nv(b);if(!x)return null;s.morphAttributes[f].push(x)}}return s}function nv(e){for(var t,n,r,i=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute||(t===void 0&&(t=o.array.constructor),t!==o.array.constructor)||(n===void 0&&(n=o.itemSize),n!==o.itemSize)||(r===void 0&&(r=o.normalized),r!==o.normalized))return null;i+=o.array.length}for(var s=new t(i),c=0,a=0;a<e.length;++a)s.set(e[a].array,c),c+=e[a].array.length;return new l.BufferAttribute(s,n,r)}function rv(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},u={},d=[],f=[`getX`,`getY`,`getZ`,`getW`],p=0,m=s.length;p<m;p++){var h=s[p];c[h]=[];var g=e.morphAttributes[h];g&&(u[h]=Array(g.length).fill().map(()=>[]))}for(var _=Math.log10(1/t),v=Math.pow(10,_),p=0;p<a;p++){for(var y=r?r.getX(p):p,b=``,x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),C=S.itemSize,w=0;w<C;w++)b+=`${~~(S[f[w]](y)*v)},`;if(b in n)d.push(n[b]);else{for(var x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),g=e.morphAttributes[h],C=S.itemSize,T=c[h],E=u[h],w=0;w<C;w++){var D=f[w];if(T.push(S[D](y)),g)for(var O=0,k=g.length;O<k;O++)E[O].push(g[O][D](y))}n[b]=o,d.push(o),o++}}let A=e.clone();for(var p=0,m=s.length;p<m;p++){var h=s[p],j=e.getAttribute(h),M=new j.array.constructor(c[h]),S=new l.BufferAttribute(M,j.itemSize,j.normalized);if(A.setAttribute(h,S),h in u)for(var x=0;x<u[h].length;x++){var N=e.morphAttributes[h][x],M=new N.array.constructor(u[h][x]),ee=new l.BufferAttribute(M,N.itemSize,N.normalized);A.morphAttributes[h][x]=ee}}return A.setIndex(d),A}var iv=new l.Sphere,av=new l.Matrix4,ov=new l.Matrix4;function sv(e,t,n=30/180*Math.PI){let r=Math.cos(n),i=[];for(let n of e.children)n instanceof W_&&n.tileset.selectedTiles.forEach(e=>{var n,a,o;let s=(a=(n=e.content)==null?void 0:n.data)==null?void 0:a.object;if(s&&s.visible){let e=[];if(s.traverseVisible(n=>{if(n instanceof l.Mesh){let r=Pp(n);if(r){av.copy(n.matrixWorld),ov.copy(av).invert(),iv.copy(t).applyMatrix4(ov);let i=r.trianglesInSphere(iv.center,iv.radius),a=new l.BufferGeometry;a.setAttribute(`position`,new l.BufferAttribute(i,3)),a.applyMatrix4(n.matrixWorld),a=rv(a,.01),e.push(a)}}}),e.length===0)return;let n=[`a`,`b`,`c`],a=tv(e,!1),c=a.getAttribute(`position`).array,u=((o=a.getIndex())==null?void 0:o.array)||[],d=[],f=[];for(let e=0,t=c.length;e<t;e+=3){let t=new l.Vector3(c[e],c[e+1],c[e+2]);d.push(t)}for(let e=0,t=u.length;e<t;e+=3){let t=u[e],n=u[e+1],r=u[e+2],i=new l.Vector3().crossVectors(d[n].clone().sub(d[t]),d[r].clone().sub(d[t])).normalize();f.push({a:t,b:n,c:r,normal:i})}let p={};for(let e=0,t=f.length;e<t;e++){let t=f[e];for(let r=0;r<3;r++){let i=t[n[r]],a=t[n[(r+1)%3]],o=[Math.min(i,a),Math.max(i,a)],s=o[0]+`-`+o[1];p[s]===void 0?p[s]={index1:o[0],index2:o[1],face1:e}:p[s].face2=e}}for(let e in p){let t=p[e];if(t.face2===void 0||f[t.face1].normal.dot(f[t.face2].normal)<=r){let e=d[t.index1],n=d[t.index2];i.push(new l.Line3(e,n))}}d.length=0,f.length=0}});return i}var cv=new l.Box3,lv=new l.Box3,uv=new l.Box3,dv=class extends l.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new X,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new l.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let i=0;for(let e of t.observers)i=Math.max(i,e.floorIndex);if(this.floorLength=i+1,t.model){this.metaPending=!0;let e=$_(t.model,{fetcher:K_(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),i=e=>this.dispatchEvent({type:`error`,error:e}),a=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),o=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,s=null;for(let t of e){if(t.visible=!1,t.onError=i,t.onTileLoad=a,t.onTileUnload=o,t.error){i(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):s===null&&(s=t)}let c=(t=n==null?r:n)==null?s:t;if(c&&(c.visible=!0),e.length)if(this.disposed)for(let t of e)t.dispose();else this.add(...e);return this}),this.loadedReady=new Promise(e=>{let t=()=>{e(this),this.removeEventListener(`load`,t),this.removeEventListener(`dispose`,t)};this.addEventListener(`load`,t),this.addEventListener(`dispose`,t)})}else this.refined=!0,this.loaded=!0,this.initReady=Promise.resolve(this),this.loadedReady=Promise.resolve(this);this.parameter.set(`boundingBox`,this.boundingBox.clone())}dispose(){this.disposed=!0;let e;for(;e=this.children[0];)typeof e.dispose==`function`&&e.dispose(),e.onError=void 0,e.onTileLoad=void 0,e.onTileUnload=void 0,this.remove(e);this.dispatchEvent({type:`dispose`})}get empty(){return this.children.length===0}get viewLayers(){return this.children}getEdgesBySphere(e,t=30/180*Math.PI){return sv(this,e,t)}intersectRaycaster(e,t){let n=t==null?[]:t,r=e.sortByDistance;e.sortByDistance=!1;for(let t=0,r=this.children.length;t<r;t++){let r=this.children[t];r.visible&&typeof r.intersectRaycaster==`function`&&r.intersectRaycaster(e,n)}return e.sortByDistance=r,Kf(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let i=this.loaded;this.refined=!this.metaPending,this.loaded=!this.metaPending,this.refineProgress[0]=this.refineProgress[1]=0,this.work.transform.equals(this.matrix)||(this.matrix.copy(this.work.transform),this.matrix.decompose(this.position,this.quaternion,this.scale),this.matrixAutoUpdate=!1,r=!0);for(let i of this.children)i.autoRefine=this.autoRefine,i.update(e,t,n,this)&&(r=!0),i.refined===!1&&(this.refined=!1),i.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=i.refineProgress[0],this.refineProgress[1]+=i.refineProgress[1];cv.makeEmpty(),uv.copy(this.work.observerBox),uv.isEmpty()||(uv.max.x+=1,uv.max.z+=1,uv.max.y+=1,--uv.min.x,--uv.min.z,cv.union(uv));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(lv.copy(e.boundingBox),cv.union(lv));return cv.applyMatrix4(this.matrix),cv.equals(this.boundingBox)||(this.boundingBox.copy(cv),this.parameter.set(`boundingBox`,cv.clone())),i===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(p_)}enuToLocal(e){return e.applyMatrix4(f_)}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}get shownFloor(){return this.shownFloorIndex===-1?null:this.shownFloorIndex}set shownFloor(e){this.shownFloorIndex=e===null?-1:e}show(e){this.shownFloor=e==null?null:e,this.dispatchEvent({type:`changeShownFloor`,floorIndex:e==null?null:e})}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).shownFloorIndex}set shownFloorIndex(e){this.parameter.set(`shownFloorIndex`,e)}get brightness(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).brightness}set brightness(e){this.parameter.set(`brightness`,e)}get clippers(){let e=[];return this.parent&&this.parent.parameter instanceof X&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e).clippers}set clippers(e){this.parameter.set(`clippers`,e)}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.viewLayers)e.resetBrightness()}};function Z(e,t,n){return Object.defineProperty(e,t,n)}var fv=ev(1,1,1);fv.applyMatrix4(new l.Matrix4().makeScale(-1,1,1));var pv=new WeakMap,mv=new l.Vector3(1,1,1),hv=new l.Box3,gv=new l.Vector3,_v=new l.Box3,vv=new l.Vector3,yv=new l.Vector3,bv=class extends kt{constructor(e={}){var t;let n=new Pr;n.colorAlpha=0,n.alphaMode=`BLEND`,n.depthWrite=!1,n.transparent=!1,n.blending=l.CustomBlending,n.blendSrc=l.SrcAlphaFactor,n.blendDst=l.OneMinusSrcAlphaFactor,n.blendSrcAlpha=l.OneFactor,n.blendDstAlpha=l.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(fv,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999}update(e,t,n){let r=!1,i=X.resolveValue(n.parameter);hv.copy(i.boundingBox),hv.getSize(gv);let a=Math.min(gv.x/2,500);hv.min.x-=a,hv.max.x+=a;let o=Math.min(gv.y/2,500);hv.min.z-=o,hv.max.z+=o;let s=gv.length()/2;if(hv.max.y=Math.max(hv.max.y,s),hv.union(_v.setFromCenterAndSize(t.position,mv)),hv.expandByScalar(1),hv.getCenter(vv),hv.getSize(yv),vv.equals(this.position)||(this.position.copy(vv),r=!0),yv.equals(this.scale)||(this.scale.copy(yv),r=!0),pv.get(this)!==i.versionNumber){pv.set(this,i.versionNumber),r=!0;let e=this.material;for(let t of e)Qt(t,i),t.visible=t.opacity!==0}return r}dispose(){for(let e of this.material)e.dispose()}},xv=new l.Box3,Sv=class extends l.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new l.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new X,this.fiveId=e.fiveId,this.boundingMesh=new bv({name:`bounding`}),this.add(this.boundingMesh);let t=this.models=[];this.shownModels=[],this.updateModelMap=new Map,this.parameter.set(`boundingBox`,this.boundingBox.clone());let n=this;Z(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),Z(t,`bounding`,{get(){return n.boundingBox}}),Z(t,`loaded`,{get(){return n.loaded}}),Z(t,`refined`,{get(){return n.refined}}),Z(t,`refineProgress`,{get(){return n.refineProgress}}),Z(t,`cacheCameras`,{get(){return n.parameter.resolveValue().cacheCameras},set(e){n.parameter.set(`cacheCameras`,e)}}),Z(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),Z(t,`setMaterial`,{value:e=>n.setMaterial(e)}),Z(t,`getMaterial`,{value:()=>n.getMaterial()}),Z(t,`resetBrightness`,{value:()=>n.resetBrightness()})}setModels(e,t){let n=e.map(e=>{let n=this.shownModels.filter(t=>t.work.workCode===e.workCode)[0];if(n||(n=this.models.filter(t=>t.work.workCode===e.workCode)[0],n))return n.work=e,n;n=new dv(this.fiveId,e,{light:t.light,textureOptions:t.textureOptions});let r=t[`3d-tiles`];return n.initReady.then(()=>{if(r)if(typeof r==`function`)for(let e of n.viewLayers){let t=r(e,n);t&&(t.viewerRequestVolume&&(e.viewerRequestVolume=kf(t.viewerRequestVolume)),e.parameter.set(Qs(t,[`showLayers`])),t.showLayers===!1?e.visible=!1:Array.isArray(t.showLayers)&&(e.visible=t.showLayers.includes(e.name)))}else for(let e of n.viewLayers)r.viewerRequestVolume&&(e.viewerRequestVolume=kf(r.viewerRequestVolume)),e.parameter.set(Qs(r,[`showLayers`])),r.showLayers===!1?e.visible=!1:Array.isArray(r.showLayers)&&(e.visible=r.showLayers.includes(e.name))}),this.dispatchEvent({type:`model.create`,model:n}),n});for(let e=0;e<this.models.length;e++){let t=this.models[e];n.indexOf(t)===-1&&this.shownModels.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.models.length=0;for(let e=0;e<n.length;e++){let t=n[e];this.models.push(t)}if(t.forceReplaceImmediately&&!Vf(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e])}return this.loaded=!1,this.refined=!1,this.models}get empty(){return this.boundingBox.isEmpty()}intersectRaycaster(e,t){let n=t==null?[]:t,r=this.shownModels.filter(e=>e.visible);if(r.length===1)r[0].intersectRaycaster(e,n);else{let t=e.sortByDistance;e.sortByDistance=!1;for(let t of r)t.intersectRaycaster(e,n);e.sortByDistance=t,Kf(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;xv.makeEmpty(),this.loaded=this.models.length>0,this.refined=this.models.length>0,this.refineProgress[0]=this.refineProgress[1]=0,this.updateModelMap.clear();for(let n=0;n<this.models.length;n++){let r=this.models[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;this.autoRefine===!1&&(r.autoRefine=!1);let i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}r.loaded===!1&&(this.loaded=!1),r.refined===!1&&(this.refined=!1),this.refineProgress[0]+=r.refineProgress[0],this.refineProgress[1]+=r.refineProgress[1]}if((this.loaded===!0||this.models.length===0)&&!Vf(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e]);n=!0}for(let n=0;n<this.shownModels.length;n++){let r=this.shownModels[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;(this.autoRefine===!1||this.models.indexOf(r)<0)&&(r.autoRefine=!1);let i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof dv&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),xv.union(t.boundingBox),this.add(t)}for(let e=0;e<this.models.length;e++){let t=this.models[e];this.shownModels.indexOf(t)===-1&&xv.union(t.boundingBox)}return xv.equals(this.boundingBox)||(this.boundingBox.copy(xv),this.parameter.set(`boundingBox`,this.boundingBox.clone()),n=!0),this.boundingMesh.update(e,t,this)&&(n=!0),this.updateModelMap.clear(),this.needsRender=n,n}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){return this.parameter.resolveValue()}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.models)e.resetBrightness()}dispose(){this.remove(this.boundingMesh),this.boundingMesh.dispose();for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof dv&&this.remove(t)}let e=Uf(this.models.concat(this.shownModels));for(let t=0;t<this.shownModels.length;t++)e[t].dispose();this.models.length=0,this.shownModels.length=0}};function Cv(e){let t={};return e.mode!==void 0&&(t.mode=e.mode),e.panoIndex!==void 0&&(t.pano_index=e.panoIndex),e.longitude!==void 0&&(t.longitude=e.longitude),e.latitude!==void 0&&(t.latitude=e.latitude),e.fov!==void 0&&(t.fov=e.fov),e.distance!==void 0&&(t.distance=e.distance),e.offset!==void 0&&(t.offset=e.offset.toArray()),t}function wv(e){var t;if(e)return{file_url:e.file,material_base_url:e.textureBase,material_textures:(t=e.textures)==null?void 0:t.slice(),up_axis:e.upAxis,layers:e.layers.map(e=>({tileset_url:e.tileset,up_axis:e.upAxis,name:e.name,type:e.type}))}}function Tv(e){return{index:e.index,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,floor_index:e.floorIndex,position:e.position.toArray(),standing_position:e.standingPosition.toArray(),quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w},visible_nodes:e.accessibleNodes.slice(),accessible_nodes:e.accessibleNodes.slice()}}function Ev(e){return{index:e.index,active:e.active,loadable:e.loadable,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,size_list:e.images.sizeList.slice(),up:e.images.up,down:e.images.down,right:e.images.right,left:e.images.left,front:e.images.front,back:e.images.back,video:e.images.video?{matrix:e.images.video.matrix.toArray(),size:e.images.video.size.toArray(),source:e.images.video.source}:void 0}}function Dv(e){return{allow_hosts:e.allowHosts.slice(),expire_at:e.expire.getTime().toString(),project_id:e.projectId,code:e.workCode,name:e.name,base_url:e.baseURL,initial:Cv(e.initial),model:wv(e.model),observers:e.observers.map(e=>Tv(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>Ev(e))}}}function Ov(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t),s=i*a,c=r,u=i*o,d=Math.abs(s),f=Math.abs(c),p=Math.abs(u),m,h;if(d>=f&&d>=p){let e=1/d;s>0?(m=`right`,h=new l.Vector2(-u*e,c*e)):(m=`left`,h=new l.Vector2(u*e,c*e))}else if(f>=d&&f>=p){let e=1/f;c>0?(m=`up`,h=new l.Vector2(s*e,-u*e)):(m=`down`,h=new l.Vector2(s*e,u*e))}else{let e=1/p;u>0?(m=`front`,h=new l.Vector2(s*e,c*e)):(m=`back`,h=new l.Vector2(-s*e,c*e))}return h.x=(h.x+1)/2,h.y=1-(h.y+1)/2,[m,h]}function kv(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,i=0,a=0,o=0;switch(e){case`right`:i=1,a=r,o=-n;break;case`left`:i=-1,a=r,o=n;break;case`up`:i=n,a=1,o=-r;break;case`down`:i=n,a=-1,o=r;break;case`front`:i=n,a=r,o=1;break;case`back`:i=-n,a=r,o=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let s=Math.sqrt(i*i+a*a+o*o);if(s===0)return new l.Vector2(.5,.5);i/=s,a/=s,o/=s;let c=Math.atan2(i,o),u=Math.asin(Math.max(-1,Math.min(1,a))),d=(c+Math.PI)/(2*Math.PI),f=(Math.PI/2-u)/Math.PI;return d%=1,d=d<0?d+1:d,f=Math.max(0,Math.min(1,f)),new l.Vector2(d,f)}function Av(e,t=`top-left`){let n=new l.Quaternion().setFromRotationMatrix(this.work.transform).invert(),r=new l.Quaternion().copy(this.quaternion).invert(),i=new l.Quaternion(0,1,0,0).invert(),a=new l.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(i),o=Math.atan2(a.x,-a.z),s=Math.asin(-a.y);if(t===`top-left`)return new l.Vector2(o/(Math.PI*2)+.5,s/Math.PI+.5);if(t===`bottom-left`)return new l.Vector2(o/(Math.PI*2)+.5,.5-s/Math.PI);throw Error(`Invalid uvOrigin ${t}`)}function jv(e,t=`top-left`){let n=0;if(t===`top-left`)n=1;else if(t===`bottom-left`)n=-1;else throw Error(`Invalid uvOrigin ${t}`);let r=new l.Quaternion().setFromRotationMatrix(this.work.transform),i=new l.Quaternion().copy(this.quaternion),a=new l.Quaternion(0,1,0,0),o=Math.PI*2*(e.x+.5),s=Math.PI*(e.y-.5),c=Math.abs(Math.cos(s)),u=Math.sin(o)*c,d=-Math.sin(s)*n,f=-Math.cos(o)*c;return new l.Vector3(u,d,f).applyQuaternion(a).applyQuaternion(i).applyQuaternion(r)}function Mv(e,t=`top-left`){let n=Ov(this.vectorToEquirectangularUv(e,`top-left`));if(t===`top-left`)return n;if(t===`bottom-left`){let[e,t]=n;return t.y=1-t.y,n}else throw Error(`Invalid uvOrigin ${t}`)}function Nv(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new l.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let i=kv(e,r);return this.equirectangularUvToVector(i)}function Pv(){return new l.Vector3().copy(this.position).applyMatrix4(this.work.transform)}function Fv(){return new l.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}function Iv(e){return typeof e==`number`}function Lv(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:Lv(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:Lv(r)}return t}}function Rv(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function zv(e,t){let n=Rv(e),r=Rv(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return Lv(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=zv(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=zv(e[n],t[n]);return e}function Bv(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=Bv(e[r],!1)+`,`;return n>-1&&(t+=Bv(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return Bv(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=Bv(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:return JSON.stringify(e.toString());case`undefined`:return t?void 0:null;case`number`:return e;default:return isFinite(e)?e:null}}function Vv(e){return Bv(e,!1)}function Hv(e){return`hash::${_t(Vv(e))}`}var Uv=/^(.*)\[(\d+)\]$/;function Wv(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function Gv(e){let t=e.match(Uv);if(t){let[e,n,r]=t,i=Math.floor(Number(r));if(!isNaN(i)&&isFinite(i))return{workCode:n,panoIndex:i}}throw Error(`Invalid PanoId`)}function Kv(e,t){return Wv(e)===Wv(t)}function qv(e){return typeof e==`string`&&Uv.test(e)}var Jv=`\\{([^\\}]+)\\}`;function Yv(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Xv(e){return RegExp(`^`+e.map(e=>Yv(e)).join(`(.+)`)+`$`)}var Zv=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(Jv,`g`),n,r=0;for(;(n=t.exec(e))!==null;)this.strings.push(e.slice(r,n.index)),this.keys.push(n[1]),r=n.index+n[0].length;this.strings.push(e.slice(r))}stringify(e){let t=[this.strings[0]];for(let n=0;n<this.keys.length;n++){let r=e[this.keys[n]];t.push(String(r),this.strings[n+1])}return t.join(``)}match(e){var t;this.matchRegexp=(t=this.matchRegexp)==null?Xv(this.strings):t;let n=e.match(this.matchRegexp);if(!n)return null;let r={};for(let e=0;e<this.keys.length;e++){let t=this.keys[e],i=n[e+1];if(r[t]!==i){if(r[t]!==void 0)return null;r[t]=i}}return r}};function Qv(e){Object.freeze(e);let t=typeof e==`function`,n=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach(function(r){n.call(e,r)&&(!t||r!==`caller`&&r!==`callee`&&r!==`arguments`)&&e[r]!==null&&(typeof e[r]==`object`||typeof e[r]==`function`)&&!Object.isFrozen(e[r])&&Qv(e[r])}),e}var $v=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,ey=Qv(JSON.parse(function(...e){return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/rnyrr;p{/9/rnyrr;p|z/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/rnyrr;nv/9/;p{/9/pq{;p{/9/pnyp{|qr;vr/j`))),ty=/^([^.]+)(\.([^.]+))*$/,ny=typeof location<`u`?location.hostname:`localhost`;function ry(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function iy(e,t){if(!ty.test(e)||!ty.test(t))return!1;if(e===`*`)return!0;let n=e.split(`.`).reverse(),r=t.split(`.`).reverse();if(n.length<=1)return e===t;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function ay(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return ny;let t=e.match($v);return t?t[2]:ny}var oy=()=>Error(`Invalid input.`),sy=()=>Error(`Invalid certificate.`),cy=()=>Error(`Invalid signature.`),ly=e=>Error(`Date(${e.toString()}) expired.`),uy=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function dy(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function fy(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=fy(e[r],!1)+`,`;return n>-1&&(t+=fy(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return fy(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=fy(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function py(e){return String(fy(e,!1))}function my(e){var t,n,r;let i={};try{i=typeof e==`string`?JSON.parse(e):e}catch(e){return oy()}if(typeof i!=`object`)return oy();let a=ny,o=Date.now(),s=new Date(typeof i.expire_at==`string`&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at),c=Array.isArray(i.allow_hosts)?i.allow_hosts:[];if(a.length===0||ry(a)||ey.filter(e=>iy(e,a)).length>0){let e=String((t=i.certificate)==null?``:t);if(e)try{let t=new V;return t.readCertPEM(e),Qv({issuer:t.getSubjectString(),expire:s,allowHosts:c})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return Qv({issuer:`none`,expire:s,allowHosts:c})}let l=String((n=i.certificate)==null?``:n);if(!l)return sy();let u=new V;u.readCertPEM(l);let d=String((r=i._signature)==null?``:r);return!d||Ct(py(dy(i,[`_signature`])),d,u)===!1?cy():o<s.getTime()?ey.concat(c).filter(e=>iy(e,a)).length===0?uy(a):Qv({issuer:u.getSubjectString(),expire:s,allowHosts:c}):ly(s)}function hy(e,t){let n=ay(e);return ny.length!==0&&!ry(ny)&&ey.filter(e=>iy(e,ny)).length===0&&!ry(n)&&ey.concat(t).filter(e=>iy(e,n)).length===0?uy(n):e}var gy=new Set,_y=new l.Vector3(1,1,1),vy=[`right`,`left`,`up`,`down`,`front`,`back`],yy=[`gainmap_right`,`gainmap_left`,`gainmap_up`,`gainmap_down`,`gainmap_front`,`gainmap_back`],by={vectorToEquirectangularUv:Av,vectorToCubemapUv:Mv,equirectangularUvToVector:jv,cubemapUvToVector:Nv,getWorldPosition:Pv,getWorldStandingPosition:Fv};function xy(e,t){if(!tc(e))return e;if(e.indexOf(t)===0)return e.slice(t.length);let n=t.replace(/^https\:/,`http:`);if(e.indexOf(n)===0)return e.slice(n.length);let r=t.replace(/^http\:/,`https:`);return e.indexOf(r)===0?e.slice(r.length):(console.warn(`${e} is not start with base_url(${t}).`),e)}function Sy(e,t,n){return!tc(e)&&typeof t==`string`&&t.length>0&&(e=rc(t,String(n),e)),e}function Cy(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function wy(e){e=e.slice().sort((e,t)=>e.level-t.level);let t=[];for(let n of e){if(t.length===0){t.push(n);continue}let e=t[t.length-1];if(n.level>e.level){t.push(n);continue}if(n.size>e.size){t[t.length-1]=n;continue}}return t}function Ty(e){let{manifest:t,baseURL:n}=e,r=[];return t.forEach((e,t)=>{let i={index:t,derived_id:e.derived_id,size_list:e.size_list,hdr_config:rc(n,e.cfg)};vy.forEach(t=>{i[t]=rc(n,e[t])}),yy.forEach(t=>{i[t]=rc(n,e[t])}),r.push(i)}),r}function Ey(e,t){var n,r,i,a,o,s,c,u,d,f,p,m,h,g,_,v,y,b,x;let S=[],C=null;for(let t of[].concat(e))if(`getURL`in t)C={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},S.push(Dv(t));else{let e=typeof t==`string`?JSON.parse(t):Lv(t),n=my(e);if(n instanceof Error)return n;C===null&&(C=n),S.push(e)}if(C===null)return Error(`Empty`);Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:C.issuer}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.expire)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.allowHosts)});let w=S.reduce((e,t)=>zv(e,t));Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=w.name)==null?`Unknown`:n)}),Z(t,`workCode`,{enumerable:!0,writable:!0,value:String(w.resource_code||w.basic_code||w.vr_code||w.code||w.project_id||w.work_code||w.workCode||Ft())}),Z(t,`projectId`,{enumerable:!0,writable:!0,value:w.project_id}),Z(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=w.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let T;typeof w.model==`object`&&(T={},Z(T,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(T,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.file_url;if(e)return xy(e,t.baseURL)})()}),Z(T,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.material_base_url;return e&&(e=xy(e,t.baseURL)),e})()}),Z(T,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(w.model.material_textures)&&(e=w.model.material_textures.slice(),Object.freeze(e)),e})()}),Z(T,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:w.model.up_axis}),Z(T,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:Lv(w.model.coordinate)}),Z(T,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let i=[];if(Array.isArray(w.model.layers)){for(let a of w.model.layers)if(a&&a.tileset_url){let o={};Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=a.name)==null?``:e}),Z(o,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=a.type)==null?`mesh`:n}),Z(o,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=a.up_axis)==null?`Z`:r}),Z(o,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:xy(a.tileset_url,t.baseURL)}),i.push(o)}}if(typeof w.model.tiles==`object`){let e=w.model.tiles;if(e&&e.tileset_url){let n={};Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),Z(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),Z(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),Z(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:xy(e.tileset_url,t.baseURL)}),i.push(n)}}return Object.freeze(i)})()})),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:T});let E=[];if(Array.isArray(w.observers)&&w.panorama&&Array.isArray(w.panorama.list||w.panorama.info)){let e=w.observers,n=t.panoHDR?Ty(t.panoHDR):(r=w.panorama.list||w.panorama.info)==null?[]:r,S=(u=(s=(a=(i=w.panorama)==null?void 0:i.pano_high_cube_base_url)==null?(o=w.panorama)==null?void 0:o.pano_cube_base_url:a)==null?(c=w.panorama)==null?void 0:c.base_url:s)==null?``:u,C=Math.min(e.length,n.length),T={};for(let e of Object.keys((d=w.panorama.pattern)==null?{}:d)){let t=e,n=w.panorama.pattern[t];if(typeof n==`string`){let e=new Zv(n);T[t]=t=>e.stringify(t)}else T[t]=()=>n}let D=(e,t)=>{var n;let r=T[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<C;r++){let i=e[r],a=n[r],o=Object.create(by);Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),Z(o,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),Z(o,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Wv({workCode:t.workCode,panoIndex:r})}),Z(o,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(f=i.floor_index)==null?i.floor:f}),Z(o,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(m=(p=i.derived_id)==null?D(a,`derived_id`):p)==null?0:m}),Z(o,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(g=(h=i.derived_id_str)==null?D(a,`derived_id_str`):h)==null?String(o.derivedId):g}),Z(o,`active`,{enumerable:!0,configurable:!1,writable:!1,value:i.active!==!1&&D(a,`active`)!==!1}),Z(o,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(v=(_=i.loadable)==null?D(a,`loadable`):_)==null?!1:v}),Z(o,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Vector3().fromArray((y=i.position)==null?[0,0,0]:y))}),Z(o,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Vector3().fromArray((x=(b=i.standing_position)==null?i.standingPosition:b)==null?[0,0,0]:x))}),Z(o,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Quaternion().fromArray(i.quaternion?[i.quaternion.x,i.quaternion.y,i.quaternion.z,i.quaternion.w]:[0,0,0,1]))}),Z(o,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new l.Matrix4().compose(o.position,o.quaternion,_y))}),Z(o,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(gy.clear(),i.accessible_nodes&&Array.isArray(i.accessible_nodes))for(let e of i.accessible_nodes)e>=C||e===r||gy.add(e);else if(i.accessibleNodes&&Array.isArray(i.accessibleNodes))for(let e of i.accessibleNodes)e>=C||e===r||gy.add(e);else if(i.visible_nodes&&Array.isArray(i.visible_nodes))for(let e of i.visible_nodes)e>=C||e===r||gy.add(e);else if(i.visibleNodes&&Array.isArray(i.visibleNodes))for(let e of i.visibleNodes)e>=C||e===r||gy.add(e);if(gy.size===0)for(let e=0;e<C;e++)e!==r&&gy.add(e);let e=Array.from(gy);return gy.clear(),Object.freeze(e)})()}),Z(o,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:o.accessibleNodes}),Z(o,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of vy)Z(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return xy(Sy((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});if(Z(e,`hdrConfig`,{enumerable:!0,configurable:!1,writable:!1,value:D(a,`hdr_config`)}),e.hdrConfig)for(let n of yy)Z(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return xy(Sy((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});return Z(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=Mc(e[vy[0]]),n=D(a,`size_list`),r=D(a,`tiles`);if(t){if(n){let e=n.slice().sort((e,t)=>e-t);return Object.freeze(e)}else if(r){let e=[t],n=r.slice().sort((e,t)=>e-t);for(let r of n){let n=512*Math.pow(2,r);n>t&&e.push(n)}return Object.freeze(e)}return Object.freeze([t])}return Object.freeze([])})()}),Z(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=Mc(e.front);if(!n)return;let i=e.sizeList.slice();if(i[0]){let e=Cy(i[0]);if(e)for(let t=e-1;t>=0;t--)i.unshift(512*Math.pow(2,t))}if(i.length<=0)return;let o=[];for(let s of i){let i=Cy(s);if(typeof i!=`number`)continue;let c={};if(Z(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:i}),s>n){Z(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),Z(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of vy)Z(c,t,{enumerable:!0,configurable:!1,writable:!1,value:Nc(e[t],s)});if(e.hdrConfig)for(let e of yy)Z(c,e,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var n;return Nc(xy(Sy((n=D(a,e))==null?``:n,S,r),t.baseURL),s)})()})}else{Z(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),Z(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/n});for(let t of vy)Z(c,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});if(e.hdrConfig)for(let e of yy)Z(c,e,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var n;return xy(Sy((n=D(a,e))==null?``:n,S,r),t.baseURL)})()})}o.push(c)}return o=wy(o),Object.freeze(o)})()}),Z(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=D(a,`video`),n;return e&&(n={},Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),Z(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Matrix4().fromArray(e.matrix)}),Z(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector2().fromArray(e.size)})),n})()}),e})()}),E.push(o)}}Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(E)});let D={};if(Z(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),w.initial){if(t.observers.length>0){let e;Iv(w.initial.panoIndex)?e=w.initial.panoIndex:Iv(w.initial.pano_index)?e=w.initial.pano_index:Iv(w.initial.pano)&&(e=w.initial.pano),typeof e==`number`&&(e=H(e,0,t.observers.length-1),Z(D,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(w.initial.mode===`Panorama`&&t.observers.length===0||w.initial.mode===`Floorplan`||w.initial.mode===`Topview`||w.initial.mode===`Model`||w.initial.mode===`Mapview`?Z(D,`mode`,{enumerable:!0,writable:!0,value:w.initial.mode}):typeof D.panoIndex==`number`?Z(D,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):Z(D,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),Iv(w.initial.latitude)&&Z(D,`latitude`,{enumerable:!0,writable:!0,value:w.initial.latitude}),Iv(w.initial.longitude)?Z(D,`longitude`,{enumerable:!0,writable:!0,value:w.initial.longitude}):Iv(w.initial.heading)&&Z(D,`longitude`,{enumerable:!0,writable:!0,value:Si(w.initial.heading)}),Iv(w.initial.fov)&&Z(D,`fov`,{enumerable:!0,writable:!0,value:w.initial.fov}),Iv(w.initial.distance)&&Z(D,`distance`,{enumerable:!0,writable:!0,value:w.initial.distance}),Array.isArray(w.initial.offset)){let e=w.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});Z(D,`offset`,{enumerable:!0,writable:!0,value:new l.Vector3().fromArray(t)})}else typeof w.initial.offset==`object`&&typeof w.initial.offset.x==`number`&&typeof w.initial.offset.y==`number`&&typeof w.initial.offset.z==`number`&&Z(D,`offset`,{enumerable:!0,writable:!0,value:new l.Vector3().fromArray([w.initial.offset.x,w.initial.offset.y,w.initial.offset.z])})}return Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:D}),t}function Dy(e,t){return Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),Z(t,`workCode`,{enumerable:!0,value:`null-`+Ft()}),Z(t,`baseURL`,{enumerable:!0,value:`/`}),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function Oy(e,t){var n,r;return Z(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),Z(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),Z(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),Z(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),Z(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?Ft():r}),Z(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),Z(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Wv({workCode:t.workCode,panoIndex:0})}),Z(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),Z(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),Z(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),Z(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),Z(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector3(0,1.5,0)}),Z(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Vector3(0,0,0)}),Z(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Quaternion(0,1,0,0)}),Z(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new l.Matrix4().compose(n.position,n.quaternion,_y)}),Z(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),Z(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),Z(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};Z(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of vy)Z(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return Z(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),Z(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=Mc(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=Cy(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let i=[];for(let a of r){let r=Cy(a);if(typeof r!=`number`)continue;let o={};if(Z(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>e){Z(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),Z(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of vy)Z(o,e,{enumerable:!0,configurable:!1,writable:!1,value:Nc(n[e],a)})}else{Z(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),Z(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/e});for(let e of vy)Z(o,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}i.push(o)}return i=wy(i),Object.freeze(i)})()}),Z(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),Z(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return Z(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),Z(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),Z(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var ky=new WeakSet,Ay=class{constructor(e,t){this.observerBox=new l.Box3,this.observerBox=new l.Box3,this.transform=new l.Matrix4,this.shortPath=!1,this.jsonp=!1,t.panoHDR&&(this.panoHDR=t.panoHDR);let n;if(n=e===null?Dy(e,this):typeof e==`object`&&typeof e.size==`number`&&typeof e.up==`string`&&typeof e.down==`string`&&typeof e.right==`string`&&typeof e.left==`string`&&typeof e.front==`string`&&typeof e.back==`string`?Oy(e,this):Ey(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
890
890
  Error work input:
891
891
  `+JSON.stringify(e));ky.add(this);for(let e of this.observers)this.observerBox.expandByPoint(e.position),this.observerBox.expandByPoint(e.standingPosition);t.baseURL&&(this.baseURL=t.baseURL),t.transform&&(Array.isArray(t.transform)?this.transform.fromArray(t.transform):this.transform.copy(t.transform)),typeof t.jsonp==`boolean`&&(this.jsonp=t.jsonp),typeof t.shortPath==`boolean`&&(this.shortPath=t.shortPath),t.workCode&&(typeof t.workCode==`string`?this.workCode=t.workCode:typeof t.workCode==`function`&&(this.workCode=t.workCode(e)));{let e=this;this.options={get transform(){return e.transform}},this.raw={get works(){return[JSON.stringify(Dv(e))]}}}}getURL(e){var t;if(!tc(e)){if(this.jsonp===!0){e=e.replace(/([\?\#].*)?$/i,``);let t=_t(`${e}`).slice(0,7);e=`${e}.${t}.jsonp`}if(this.shortPath===!0){let n=e.replace(e,``).split(`.`),r=(t=n.shift())==null?``:t,i=n.join(`.`);e=_t(r)+(i?`.`+i:``)}e=rc(this.baseURL,e)}return e=nc(e),e}verifyURL(e){return typeof hy(this.getURL(e),this.allowHosts)==`string`}toJSON(){return Dv(this)}};Ay.parse=jy;function jy(e,t){typeof e==`string`&&e.trim()[0]===`{`&&(e=JSON.parse(e));try{return new Ay(e,t==null?{}:t)}catch(t){console.log(t);let n=t instanceof Error?t.message:String(t);throw Error(`[PARSE Error]: `+n+`
892
892
  Error work input:
@@ -1159,4 +1159,4 @@ void main() {
1159
1159
  float cameraDepth = length(cameraVertex);
1160
1160
  gl_FragColor = packDepthToRGBA(clamp(cameraDepth / maxDepth, 0.0, 1.0));
1161
1161
  }
1162
- `,uniforms:{maxDepth:new l.Uniform(0)}});function lC(e,t,n,r=1e3){cC.uniforms.maxDepth.value=r,e.getClearColor(sC);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=cC,e.setClearColor(oC,0),n.update(e,t),e.setClearColor(sC,i),t.overrideMaterial=a}var uC=im,dC=new l.Raycaster,fC=new l.Vector3,pC=[new l.Vector3(0,0,0).multiplyScalar(.1),new l.Vector3(1,0,0).multiplyScalar(.1),new l.Vector3(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new l.Vector3(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],mC=Object.assign(Object.assign({},yS),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new dx:new rx,adjustPanoCircleMeshPositionBasedOnModel:!1,tileLevelForFov:((e,t)=>{var n;let r=e=>e/180*Math.PI,i=(n=Math.log2)==null?(e=>Math.log(e)*Math.LOG2E):n,a=t.height/2/Math.tan(r(e/2))*Math.tan(r(45))*2,o=Math.max(i(a/512),0);return o<2.3&&o>.1&&(o=1),o=o%1>.75?Math.ceil(o):Math.floor(o),o}),tileAppearDuration:.5,tileMaxRequest:3,flyEffectUseDepthBuffer:!1}),hC=class e extends bS{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{maxAccessibleDistance:(n=t.maxAccessibleDistance)==null?mC.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?mC.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?mC.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?mC.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?mC.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?mC.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?mC.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?mC.flyEffectUseDepthBuffer:l})}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`Panorama`})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Panorama`,this.initAnimationed=!1,this.maxAccessibleDistance=n.maxAccessibleDistance,this.panoTapTriggerRadius=n.panoTapTriggerRadius,this.panoCircleMeshCreator=n.panoCircleMeshCreator,this.adjustPanoCircleMeshPositionBasedOnModel=n.adjustPanoCircleMeshPositionBasedOnModel,this.tileLevelForFov=n.tileLevelForFov,this.tileAppearDuration=n.tileAppearDuration,this.tileMaxRequest=n.tileMaxRequest,this.flyEffectUseDepthBuffer=n.flyEffectUseDepthBuffer,this.adjustPanoCircleMeshPositionFix=new Map;let{pano0:r,pano1:i}=this.modelScene.parameter.resolveValue();r&&(i==null?void 0:i.map)!==r.map&&(this.modelScene.parameter.set({pano0:i}),r.map.dispose());let a=new Set;r&&a.add(r),i&&a.add(i),this.panoMeshes=new Map,this.locationMotion=new J({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Ft()]={panoId:Wv(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:uC,fixCameraTransform:new l.Matrix4},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new Qc,this.tiling=new eC({fiveId:this.fiveId}),this.panoVideo=new aC,this.scene.add(this.panoVideo.object),this.accessibleObserverFloorCheckCount=0}get tileLevel(){return this.tiling.level}updateConfiguration(e){return super.updateConfiguration(e)===!1?!1:(e.maxAccessibleDistance!==void 0&&this.maxAccessibleDistance!==e.maxAccessibleDistance&&(this.maxAccessibleDistance=e.maxAccessibleDistance),e.panoTapTriggerRadius!==void 0&&this.panoTapTriggerRadius!==e.panoTapTriggerRadius&&(this.panoTapTriggerRadius=e.panoTapTriggerRadius),e.panoCircleMeshCreator!==void 0&&this.panoCircleMeshCreator!==e.panoCircleMeshCreator&&(this.panoCircleMeshCreator=e.panoCircleMeshCreator,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear())),e.tileLevelForFov!==void 0&&this.tileLevelForFov!==e.tileLevelForFov&&(this.tileLevelForFov=e.tileLevelForFov),e.tileMaxRequest!==void 0&&this.tileMaxRequest!==e.tileMaxRequest&&(this.tileMaxRequest=e.tileMaxRequest),e.flyEffectUseDepthBuffer!==void 0&&this.flyEffectUseDepthBuffer!==e.flyEffectUseDepthBuffer&&(this.flyEffectUseDepthBuffer=e.flyEffectUseDepthBuffer),e.adjustPanoCircleMeshPositionBasedOnModel!==void 0&&this.adjustPanoCircleMeshPositionBasedOnModel!==e.adjustPanoCircleMeshPositionBasedOnModel&&(this.adjustPanoCircleMeshPositionBasedOnModel=e.adjustPanoCircleMeshPositionBasedOnModel,this.adjustPanoCircleMeshPositionBasedOnModel||this.adjustPanoCircleMeshPositionFix.clear()),!0)}destroy(){super.destroy(),this.tiling.dispose(),this.modelScene.parameter.set({refinedScreen:null,pano0Depth:null,pano1Depth:null}),this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0),this.locationMotion.dispose(),this.pendingTextureTask=void 0,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear());let e=this.videoTexture.image;e.pause(),e.oncanplay=K,e.ontimeupdate=K,this.scene.remove(this.panoVideo.object),this.panoVideo.setMaterial(null),this.panoVideo.dispose();let{pano0:t,pano1:n}=this.modelScene.parameter.resolveValue();for(let e of Object.keys(this.panoResources)){let r=this.panoResources[e];if(r.panoPicture){let e=r.panoPicture.map;e&&e!==(t==null?void 0:t.map)&&e!==(n==null?void 0:n.map)&&(e.dispose(),r.panoPicture=null)}delete this.panoResources[e]}}isReady(){return this.locationMotion.ended===!0?super.isReady():!1}isTileReady(){let e=this.tiling.pedding<=0;return this.initAnimationed&&e}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&(this.initAnimationed=!1,this.moveToPano({workCode:a.workCode,panoIndex:a.panoIndex},{effect:r.effect,duration:r.duration,longitude:a.longitude,latitude:a.latitude,fov:a.fov,moveEndCallback:()=>{this.initAnimationed=!0},moveCancelCallback:()=>{this.initAnimationed=!0}},i)),!0}updateModel(e){this.modelScene=e,this.hideIntersectMesh()}updateTime(e,t,...n){var r,i,a,o,s,c,u;if(this.destroyed)return;let d={},f={},p=this.camera.getDirection(new l.Vector3),m=this.locationMotion.keyframes[0],h=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[g,_]=this.locationMotion.getKeyFrameSegment(e),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(_),b=this.panoResourceFromLocationMotionKeyframe(m),x=this.panoResourceFromLocationMotionKeyframe(h),S=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),f.longitude=this.cameraMotion.value.longitude,f.latitude=this.cameraMotion.value.latitude,f.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),d.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-_.value.count+1,n=new l.Vector3().copy(v.position),a=new l.Vector3().copy(y.position);if(d.progress=y.effectEasing(t),t>=.01&&t<=.99&&(d.progress=H(y.effectEasing(t),.01,.99)),y.panoPicture&&(t<1?v.panoPicture&&(d.pano0=v.panoPicture):d.pano0=y.panoPicture,d.pano1=y.panoPicture),y.effect===`montage`?d.transition=`BLACK`:y.effect===`spread`?d.transition=`SPREAD`:d.transition=`FADE`,y.effect===`zoomin`||y.effect===`zoomout`?d.progress=Math.pow(t,3):y.effect===`model`&&this.camera.pose.distance<.01&&(d.modelAlpha=1-Math.pow(H(Math.abs(t-.5)*2,0,1),4)),t<1&&y.effect!==`fly`&&y.effect!==`model`){if(d.pano0&&v.panoPicture){let e={panoId:d.pano0.panoId,map:d.pano0.map,mapHistogram:d.pano0.mapHistogram,mapSize:d.pano0.mapSize,zoom:d.pano0.zoom,matrix:v.panoPicture.matrix.clone().premultiply(v.fixCameraTransform).setPosition(y.position),hdrConfig:d.pano0.hdrConfig?Object.assign({},d.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(d.pano0);t&&this.panoPictureObserverMap.set(e,t),d.pano0=e}n.copy(a),S=!0}f.distance=this.locationMotion.value.distance,f.offset=new l.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=d.pano0)==null?void 0:r.map)||e===((i=d.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let c=Gv(y.panoId);c!==this.currentPano&&(this.currentPano=c,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:Gv(b.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Gv(x.panoId)),{mode:this.mode}),Ox(this.camera.pose)),f),options:{},progress:this.locationMotion.progress,error:null}))}jx(d)===!1&&this.modelScene.parameter.set(d),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),jx(f)===!1&&this.setCamera(f);let C=this.works.getObserver(this.currentPano),w=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,T=this.works.getObserver(v.panoId),E=this.works.getObserver(y.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&C){let e=[],t=C.work.observers;for(let n of C.accessibleNodes){let r=t[n];r&&e.push(r)}let n=new Map;if(e.sort((e,t)=>{let r=n.get(e);r===void 0&&(r=e.standingPosition.distanceTo(C.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(C.standingPosition),n.set(t,i)),r-i}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let t=e[this.accessibleObserverFloorCheckCount],n=this.modelScene.models.find(e=>e.work===(t==null?void 0:t.work));if(t&&n&&n.visible){let e=.3,r=.005,i=t.standingPosition.clone().applyMatrix4(t.work.transform),a=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=pC.map(t=>{dC.ray.origin.copy(i),dC.ray.origin.add(fC.copy(t).setY(e)),dC.ray.direction.set(0,-1,0),dC.firstHitOnly=!0,dC.floorIndex=-1;let[a]=n.intersectRaycaster(dC);return a&&a.distance-r<=e?new l.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[c]=o.filter(e=>e.distanceTo(s)<=.05);if(c){let e=new l.Vector4(i.x,i.y,i.z,c.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let D=new Map;if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(E)for(let e of E.accessibleNodes){let t=E.work.observers[e];if(t){let e=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{D.get(t)?D.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),D.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),D.delete(t)}),this.panoMeshes.forEach((e,t)=>{let n=this.works.getObserver(t);if(n){let r=n.position.distanceTo(n.standingPosition)>this.aerialObserverMinHeight;if(r)e.position.copy(n.position).applyMatrix4(n.work.transform),e.scale.setScalar(18);else{e.position.copy(n.standingPosition).applyMatrix4(n.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(n.panoId);t&&(fC.set(t.x,t.y,t.z),fC.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new l.Vector3().copy(e.position).sub(i).normalize();if(t===Wv(this.currentPano)){let t=H((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(p.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new l.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||S)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(C){let n=C.work.observers,[,r]=Bf(C.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:C.standingPosition.distanceTo(t.standingPosition)},!0);r=H(r,3,1/0);let i=C.accessibleNodes.concat(C.panoIndex).map(e=>Wv({panoIndex:e,workCode:C.work.workCode}));this.panoMeshes.forEach((n,a)=>{let o=this.works.getObserver(a),s=!1,c=1;if(i.indexOf(a)===-1)s=!1,c=0;else if(!o)s=!1,c=0;else if(!o.loadable&&!o.active)s=!1,c=0;else{let e=n.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&w!==null&&Wv({panoIndex:w.panoIndex,workCode:w.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:H(r/t,.1,.85)}o&&o===E&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue().modelAlpha>0&&(c=0),n.setCurrent(s),n.setOpacity(c),n.updateTime&&n.updateTime(e,t)})}{let e=(a=this.modelScene.parameter.progress)==null?1:a,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,c;if(i&&(c=this.works.getObserver(i.panoId),c||(c=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(Wc()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!c||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:null,gainMap:void 0,panoMatrix:new l.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Fc(i.mapSize),a=e+1,u=new l.Vector2().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),d=Math.floor(this.tileLevelForFov(this.camera.fov,u)),f=d>e?d:0;this.tiling.setObserver(c);let p={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:i.map,gainMap:(o=i.hdrConfig)==null?void 0:o.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:a,level:f,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},m=this.tiling.update(p),h={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:t,opacity:(n==null?void 0:n.panoId)===(r==null?void 0:r.panoId)?1:om(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},g=this.modelScene.parameter.refinedScreen;(m||h.pano!==(g==null?void 0:g.pano)||h.opacity!==(g==null?void 0:g.opacity))&&this.modelScene.parameter.set(`refinedScreen`,h)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),C&&C.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&C&&C.position.y-C.standingPosition.y>10){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1);{let e=y.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((c=this.modelScene.parameter.pano0Depth)==null?void 0:c.panoId)!==t.panoId||((u=this.modelScene.parameter.pano1Depth)==null?void 0:u.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new l.CubeRenderTarget(512,{minFilter:l.NearestFilter,magFilter:l.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new l.CubeRenderTarget(512,{minFilter:l.NearestFilter,magFilter:l.NearestFilter,generateMipmaps:!1});let e=new l.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,lC(this.renderer,this.modelScene,e,500);let r=new l.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,lC(this.renderer,this.modelScene,r,500),this.modelScene.parameter.set({pano0Depth:{panoId:t.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:n.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1],n=this.panoResourceFromLocationMotionKeyframe(t),r=this.works.getObserver(n.panoId);return{workCode:r?r.work.workCode:this.currentPano.workCode,panoIndex:r?r.panoIndex:this.currentPano.panoIndex,mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:r?r.position.clone().applyMatrix4(r.work.transform):this.camera.position.clone(),distance:this.locationMotion.value.distance}}moveToPano(e,t,n){var r,i,a;let o=(r=t.effect)==null?`fly`:r;this.userAction=n,this.stopMomentumMovement();let s=Wv(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let u=Mc(c.images.up),d=this.imageOptions.size;d===void 0&&c&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=Object.assign({key:`pano.${s}`},Zs(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),m={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},h,g=``;c.images.hdrConfig&&(h={right:c.images.work.getURL(c.images.gainmap_right),left:c.images.work.getURL(c.images.gainmap_left),up:c.images.work.getURL(c.images.gainmap_up),down:c.images.work.getURL(c.images.gainmap_down),front:c.images.work.getURL(c.images.gainmap_front),back:c.images.work.getURL(c.images.gainmap_back)},g=c.images.work.getURL(c.images.hdrConfig));let _=`pano:`+Hv([m,p,f]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===_)return;{let e=this.pendingTextureTask.panoId;(i=this.panoMeshes.get(e))==null||i.setProgress(0),this.emit(`pano.texture.abort`,$(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode}}))}}let v=`move-to-pano-`+s;this.pending.add(v);let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===_?b=y.pano0:y.pano1&&y.pano1.map.name===_&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?uC:a,panoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:b.hdrConfig?Object.assign({},b.hdrConfig):void 0},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new l.Matrix4};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,c),this.pendingTextureTask=void 0,Bc.shared.add(()=>{this.pending.delete(v),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:_,onLoad:(n,r)=>Dd(this,void 0,void 0,function*(){var i,a;let u=n.body;if(this.destroyed)u.dispose();else{u.name=_;let n=Array.isArray(u.image)?u.image[0]:u.image,d=(i=n==null?void 0:n.width)==null?2048:i,{data:f}=yield qx(this.renderer,u,!0,eb),p=new ib().formPixels(f),m={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?uC:a,panoPicture:{panoId:s,map:u,mapSize:d,mapHistogram:new l.Vector4().fromArray(p.toArray()),matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:r},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new l.Matrix4};m.panoPicture&&this.panoPictureObserverMap.set(m.panoPicture,c),this.doMoveToPano(e,m,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),Ox(this.camera.pose));this.emit(`pano.error`,$(`pano.error`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`pano.cancel`,$(`pano.cancel`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`error`,n),t.moveCancelCallback&&t.moveCancelCallback()}};let x=this.panoMeshes.get(s);x&&x.tap&&x.tap();let S=[this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,$(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];g&&S.push(fetch(g).then(e=>e.json()),this.textureLoader.loadCubeTexture(h,{imageURL:{transform:f,options:p},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,c.work)},void 0,void 0,void 0,this.renderer)),Promise.all(S).then(([t,n,r])=>{var i,a;this.pending.delete(v),((i=this.pendingTextureTask)==null?void 0:i.hash)===_?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},fS(n))),this.pendingTextureTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,$(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}))}).catch(t=>{var n,r;this.pending.delete(v),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&(this.pendingTextureTask.onError(t),this.pendingTextureTask=void 0,(r=this.panoMeshes.get(s))==null||r.setProgress(0)),this.emit(`pano.texture.error`,$(`pano.texture.error`,{error:t,progress:0,meta:null,pano:e})),this.emit(`error`,t)}),this.emit(`pano.texture.load`,$(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{duration:n,effect:r,userAction:i}=this.initial;this.userAction=i;let a=e.initAnimationEndState(this),o={workCode:a.workCode,panoIndex:a.panoIndex},s={modelAlpha:0},c={perspToOrtho:0},l=!1;this.moveToPano(o,{longitude:a.longitude,latitude:a.latitude,fov:a.fov,effect:r,duration:n,moveStartCallback:e=>{l=!0,this.perspToOrthoMotion.set(c,n).catch(K),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:s}],n).catch(K),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()},moveCancelCallback:()=>{let e=Object.assign(Object.assign(Object.assign({},o),{mode:this.mode}),Ox(this.camera.pose));l===!1&&this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction})),this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()}},i)})}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}locationMotionKeyframesLength(e){let t=0;for(let n=1;n<e.length;n++){let r=this.panoResourceFromLocationMotionKeyframe(e[n-1]).position,i=this.panoResourceFromLocationMotionKeyframe(e[n]).position,a=r.distanceTo(i)*(e[n].value.count-e[n-1].value.count);t+=a}return t}doMoveToPano(e,t,n={}){var r,i,a,o,s,c,u,d,f,p,m;let h=G(),g=Ft();this.panoResources[g]=t;let _,v,y;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;_=Math.max(a.distanceTo(o),1),v=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],y=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(n).position,o=t.position,s=n.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;_=c+Math.max(a.distanceTo(o),1),v=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/_,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(v);y=l===0||l===0?0:this.locationMotion.getProgressVelocity(h)*l/u}let b=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?_:0),x={longitude:n.longitude,latitude:n.latitude,fov:n.fov},S=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=x.longitude)==null?this.camera.pose.longitude:i,latitude:(a=x.latitude)==null?this.camera.pose.latitude:a,fov:(o=x.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),C=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(S),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(x,b).catch(K);else{let e=yi({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=yi({longitude:(s=x.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=x.latitude)==null?this.cameraMotion.value.latitude:c}),r=new l.Object3D;r.lookAt(e);let i=new l.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new l.Matrix4().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),h=this.cameraMotion.value.fov,g=(u=x.fov)==null?this.cameraMotion.value.fov:u,_=1;t.effect===`zoomin`?_=1.5:t.effect===`zoomout`&&(_=.4);let y=H(g*_,1,170);for(let e=0;e<v.length-1;e++){let t=v[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(y/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=x.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=x.latitude)==null?this.cameraMotion.value.latitude:f,fov:y}},{progress:1,value:{longitude:(p=x.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=x.latitude)==null?this.cameraMotion.value.latitude:m,fov:g}}],b).catch(K)}this.locationMotion.setKeyframes(v,b,y).then(()=>{for(let e of this.modelScene.children)e instanceof dv&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance});this.emit(`pano.arrived`,$(`pano.arrived`,{options:n,prevPano:C,progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(e);if(r&&r.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:r.images.video.size.clone(),matrix:r.images.video.matrix.clone(),panoMatrix:r.matrix.clone().premultiply(r.work.transform),alpha:1},t=Ft(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=K,n.ontimeupdate=K,CS().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=K,e.ontimeupdate=K}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}getForwardObserverOrNot(e,t){let n=this.works.getObserver(this.currentPano);if(!n)return null;let r=t==null?new l.Raycaster(e.position.clone(),e.getWorldDirection(new l.Vector3)):t;r.params.Points={threshold:.1},r.firstHitOnly=!0,r.floorIndex=-1;let i=n.standingPosition.clone().applyMatrix4(n.work.transform);if(n.position.clone().applyMatrix4(n.work.transform).distanceTo(r.ray.origin)>1){let e=new l.Raycaster(r.ray.origin,new l.Vector3(0,-1,0));e.firstHitOnly=r.firstHitOnly,e.floorIndex=r.floorIndex;let[t]=this.modelScene.intersectRaycaster(e);t&&t.distance<=2?i.copy(t.point):i.copy(r.ray.origin).add(new l.Vector3(0,-1.5,0))}let[a]=this.modelScene.intersectRaycaster(r),o=(a?a.point:r.ray.origin.clone().add(r.ray.direction.clone().normalize().multiplyScalar(3))).clone().sub(i).normalize();if(o.length()===0)return null;let s=n.work.observers,c=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.standingPosition.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),u=new Map,d=c.slice().sort((e,t)=>{let n=s[e],r=u.get(n);r===void 0&&(r=fC.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),u.set(n,r));let a=s[t],o=u.get(a);return o===void 0&&(o=fC.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),u.set(a,o)),r-o});u.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of d){let n=s[t];if(n){let t=fC.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let f=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,fC);n&&(n.project(e),Math.abs(n.z)<=1&&(f=n.clone()))}else f=new l.Vector3(0,0,0);if(f){let t=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.position.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),r=new Map,i=t.slice().sort((t,n)=>{let i=s[t],a=r.get(i);a===void 0&&(a=fC.copy(i.position).applyMatrix4(i.work.transform).distanceTo(e.position),r.set(i,a));let o=s[n],c=r.get(o);return c===void 0&&(c=fC.copy(o.position).applyMatrix4(o.work.transform).distanceTo(e.position),r.set(o,c)),a-c});r.clear();for(let t of i){let n=s[t];if(n){let t=fC.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(f.x-t.x,2)+Math.pow(f.y-t.y,2)<Math.pow(.4,2))return n}}}return null}onTapGesture(e){var t;if(this.userAction=e.userAction,this.stopMomentumMovement(),!this.initAnimationed)return;let n=e.center.raycaster;n.floorIndex=-1;let r=this.camera.getDirection(new l.Vector3).setY(0),i=null,a=this.works.getObserver(this.currentPano);if(!a)return;let o=a.work.observers,s=a.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&a.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||fC.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(n);if(c){let[e,n]=Bf(s,e=>{let t=o[e];return t?fC.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&n<this.panoTapTriggerRadius&&(i=(t=o[e])==null?null:t)}if(i||(i=this.getForwardObserverOrNot(this.camera,n)),i&&i.panoId===Wv(this.currentPano)&&(i=null),i&&!this.locationMotion.ended){for(let e of this.locationMotion.keyframes)if(this.panoResourceFromLocationMotionKeyframe(e).panoId===i.panoId){i=null;break}}if(!i)this.emit(`gesture.tap`,e),e.defaultPrevented||this.locationMotion.ended===!0&&this.cameraBounce();else{let t={},n=Math.PI/6,o=Math.PI/12,s=i.position.clone().applyMatrix4(i.work.transform).setY(0).sub(a.position.clone().applyMatrix4(i.work.transform).setY(0)).normalize(),c=[],l=[],u=[],d=i.work.observers;for(let e of i.accessibleNodes){if(i.panoIndex===e||e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)continue;let t=d[e];if(!t)continue;let r=t.position.clone().applyMatrix4(t.work.transform).sub(i.position.clone().applyMatrix4(i.work.transform)).setY(0).normalize();s.angleTo(r)<n&&u.push(r)}let[f]=(u.length>0?u:[...c,...l]).slice().sort((e,t)=>e.angleTo(s)-t.angleTo(s));if(f&&f.angleTo(r)>o&&(t.longitude=Math.atan2(-f.x,-f.z)),this.cameraMotion.value.latitude<-Math.PI/4){let n=e.state.fov;t.latitude=H(0,H(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),H(typeof this.maxLatitude==`function`?this.maxLatitude(n):this.maxLatitude,-Math.PI/2,Math.PI/2))}let p=Object.assign({},e.state);if(p.workCode=i.work.workCode,p.panoIndex=i.panoIndex,t.longitude!==void 0&&(p.longitude=t.longitude),t.latitude!==void 0&&(p.latitude=t.latitude),t.fov!==void 0&&(p.fov=t.fov),p.distance=0,p.offset=i.position.clone(),e.state=p,this.emit(`gesture.tap`,e),!e.defaultPrevented){if(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:p,userAction:e.userAction,options:t,progress:0,error:null})),i&&!i.active){let e=Wv({panoIndex:i.panoIndex,workCode:i.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}i&&i.active&&this.emit(`pano.request`,$(`pano.request`,{userAction:e.userAction,prevPano:this.currentPano,progress:0,state:p,options:t,error:null}))}}}},gC=new l.Vector3(0,1.6,0),_C=new l.Box3,vC=new l.Vector3,yC=Object.assign({},yS),bC=class e extends bS{static parseArgs(t){return t instanceof e?t:super.parseArgs(t)}static initAnimationEndState(e){var t,n,r,i,a,o;let s=this.parseArgs(e),c=s.works,{state:u,currentState:d}=e.initial,f=typeof u.panoIndex==`number`?{workCode:(r=(t=u.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:u.panoIndex}:{workCode:d.workCode,panoIndex:d.panoIndex},p=c.getObserver(f),m=H((i=u.fov)==null?!p||Ax(d.mode)?d.fov:s.defaultFov:i,s.minFov,s.maxFov),h=(a=u.longitude)==null?d.longitude:a,g=H(typeof s.minLatitude==`function`?s.minLatitude(m):s.minLatitude,-Math.PI/2,Math.PI/2),_=H(typeof s.maxLatitude==`function`?s.maxLatitude(m):s.maxLatitude,-Math.PI/2,Math.PI/2),v=H((o=u.latitude)==null?!p||Ax(d.mode)?d.latitude:s.defaultLatitude:o,g,_),y=new l.Vector3;if(s.initial.state.offset)y.copy(s.initial.state.offset);else if(p)y.copy(p.position).applyMatrix4(p.work.transform);else{let e=yi(d).setLength(d.distance);y.copy(s.initial.currentState.offset).sub(e)}return{workCode:f.workCode,panoIndex:f.panoIndex,mode:`Model`,longitude:h,latitude:v,fov:m,offset:y,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new J({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x})}updateConfiguration(e){return super.updateConfiguration(e)}destroy(){super.destroy(),this.locationMotion.dispose()}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&this.moveToPosition(a.offset,{duration:0,longitude:a.longitude,latitude:a.latitude,fov:a.fov},i),!0}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return r.distance=0,e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(K),this.cameraMotion.set(i,t).catch(K)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:0,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(K),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t,...n){if(this.destroyed)return;let r={},i={};if(this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),r.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),r.progress=1,r.pano0=r.pano1=t}if(this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),n=[];for(let e of this.works){let r=this.modelScene.models.find(t=>t.work===e);if(!(!r||r.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=Bf(n,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t));this.currentPano=r?{workCode:r.work.workCode,panoIndex:r.panoIndex}:{workCode:``,panoIndex:0}}this.cameraMotion.ended||(this.cameraMotion.update(e),i.longitude=this.cameraMotion.value.longitude,i.latitude=this.cameraMotion.value.latitude,i.fov=this.cameraMotion.value.fov),jx(r)||this.modelScene.parameter.set(r),jx(i)||this.setCamera(i);let a=this.works.getObserver(this.currentPano);if(this.intersectMesh&&this.intersectMesh.parent&&a&&a.position.y-a.standingPosition.y>10){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1)}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={modelAlpha:1},c={perspToOrtho:0},l={longitude:o.longitude,latitude:o.latitude,fov:o.fov,duration:i,moveStartCallback:e=>{this.perspToOrthoMotion.set(c,i).catch(K),this.modelAlphaMotion.set(s,i).catch(K),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),t()},moveCancelCallback:()=>{let e=this.currentPano,n=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance});this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:n,userAction:this.userAction})),t()}};this.moveToPosition(o.offset,l,a)})}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:new l.Vector3(t.value.x,t.value.y,t.value.z),distance:t.value.distance})}moveToPano(e,t={},n){let r=this.works.getObserver(e);if(r){let e=new l.Vector3().copy(r.position).applyMatrix4(r.work.transform);this.moveToPosition(e,t,n)}}moveToPosition(e,t={},n){var r,i,a;this.userAction=n,this.stopMomentumMovement();let o=G(),s=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),c=s.distanceTo(e),u=this.locationMotion.getProgressVelocity(o),d=0;for(let e=1;e<this.locationMotion.keyframes.length;e++){let{x:t,y:n,z:r}=this.locationMotion.keyframes[e-1].value,{x:i,y:a,z:o}=this.locationMotion.keyframes[e].value;d+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let f=c===0?0:u*d/c,p=this.calculateMovingDuration(t.duration,c),m={x:e.x,y:e.y,z:e.z,distance:0},h={longitude:t.longitude,latitude:t.latitude,fov:t.fov},g=[];for(let e of this.works){let t=this.modelScene.models.find(t=>t.work===e);if(!(!t||t.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(s)))for(let t of e.observers)g.push(t)}let _=Bf(g,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),v=_?{workCode:_.work.workCode,panoIndex:_.panoIndex}:{workCode:``,panoIndex:0},y=Object.assign(Object.assign({},v),{mode:this.mode,longitude:(r=h.longitude)==null?this.camera.pose.longitude:r,latitude:(i=h.latitude)==null?this.camera.pose.latitude:i,fov:(a=h.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),b=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(y),this.cameraMotion.set(h,p).catch(K),this.locationMotion.set(m,p,f).then(()=>{for(let e of this.modelScene.children)e instanceof dv&&e.show();let e=Object.assign(Object.assign(Object.assign({},v),{mode:this.mode}),Ox(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:b,progress:0,state:e,userAction:this.userAction,error:null})),t.moveEndCallback&&t.moveEndCallback(e)},()=>{t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.cancel`,$(`pano.cancel`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null}))})}onTapGesture(e){let t=e.center.raycaster;this.stopMomentumMovement();let[n]=this.modelScene.intersectRaycaster(t);if(n&&n.face){let e=n.face.normal,t=n.point;if(new l.Vector3(0,1,0).angleTo(e)>Math.PI/3){let r=new l.Raycaster;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new l.Vector3(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new l.Vector3().copy(n.point).add(gC),r=[];for(let e of this.works){let n=this.modelScene.models.find(t=>t.work===e);if(!(!n||n.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=Bf(r,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=vC.copy(i.position).applyMatrix4(i.work.transform).y),e.state.offset.copy(t),e.state.distance=0,this.emit(`gesture.tap`,e),e.defaultPrevented||this.moveToPosition(t,{},!0)}else this.emit(`gesture.tap`,e),e.defaultPrevented||this.cameraBounce()}},xC=new l.Box3,SC=new l.Vector3,CC=.5,wC=Math.PI/7,TC={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new lS},EC={Floorplan:gS,Topview:vS,Panorama:hC,Model:bC,Mapview:class e extends Yx{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{defaultLongitude:(n=t.defaultLongitude)==null?TC.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?TC.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?TC.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?TC.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?TC.minLatitude:o,cameraType:(s=t.cameraType)==null?TC.cameraType:s,cameraFence:(c=t.cameraFence)==null?TC.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?TC.intersectMeshCreator:l})}static distanceFromModel(e,t,n){let r=e.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2);i=isNaN(i)||!isFinite(i)?1:i;let a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),isNaN(a)||!isFinite(a)?i:a}static initAnimationEndState(t){var n,r,i,a,o,s,c;let u=this.parseArgs(t),d=u.works,f=u.modelScene,{state:p,currentState:m}=t.initial,h=typeof p.panoIndex==`number`?{workCode:(i=(n=p.workCode)==null?(r=u.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:p.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},g=(a=p.fov)==null?60:a,_=H(typeof u.minLatitude==`function`?u.minLatitude(g):u.minLatitude,-Math.PI/2,Math.PI/2),v=H(typeof u.maxLatitude==`function`?u.maxLatitude(g):u.maxLatitude,-Math.PI/2,Math.PI/2),y=H((o=p.latitude)==null?kx(m.mode)?m.latitude:u.defaultLatitude:o,_,v),b=e.distanceFromModel(u.modelScene,g,u.camera.aspect),x=new l.Vector3,S=(s=p.distance)==null?Math.min(u.defaultDistance,b):s,C=(c=p.longitude)==null?kx(m.mode)?m.longitude:u.defaultLongitude:c;if(p.offset)x.copy(p.offset);else{let e=d.getObserver(h);u.defaultDistance<b&&e?(x.copy(e.position).applyMatrix4(e.work.transform),p.longitude===void 0&&(C=m.longitude)):(f.boundingBox.getCenter(x),S=b)}return Object.assign(Object.assign({},h),{mode:`Mapview`,longitude:C,latitude:y,fov:g,offset:x,distance:S})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Mapview`,this.defaultLongitude=n.defaultLongitude,this.defaultLatitude=n.defaultLatitude,this.defaultDistance=n.defaultDistance,this.maxLatitude=n.maxLatitude,this.minLatitude=n.minLatitude,this.cameraType=n.cameraType,this.cameraFence=n.cameraFence,this.locationMotion=new J({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new Qc,this.intersectMeshCreator=n.intersectMeshCreator,this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=`intersect`,this.intersectMesh.visible=!1,this.helper.add(this.intersectMesh)}updateConfiguration(e){if(super.updateConfiguration(e)===!1)return!1;if(e.defaultLongitude!==void 0&&this.defaultLongitude!==e.defaultLongitude&&(this.defaultLongitude=e.defaultLongitude),e.defaultLatitude!==void 0&&this.defaultLatitude!==e.defaultLatitude&&(this.defaultLatitude=e.defaultLatitude),e.defaultDistance!==void 0&&this.defaultDistance!==e.defaultDistance&&(this.defaultDistance=e.defaultDistance),e.maxLatitude!==void 0&&this.maxLatitude!==e.maxLatitude&&(this.maxLatitude=e.maxLatitude),e.minLatitude!==void 0&&this.minLatitude!==e.minLatitude&&(this.minLatitude=e.minLatitude),e.cameraType!==void 0&&this.cameraType!==e.cameraType&&(this.cameraType=e.cameraType),this.cameraFence instanceof l.Box3&&e.cameraFence instanceof l.Box3||this.cameraFence instanceof l.Sphere&&e.cameraFence instanceof l.Sphere?this.cameraFence.equals(e.cameraFence)||(this.cameraFence=e.cameraFence):e.cameraFence!==void 0&&(this.cameraFence=e.cameraFence),e.intersectMeshCreator!==void 0&&this.intersectMeshCreator!==e.intersectMeshCreator){this.intersectMeshCreator=e.intersectMeshCreator;let t=this.intersectMesh;this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=t.name,this.intersectMesh.visible=t.visible;let n=this.intersectMesh.parent;n&&n.add(this.intersectMesh),t.dispose()}return!0}destroy(){super.destroy(),this.pendingTextureId=null,this.locationMotion.dispose(),this.panState=void 0,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));this.currentPano={workCode:a.workCode,panoIndex:a.panoIndex};let o={longitude:a.longitude,latitude:a.latitude,fov:a.fov},s={x:a.offset.x,y:a.offset.y,z:a.offset.z,distance:a.distance};return(o.longitude!==this.cameraMotion.value.longitude||o.latitude!==this.cameraMotion.value.latitude||o.fov!==this.cameraMotion.value.fov)&&this.cameraMotion.set(o,r.duration).catch(K),(s.x!==this.locationMotion.value.x||s.y!==this.locationMotion.value.y||s.z!==this.locationMotion.value.z||s.distance!==this.locationMotion.value.distance)&&this.locationMotion.set(s,r.duration).catch(K),!0}updateModel(e){super.updateModel(e),this.hideIntersectMesh()}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return e.distance!==void 0&&(r.distance=e.distance),e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(K),this.cameraMotion.set(i,t).catch(K)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:t.value.distance,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(K),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t){if(this.destroyed)return;let n={},r={};if(this.locationMotion.ended||(this.locationMotion.update(e),r.distance=this.locationMotion.value.distance,r.offset=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),r.longitude=this.cameraMotion.value.longitude,r.latitude=this.cameraMotion.value.latitude,r.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),n.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),n.progress=1,n.pano0=n.pano1=t}let i=0;if(this.cameraType===`auto`?i=+(Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02):this.cameraType===`perspective`?i=0:this.cameraType===`orthographic`&&(i=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==i&&this.perspToOrthoMotion.set({perspToOrtho:i},500).catch(K),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),jx(n)||this.modelScene.parameter.set(n),jx(r)||this.setCamera(r),this.cameraFence&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&!this.inMomentumMovement&&this.locationMotion.ended&&this.perspToOrthoMotion.ended&&this.cameraMotion.ended){let e=yi(this.camera.pose,new l.Vector3),t=new l.Vector3().copy(this.camera.pose.offset).sub(e.clone().multiplyScalar(this.camera.pose.distance));if(this.cameraFence.distanceToPoint(t)>.01){let e=this.cameraFence.clampPoint(t,new l.Vector3),n=this.camera.pose.offset.clone().add(e).sub(t),r=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:n,distance:this.camera.pose.distance});this.fixFinalState(r),this.locationMotion.set({x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance},300).catch(K)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1)}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:t.value.distance,offset:new l.Vector3(t.value.x,t.value.y,t.value.z)})}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={longitude:o.longitude,latitude:o.latitude,fov:o.fov},c={x:o.offset.x,y:o.offset.y,z:o.offset.z,distance:o.distance};this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:o,userAction:this.userAction})),this.perspToOrthoMotion.set({perspToOrtho:0},i).catch(K),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(K),this.cameraMotion.set(s,i).catch(K),this.locationMotion.set(c,i).then(()=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:o,userAction:this.userAction}))},e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),Ox(this.camera.pose));this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:t,userAction:this.userAction}))}).then(()=>{t()})})}getForwardObserverOrNot(e){let[t]=this.modelScene.intersectRaycaster(e);if(!t)return null;let n=[];for(let t of this.works){let r=this.modelScene.models.find(e=>e.work===t);if(!(!r||r.visible===!1)&&!(t.observers.length<=0)&&(xC.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),xC.containsPoint(e.ray.origin)||e.ray.intersectsBox(xC)))for(let e of t.observers)n.push(e)}let[r,i]=Bf(n,e=>SC.copy(e.standingPosition).applyMatrix4(e.work.transform).distanceTo(t.point),!0);return r&&i<Math.max(r.standingPosition.distanceTo(this.camera.position)/5,10)?r:null}coordinatesForOffset(e){let t=this.renderer.getSize(new l.Vector2);return{longitude:-2*e.x/(t.x*this.viewport.width),latitude:2*e.y/(t.y*this.viewport.height)}}requestMomentumMovement(e,t,n,r){if(this.inMomentumMovement===null)return;r=Math.max(r,1);let i=Object.assign({},n),a={longitude:0,latitude:0,x:0,y:0,z:0};for(let e=0;e<r;e++)i.longitude*=.996,i.latitude*=.996*.998,i.x*=.99,i.y*=.99,i.z*=.99,a.longitude+=i.longitude,a.latitude+=i.latitude,a.x+=i.x,a.y+=i.y,a.z+=i.z;let o=this.cameraMotion.value.fov,s=vi(this.cameraMotion.value.longitude+a.longitude),c=H(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),u=H(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),d=H(this.cameraMotion.value.latitude+a.latitude,c,u),f=new l.Vector3(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),p=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:d,offset:f,fov:o,distance:this.locationMotion.value.distance}),m=e.state.offset.clone().sub(yi(e.state).setLength(p.distance)),h=!(Math.abs(i.longitude)>1e-4||Math.abs(i.latitude)>1e-4||Math.abs(i.x)>1e-4||Math.abs(i.y)>1e-4||Math.abs(i.z)>1e-4);(this.cameraFence?this.cameraFence.containsPoint(m):!0)===!1&&(h=!0);let g=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:h,state:p}));if(this.inMomentumMovement.event=g,this.emit(`gesture.momentum`,g),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:d},0).catch(K),this.locationMotion.set({x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance},0).catch(K),h?this.inMomentumMovement=null:Bc.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=yi(e,new l.Vector3),n=new l.Vector3().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new l.Raycaster(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>CC+r.near,r.near=this.camera.near,r.far=this.camera.far;let i;if(i=this.modelScene.intersectRaycaster(r)[0],i&&i.distance<this.camera.near&&(i=void 0),!i){let e=new l.Plane(new l.Vector3(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new l.Vector3);if(t){let e=t.distanceTo(r.ray.origin);e<1e3&&e>=r.near&&(i={distance:e,floorIndex:0,floor:0,point:t,object:this.scene,face:null})}}if(!i){let r=Math.max(e.distance,3);i={distance:r,floorIndex:0,floor:0,point:n.clone().add(t.clone().setLength(r)),object:this.scene,face:null}}i.distance>=this.camera.near&&vx(e.distance,i.distance)&&(e.distance=i.distance,e.offset=i.point)}onPanGesture(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.pointers.length,n=this.panState,r=0,i=!1;e.pointerType===`mouse`&&(r=e.center.buttons,i=e.center.shiftKey),n&&r===0&&n.buttons!==0&&(r=n.buttons);let a=n==null?void 0:n.target;if(!a){let t=this.relativeClientPosition(e.center),n=this.createRaycasterFromCamera(t,this.camera);a=new l.Vector3().copy(n.ray.direction).multiplyScalar(3).add(n.ray.origin);let[r]=this.modelScene.intersectRaycaster(n);if(!r&&n.ray.direction.y<-.3){let e=new l.Plane(new l.Vector3(0,1,0),0),t=n.ray.intersectPlane(e,new l.Vector3);if(t){let e=t.distanceTo(n.ray.origin);e<1e4&&e>=n.near&&(r={distance:e,floorIndex:0,floor:0,point:t,object:this.scene})}}if(r)a.copy(r.point);else{let e=new l.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new l.Plane().setFromNormalAndCoplanarPoint(e,this.camera.pose.offset);n.ray.intersectPlane(t,a)}}if(e.isFinal?this.panState=void 0:this.panState={target:a,buttons:r,pointerLength:t,x:e.center.x,y:e.center.y},!(n===void 0||n.pointerLength!==t))if(t>1||r===2||i){let t={x:e.center.x-n.x,y:e.center.y-n.y},r=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=yi(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new l.Vector3().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new l.Vector2),s=2*t.x*a/o.y,c=2*t.y*a/o.y,u=new l.Vector3;u.setFromMatrixColumn(this.camera.matrix,0),u.multiplyScalar(-s),r.add(u),this.camera.pose.latitude<wC?u.setFromMatrixColumn(this.camera.matrix,1):(u.setFromMatrixColumn(this.camera.matrix,0),u.crossVectors(this.camera.up,u)),u.multiplyScalar(c),r.add(u);let d=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:r,distance:this.camera.pose.distance});if(e.state=d,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K),e.isFinal&&(this.fixFinalState(d),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:d.distance,x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K)),e.isFinal){let t=this.renderer.getSize(new l.Vector2),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new l.Vector3,o=new l.Vector3;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<wC?i.setFromMatrixColumn(this.camera.matrix,1):(i.setFromMatrixColumn(this.camera.matrix,0),i.crossVectors(this.camera.up,i)),i.multiplyScalar(r),o.add(i),this.inMomentumMovement={uuid:Ft()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:o.x,y:o.y,z:o.z},0)}}else{let t={x:e.center.x-n.x,y:e.center.y-n.y},r=this.coordinatesForOffset(t),i=vi(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=H(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=H(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=H(this.cameraMotion.value.latitude+r.latitude,o,s);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(c=this.cameraMotion.value.latitude);let l=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:i,latitude:c,fov:a,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=l,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:l.distance,x:l.offset.x,y:l.offset.y,z:l.offset.z},0).catch(K):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(K),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:Ft()},this.requestMomentumMovement(e,!0,Object.assign(Object.assign({},this.coordinatesForOffset({x:t,y:n})),{x:0,y:0,z:0}),0)}}}onPinchGesture(t){var n;if(!this.initAnimationIsReady)return;this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let r=(n=this.pinchState)==null?void 0:n.distance;if(t.isFirst){this.pinchState={x:t.center.x,y:t.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(r===void 0)return;let i=this.modelScene.boundingBox.getCenter(new l.Vector3),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=H(r/t.scale,CC,1/0),s=t.state.offset.clone().sub(yi(t.state).setLength(o)),c=this.modelScene.boundingBox.containsPoint(s),u;if(!c&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?u=t.state.distance:(u=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=u,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(K),t.pointerType!==`mouse`&&(t.type=`gesture.pan`,this.onPanGesture(t)),t.isFinal)){if(!(`__fixFinalState`in t)){let e=t.state;this.fixFinalState(t.state);let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(K)}this.panState=void 0,this.pinchState=void 0}}onMouseMove(e){var t,n;if(!this.intersectMesh.parent||this.panState||this.pinchState||this.mouseWheelState||(this.emit(`gesture.mousemove`,e),e.defaultPrevented))return;let r=e.center.raycaster;if(e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}let[i]=this.modelScene.intersectRaycaster(r),a=$(`intersect.update`,{raycaster:r,intersection:i==null?null:i,object:this.intersectMesh});if(this.emit(`intersect.update`,a),a.defaultPrevented){this.hideIntersectMesh();return}if(i){let e=(n=(t=i.face)==null?void 0:t.normal)==null?new l.Vector3().copy(r.ray.direction).multiplyScalar(-1):n,a=e.clone(),o=i.point.clone();this.intersectMesh.position.copy(o);let s=o.clone().add(a);if(this.intersectMesh.lookAt(s),Math.abs(e.y)>.99){let e=this.camera.position.clone().sub(o);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}onMouseWheel(t){if(this.initAnimationIsReady)if(this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),t.isFinal){let e=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov,offset:new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),distance:this.locationMotion.value.distance});if(this.fixFinalState(e),this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(K)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=yi(this.cameraMotion.value,new l.Vector3).negate(),a=new l.Ray(r,i).intersectBox(this.modelScene.boundingBox,new l.Vector3);a&&(n+=a.distanceTo(r));let o=Math.max(this.locationMotion.value.distance-this.camera.near,0),s=t.center.delta/10*Math.max(o/5,.1);if(o<=n||s>0)if(this.locationMotion.value.distance-s>=CC){let e=this.locationMotion.value.distance-s;t.state.distance=e}else{let e=yi(this.cameraMotion.value);e.setLength(s),t.state.offset.add(e)}if(this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;this.locationMotion.set({distance:t.state.distance,x:t.state.offset.x,y:t.state.offset.y,z:t.state.offset.z},0).catch(K)}}onTapGesture(e){var t;this.userAction=e.userAction,this.stopMomentumMovement();let n=e.center.raycaster,r=this.getForwardObserverOrNot(n);if(!r)this.emit(`gesture.tap`,e);else{let n={longitude:this.camera.pose.longitude,latitude:0},i=Object.assign(Object.assign({},e.state),{mode:`Panorama`,workCode:r.work.workCode,panoIndex:r.panoIndex,longitude:n.longitude,latitude:n.latitude,offset:r?r.position.clone():new l.Vector3,distance:0});if(e.state=i,this.emit(`gesture.tap`,e),!e.defaultPrevented&&(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:i,userAction:e.userAction,options:n,progress:0,error:null})),r&&r.active)){let e=this.pendingTextureId=Ft(),a=Wv({panoIndex:r.panoIndex,workCode:r.work.workCode}),o={right:r.images.work.getURL(r.images.right),left:r.images.work.getURL(r.images.left),up:r.images.work.getURL(r.images.up),down:r.images.work.getURL(r.images.down),front:r.images.work.getURL(r.images.front),back:r.images.work.getURL(r.images.back)},s=this.imageOptions.transform,c=Object.assign({key:`pano.${a}`},Zs(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),u=`pano:`+Hv([o,c,s]),d=this.modelScene.parameter,f;if(d.pano0&&d.pano0.map.name===u?f=d.pano0:d.pano1&&d.pano1.map.name===u&&(f=d.pano1),f)d.pano0&&d.pano0.map!==f.map&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==f.map&&d.pano1.map!==((t=d.pano0)==null?void 0:t.map)&&d.pano1.map.dispose(),d.set({pano0:f,pano1:f}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,f=``;r.images.hdrConfig&&(t={right:r.images.work.getURL(r.images.gainmap_right),left:r.images.work.getURL(r.images.gainmap_left),up:r.images.work.getURL(r.images.gainmap_up),down:r.images.work.getURL(r.images.gainmap_down),front:r.images.work.getURL(r.images.gainmap_front),back:r.images.work.getURL(r.images.gainmap_back)},f=r.images.work.getURL(r.images.hdrConfig));let p=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:c},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),m=f?[fetch(f).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:c},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([p,...m]).then(t=>Dd(this,[t],void 0,function*([t,o,s]){var c,f;let{body:p}=t;if(this.destroyed||this.pendingTextureId!==e){p.dispose();return}this.pendingTextureId=null,p.name=u;let m=Array.isArray(p.image)?p.image[0]:p.image,h=(c=m==null?void 0:m.width)==null?2048:c,g=yield qx(this.renderer,p,!0,eb),_=new ib().formPixels(g.data),v={panoId:a,map:p,mapSize:h,mapHistogram:new l.Vector4().fromArray(_.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},fS(o)):void 0};d.pano0&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==((f=d.pano0)==null?void 0:f.map)&&d.pano1.map.dispose(),d.set({pano0:v,pano1:v}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}))})).catch(t=>{this.destroyed||this.pendingTextureId!==e||(this.pendingTextureId=null)})}}}}onDblTapGesture(e){if(!this.initAnimationIsReady)return;this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.state,n=e.center.raycaster,r=n.ray.origin.clone().add(n.ray.direction.clone().setLength(3)),i=1,[a]=this.modelScene.intersectRaycaster(n);if(a&&(r=a.point.clone(),i=a.distance>4/2?1:3),e.state.distance=i,e.state.offset=r,this.emit(`gesture.dbltap`,e),e.defaultPrevented)return;let o={x:t.offset.x,y:t.offset.y,z:t.offset.z,distance:t.distance};this.locationMotion.set(o,360).catch(K),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},DC={Floorplan:hS,Topview:_S,Panorama:mC,Model:yC,Mapview:TC},OC=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.create,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function kC(e){e.on(`initAnimation.start`,t=>{e.emit(`initAnimationWillStart`,t.state.panoIndex,t.state,t.userAction)}),e.on(`initAnimation.end`,t=>{e.emit(`initAnimationEnded`,t.state.panoIndex,t.state,t.userAction)}),e.on(`gesture.pan`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pan`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPanGesture`,t.state,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pan`,t.pointers,t.isFinal),e.emit(`panGesture`,t.state,t.isFinal))}),e.on(`gesture.tap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`tap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`tap`,t.pointers,t.isFinal),e.emit(`tapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.dbltap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`dbltap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsDblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`dbltap`,t.pointers,t.isFinal),e.emit(`dblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.press`,t=>{let n=!1;n=e.emit(`wantsGesture`,`press`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`press`,t.pointers,t.isFinal),e.emit(`pressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),e.on(`gesture.pinch`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pinch`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPinchGesture`,t.scale,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pinch`,t.pointers,t.isFinal),e.emit(`pinchGesture`,t.scale,t.state.fov,t.isFinal))}),e.on(`gesture.mousewheel`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseWheel`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsMouseWheel`,t.center.delta,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseWheel`,t.pointers,t.isFinal),e.emit(`mouseWheel`,t.center.delta,t.state.fov,t.isFinal))}),e.on(`gesture.mousemove`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseMove`,t.pointers,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseMove`,t.pointers,t.isFinal),n=e.emit(`wantsChangeCameraFov`,t.state.fov),n&&t.preventDefault())}),e.on(`gesture.momentum`,t=>{let n=!1;n=e.emit(`wantsInteriaPan`,t.state),n&&t.preventDefault(),t.defaultPrevented||e.emit(`interiaPan`,t.state,t.isFinal)}),e.on(`camera.update`,t=>{e.emit(`cameraFovUpdate`,t.state.fov,t.userAction),e.emit(`cameraDirectionUpdate`,t.state,t.userAction);let n=yi(t.state);n.setLength(t.state.distance);let r=t.state.offset.clone().sub(n);e.emit(`cameraPositionUpdate`,r,t.userAction),e.emit(`cameraUpdate`,t.state,t.userAction)}),e.on(`intersect.update`,t=>{if(t.intersection){let n=!1;n=e.emit(`wantsShowIntersectionOnModel`,t.raycaster),n&&t.preventDefault(),t.defaultPrevented||e.emit(`intersectionOnModelUpdate`,t.intersection,t.object)}else e.emit(`intersectionHidden`)}),e.on(`pano.request`,t=>{let n=e.emit(`wantsMoveToPano`,t.state.panoIndex,t.options,t.userAction);n||(n=e.emit(`wantsToMoveToPano`,t.state.panoIndex,t.options,t.userAction)),n&&t.preventDefault(),t.defaultPrevented||e.emit(`panoWillLoad`,t.state.panoIndex)}),e.on(`pano.select`,t=>{e.emit(`panoSelected`,t.state.panoIndex)}),e.on(`pano.moveTo`,t=>{e.emit(`panoLoaded`,t.state.panoIndex),e.emit(`moveToPano`,t.state.panoIndex,t.userAction),e.emit(`panoWillArrive`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.moving`,t=>{e.emit(`movingToPano`,t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),e.on(`pano.arrived`,t=>{e.emit(`panoArrived`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.cancel`,t=>{e.emit(`moveToPanoCanceled`,t.state.panoIndex)}),e.on(`pano.error`,t=>{e.emit(`panoLoadError`,t.error,t.state.panoIndex)}),e.on(`pano.texture.load`,t=>{e.emit(`textureStartLoad`,t.pano.panoIndex)}),e.on(`pano.texture.success`,t=>{e.emit(`textureLoaded`,t.pano.panoIndex,t.meta)}),e.on(`pano.texture.error`,t=>{e.emit(`textureError`,t.error,t.pano.panoIndex)}),e.on(`pano.texture.abort`,t=>{e.emit(`textureAbort`,t.pano.panoIndex)}),e.on(`pano.texture.progress`,t=>{e.emit(`textureLoading`,t.progress,t.pano.panoIndex)}),e.on(`xr.session.start`,t=>{e.emit(`webXRSessionStart`)}),e.on(`xr.session.end`,t=>{e.emit(`webXRSessionEnd`)}),e.on(`xr.gesture.tap`,t=>{e.emit(`webXRControllerEvent`,`tap`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.press`,t=>{e.emit(`webXRControllerEvent`,`press`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonUp`,t=>{e.emit(`webXRControllerEvent`,`buttonUp`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonDown`,t=>{e.emit(`webXRControllerEvent`,`buttonDown`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.controller.update`,t=>{e.emit(`webXRControllerRayUpdate`,{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&e.emit(`webXRAxesUpdate`,`left`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.left.axes.up,down:t.left.axes.down,left:t.left.axes.left,right:t.left.axes.right},deltaTime:t.left.deltaTime}),t.right&&e.emit(`webXRAxesUpdate`,`right`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.right.axes.up,down:t.right.axes.down,left:t.right.axes.left,right:t.right.axes.right},deltaTime:t.right.deltaTime})}),e.on(`works.request`,t=>{e.emit(`willLoad`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.load`,t=>{e.emit(`load`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.ready`,t=>{e.emit(`loaded`,t.input,t.works[0])}),e.on(`state.change`,t=>{e.emit(`stateChange`,t.state,t.userAction)}),e.on(`currentState.change`,t=>{e.emit(`currentStateChange`,t.state,t.userAction)}),e.on(`state.set`,t=>{e.emit(`setState`,t.state)}),e.on(`state.synced`,t=>{e.emit(`stateSynced`,t.state)}),e.on(`model.request`,t=>{e.emit(`modelWillLoad`,t.work.model)}),e.on(`model.error`,t=>{e.emit(`modelLoadError`,t.error,t.model)}),e.on(`model.load`,t=>{e.emit(`modelLoaded`,t.model)}),e.on(`model.changeShownFloor`,t=>{e.emit(`modelShownFloorChange`,t.model.shownFloor,t.model.floorLength)}),e.on(`render`,t=>{e.emit(`renderFrame`,t.needsRender)}),e.on(`mode.change.request`,t=>{e.emit(`wantsChangeMode`,t.mode,t.prevMode)}),e.on(`mode.change`,t=>{e.emit(`modeChange`,t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),e.on(`helpers.visible`,t=>{e.emit(`helpersVisibleChange`,t.object.visible)}),e.on(`network.resource`,t=>{e.emit(`network`,t.source,t.requestType,t.requestState,t.detail)})}function AC(){if(typeof window<`u`){let e=document.createElement(`video`);e.loop=!0,e.autoplay=!0,e.playsInline=!0,e.muted=!0,e.crossOrigin=``;let t=()=>{document.removeEventListener(`touchstart`,t,!1),document.removeEventListener(`mousedown`,t,!1),e.muted=!1};return document.addEventListener(`touchstart`,t,!1),document.addEventListener(`mousedown`,t,!1),e}else return{}}function jC(){let e=new l.Group;e.name=`internalLights`;{let t=new l.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new l.Vector3(0,1,0)),e.add(t)}{let t=new l.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new l.Vector3(-1,-1,-1)),e.add(t)}{let t=new l.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new l.Vector3(1,1,1)),e.add(t)}{let t=new l.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function MC(e){var t,n;let r={},i=e.split(/(\;|\,)/);for(let e of i){let i=e.split(`=`),a=(t=i[0])==null?void 0:t.trim(),o=(n=i[1])==null?void 0:n.trim();a&&o&&(r[a]=o)}return r}function NC(){var e;if(typeof document<`u`){let t=document.getElementsByTagName(`meta`);for(let n=0;n<t.length;n++){let r=t[n];if(r.getAttribute(`name`)===`viewport`){let t=MC((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var PC=1e3,FC=90,IC=e=>e.replace(`//vrlab-public.ljcdn.com/`,`//vr-public.realsee-cdn.cn/`).replace(`//vrlab-image4.ljcdn.com/`,`//vr-image-4.realsee-cdn.cn/`).replace(`//vrlab-image3.ljcdn.com/`,`//vr-image-3.realsee-cdn.cn/`).replace(`//vrlab-image2.ljcdn.com/`,`//vr-image-2.realsee-cdn.cn/`).replace(`//vrlab-image1.ljcdn.com/`,`//vr-image-1.realsee-cdn.cn/`),LC=new l.Sphere,RC=new l.Box3,zC=new l.Vector4,BC=new l.Vector4,VC=new l.Color,HC=new l.Vector2,UC=new WeakMap,WC=Py([jy(null)]),GC={},KC=class e extends Bt{static get version(){return`1.0.0-alpha.3`}static get dracoPath(){return Vu.decoderPath}static set dracoPath(e){Vu.setDecoderPath(e)}static get ktx2Path(){return Yu.transcoderPath}static set ktx2Path(e){Yu.setTranscoderPath(e)}static get useNativeImageBitmap(){return Wc()}static set useNativeImageBitmap(e){Uc(e)}constructor(e={}){var t,n,r,i,a,o,s,c,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Ft(),GC[this.fiveId]=this,this.currentUpdateArgs={time:G(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!0,this.onlyRenderIfNeeds=(t=e.onlyRenderIfNeeds)==null?!0:t,this.imageOptions=Object.assign({},(n=e.imageOptions)==null?{}:n),this.textureOptions=Object.assign({},(r=e.textureOptions)==null?{}:r),this.poweredByRealsee=(i=e.poweredByRealsee)==null?!0:i,this.backgroundColor=new l.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview)},this.fps={testCount:0,testTime:G()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?PC:s,this.enableWheel=(c=e.enableWheel)==null?!0:c,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Ub&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Ub({outputType:e.enableHDR?l.HalfFloatType:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=NC();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new l.RenderTarget(1,1,{colorSpace:(d=(u=this.renderer)==null?void 0:u.outputColorSpace)==null?l.SRGBColorSpace:d,generateMipmaps:!1}),this.renderer&&Ms(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Mi(FC),this.scene=new Yb,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new l.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(f=e.requestProxy)==null?IC:f,this.networkSubscribe=new Ws,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,$(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new l.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),UC.set(this,WC),this.modelScene=new Sv({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(WC,{forceReplaceImmediately:!0});Z(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new l.VideoTexture(e.videoInstance||AC());let m=jC();this.scene.add(m),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=Bc.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,h,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,h,!1)},this.loadWorkTask=this.prepare(),this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}kC(this),this.fiveRenderer=new Bb({outputType:e.enableHDR?l.HalfFloatType:void 0}),this.adaptiveLuminancePass=new bb,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Sb(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new Mr,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([fc().catch(K)]).then(K)}dispose(){var e;if(this.destroyed===!0)return;delete GC[this.fiveId],this.emit(`dispose`),this.destroyed=!0,this.pause(),this.stopAnimationLoop&&(this.stopAnimationLoop(),this.stopAnimationLoop=void 0),this.off(),this.networkSubscribe.off(),this.controller&&(this.controller.destroy(),this.controller=void 0);let t=this.getElement();t&&t.parentNode&&t.parentNode.removeChild(t);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((e=n.pano0)==null?void 0:e.map)&&n.pano1.map.dispose(),n.reset(`pano0`,`pano1`),this.modelScene.dispose(),UC.set(this,WC),this.renderer&&(!(this.renderer instanceof Ub)||this.renderer.isInitialized)&&this.renderer.render(new l.Scene,new l.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Ub&&this.renderer.dispose()}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,$(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,$s(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,$s(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,$s(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,$s(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,$s(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),this.currentMode===`Panorama`&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof Ub)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,i,a,o,s;if(!this.renderer)return;let c=this.renderer.domElement.parentNode,{width:l=(n=c==null?void 0:c.offsetWidth)==null?512:n,height:u=(r=c==null?void 0:c.offsetHeight)==null?512:r}=e;if(l=Math.max(1,l),u=Math.max(1,u),!t){let e=NC(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(l,u)*t,n=Math.min((s=(o=(a=this.renderer.backend.device)==null?void 0:a.limits)==null?void 0:o.maxTextureDimension2D)==null?8192:s,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(l,u),this.needsRender=!0;let d=G(),f=d-this.currentUpdateArgs.time,p=this.currentUpdateArgs.args;this.updateTime(d,f,...p)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return UC.get(this)||WC}get work(){return this.works[0]}get observers(){return this.work.observers}get models(){return this.modelScene.models}get model(){return this.modelScene.models[0]}load(e,t,n,r=!0){if(!this.renderer)throw Error(`renderer is not initialized`);let i=this.loadWorkTask.then(()=>xx(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,c,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===WC&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof Ay?v.push(e):typeof e!=`string`&&`work`in e?v.push(jy(e.work,e)):v.push(jy(e));else t instanceof Ay?v.push(t):v.push(jy(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=Py(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===WC&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(c=x.offset)==null?void 0:c.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new l.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;w===`Panorama`&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,$(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=EC[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=EC[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=$(`mode.change`,{prevMode:b,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.state.workCode=this.pano.workCode,this.state.panoIndex=this.pano.panoIndex,this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};UC.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),Dx(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),UC.set(this,WC),this.modelScene.setModels(WC,{forceReplaceImmediately:!0}),this.renderer&&this.modelScene.update(this.renderer,this.camera),this.needsRender=!0,this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.camera.setFromPose({distance:0,fov:FC,longitude:0,latitude:0,offset:new l.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if(t===e.Mode.Panorama&&!this.works.getObserver(m)){let e=Error(`PanoId ${Wv(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model?!Kv(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(Kv(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=EC[t].initAnimationEndState(r),o=$(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=$(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=Bc.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),Bc.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return Dd(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=G(),c=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new l.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?c:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&this.controller instanceof EC.Panorama&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=this.renderer.getClearColor(VC),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera||this.backgroundAlpha<1?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=c,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);let te=yield this.renderer.readRenderTargetPixelsAsync(C,0,0,M,N),F=M*4;if(te.length===P)b.set(te);else{let e=Math.ceil(F/256)*256;for(let t=0;t<N;t++){let n=t*e;b.set(te.subarray(n,n+F),t*F)}}if(!_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b})}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=t.getClearColor(VC),c=t.getClearAlpha(),l=t.getViewport(zC),u=t.getScissor(BC),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(HC),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera||this.backgroundAlpha<1?null:v;let y=!0;this.controller&&this.controller.render()&&(y=!1),y&&this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender),this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&Bc.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&Yu.detectSupport(this.renderer),this.syncingState=this.syncState(e,t),this.controller&&this.controller.updateTime(e,t,...n),this.renderer&&(this.camera.pixelRatio=this.renderer.getPixelRatio(),this.getSize(this.camera.resolution),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height),this.camera.controllerMode=this.currentMode,this.camera.updateTime(e),this.renderer){let e=this.modelScene.loaded,t=this.modelScene.refined;this.modelScene.update(this.renderer,this.camera),e===!1&&this.modelScene.loaded===!0&&(this.controller&&this.controller.updateModel(this.modelScene),Bc.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&Bc.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){RC.makeEmpty(),RC.expandByObject(this.modelScene.boundingMesh);let t=RC.getBoundingSphere(LC),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=H(n/500,.001,.1),i=H(n,800);this.camera.near!==r&&(this.camera.near=r),this.camera.far!==i&&(this.camera.far=i),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0||this.renderer instanceof Ub&&!this.renderer.isInitialized)return;let r=$(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,$(`render`,{needsRender:i})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof Ub&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=K){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],i=G();return Promise.all(r.map(e=>{let t=Wv({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},Zs(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):kc(i,r);return K_(this.fiveId,n.work).preload(a)})).then(()=>{let e=G()-i;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new l.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new l.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new l.Vector2(o,s)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,i,a,o,s,c,u,d,f,p;e=Zs(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof l.Vector3)&&(e.offset=new l.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof l.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),r=EC[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(c=e.fov)==null?this.state.fov:c,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,$(`state.set`,{userAction:n,state:x})),Ex(this.state,x)||(Tx(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(G(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(G(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state))}syncState(t,n,r=!1){let i=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof EC.Model){if(bx(this.camera.pose.offset,this.state.offset)){let e={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset};return this.controller.moveToPosition(this.state.offset,Object.assign(Object.assign({},e),{duration:r?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!Kv(e,this.pano)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`){let t={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.controller.moveToPano(e,t,!1),!0}}if(this.controller instanceof EC.Floorplan||this.controller instanceof EC.Topview||this.controller instanceof EC.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:sb(this.camera.pose.fov,this.state.fov,1),i=Math.abs(this.camera.pose.distance-this.state.distance),a=i>e*15?i/15:.2,o=r?this.state.distance:sb(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),c=s>e*15?s/15:e,u=r?new l.Vector3().copy(this.state.offset):cb(this.camera.pose.offset,this.state.offset,c),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:lb({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(vx(n,this.camera.pose.fov)||bx(u,this.camera.pose.offset)||vx(o,this.camera.pose.distance)||vx(d,this.camera.pose.longitude,Math.PI*2)||vx(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:sb(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:lb({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new l.Vector3().copy(this.state.offset);if(vx(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),bx(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),vx(n,this.camera.pose.longitude,Math.PI*2)||vx(i,this.camera.pose.latitude)||vx(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof EC.Panorama&&t.tile===!0?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(K)}requestFullscreen(){var e;if(!wx)return;let t=(e=this.getElement())==null?void 0:e.parentNode;t&&`requestFullscreen`in t&&typeof document<`u`&&document.fullscreenElement===null&&t.requestFullscreen()}exitFullscreen(){typeof document<`u`&&document.fullscreenElement&&`exitFullscreen`in document&&document.exitFullscreen()}throwError(e){this.hasListener(`error`)?this.emit(`error`,e):console.error(e)}bindModel(e){let t=()=>{Bc.shared.add(()=>{this.emit(`model.load`,$(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,$(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,$(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,$(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,$(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,$(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new Ys({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=hy(e,r);return t instanceof Error?Promise.reject(t):t})}});q_(this.fiveId,e,i)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(e,t){if(!this.renderer)throw Error(`renderer is not initialized.`);let n=EC[e];this.currentMode=e;let r=new n(t);for(let e of OC)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=EC[e].initAnimationEndState(t),r=t.initial.userAction;Ex(this.state,n)||(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,$(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return r.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,$(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),r.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,$(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),r.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),r.on(`error`,e=>this.throwError(e)),r}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let t=new l.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new l.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().invert();return n.applyQuaternion(r),{theta:Math.atan2(n.x,-n.z),phi:-Math.asin(n.y),lookAtVector:n}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}};KC.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:l,constructor:KC,instances:GC}}),exports.AdaptiveLuminancePass=bb,exports.AnimationFrameLoop=Bc,exports.BoundingMesh=bv,exports.Camera=Mi,exports.EffectComposer=Iy,exports.EyeDomeLightingPass=Sb,exports.Fetcher=Ys,exports.Five=KC,exports.FivePass=Ry,exports.FiveRenderer=Bb,exports.FlowingFireworks3DPass=Mb,exports.FlowingLight2DPass=Eb,exports.FlowingLight3DPass=wb,exports.FullScreenQuad=Ly,exports.GaussianBlurPass=Cb,exports.Histogram=ib,exports.InternalWebGPURenderer=Ub,exports.Model=dv,exports.ModelScene=Sv,exports.Motion=J,exports.NetworkSubscribe=Ws,exports.PBMGSObject=Mt,exports.PBMGaussianSplattingObject=Mt,exports.PBMGaussianSplattingNodeMaterial=dr,exports.PBMGaussianSplattingRenderMesh=Mr,exports.PBMGroup=wt,exports.PBMMesh=kt,exports.PBMMeshBasicMaterial=Nr,exports.PBMMeshBasicNodeMaterial=Cs,exports.PBMMeshPanoOnlyMaterial=Pr,exports.PBMMeshPanoOnlyNodeMaterial=ks,exports.PBMMeshPhongMaterial=Fr,exports.PBMMeshPhongNodeMaterial=Ts,exports.PBMMeshPhysicalMaterial=Ir,exports.PBMMeshPhysicalNodeMaterial=Ds,exports.PBMPanoFilter=Ht,exports.PBMPointCloud=on,exports.PBMSkinnedMesh=At,exports.PBMUpdateable=Vt,exports.PROXY_CONTROLLER_EVENT_NAMES=OC,exports.PanoCircleMesh=rx,exports.PanoCircleMeshCustom=gx,exports.PanoCircleMeshSolid=dx,exports.Parameter=X,exports.Scene=Yb,exports.Subscribe=Bt,exports.TextureLoader=Qc,exports.Tile=Rf,exports.Tile3D=W_,exports.Tile3DModel=W_,exports.TileCache=Sm,exports.TileNode=dm,exports.TileRequestScheduler=ym,exports.Tileset=Om,exports.Trajectory=hm,exports.TrajectoryNode=gm,exports.Work=Ay,exports.WorkResolvedObserver=Ny,exports.controllersDefaultInitArgs=DC,exports.coordinatesToVector=yi,exports.createDebugBoundingMesh=Nf,exports.createWorks=Py,exports.defaultImageURLTransform=kc,exports.draco=Vu,exports.getViewportScale=NC,exports.headingToLongitude=Si,exports.imageSupport=fc,exports.isBoundingVolume=Of,exports.isPanoId=qv,exports.loadAt3d=zl,exports.loadDome=Ul,exports.loadDomez=Xl,exports.loadGltf=sf,exports.loadPbm=_l,exports.loadPly=eu,exports.longitudeToHeading=xi,exports.makeBoundingVolume=kf,exports.panoEqual=Kv,exports.panoParse=Gv,exports.panoStringify=Wv,exports.parseWork=jy,exports.registerPBMMaterials=Ms,exports.vectorToCoordinates=bi,exports.workToJson=Dv;
1162
+ `,uniforms:{maxDepth:new l.Uniform(0)}});function lC(e,t,n,r=1e3){cC.uniforms.maxDepth.value=r,e.getClearColor(sC);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=cC,e.setClearColor(oC,0),n.update(e,t),e.setClearColor(sC,i),t.overrideMaterial=a}var uC=im,dC=new l.Raycaster,fC=new l.Vector3,pC=[new l.Vector3(0,0,0).multiplyScalar(.1),new l.Vector3(1,0,0).multiplyScalar(.1),new l.Vector3(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new l.Vector3(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],mC=Object.assign(Object.assign({},yS),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new dx:new rx,adjustPanoCircleMeshPositionBasedOnModel:!1,tileLevelForFov:((e,t)=>{var n;let r=e=>e/180*Math.PI,i=(n=Math.log2)==null?(e=>Math.log(e)*Math.LOG2E):n,a=t.height/2/Math.tan(r(e/2))*Math.tan(r(45))*2,o=Math.max(i(a/512),0);return o<2.3&&o>.1&&(o=1),o=o%1>.75?Math.ceil(o):Math.floor(o),o}),tileAppearDuration:.5,tileMaxRequest:3,flyEffectUseDepthBuffer:!1}),hC=class e extends bS{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{maxAccessibleDistance:(n=t.maxAccessibleDistance)==null?mC.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?mC.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?mC.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?mC.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?mC.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?mC.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?mC.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?mC.flyEffectUseDepthBuffer:l})}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`Panorama`})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Panorama`,this.initAnimationed=!1,this.maxAccessibleDistance=n.maxAccessibleDistance,this.panoTapTriggerRadius=n.panoTapTriggerRadius,this.panoCircleMeshCreator=n.panoCircleMeshCreator,this.adjustPanoCircleMeshPositionBasedOnModel=n.adjustPanoCircleMeshPositionBasedOnModel,this.tileLevelForFov=n.tileLevelForFov,this.tileAppearDuration=n.tileAppearDuration,this.tileMaxRequest=n.tileMaxRequest,this.flyEffectUseDepthBuffer=n.flyEffectUseDepthBuffer,this.adjustPanoCircleMeshPositionFix=new Map;let{pano0:r,pano1:i}=this.modelScene.parameter.resolveValue();r&&(i==null?void 0:i.map)!==r.map&&(this.modelScene.parameter.set({pano0:i}),r.map.dispose());let a=new Set;r&&a.add(r),i&&a.add(i),this.panoMeshes=new Map,this.locationMotion=new J({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Ft()]={panoId:Wv(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:uC,fixCameraTransform:new l.Matrix4},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new Qc,this.tiling=new eC({fiveId:this.fiveId}),this.panoVideo=new aC,this.scene.add(this.panoVideo.object),this.accessibleObserverFloorCheckCount=0}get tileLevel(){return this.tiling.level}updateConfiguration(e){return super.updateConfiguration(e)===!1?!1:(e.maxAccessibleDistance!==void 0&&this.maxAccessibleDistance!==e.maxAccessibleDistance&&(this.maxAccessibleDistance=e.maxAccessibleDistance),e.panoTapTriggerRadius!==void 0&&this.panoTapTriggerRadius!==e.panoTapTriggerRadius&&(this.panoTapTriggerRadius=e.panoTapTriggerRadius),e.panoCircleMeshCreator!==void 0&&this.panoCircleMeshCreator!==e.panoCircleMeshCreator&&(this.panoCircleMeshCreator=e.panoCircleMeshCreator,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear())),e.tileLevelForFov!==void 0&&this.tileLevelForFov!==e.tileLevelForFov&&(this.tileLevelForFov=e.tileLevelForFov),e.tileMaxRequest!==void 0&&this.tileMaxRequest!==e.tileMaxRequest&&(this.tileMaxRequest=e.tileMaxRequest),e.flyEffectUseDepthBuffer!==void 0&&this.flyEffectUseDepthBuffer!==e.flyEffectUseDepthBuffer&&(this.flyEffectUseDepthBuffer=e.flyEffectUseDepthBuffer),e.adjustPanoCircleMeshPositionBasedOnModel!==void 0&&this.adjustPanoCircleMeshPositionBasedOnModel!==e.adjustPanoCircleMeshPositionBasedOnModel&&(this.adjustPanoCircleMeshPositionBasedOnModel=e.adjustPanoCircleMeshPositionBasedOnModel,this.adjustPanoCircleMeshPositionBasedOnModel||this.adjustPanoCircleMeshPositionFix.clear()),!0)}destroy(){super.destroy(),this.tiling.dispose(),this.modelScene.parameter.set({refinedScreen:null,pano0Depth:null,pano1Depth:null}),this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0),this.locationMotion.dispose(),this.pendingTextureTask=void 0,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear());let e=this.videoTexture.image;e.pause(),e.oncanplay=K,e.ontimeupdate=K,this.scene.remove(this.panoVideo.object),this.panoVideo.setMaterial(null),this.panoVideo.dispose();let{pano0:t,pano1:n}=this.modelScene.parameter.resolveValue();for(let e of Object.keys(this.panoResources)){let r=this.panoResources[e];if(r.panoPicture){let e=r.panoPicture.map;e&&e!==(t==null?void 0:t.map)&&e!==(n==null?void 0:n.map)&&(e.dispose(),r.panoPicture=null)}delete this.panoResources[e]}}isReady(){return this.locationMotion.ended===!0?super.isReady():!1}isTileReady(){let e=this.tiling.pedding<=0;return this.initAnimationed&&e}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&(this.initAnimationed=!1,this.moveToPano({workCode:a.workCode,panoIndex:a.panoIndex},{effect:r.effect,duration:r.duration,longitude:a.longitude,latitude:a.latitude,fov:a.fov,moveEndCallback:()=>{this.initAnimationed=!0},moveCancelCallback:()=>{this.initAnimationed=!0}},i)),!0}updateModel(e){this.modelScene=e,this.hideIntersectMesh()}updateTime(e,t,...n){var r,i,a,o,s,c,u;if(this.destroyed)return;let d={},f={},p=this.camera.getDirection(new l.Vector3),m=this.locationMotion.keyframes[0],h=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[g,_]=this.locationMotion.getKeyFrameSegment(e),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(_),b=this.panoResourceFromLocationMotionKeyframe(m),x=this.panoResourceFromLocationMotionKeyframe(h),S=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),f.longitude=this.cameraMotion.value.longitude,f.latitude=this.cameraMotion.value.latitude,f.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),d.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-_.value.count+1,n=new l.Vector3().copy(v.position),a=new l.Vector3().copy(y.position);if(d.progress=y.effectEasing(t),t>=.01&&t<=.99&&(d.progress=H(y.effectEasing(t),.01,.99)),y.panoPicture&&(t<1?v.panoPicture&&(d.pano0=v.panoPicture):d.pano0=y.panoPicture,d.pano1=y.panoPicture),y.effect===`montage`?d.transition=`BLACK`:y.effect===`spread`?d.transition=`SPREAD`:d.transition=`FADE`,y.effect===`zoomin`||y.effect===`zoomout`?d.progress=Math.pow(t,3):y.effect===`model`&&this.camera.pose.distance<.01&&(d.modelAlpha=1-Math.pow(H(Math.abs(t-.5)*2,0,1),4)),t<1&&y.effect!==`fly`&&y.effect!==`model`){if(d.pano0&&v.panoPicture){let e={panoId:d.pano0.panoId,map:d.pano0.map,mapHistogram:d.pano0.mapHistogram,mapSize:d.pano0.mapSize,zoom:d.pano0.zoom,matrix:v.panoPicture.matrix.clone().premultiply(v.fixCameraTransform).setPosition(y.position),hdrConfig:d.pano0.hdrConfig?Object.assign({},d.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(d.pano0);t&&this.panoPictureObserverMap.set(e,t),d.pano0=e}n.copy(a),S=!0}f.distance=this.locationMotion.value.distance,f.offset=new l.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=d.pano0)==null?void 0:r.map)||e===((i=d.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let c=Gv(y.panoId);c!==this.currentPano&&(this.currentPano=c,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:Gv(b.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Gv(x.panoId)),{mode:this.mode}),Ox(this.camera.pose)),f),options:{},progress:this.locationMotion.progress,error:null}))}jx(d)===!1&&this.modelScene.parameter.set(d),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),jx(f)===!1&&this.setCamera(f);let C=this.works.getObserver(this.currentPano),w=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,T=this.works.getObserver(v.panoId),E=this.works.getObserver(y.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&C){let e=[],t=C.work.observers;for(let n of C.accessibleNodes){let r=t[n];r&&e.push(r)}let n=new Map;if(e.sort((e,t)=>{let r=n.get(e);r===void 0&&(r=e.standingPosition.distanceTo(C.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(C.standingPosition),n.set(t,i)),r-i}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let t=e[this.accessibleObserverFloorCheckCount],n=this.modelScene.models.find(e=>e.work===(t==null?void 0:t.work));if(t&&n&&n.visible){let e=.3,r=.005,i=t.standingPosition.clone().applyMatrix4(t.work.transform),a=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=pC.map(t=>{dC.ray.origin.copy(i),dC.ray.origin.add(fC.copy(t).setY(e)),dC.ray.direction.set(0,-1,0),dC.firstHitOnly=!0,dC.floorIndex=-1;let[a]=n.intersectRaycaster(dC);return a&&a.distance-r<=e?new l.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[c]=o.filter(e=>e.distanceTo(s)<=.05);if(c){let e=new l.Vector4(i.x,i.y,i.z,c.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let D=new Map;if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(E)for(let e of E.accessibleNodes){let t=E.work.observers[e];if(t){let e=Wv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{D.get(t)?D.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),D.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),D.delete(t)}),this.panoMeshes.forEach((e,t)=>{let n=this.works.getObserver(t);if(n){let r=n.position.distanceTo(n.standingPosition)>this.aerialObserverMinHeight;if(r)e.position.copy(n.position).applyMatrix4(n.work.transform),e.scale.setScalar(18);else{e.position.copy(n.standingPosition).applyMatrix4(n.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(n.panoId);t&&(fC.set(t.x,t.y,t.z),fC.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new l.Vector3().copy(e.position).sub(i).normalize();if(t===Wv(this.currentPano)){let t=H((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(p.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new l.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||S)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(C){let n=C.work.observers,[,r]=Bf(C.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:C.standingPosition.distanceTo(t.standingPosition)},!0);r=H(r,3,1/0);let i=C.accessibleNodes.concat(C.panoIndex).map(e=>Wv({panoIndex:e,workCode:C.work.workCode}));this.panoMeshes.forEach((n,a)=>{let o=this.works.getObserver(a),s=!1,c=1;if(i.indexOf(a)===-1)s=!1,c=0;else if(!o)s=!1,c=0;else if(!o.loadable&&!o.active)s=!1,c=0;else{let e=n.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&w!==null&&Wv({panoIndex:w.panoIndex,workCode:w.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:H(r/t,.1,.85)}o&&o===E&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue().modelAlpha>0&&(c=0),n.setCurrent(s),n.setOpacity(c),n.updateTime&&n.updateTime(e,t)})}{let e=(a=this.modelScene.parameter.progress)==null?1:a,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,c;if(i&&(c=this.works.getObserver(i.panoId),c||(c=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(Wc()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!c||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:null,gainMap:void 0,panoMatrix:new l.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Fc(i.mapSize),a=e+1,u=new l.Vector2().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),d=Math.floor(this.tileLevelForFov(this.camera.fov,u)),f=d>e?d:0;this.tiling.setObserver(c);let p={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:i.map,gainMap:(o=i.hdrConfig)==null?void 0:o.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:a,level:f,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},m=this.tiling.update(p),h={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:t,opacity:(n==null?void 0:n.panoId)===(r==null?void 0:r.panoId)?1:om(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},g=this.modelScene.parameter.refinedScreen;(m||h.pano!==(g==null?void 0:g.pano)||h.opacity!==(g==null?void 0:g.opacity))&&this.modelScene.parameter.set(`refinedScreen`,h)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),C&&C.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&C&&C.position.y-C.standingPosition.y>10){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1);{let e=y.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((c=this.modelScene.parameter.pano0Depth)==null?void 0:c.panoId)!==t.panoId||((u=this.modelScene.parameter.pano1Depth)==null?void 0:u.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new l.CubeRenderTarget(512,{minFilter:l.NearestFilter,magFilter:l.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new l.CubeRenderTarget(512,{minFilter:l.NearestFilter,magFilter:l.NearestFilter,generateMipmaps:!1});let e=new l.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,lC(this.renderer,this.modelScene,e,500);let r=new l.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,lC(this.renderer,this.modelScene,r,500),this.modelScene.parameter.set({pano0Depth:{panoId:t.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:n.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1],n=this.panoResourceFromLocationMotionKeyframe(t),r=this.works.getObserver(n.panoId);return{workCode:r?r.work.workCode:this.currentPano.workCode,panoIndex:r?r.panoIndex:this.currentPano.panoIndex,mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:r?r.position.clone().applyMatrix4(r.work.transform):this.camera.position.clone(),distance:this.locationMotion.value.distance}}moveToPano(e,t,n){var r,i,a;let o=(r=t.effect)==null?`fly`:r;this.userAction=n,this.stopMomentumMovement();let s=Wv(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let u=Mc(c.images.up),d=this.imageOptions.size;d===void 0&&c&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=Object.assign({key:`pano.${s}`},Zs(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),m={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},h,g=``;c.images.hdrConfig&&(h={right:c.images.work.getURL(c.images.gainmap_right),left:c.images.work.getURL(c.images.gainmap_left),up:c.images.work.getURL(c.images.gainmap_up),down:c.images.work.getURL(c.images.gainmap_down),front:c.images.work.getURL(c.images.gainmap_front),back:c.images.work.getURL(c.images.gainmap_back)},g=c.images.work.getURL(c.images.hdrConfig));let _=`pano:`+Hv([m,p,f]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===_)return;{let e=this.pendingTextureTask.panoId;(i=this.panoMeshes.get(e))==null||i.setProgress(0),this.emit(`pano.texture.abort`,$(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode}}))}}let v=`move-to-pano-`+s;this.pending.add(v);let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===_?b=y.pano0:y.pano1&&y.pano1.map.name===_&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?uC:a,panoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:b.hdrConfig?Object.assign({},b.hdrConfig):void 0},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new l.Matrix4};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,c),this.pendingTextureTask=void 0,Bc.shared.add(()=>{this.pending.delete(v),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:_,onLoad:(n,r)=>Dd(this,void 0,void 0,function*(){var i,a;let u=n.body;if(this.destroyed)u.dispose();else{u.name=_;let n=Array.isArray(u.image)?u.image[0]:u.image,d=(i=n==null?void 0:n.width)==null?2048:i,{data:f}=yield qx(this.renderer,u,!0,eb),p=new ib().formPixels(f),m={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?uC:a,panoPicture:{panoId:s,map:u,mapSize:d,mapHistogram:new l.Vector4().fromArray(p.toArray()),matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:r},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new l.Matrix4};m.panoPicture&&this.panoPictureObserverMap.set(m.panoPicture,c),this.doMoveToPano(e,m,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),Ox(this.camera.pose));this.emit(`pano.error`,$(`pano.error`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`pano.cancel`,$(`pano.cancel`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`error`,n),t.moveCancelCallback&&t.moveCancelCallback()}};let x=this.panoMeshes.get(s);x&&x.tap&&x.tap();let S=[this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,$(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];g&&S.push(fetch(g).then(e=>e.json()),this.textureLoader.loadCubeTexture(h,{imageURL:{transform:f,options:p},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,c.work)},void 0,void 0,void 0,this.renderer)),Promise.all(S).then(([t,n,r])=>{var i,a;this.pending.delete(v),((i=this.pendingTextureTask)==null?void 0:i.hash)===_?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},fS(n))),this.pendingTextureTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,$(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}))}).catch(t=>{var n,r;this.pending.delete(v),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&(this.pendingTextureTask.onError(t),this.pendingTextureTask=void 0,(r=this.panoMeshes.get(s))==null||r.setProgress(0)),this.emit(`pano.texture.error`,$(`pano.texture.error`,{error:t,progress:0,meta:null,pano:e})),this.emit(`error`,t)}),this.emit(`pano.texture.load`,$(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{duration:n,effect:r,userAction:i}=this.initial;this.userAction=i;let a=e.initAnimationEndState(this),o={workCode:a.workCode,panoIndex:a.panoIndex},s={modelAlpha:0},c={perspToOrtho:0},l=!1;this.moveToPano(o,{longitude:a.longitude,latitude:a.latitude,fov:a.fov,effect:r,duration:n,moveStartCallback:e=>{l=!0,this.perspToOrthoMotion.set(c,n).catch(K),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:s}],n).catch(K),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()},moveCancelCallback:()=>{let e=Object.assign(Object.assign(Object.assign({},o),{mode:this.mode}),Ox(this.camera.pose));l===!1&&this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction})),this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()}},i)})}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}locationMotionKeyframesLength(e){let t=0;for(let n=1;n<e.length;n++){let r=this.panoResourceFromLocationMotionKeyframe(e[n-1]).position,i=this.panoResourceFromLocationMotionKeyframe(e[n]).position,a=r.distanceTo(i)*(e[n].value.count-e[n-1].value.count);t+=a}return t}doMoveToPano(e,t,n={}){var r,i,a,o,s,c,u,d,f,p,m;let h=G(),g=Ft();this.panoResources[g]=t;let _,v,y;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;_=Math.max(a.distanceTo(o),1),v=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],y=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(n).position,o=t.position,s=n.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;_=c+Math.max(a.distanceTo(o),1),v=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/_,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(v);y=l===0||l===0?0:this.locationMotion.getProgressVelocity(h)*l/u}let b=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?_:0),x={longitude:n.longitude,latitude:n.latitude,fov:n.fov},S=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=x.longitude)==null?this.camera.pose.longitude:i,latitude:(a=x.latitude)==null?this.camera.pose.latitude:a,fov:(o=x.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),C=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(S),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(x,b).catch(K);else{let e=yi({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=yi({longitude:(s=x.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=x.latitude)==null?this.cameraMotion.value.latitude:c}),r=new l.Object3D;r.lookAt(e);let i=new l.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new l.Matrix4().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),h=this.cameraMotion.value.fov,g=(u=x.fov)==null?this.cameraMotion.value.fov:u,_=1;t.effect===`zoomin`?_=1.5:t.effect===`zoomout`&&(_=.4);let y=H(g*_,1,170);for(let e=0;e<v.length-1;e++){let t=v[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(y/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=x.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=x.latitude)==null?this.cameraMotion.value.latitude:f,fov:y}},{progress:1,value:{longitude:(p=x.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=x.latitude)==null?this.cameraMotion.value.latitude:m,fov:g}}],b).catch(K)}this.locationMotion.setKeyframes(v,b,y).then(()=>{for(let e of this.modelScene.children)e instanceof dv&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance});this.emit(`pano.arrived`,$(`pano.arrived`,{options:n,prevPano:C,progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(e);if(r&&r.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:r.images.video.size.clone(),matrix:r.images.video.matrix.clone(),panoMatrix:r.matrix.clone().premultiply(r.work.transform),alpha:1},t=Ft(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=K,n.ontimeupdate=K,CS().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=K,e.ontimeupdate=K}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}getForwardObserverOrNot(e,t){let n=this.works.getObserver(this.currentPano);if(!n)return null;let r=t==null?new l.Raycaster(e.position.clone(),e.getWorldDirection(new l.Vector3)):t;r.params.Points={threshold:.1},r.firstHitOnly=!0,r.floorIndex=-1;let i=n.standingPosition.clone().applyMatrix4(n.work.transform);if(n.position.clone().applyMatrix4(n.work.transform).distanceTo(r.ray.origin)>1){let e=new l.Raycaster(r.ray.origin,new l.Vector3(0,-1,0));e.firstHitOnly=r.firstHitOnly,e.floorIndex=r.floorIndex;let[t]=this.modelScene.intersectRaycaster(e);t&&t.distance<=2?i.copy(t.point):i.copy(r.ray.origin).add(new l.Vector3(0,-1.5,0))}let[a]=this.modelScene.intersectRaycaster(r),o=(a?a.point:r.ray.origin.clone().add(r.ray.direction.clone().normalize().multiplyScalar(3))).clone().sub(i).normalize();if(o.length()===0)return null;let s=n.work.observers,c=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.standingPosition.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),u=new Map,d=c.slice().sort((e,t)=>{let n=s[e],r=u.get(n);r===void 0&&(r=fC.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),u.set(n,r));let a=s[t],o=u.get(a);return o===void 0&&(o=fC.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),u.set(a,o)),r-o});u.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of d){let n=s[t];if(n){let t=fC.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let f=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,fC);n&&(n.project(e),Math.abs(n.z)<=1&&(f=n.clone()))}else f=new l.Vector3(0,0,0);if(f){let t=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.position.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),r=new Map,i=t.slice().sort((t,n)=>{let i=s[t],a=r.get(i);a===void 0&&(a=fC.copy(i.position).applyMatrix4(i.work.transform).distanceTo(e.position),r.set(i,a));let o=s[n],c=r.get(o);return c===void 0&&(c=fC.copy(o.position).applyMatrix4(o.work.transform).distanceTo(e.position),r.set(o,c)),a-c});r.clear();for(let t of i){let n=s[t];if(n){let t=fC.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(f.x-t.x,2)+Math.pow(f.y-t.y,2)<Math.pow(.4,2))return n}}}return null}onTapGesture(e){var t;if(this.userAction=e.userAction,this.stopMomentumMovement(),!this.initAnimationed)return;let n=e.center.raycaster;n.floorIndex=-1;let r=this.camera.getDirection(new l.Vector3).setY(0),i=null,a=this.works.getObserver(this.currentPano);if(!a)return;let o=a.work.observers,s=a.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&a.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||fC.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(n);if(c){let[e,n]=Bf(s,e=>{let t=o[e];return t?fC.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&n<this.panoTapTriggerRadius&&(i=(t=o[e])==null?null:t)}if(i||(i=this.getForwardObserverOrNot(this.camera,n)),i&&i.panoId===Wv(this.currentPano)&&(i=null),i&&!this.locationMotion.ended){for(let e of this.locationMotion.keyframes)if(this.panoResourceFromLocationMotionKeyframe(e).panoId===i.panoId){i=null;break}}if(!i)this.emit(`gesture.tap`,e),e.defaultPrevented||this.locationMotion.ended===!0&&this.cameraBounce();else{let t={},n=Math.PI/6,o=Math.PI/12,s=i.position.clone().applyMatrix4(i.work.transform).setY(0).sub(a.position.clone().applyMatrix4(i.work.transform).setY(0)).normalize(),c=[],l=[],u=[],d=i.work.observers;for(let e of i.accessibleNodes){if(i.panoIndex===e||e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)continue;let t=d[e];if(!t)continue;let r=t.position.clone().applyMatrix4(t.work.transform).sub(i.position.clone().applyMatrix4(i.work.transform)).setY(0).normalize();s.angleTo(r)<n&&u.push(r)}let[f]=(u.length>0?u:[...c,...l]).slice().sort((e,t)=>e.angleTo(s)-t.angleTo(s));if(f&&f.angleTo(r)>o&&(t.longitude=Math.atan2(-f.x,-f.z)),this.cameraMotion.value.latitude<-Math.PI/4){let n=e.state.fov;t.latitude=H(0,H(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),H(typeof this.maxLatitude==`function`?this.maxLatitude(n):this.maxLatitude,-Math.PI/2,Math.PI/2))}let p=Object.assign({},e.state);if(p.workCode=i.work.workCode,p.panoIndex=i.panoIndex,t.longitude!==void 0&&(p.longitude=t.longitude),t.latitude!==void 0&&(p.latitude=t.latitude),t.fov!==void 0&&(p.fov=t.fov),p.distance=0,p.offset=i.position.clone(),e.state=p,this.emit(`gesture.tap`,e),!e.defaultPrevented){if(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:p,userAction:e.userAction,options:t,progress:0,error:null})),i&&!i.active){let e=Wv({panoIndex:i.panoIndex,workCode:i.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}i&&i.active&&this.emit(`pano.request`,$(`pano.request`,{userAction:e.userAction,prevPano:this.currentPano,progress:0,state:p,options:t,error:null}))}}}},gC=new l.Vector3(0,1.6,0),_C=new l.Box3,vC=new l.Vector3,yC=Object.assign({},yS),bC=class e extends bS{static parseArgs(t){return t instanceof e?t:super.parseArgs(t)}static initAnimationEndState(e){var t,n,r,i,a,o;let s=this.parseArgs(e),c=s.works,{state:u,currentState:d}=e.initial,f=typeof u.panoIndex==`number`?{workCode:(r=(t=u.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:u.panoIndex}:{workCode:d.workCode,panoIndex:d.panoIndex},p=c.getObserver(f),m=H((i=u.fov)==null?!p||Ax(d.mode)?d.fov:s.defaultFov:i,s.minFov,s.maxFov),h=(a=u.longitude)==null?d.longitude:a,g=H(typeof s.minLatitude==`function`?s.minLatitude(m):s.minLatitude,-Math.PI/2,Math.PI/2),_=H(typeof s.maxLatitude==`function`?s.maxLatitude(m):s.maxLatitude,-Math.PI/2,Math.PI/2),v=H((o=u.latitude)==null?!p||Ax(d.mode)?d.latitude:s.defaultLatitude:o,g,_),y=new l.Vector3;if(s.initial.state.offset)y.copy(s.initial.state.offset);else if(p)y.copy(p.position).applyMatrix4(p.work.transform);else{let e=yi(d).setLength(d.distance);y.copy(s.initial.currentState.offset).sub(e)}return{workCode:f.workCode,panoIndex:f.panoIndex,mode:`Model`,longitude:h,latitude:v,fov:m,offset:y,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new J({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x})}updateConfiguration(e){return super.updateConfiguration(e)}destroy(){super.destroy(),this.locationMotion.dispose()}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&this.moveToPosition(a.offset,{duration:0,longitude:a.longitude,latitude:a.latitude,fov:a.fov},i),!0}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return r.distance=0,e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(K),this.cameraMotion.set(i,t).catch(K)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:0,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(K),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t,...n){if(this.destroyed)return;let r={},i={};if(this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),r.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),r.progress=1,r.pano0=r.pano1=t}if(this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),n=[];for(let e of this.works){let r=this.modelScene.models.find(t=>t.work===e);if(!(!r||r.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=Bf(n,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t));this.currentPano=r?{workCode:r.work.workCode,panoIndex:r.panoIndex}:{workCode:``,panoIndex:0}}this.cameraMotion.ended||(this.cameraMotion.update(e),i.longitude=this.cameraMotion.value.longitude,i.latitude=this.cameraMotion.value.latitude,i.fov=this.cameraMotion.value.fov),jx(r)||this.modelScene.parameter.set(r),jx(i)||this.setCamera(i);let a=this.works.getObserver(this.currentPano);if(this.intersectMesh&&this.intersectMesh.parent&&a&&a.position.y-a.standingPosition.y>10){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1)}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={modelAlpha:1},c={perspToOrtho:0},l={longitude:o.longitude,latitude:o.latitude,fov:o.fov,duration:i,moveStartCallback:e=>{this.perspToOrthoMotion.set(c,i).catch(K),this.modelAlphaMotion.set(s,i).catch(K),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),t()},moveCancelCallback:()=>{let e=this.currentPano,n=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance});this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:n,userAction:this.userAction})),t()}};this.moveToPosition(o.offset,l,a)})}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:new l.Vector3(t.value.x,t.value.y,t.value.z),distance:t.value.distance})}moveToPano(e,t={},n){let r=this.works.getObserver(e);if(r){let e=new l.Vector3().copy(r.position).applyMatrix4(r.work.transform);this.moveToPosition(e,t,n)}}moveToPosition(e,t={},n){var r,i,a;this.userAction=n,this.stopMomentumMovement();let o=G(),s=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),c=s.distanceTo(e),u=this.locationMotion.getProgressVelocity(o),d=0;for(let e=1;e<this.locationMotion.keyframes.length;e++){let{x:t,y:n,z:r}=this.locationMotion.keyframes[e-1].value,{x:i,y:a,z:o}=this.locationMotion.keyframes[e].value;d+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let f=c===0?0:u*d/c,p=this.calculateMovingDuration(t.duration,c),m={x:e.x,y:e.y,z:e.z,distance:0},h={longitude:t.longitude,latitude:t.latitude,fov:t.fov},g=[];for(let e of this.works){let t=this.modelScene.models.find(t=>t.work===e);if(!(!t||t.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(s)))for(let t of e.observers)g.push(t)}let _=Bf(g,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),v=_?{workCode:_.work.workCode,panoIndex:_.panoIndex}:{workCode:``,panoIndex:0},y=Object.assign(Object.assign({},v),{mode:this.mode,longitude:(r=h.longitude)==null?this.camera.pose.longitude:r,latitude:(i=h.latitude)==null?this.camera.pose.latitude:i,fov:(a=h.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),b=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(y),this.cameraMotion.set(h,p).catch(K),this.locationMotion.set(m,p,f).then(()=>{for(let e of this.modelScene.children)e instanceof dv&&e.show();let e=Object.assign(Object.assign(Object.assign({},v),{mode:this.mode}),Ox(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:b,progress:0,state:e,userAction:this.userAction,error:null})),t.moveEndCallback&&t.moveEndCallback(e)},()=>{t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.cancel`,$(`pano.cancel`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null}))})}onTapGesture(e){let t=e.center.raycaster;this.stopMomentumMovement();let[n]=this.modelScene.intersectRaycaster(t);if(n&&n.face){let e=n.face.normal,t=n.point;if(new l.Vector3(0,1,0).angleTo(e)>Math.PI/3){let r=new l.Raycaster;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new l.Vector3(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new l.Vector3().copy(n.point).add(gC),r=[];for(let e of this.works){let n=this.modelScene.models.find(t=>t.work===e);if(!(!n||n.visible===!1)&&!(e.observers.length<=0)&&(_C.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),_C.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=Bf(r,e=>vC.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=vC.copy(i.position).applyMatrix4(i.work.transform).y),e.state.offset.copy(t),e.state.distance=0,this.emit(`gesture.tap`,e),e.defaultPrevented||this.moveToPosition(t,{},!0)}else this.emit(`gesture.tap`,e),e.defaultPrevented||this.cameraBounce()}},xC=new l.Box3,SC=new l.Vector3,CC=.5,wC=Math.PI/7,TC={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new lS},EC={Floorplan:gS,Topview:vS,Panorama:hC,Model:bC,Mapview:class e extends Yx{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{defaultLongitude:(n=t.defaultLongitude)==null?TC.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?TC.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?TC.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?TC.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?TC.minLatitude:o,cameraType:(s=t.cameraType)==null?TC.cameraType:s,cameraFence:(c=t.cameraFence)==null?TC.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?TC.intersectMeshCreator:l})}static distanceFromModel(e,t,n){let r=e.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2);i=isNaN(i)||!isFinite(i)?1:i;let a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),isNaN(a)||!isFinite(a)?i:a}static initAnimationEndState(t){var n,r,i,a,o,s,c;let u=this.parseArgs(t),d=u.works,f=u.modelScene,{state:p,currentState:m}=t.initial,h=typeof p.panoIndex==`number`?{workCode:(i=(n=p.workCode)==null?(r=u.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:p.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},g=(a=p.fov)==null?60:a,_=H(typeof u.minLatitude==`function`?u.minLatitude(g):u.minLatitude,-Math.PI/2,Math.PI/2),v=H(typeof u.maxLatitude==`function`?u.maxLatitude(g):u.maxLatitude,-Math.PI/2,Math.PI/2),y=H((o=p.latitude)==null?kx(m.mode)?m.latitude:u.defaultLatitude:o,_,v),b=e.distanceFromModel(u.modelScene,g,u.camera.aspect),x=new l.Vector3,S=(s=p.distance)==null?Math.min(u.defaultDistance,b):s,C=(c=p.longitude)==null?kx(m.mode)?m.longitude:u.defaultLongitude:c;if(p.offset)x.copy(p.offset);else{let e=d.getObserver(h);u.defaultDistance<b&&e?(x.copy(e.position).applyMatrix4(e.work.transform),p.longitude===void 0&&(C=m.longitude)):(f.boundingBox.getCenter(x),S=b)}return Object.assign(Object.assign({},h),{mode:`Mapview`,longitude:C,latitude:y,fov:g,offset:x,distance:S})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Mapview`,this.defaultLongitude=n.defaultLongitude,this.defaultLatitude=n.defaultLatitude,this.defaultDistance=n.defaultDistance,this.maxLatitude=n.maxLatitude,this.minLatitude=n.minLatitude,this.cameraType=n.cameraType,this.cameraFence=n.cameraFence,this.locationMotion=new J({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new Qc,this.intersectMeshCreator=n.intersectMeshCreator,this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=`intersect`,this.intersectMesh.visible=!1,this.helper.add(this.intersectMesh)}updateConfiguration(e){if(super.updateConfiguration(e)===!1)return!1;if(e.defaultLongitude!==void 0&&this.defaultLongitude!==e.defaultLongitude&&(this.defaultLongitude=e.defaultLongitude),e.defaultLatitude!==void 0&&this.defaultLatitude!==e.defaultLatitude&&(this.defaultLatitude=e.defaultLatitude),e.defaultDistance!==void 0&&this.defaultDistance!==e.defaultDistance&&(this.defaultDistance=e.defaultDistance),e.maxLatitude!==void 0&&this.maxLatitude!==e.maxLatitude&&(this.maxLatitude=e.maxLatitude),e.minLatitude!==void 0&&this.minLatitude!==e.minLatitude&&(this.minLatitude=e.minLatitude),e.cameraType!==void 0&&this.cameraType!==e.cameraType&&(this.cameraType=e.cameraType),this.cameraFence instanceof l.Box3&&e.cameraFence instanceof l.Box3||this.cameraFence instanceof l.Sphere&&e.cameraFence instanceof l.Sphere?this.cameraFence.equals(e.cameraFence)||(this.cameraFence=e.cameraFence):e.cameraFence!==void 0&&(this.cameraFence=e.cameraFence),e.intersectMeshCreator!==void 0&&this.intersectMeshCreator!==e.intersectMeshCreator){this.intersectMeshCreator=e.intersectMeshCreator;let t=this.intersectMesh;this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=t.name,this.intersectMesh.visible=t.visible;let n=this.intersectMesh.parent;n&&n.add(this.intersectMesh),t.dispose()}return!0}destroy(){super.destroy(),this.pendingTextureId=null,this.locationMotion.dispose(),this.panState=void 0,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));this.currentPano={workCode:a.workCode,panoIndex:a.panoIndex};let o={longitude:a.longitude,latitude:a.latitude,fov:a.fov},s={x:a.offset.x,y:a.offset.y,z:a.offset.z,distance:a.distance};return(o.longitude!==this.cameraMotion.value.longitude||o.latitude!==this.cameraMotion.value.latitude||o.fov!==this.cameraMotion.value.fov)&&this.cameraMotion.set(o,r.duration).catch(K),(s.x!==this.locationMotion.value.x||s.y!==this.locationMotion.value.y||s.z!==this.locationMotion.value.z||s.distance!==this.locationMotion.value.distance)&&this.locationMotion.set(s,r.duration).catch(K),!0}updateModel(e){super.updateModel(e),this.hideIntersectMesh()}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return e.distance!==void 0&&(r.distance=e.distance),e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(K),this.cameraMotion.set(i,t).catch(K)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:t.value.distance,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(K),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t){if(this.destroyed)return;let n={},r={};if(this.locationMotion.ended||(this.locationMotion.update(e),r.distance=this.locationMotion.value.distance,r.offset=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),r.longitude=this.cameraMotion.value.longitude,r.latitude=this.cameraMotion.value.latitude,r.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),n.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),n.progress=1,n.pano0=n.pano1=t}let i=0;if(this.cameraType===`auto`?i=+(Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02):this.cameraType===`perspective`?i=0:this.cameraType===`orthographic`&&(i=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==i&&this.perspToOrthoMotion.set({perspToOrtho:i},500).catch(K),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),jx(n)||this.modelScene.parameter.set(n),jx(r)||this.setCamera(r),this.cameraFence&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&!this.inMomentumMovement&&this.locationMotion.ended&&this.perspToOrthoMotion.ended&&this.cameraMotion.ended){let e=yi(this.camera.pose,new l.Vector3),t=new l.Vector3().copy(this.camera.pose.offset).sub(e.clone().multiplyScalar(this.camera.pose.distance));if(this.cameraFence.distanceToPoint(t)>.01){let e=this.cameraFence.clampPoint(t,new l.Vector3),n=this.camera.pose.offset.clone().add(e).sub(t),r=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:n,distance:this.camera.pose.distance});this.fixFinalState(r),this.locationMotion.set({x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance},300).catch(K)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=H(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1)}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:t.value.distance,offset:new l.Vector3(t.value.x,t.value.y,t.value.z)})}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={longitude:o.longitude,latitude:o.latitude,fov:o.fov},c={x:o.offset.x,y:o.offset.y,z:o.offset.z,distance:o.distance};this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:o,userAction:this.userAction})),this.perspToOrthoMotion.set({perspToOrtho:0},i).catch(K),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(K),this.cameraMotion.set(s,i).catch(K),this.locationMotion.set(c,i).then(()=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:o,userAction:this.userAction}))},e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),Ox(this.camera.pose));this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:t,userAction:this.userAction}))}).then(()=>{t()})})}getForwardObserverOrNot(e){let[t]=this.modelScene.intersectRaycaster(e);if(!t)return null;let n=[];for(let t of this.works){let r=this.modelScene.models.find(e=>e.work===t);if(!(!r||r.visible===!1)&&!(t.observers.length<=0)&&(xC.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),xC.containsPoint(e.ray.origin)||e.ray.intersectsBox(xC)))for(let e of t.observers)n.push(e)}let[r,i]=Bf(n,e=>SC.copy(e.standingPosition).applyMatrix4(e.work.transform).distanceTo(t.point),!0);return r&&i<Math.max(r.standingPosition.distanceTo(this.camera.position)/5,10)?r:null}coordinatesForOffset(e){let t=this.renderer.getSize(new l.Vector2);return{longitude:-2*e.x/(t.x*this.viewport.width),latitude:2*e.y/(t.y*this.viewport.height)}}requestMomentumMovement(e,t,n,r){if(this.inMomentumMovement===null)return;r=Math.max(r,1);let i=Object.assign({},n),a={longitude:0,latitude:0,x:0,y:0,z:0};for(let e=0;e<r;e++)i.longitude*=.996,i.latitude*=.996*.998,i.x*=.99,i.y*=.99,i.z*=.99,a.longitude+=i.longitude,a.latitude+=i.latitude,a.x+=i.x,a.y+=i.y,a.z+=i.z;let o=this.cameraMotion.value.fov,s=vi(this.cameraMotion.value.longitude+a.longitude),c=H(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),u=H(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),d=H(this.cameraMotion.value.latitude+a.latitude,c,u),f=new l.Vector3(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),p=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:d,offset:f,fov:o,distance:this.locationMotion.value.distance}),m=e.state.offset.clone().sub(yi(e.state).setLength(p.distance)),h=!(Math.abs(i.longitude)>1e-4||Math.abs(i.latitude)>1e-4||Math.abs(i.x)>1e-4||Math.abs(i.y)>1e-4||Math.abs(i.z)>1e-4);(this.cameraFence?this.cameraFence.containsPoint(m):!0)===!1&&(h=!0);let g=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:h,state:p}));if(this.inMomentumMovement.event=g,this.emit(`gesture.momentum`,g),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:d},0).catch(K),this.locationMotion.set({x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance},0).catch(K),h?this.inMomentumMovement=null:Bc.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=yi(e,new l.Vector3),n=new l.Vector3().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new l.Raycaster(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>CC+r.near,r.near=this.camera.near,r.far=this.camera.far;let i;if(i=this.modelScene.intersectRaycaster(r)[0],i&&i.distance<this.camera.near&&(i=void 0),!i){let e=new l.Plane(new l.Vector3(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new l.Vector3);if(t){let e=t.distanceTo(r.ray.origin);e<1e3&&e>=r.near&&(i={distance:e,floorIndex:0,floor:0,point:t,object:this.scene,face:null})}}if(!i){let r=Math.max(e.distance,3);i={distance:r,floorIndex:0,floor:0,point:n.clone().add(t.clone().setLength(r)),object:this.scene,face:null}}i.distance>=this.camera.near&&vx(e.distance,i.distance)&&(e.distance=i.distance,e.offset=i.point)}onPanGesture(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.pointers.length,n=this.panState,r=0,i=!1;e.pointerType===`mouse`&&(r=e.center.buttons,i=e.center.shiftKey),n&&r===0&&n.buttons!==0&&(r=n.buttons);let a=n==null?void 0:n.target;if(!a){let t=this.relativeClientPosition(e.center),n=this.createRaycasterFromCamera(t,this.camera);a=new l.Vector3().copy(n.ray.direction).multiplyScalar(3).add(n.ray.origin);let[r]=this.modelScene.intersectRaycaster(n);if(!r&&n.ray.direction.y<-.3){let e=new l.Plane(new l.Vector3(0,1,0),0),t=n.ray.intersectPlane(e,new l.Vector3);if(t){let e=t.distanceTo(n.ray.origin);e<1e4&&e>=n.near&&(r={distance:e,floorIndex:0,floor:0,point:t,object:this.scene})}}if(r)a.copy(r.point);else{let e=new l.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new l.Plane().setFromNormalAndCoplanarPoint(e,this.camera.pose.offset);n.ray.intersectPlane(t,a)}}if(e.isFinal?this.panState=void 0:this.panState={target:a,buttons:r,pointerLength:t,x:e.center.x,y:e.center.y},!(n===void 0||n.pointerLength!==t))if(t>1||r===2||i){let t={x:e.center.x-n.x,y:e.center.y-n.y},r=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=yi(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new l.Vector3().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new l.Vector2),s=2*t.x*a/o.y,c=2*t.y*a/o.y,u=new l.Vector3;u.setFromMatrixColumn(this.camera.matrix,0),u.multiplyScalar(-s),r.add(u),this.camera.pose.latitude<wC?u.setFromMatrixColumn(this.camera.matrix,1):(u.setFromMatrixColumn(this.camera.matrix,0),u.crossVectors(this.camera.up,u)),u.multiplyScalar(c),r.add(u);let d=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:r,distance:this.camera.pose.distance});if(e.state=d,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K),e.isFinal&&(this.fixFinalState(d),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:d.distance,x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K)),e.isFinal){let t=this.renderer.getSize(new l.Vector2),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new l.Vector3,o=new l.Vector3;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<wC?i.setFromMatrixColumn(this.camera.matrix,1):(i.setFromMatrixColumn(this.camera.matrix,0),i.crossVectors(this.camera.up,i)),i.multiplyScalar(r),o.add(i),this.inMomentumMovement={uuid:Ft()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:o.x,y:o.y,z:o.z},0)}}else{let t={x:e.center.x-n.x,y:e.center.y-n.y},r=this.coordinatesForOffset(t),i=vi(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=H(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=H(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=H(this.cameraMotion.value.latitude+r.latitude,o,s);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(c=this.cameraMotion.value.latitude);let l=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:i,latitude:c,fov:a,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=l,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:l.distance,x:l.offset.x,y:l.offset.y,z:l.offset.z},0).catch(K):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(K),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:Ft()},this.requestMomentumMovement(e,!0,Object.assign(Object.assign({},this.coordinatesForOffset({x:t,y:n})),{x:0,y:0,z:0}),0)}}}onPinchGesture(t){var n;if(!this.initAnimationIsReady)return;this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let r=(n=this.pinchState)==null?void 0:n.distance;if(t.isFirst){this.pinchState={x:t.center.x,y:t.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(r===void 0)return;let i=this.modelScene.boundingBox.getCenter(new l.Vector3),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=H(r/t.scale,CC,1/0),s=t.state.offset.clone().sub(yi(t.state).setLength(o)),c=this.modelScene.boundingBox.containsPoint(s),u;if(!c&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?u=t.state.distance:(u=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=u,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(K),t.pointerType!==`mouse`&&(t.type=`gesture.pan`,this.onPanGesture(t)),t.isFinal)){if(!(`__fixFinalState`in t)){let e=t.state;this.fixFinalState(t.state);let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(K)}this.panState=void 0,this.pinchState=void 0}}onMouseMove(e){var t,n;if(!this.intersectMesh.parent||this.panState||this.pinchState||this.mouseWheelState||(this.emit(`gesture.mousemove`,e),e.defaultPrevented))return;let r=e.center.raycaster;if(e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}let[i]=this.modelScene.intersectRaycaster(r),a=$(`intersect.update`,{raycaster:r,intersection:i==null?null:i,object:this.intersectMesh});if(this.emit(`intersect.update`,a),a.defaultPrevented){this.hideIntersectMesh();return}if(i){let e=(n=(t=i.face)==null?void 0:t.normal)==null?new l.Vector3().copy(r.ray.direction).multiplyScalar(-1):n,a=e.clone(),o=i.point.clone();this.intersectMesh.position.copy(o);let s=o.clone().add(a);if(this.intersectMesh.lookAt(s),Math.abs(e.y)>.99){let e=this.camera.position.clone().sub(o);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}onMouseWheel(t){if(this.initAnimationIsReady)if(this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),t.isFinal){let e=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov,offset:new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),distance:this.locationMotion.value.distance});if(this.fixFinalState(e),this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(K)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new l.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=yi(this.cameraMotion.value,new l.Vector3).negate(),a=new l.Ray(r,i).intersectBox(this.modelScene.boundingBox,new l.Vector3);a&&(n+=a.distanceTo(r));let o=Math.max(this.locationMotion.value.distance-this.camera.near,0),s=t.center.delta/10*Math.max(o/5,.1);if(o<=n||s>0)if(this.locationMotion.value.distance-s>=CC){let e=this.locationMotion.value.distance-s;t.state.distance=e}else{let e=yi(this.cameraMotion.value);e.setLength(s),t.state.offset.add(e)}if(this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;this.locationMotion.set({distance:t.state.distance,x:t.state.offset.x,y:t.state.offset.y,z:t.state.offset.z},0).catch(K)}}onTapGesture(e){var t;this.userAction=e.userAction,this.stopMomentumMovement();let n=e.center.raycaster,r=this.getForwardObserverOrNot(n);if(!r)this.emit(`gesture.tap`,e);else{let n={longitude:this.camera.pose.longitude,latitude:0},i=Object.assign(Object.assign({},e.state),{mode:`Panorama`,workCode:r.work.workCode,panoIndex:r.panoIndex,longitude:n.longitude,latitude:n.latitude,offset:r?r.position.clone():new l.Vector3,distance:0});if(e.state=i,this.emit(`gesture.tap`,e),!e.defaultPrevented&&(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:i,userAction:e.userAction,options:n,progress:0,error:null})),r&&r.active)){let e=this.pendingTextureId=Ft(),a=Wv({panoIndex:r.panoIndex,workCode:r.work.workCode}),o={right:r.images.work.getURL(r.images.right),left:r.images.work.getURL(r.images.left),up:r.images.work.getURL(r.images.up),down:r.images.work.getURL(r.images.down),front:r.images.work.getURL(r.images.front),back:r.images.work.getURL(r.images.back)},s=this.imageOptions.transform,c=Object.assign({key:`pano.${a}`},Zs(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),u=`pano:`+Hv([o,c,s]),d=this.modelScene.parameter,f;if(d.pano0&&d.pano0.map.name===u?f=d.pano0:d.pano1&&d.pano1.map.name===u&&(f=d.pano1),f)d.pano0&&d.pano0.map!==f.map&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==f.map&&d.pano1.map!==((t=d.pano0)==null?void 0:t.map)&&d.pano1.map.dispose(),d.set({pano0:f,pano1:f}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,f=``;r.images.hdrConfig&&(t={right:r.images.work.getURL(r.images.gainmap_right),left:r.images.work.getURL(r.images.gainmap_left),up:r.images.work.getURL(r.images.gainmap_up),down:r.images.work.getURL(r.images.gainmap_down),front:r.images.work.getURL(r.images.gainmap_front),back:r.images.work.getURL(r.images.gainmap_back)},f=r.images.work.getURL(r.images.hdrConfig));let p=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:c},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),m=f?[fetch(f).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:c},format:l.RGBAFormat,viaAjax:!0,fetcher:K_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([p,...m]).then(t=>Dd(this,[t],void 0,function*([t,o,s]){var c,f;let{body:p}=t;if(this.destroyed||this.pendingTextureId!==e){p.dispose();return}this.pendingTextureId=null,p.name=u;let m=Array.isArray(p.image)?p.image[0]:p.image,h=(c=m==null?void 0:m.width)==null?2048:c,g=yield qx(this.renderer,p,!0,eb),_=new ib().formPixels(g.data),v={panoId:a,map:p,mapSize:h,mapHistogram:new l.Vector4().fromArray(_.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},fS(o)):void 0};d.pano0&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==((f=d.pano0)==null?void 0:f.map)&&d.pano1.map.dispose(),d.set({pano0:v,pano1:v}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}))})).catch(t=>{this.destroyed||this.pendingTextureId!==e||(this.pendingTextureId=null)})}}}}onDblTapGesture(e){if(!this.initAnimationIsReady)return;this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.state,n=e.center.raycaster,r=n.ray.origin.clone().add(n.ray.direction.clone().setLength(3)),i=1,[a]=this.modelScene.intersectRaycaster(n);if(a&&(r=a.point.clone(),i=a.distance>4/2?1:3),e.state.distance=i,e.state.offset=r,this.emit(`gesture.dbltap`,e),e.defaultPrevented)return;let o={x:t.offset.x,y:t.offset.y,z:t.offset.z,distance:t.distance};this.locationMotion.set(o,360).catch(K),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},DC={Floorplan:hS,Topview:_S,Panorama:mC,Model:yC,Mapview:TC},OC=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.create,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function kC(e){e.on(`initAnimation.start`,t=>{e.emit(`initAnimationWillStart`,t.state.panoIndex,t.state,t.userAction)}),e.on(`initAnimation.end`,t=>{e.emit(`initAnimationEnded`,t.state.panoIndex,t.state,t.userAction)}),e.on(`gesture.pan`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pan`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPanGesture`,t.state,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pan`,t.pointers,t.isFinal),e.emit(`panGesture`,t.state,t.isFinal))}),e.on(`gesture.tap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`tap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`tap`,t.pointers,t.isFinal),e.emit(`tapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.dbltap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`dbltap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsDblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`dbltap`,t.pointers,t.isFinal),e.emit(`dblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.press`,t=>{let n=!1;n=e.emit(`wantsGesture`,`press`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`press`,t.pointers,t.isFinal),e.emit(`pressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),e.on(`gesture.pinch`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pinch`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPinchGesture`,t.scale,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pinch`,t.pointers,t.isFinal),e.emit(`pinchGesture`,t.scale,t.state.fov,t.isFinal))}),e.on(`gesture.mousewheel`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseWheel`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsMouseWheel`,t.center.delta,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseWheel`,t.pointers,t.isFinal),e.emit(`mouseWheel`,t.center.delta,t.state.fov,t.isFinal))}),e.on(`gesture.mousemove`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseMove`,t.pointers,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseMove`,t.pointers,t.isFinal),n=e.emit(`wantsChangeCameraFov`,t.state.fov),n&&t.preventDefault())}),e.on(`gesture.momentum`,t=>{let n=!1;n=e.emit(`wantsInteriaPan`,t.state),n&&t.preventDefault(),t.defaultPrevented||e.emit(`interiaPan`,t.state,t.isFinal)}),e.on(`camera.update`,t=>{e.emit(`cameraFovUpdate`,t.state.fov,t.userAction),e.emit(`cameraDirectionUpdate`,t.state,t.userAction);let n=yi(t.state);n.setLength(t.state.distance);let r=t.state.offset.clone().sub(n);e.emit(`cameraPositionUpdate`,r,t.userAction),e.emit(`cameraUpdate`,t.state,t.userAction)}),e.on(`intersect.update`,t=>{if(t.intersection){let n=!1;n=e.emit(`wantsShowIntersectionOnModel`,t.raycaster),n&&t.preventDefault(),t.defaultPrevented||e.emit(`intersectionOnModelUpdate`,t.intersection,t.object)}else e.emit(`intersectionHidden`)}),e.on(`pano.request`,t=>{let n=e.emit(`wantsMoveToPano`,t.state.panoIndex,t.options,t.userAction);n||(n=e.emit(`wantsToMoveToPano`,t.state.panoIndex,t.options,t.userAction)),n&&t.preventDefault(),t.defaultPrevented||e.emit(`panoWillLoad`,t.state.panoIndex)}),e.on(`pano.select`,t=>{e.emit(`panoSelected`,t.state.panoIndex)}),e.on(`pano.moveTo`,t=>{e.emit(`panoLoaded`,t.state.panoIndex),e.emit(`moveToPano`,t.state.panoIndex,t.userAction),e.emit(`panoWillArrive`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.moving`,t=>{e.emit(`movingToPano`,t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),e.on(`pano.arrived`,t=>{e.emit(`panoArrived`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.cancel`,t=>{e.emit(`moveToPanoCanceled`,t.state.panoIndex)}),e.on(`pano.error`,t=>{e.emit(`panoLoadError`,t.error,t.state.panoIndex)}),e.on(`pano.texture.load`,t=>{e.emit(`textureStartLoad`,t.pano.panoIndex)}),e.on(`pano.texture.success`,t=>{e.emit(`textureLoaded`,t.pano.panoIndex,t.meta)}),e.on(`pano.texture.error`,t=>{e.emit(`textureError`,t.error,t.pano.panoIndex)}),e.on(`pano.texture.abort`,t=>{e.emit(`textureAbort`,t.pano.panoIndex)}),e.on(`pano.texture.progress`,t=>{e.emit(`textureLoading`,t.progress,t.pano.panoIndex)}),e.on(`xr.session.start`,t=>{e.emit(`webXRSessionStart`)}),e.on(`xr.session.end`,t=>{e.emit(`webXRSessionEnd`)}),e.on(`xr.gesture.tap`,t=>{e.emit(`webXRControllerEvent`,`tap`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.press`,t=>{e.emit(`webXRControllerEvent`,`press`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonUp`,t=>{e.emit(`webXRControllerEvent`,`buttonUp`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonDown`,t=>{e.emit(`webXRControllerEvent`,`buttonDown`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.controller.update`,t=>{e.emit(`webXRControllerRayUpdate`,{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&e.emit(`webXRAxesUpdate`,`left`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.left.axes.up,down:t.left.axes.down,left:t.left.axes.left,right:t.left.axes.right},deltaTime:t.left.deltaTime}),t.right&&e.emit(`webXRAxesUpdate`,`right`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.right.axes.up,down:t.right.axes.down,left:t.right.axes.left,right:t.right.axes.right},deltaTime:t.right.deltaTime})}),e.on(`works.request`,t=>{e.emit(`willLoad`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.load`,t=>{e.emit(`load`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.ready`,t=>{e.emit(`loaded`,t.input,t.works[0])}),e.on(`state.change`,t=>{e.emit(`stateChange`,t.state,t.userAction)}),e.on(`currentState.change`,t=>{e.emit(`currentStateChange`,t.state,t.userAction)}),e.on(`state.set`,t=>{e.emit(`setState`,t.state)}),e.on(`state.synced`,t=>{e.emit(`stateSynced`,t.state)}),e.on(`model.request`,t=>{e.emit(`modelWillLoad`,t.work.model)}),e.on(`model.error`,t=>{e.emit(`modelLoadError`,t.error,t.model)}),e.on(`model.load`,t=>{e.emit(`modelLoaded`,t.model)}),e.on(`model.changeShownFloor`,t=>{e.emit(`modelShownFloorChange`,t.model.shownFloor,t.model.floorLength)}),e.on(`render`,t=>{e.emit(`renderFrame`,t.needsRender)}),e.on(`mode.change.request`,t=>{e.emit(`wantsChangeMode`,t.mode,t.prevMode)}),e.on(`mode.change`,t=>{e.emit(`modeChange`,t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),e.on(`helpers.visible`,t=>{e.emit(`helpersVisibleChange`,t.object.visible)}),e.on(`network.resource`,t=>{e.emit(`network`,t.source,t.requestType,t.requestState,t.detail)})}function AC(){if(typeof window<`u`){let e=document.createElement(`video`);e.loop=!0,e.autoplay=!0,e.playsInline=!0,e.muted=!0,e.crossOrigin=``;let t=()=>{document.removeEventListener(`touchstart`,t,!1),document.removeEventListener(`mousedown`,t,!1),e.muted=!1};return document.addEventListener(`touchstart`,t,!1),document.addEventListener(`mousedown`,t,!1),e}else return{}}function jC(){let e=new l.Group;e.name=`internalLights`;{let t=new l.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new l.Vector3(0,1,0)),e.add(t)}{let t=new l.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new l.Vector3(-1,-1,-1)),e.add(t)}{let t=new l.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new l.Vector3(1,1,1)),e.add(t)}{let t=new l.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function MC(e){var t,n;let r={},i=e.split(/(\;|\,)/);for(let e of i){let i=e.split(`=`),a=(t=i[0])==null?void 0:t.trim(),o=(n=i[1])==null?void 0:n.trim();a&&o&&(r[a]=o)}return r}function NC(){var e;if(typeof document<`u`){let t=document.getElementsByTagName(`meta`);for(let n=0;n<t.length;n++){let r=t[n];if(r.getAttribute(`name`)===`viewport`){let t=MC((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var PC=1e3,FC=90,IC=e=>e.replace(`//vrlab-public.ljcdn.com/`,`//vr-public.realsee-cdn.cn/`).replace(`//vrlab-image4.ljcdn.com/`,`//vr-image-4.realsee-cdn.cn/`).replace(`//vrlab-image3.ljcdn.com/`,`//vr-image-3.realsee-cdn.cn/`).replace(`//vrlab-image2.ljcdn.com/`,`//vr-image-2.realsee-cdn.cn/`).replace(`//vrlab-image1.ljcdn.com/`,`//vr-image-1.realsee-cdn.cn/`),LC=new l.Sphere,RC=new l.Box3,zC=new l.Vector4,BC=new l.Vector4,VC=new l.Color,HC=new l.Vector2,UC=new WeakMap,WC=Py([jy(null)]),GC={},KC=class e extends Bt{static get version(){return`1.0.0-alpha.4`}static get dracoPath(){return Vu.decoderPath}static set dracoPath(e){Vu.setDecoderPath(e)}static get ktx2Path(){return Yu.transcoderPath}static set ktx2Path(e){Yu.setTranscoderPath(e)}static get useNativeImageBitmap(){return Wc()}static set useNativeImageBitmap(e){Uc(e)}constructor(e={}){var t,n,r,i,a,o,s,c,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Ft(),GC[this.fiveId]=this,this.currentUpdateArgs={time:G(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!0,this.onlyRenderIfNeeds=(t=e.onlyRenderIfNeeds)==null?!0:t,this.imageOptions=Object.assign({},(n=e.imageOptions)==null?{}:n),this.textureOptions=Object.assign({},(r=e.textureOptions)==null?{}:r),this.poweredByRealsee=(i=e.poweredByRealsee)==null?!0:i,this.backgroundColor=new l.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview)},this.fps={testCount:0,testTime:G()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?PC:s,this.enableWheel=(c=e.enableWheel)==null?!0:c,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Ub&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Ub({outputType:e.enableHDR?l.HalfFloatType:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=NC();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new l.RenderTarget(1,1,{colorSpace:(d=(u=this.renderer)==null?void 0:u.outputColorSpace)==null?l.SRGBColorSpace:d,generateMipmaps:!1}),this.renderer&&Ms(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Mi(FC),this.scene=new Yb,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new l.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(f=e.requestProxy)==null?IC:f,this.networkSubscribe=new Ws,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,$(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new l.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),UC.set(this,WC),this.modelScene=new Sv({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(WC,{forceReplaceImmediately:!0});Z(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new l.VideoTexture(e.videoInstance||AC());let m=jC();this.scene.add(m),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=Bc.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,h,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,h,!1)},this.loadWorkTask=this.prepare(),this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}kC(this),this.fiveRenderer=new Bb({outputType:e.enableHDR?l.HalfFloatType:void 0}),this.adaptiveLuminancePass=new bb,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Sb(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new Mr,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([fc().catch(K)]).then(K)}dispose(){var e;if(this.destroyed===!0)return;delete GC[this.fiveId],this.emit(`dispose`),this.destroyed=!0,this.pause(),this.stopAnimationLoop&&(this.stopAnimationLoop(),this.stopAnimationLoop=void 0),this.off(),this.networkSubscribe.off(),this.controller&&(this.controller.destroy(),this.controller=void 0);let t=this.getElement();t&&t.parentNode&&t.parentNode.removeChild(t);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((e=n.pano0)==null?void 0:e.map)&&n.pano1.map.dispose(),n.reset(`pano0`,`pano1`),this.modelScene.dispose(),UC.set(this,WC),this.renderer&&(!(this.renderer instanceof Ub)||this.renderer.isInitialized)&&this.renderer.render(new l.Scene,new l.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Ub&&this.renderer.dispose()}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,$(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,$s(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,$s(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,$s(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,$s(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,$s(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),this.currentMode===`Panorama`&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof Ub)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,i,a,o,s;if(!this.renderer)return;let c=this.renderer.domElement.parentNode,{width:l=(n=c==null?void 0:c.offsetWidth)==null?512:n,height:u=(r=c==null?void 0:c.offsetHeight)==null?512:r}=e;if(l=Math.max(1,l),u=Math.max(1,u),!t){let e=NC(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(l,u)*t,n=Math.min((s=(o=(a=this.renderer.backend.device)==null?void 0:a.limits)==null?void 0:o.maxTextureDimension2D)==null?8192:s,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(l,u),this.needsRender=!0;let d=G(),f=d-this.currentUpdateArgs.time,p=this.currentUpdateArgs.args;this.updateTime(d,f,...p)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return UC.get(this)||WC}get work(){return this.works[0]}get observers(){return this.work.observers}get models(){return this.modelScene.models}get model(){return this.modelScene.models[0]}load(e,t,n,r=!0){if(!this.renderer)throw Error(`renderer is not initialized`);let i=this.loadWorkTask.then(()=>xx(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,c,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===WC&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof Ay?v.push(e):typeof e!=`string`&&`work`in e?v.push(jy(e.work,e)):v.push(jy(e));else t instanceof Ay?v.push(t):v.push(jy(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=Py(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===WC&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(c=x.offset)==null?void 0:c.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new l.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;w===`Panorama`&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,$(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=EC[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=EC[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=$(`mode.change`,{prevMode:b,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.state.workCode=this.pano.workCode,this.state.panoIndex=this.pano.panoIndex,this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};UC.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),Dx(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),UC.set(this,WC),this.modelScene.setModels(WC,{forceReplaceImmediately:!0}),this.renderer&&this.modelScene.update(this.renderer,this.camera),this.needsRender=!0,this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.camera.setFromPose({distance:0,fov:FC,longitude:0,latitude:0,offset:new l.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if(t===e.Mode.Panorama&&!this.works.getObserver(m)){let e=Error(`PanoId ${Wv(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model?!Kv(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(Kv(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=EC[t].initAnimationEndState(r),o=$(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=$(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=Bc.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),Bc.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return Dd(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=G(),c=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new l.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?c:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&this.controller instanceof EC.Panorama&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=this.renderer.getClearColor(VC),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera||this.backgroundAlpha<1?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=c,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);let te=yield this.renderer.readRenderTargetPixelsAsync(C,0,0,M,N),F=M*4;if(te.length===P)b.set(te);else{let e=Math.ceil(F/256)*256;for(let t=0;t<N;t++){let n=t*e;b.set(te.subarray(n,n+F),t*F)}}if(!_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b})}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=t.getClearColor(VC),c=t.getClearAlpha(),l=t.getViewport(zC),u=t.getScissor(BC),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(HC),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera||this.backgroundAlpha<1?null:v;let y=!0;this.controller&&this.controller.render()&&(y=!1),y&&this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender),this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&Bc.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&Yu.detectSupport(this.renderer),this.syncingState=this.syncState(e,t),this.controller&&this.controller.updateTime(e,t,...n),this.renderer&&(this.camera.pixelRatio=this.renderer.getPixelRatio(),this.getSize(this.camera.resolution),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height),this.camera.controllerMode=this.currentMode,this.camera.updateTime(e),this.renderer){let e=this.modelScene.loaded,t=this.modelScene.refined;this.modelScene.update(this.renderer,this.camera),e===!1&&this.modelScene.loaded===!0&&(this.controller&&this.controller.updateModel(this.modelScene),Bc.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&Bc.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){RC.makeEmpty(),RC.expandByObject(this.modelScene.boundingMesh);let t=RC.getBoundingSphere(LC),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=H(n/500,.001,.1),i=H(n,800);this.camera.near!==r&&(this.camera.near=r),this.camera.far!==i&&(this.camera.far=i),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0||this.renderer instanceof Ub&&!this.renderer.isInitialized)return;let r=$(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,$(`render`,{needsRender:i})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof Ub&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=K){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],i=G();return Promise.all(r.map(e=>{let t=Wv({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},Zs(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):kc(i,r);return K_(this.fiveId,n.work).preload(a)})).then(()=>{let e=G()-i;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new l.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new l.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new l.Vector2(o,s)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,i,a,o,s,c,u,d,f,p;e=Zs(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof l.Vector3)&&(e.offset=new l.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof l.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),r=EC[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(c=e.fov)==null?this.state.fov:c,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,$(`state.set`,{userAction:n,state:x})),Ex(this.state,x)||(Tx(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(G(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(G(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state))}syncState(t,n,r=!1){let i=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof EC.Model){if(bx(this.camera.pose.offset,this.state.offset)){let e={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset};return this.controller.moveToPosition(this.state.offset,Object.assign(Object.assign({},e),{duration:r?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!Kv(e,this.pano)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`){let t={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.controller.moveToPano(e,t,!1),!0}}if(this.controller instanceof EC.Floorplan||this.controller instanceof EC.Topview||this.controller instanceof EC.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:sb(this.camera.pose.fov,this.state.fov,1),i=Math.abs(this.camera.pose.distance-this.state.distance),a=i>e*15?i/15:.2,o=r?this.state.distance:sb(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),c=s>e*15?s/15:e,u=r?new l.Vector3().copy(this.state.offset):cb(this.camera.pose.offset,this.state.offset,c),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:lb({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(vx(n,this.camera.pose.fov)||bx(u,this.camera.pose.offset)||vx(o,this.camera.pose.distance)||vx(d,this.camera.pose.longitude,Math.PI*2)||vx(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:sb(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:lb({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new l.Vector3().copy(this.state.offset);if(vx(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),bx(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),vx(n,this.camera.pose.longitude,Math.PI*2)||vx(i,this.camera.pose.latitude)||vx(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof EC.Panorama&&t.tile===!0?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(K)}requestFullscreen(){var e;if(!wx)return;let t=(e=this.getElement())==null?void 0:e.parentNode;t&&`requestFullscreen`in t&&typeof document<`u`&&document.fullscreenElement===null&&t.requestFullscreen()}exitFullscreen(){typeof document<`u`&&document.fullscreenElement&&`exitFullscreen`in document&&document.exitFullscreen()}throwError(e){this.hasListener(`error`)?this.emit(`error`,e):console.error(e)}bindModel(e){let t=()=>{Bc.shared.add(()=>{this.emit(`model.load`,$(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,$(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,$(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,$(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,$(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,$(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new Ys({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=hy(e,r);return t instanceof Error?Promise.reject(t):t})}});q_(this.fiveId,e,i)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(e,t){if(!this.renderer)throw Error(`renderer is not initialized.`);let n=EC[e];this.currentMode=e;let r=new n(t);for(let e of OC)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=EC[e].initAnimationEndState(t),r=t.initial.userAction;Ex(this.state,n)||(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,$(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return r.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,$(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),r.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Ex(this.state,n)&&(Tx(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,$(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),r.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),r.on(`error`,e=>this.throwError(e)),r}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let t=new l.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new l.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().invert();return n.applyQuaternion(r),{theta:Math.atan2(n.x,-n.z),phi:-Math.asin(n.y),lookAtVector:n}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}};KC.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:l,constructor:KC,instances:GC}}),exports.AdaptiveLuminancePass=bb,exports.AnimationFrameLoop=Bc,exports.BoundingMesh=bv,exports.Camera=Mi,exports.EffectComposer=Iy,exports.EyeDomeLightingPass=Sb,exports.Fetcher=Ys,exports.Five=KC,exports.FivePass=Ry,exports.FiveRenderer=Bb,exports.FlowingFireworks3DPass=Mb,exports.FlowingLight2DPass=Eb,exports.FlowingLight3DPass=wb,exports.FullScreenQuad=Ly,exports.GaussianBlurPass=Cb,exports.Histogram=ib,exports.InternalWebGPURenderer=Ub,exports.Model=dv,exports.ModelScene=Sv,exports.Motion=J,exports.NetworkSubscribe=Ws,exports.PBMGSObject=Mt,exports.PBMGaussianSplattingObject=Mt,exports.PBMGaussianSplattingNodeMaterial=dr,exports.PBMGaussianSplattingRenderMesh=Mr,exports.PBMGroup=wt,exports.PBMMesh=kt,exports.PBMMeshBasicMaterial=Nr,exports.PBMMeshBasicNodeMaterial=Cs,exports.PBMMeshPanoOnlyMaterial=Pr,exports.PBMMeshPanoOnlyNodeMaterial=ks,exports.PBMMeshPhongMaterial=Fr,exports.PBMMeshPhongNodeMaterial=Ts,exports.PBMMeshPhysicalMaterial=Ir,exports.PBMMeshPhysicalNodeMaterial=Ds,exports.PBMPanoFilter=Ht,exports.PBMPointCloud=on,exports.PBMSkinnedMesh=At,exports.PBMUpdateable=Vt,exports.PROXY_CONTROLLER_EVENT_NAMES=OC,exports.PanoCircleMesh=rx,exports.PanoCircleMeshCustom=gx,exports.PanoCircleMeshSolid=dx,exports.Parameter=X,exports.Scene=Yb,exports.Subscribe=Bt,exports.TextureLoader=Qc,exports.Tile=Rf,exports.Tile3D=W_,exports.Tile3DModel=W_,exports.TileCache=Sm,exports.TileNode=dm,exports.TileRequestScheduler=ym,exports.Tileset=Om,exports.Trajectory=hm,exports.TrajectoryNode=gm,exports.Work=Ay,exports.WorkResolvedObserver=Ny,exports.controllersDefaultInitArgs=DC,exports.coordinatesToVector=yi,exports.createDebugBoundingMesh=Nf,exports.createWorks=Py,exports.defaultImageURLTransform=kc,exports.draco=Vu,exports.getViewportScale=NC,exports.headingToLongitude=Si,exports.imageSupport=fc,exports.isBoundingVolume=Of,exports.isPanoId=qv,exports.loadAt3d=zl,exports.loadDome=Ul,exports.loadDomez=Xl,exports.loadGltf=sf,exports.loadPbm=_l,exports.loadPly=eu,exports.longitudeToHeading=xi,exports.makeBoundingVolume=kf,exports.panoEqual=Kv,exports.panoParse=Gv,exports.panoStringify=Wv,exports.parseWork=jy,exports.registerPBMMaterials=Ms,exports.vectorToCoordinates=bi,exports.workToJson=Dv;