@roomle/web-sdk 2.64.0 → 2.64.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{banana-for-scale-f7852385.js → banana-for-scale-0f92123a.js} +2 -2
- package/lib/{banana-for-scale-f7852385.js.map → banana-for-scale-0f92123a.js.map} +1 -1
- package/lib/{banana-for-scale-381d6064.nomodule.js → banana-for-scale-13824fc9.nomodule.js} +2 -2
- package/lib/{banana-for-scale-381d6064.nomodule.js.map → banana-for-scale-13824fc9.nomodule.js.map} +1 -1
- package/lib/{component-dimensioning-1f3f5178.nomodule.js → component-dimensioning-33a84630.nomodule.js} +2 -2
- package/lib/component-dimensioning-33a84630.nomodule.js.map +1 -0
- package/lib/{component-dimensioning-c6c9d3b5.js → component-dimensioning-d5e9d122.js} +2 -2
- package/lib/component-dimensioning-d5e9d122.js.map +1 -0
- package/lib/{component-raycast-helper-a2f853c7.js → component-raycast-helper-b0715d24.js} +2 -2
- package/lib/component-raycast-helper-b0715d24.js.map +1 -0
- package/lib/{component-raycast-helper-7a555961.nomodule.js → component-raycast-helper-e37add25.nomodule.js} +2 -2
- package/lib/component-raycast-helper-e37add25.nomodule.js.map +1 -0
- package/lib/{configurator-70c9acbd.nomodule.js → configurator-7561545c.nomodule.js} +2 -2
- package/lib/configurator-7561545c.nomodule.js.map +1 -0
- package/lib/{configurator-2275a6e4.js → configurator-b13c23c5.js} +2 -2
- package/lib/configurator-b13c23c5.js.map +1 -0
- package/lib/configurator-main-d322b9af.js +2 -0
- package/lib/configurator-main-d322b9af.js.map +1 -0
- package/lib/configurator-main.nomodule.js +1 -1
- package/lib/{continuous-drawing-helper-6cd36367.nomodule.js → continuous-drawing-helper-21108161.nomodule.js} +2 -2
- package/lib/continuous-drawing-helper-21108161.nomodule.js.map +1 -0
- package/lib/{continuous-drawing-helper-f474e3dd.js → continuous-drawing-helper-485939ce.js} +2 -2
- package/lib/continuous-drawing-helper-485939ce.js.map +1 -0
- package/lib/{default-light-setting-48c85a32.js → default-light-setting-161b9985.js} +2 -2
- package/lib/default-light-setting-161b9985.js.map +1 -0
- package/lib/{default-light-setting-a8790464.nomodule.js → default-light-setting-44dfb3dc.nomodule.js} +2 -2
- package/lib/default-light-setting-44dfb3dc.nomodule.js.map +1 -0
- package/lib/definitions/common-core/src/webgl/renderer/gbuffer-render-target.d.ts +1 -13
- package/lib/definitions/common-core/src/webgl/renderer/render-cache.d.ts +1 -20
- package/lib/definitions/common-core/src/webgl/renderer/scene-renderer.d.ts +2 -0
- package/lib/definitions/common-core/src/webgl/renderer/screen-space-shadow-map.d.ts +9 -10
- package/lib/{dimensioning-helper-2281ee76.js → dimensioning-helper-52eba523.js} +2 -2
- package/lib/{dimensioning-helper-2281ee76.js.map → dimensioning-helper-52eba523.js.map} +1 -1
- package/lib/{dimensioning-helper-517963c4.nomodule.js → dimensioning-helper-a4cfa639.nomodule.js} +2 -2
- package/lib/{dimensioning-helper-517963c4.nomodule.js.map → dimensioning-helper-a4cfa639.nomodule.js.map} +1 -1
- package/lib/{glb-viewer-9662e19f.js → glb-viewer-101830b9.js} +2 -2
- package/lib/{glb-viewer-9662e19f.js.map → glb-viewer-101830b9.js.map} +1 -1
- package/lib/{glb-viewer-19e7bed3.nomodule.js → glb-viewer-7a45fbbb.nomodule.js} +2 -2
- package/lib/{glb-viewer-19e7bed3.nomodule.js.map → glb-viewer-7a45fbbb.nomodule.js.map} +1 -1
- package/lib/glb-viewer-main-dd75e952.js +2 -0
- package/lib/glb-viewer-main-dd75e952.js.map +1 -0
- package/lib/glb-viewer-main.nomodule.js +1 -1
- package/lib/legacy/{banana-for-scale-57d86616.legacy.js → banana-for-scale-4cceef06.legacy.js} +2 -2
- package/lib/legacy/{banana-for-scale-57d86616.legacy.js.map → banana-for-scale-4cceef06.legacy.js.map} +1 -1
- package/lib/legacy/{component-dimensioning-0a99aa7e.legacy.js → component-dimensioning-9cde7efe.legacy.js} +2 -2
- package/lib/legacy/component-dimensioning-9cde7efe.legacy.js.map +1 -0
- package/lib/legacy/{component-raycast-helper-862a6ca5.legacy.js → component-raycast-helper-82d47273.legacy.js} +2 -2
- package/lib/legacy/component-raycast-helper-82d47273.legacy.js.map +1 -0
- package/lib/legacy/{configurator-b7377779.legacy.js → configurator-9c7bcb82.legacy.js} +2 -2
- package/lib/legacy/configurator-9c7bcb82.legacy.js.map +1 -0
- package/lib/legacy/configurator-main.legacy.js +1 -1
- package/lib/legacy/{continuous-drawing-helper-57fd5629.legacy.js → continuous-drawing-helper-81709d5d.legacy.js} +2 -2
- package/lib/legacy/continuous-drawing-helper-81709d5d.legacy.js.map +1 -0
- package/lib/legacy/{default-light-setting-6c24385e.legacy.js → default-light-setting-06b7c955.legacy.js} +2 -2
- package/lib/legacy/default-light-setting-06b7c955.legacy.js.map +1 -0
- package/lib/legacy/{dimensioning-helper-8e379808.legacy.js → dimensioning-helper-d8719bb9.legacy.js} +2 -2
- package/lib/legacy/{dimensioning-helper-8e379808.legacy.js.map → dimensioning-helper-d8719bb9.legacy.js.map} +1 -1
- package/lib/legacy/{glb-viewer-4dd2ed8b.legacy.js → glb-viewer-f34e4155.legacy.js} +2 -2
- package/lib/legacy/{glb-viewer-4dd2ed8b.legacy.js.map → glb-viewer-f34e4155.legacy.js.map} +1 -1
- package/lib/legacy/glb-viewer-main.legacy.js +1 -1
- package/lib/legacy/{material-viewer-1e8ce900.legacy.js → material-viewer-18b4bae8.legacy.js} +2 -2
- package/lib/legacy/material-viewer-18b4bae8.legacy.js.map +1 -0
- package/lib/legacy/material-viewer-main.legacy.js +1 -1
- package/lib/legacy/{planner-bce26950.legacy.js → planner-cb24d97f.legacy.js} +2 -2
- package/lib/legacy/{planner-bce26950.legacy.js.map → planner-cb24d97f.legacy.js.map} +1 -1
- package/lib/legacy/planner-main.legacy.js +1 -1
- package/lib/legacy/{roomle-configurator-a69d9037.legacy.js → roomle-configurator-9bcce27a.legacy.js} +2 -2
- package/lib/legacy/roomle-configurator-9bcce27a.legacy.js.map +1 -0
- package/lib/legacy/{roomle-dependency-injection-7e8c3939.legacy.js → roomle-dependency-injection-499e2afe.legacy.js} +3 -3
- package/lib/legacy/{roomle-dependency-injection-7e8c3939.legacy.js.map → roomle-dependency-injection-499e2afe.legacy.js.map} +1 -1
- package/lib/legacy/roomle-sdk.legacy.js +1 -1
- package/lib/legacy/{scene-manager-4ce0936d.legacy.js → scene-manager-6990a483.legacy.js} +2 -2
- package/lib/legacy/{scene-manager-4ce0936d.legacy.js.map → scene-manager-6990a483.legacy.js.map} +1 -1
- package/lib/legacy/{script-loader-0299c701.legacy.js → script-loader-c9c8cd44.legacy.js} +2 -2
- package/lib/legacy/script-loader-c9c8cd44.legacy.js.map +1 -0
- package/lib/legacy/{stats-helper-e9d97596.legacy.js → stats-helper-90581f37.legacy.js} +2 -2
- package/lib/legacy/stats-helper-90581f37.legacy.js.map +1 -0
- package/lib/legacy/{tools-core-95abe8b2.legacy.js → tools-core-da3a4e03.legacy.js} +2 -2
- package/lib/legacy/tools-core-da3a4e03.legacy.js.map +1 -0
- package/lib/{material-viewer-c0200255.nomodule.js → material-viewer-43a81a41.nomodule.js} +2 -2
- package/lib/material-viewer-43a81a41.nomodule.js.map +1 -0
- package/lib/{material-viewer-0d23a214.js → material-viewer-edcb43b5.js} +2 -2
- package/lib/material-viewer-edcb43b5.js.map +1 -0
- package/lib/material-viewer-main-f58cb168.js +2 -0
- package/lib/material-viewer-main-f58cb168.js.map +1 -0
- package/lib/material-viewer-main.nomodule.js +1 -1
- package/lib/{planner-7f6f3c30.js → planner-6bf4a4da.js} +2 -2
- package/lib/{planner-7f6f3c30.js.map → planner-6bf4a4da.js.map} +1 -1
- package/lib/{planner-6318245a.nomodule.js → planner-c40a6507.nomodule.js} +2 -2
- package/lib/{planner-6318245a.nomodule.js.map → planner-c40a6507.nomodule.js.map} +1 -1
- package/lib/planner-main-dd92b8bc.js +2 -0
- package/lib/planner-main-dd92b8bc.js.map +1 -0
- package/lib/planner-main.nomodule.js +1 -1
- package/lib/{roomle-configurator-c692dc25.nomodule.js → roomle-configurator-1154f586.nomodule.js} +2 -2
- package/lib/roomle-configurator-1154f586.nomodule.js.map +1 -0
- package/lib/{roomle-configurator-0ab58fdb.js → roomle-configurator-95af1561.js} +2 -2
- package/lib/roomle-configurator-95af1561.js.map +1 -0
- package/lib/{roomle-dependency-injection-d9e85799.nomodule.js → roomle-dependency-injection-060afa00.nomodule.js} +3 -3
- package/lib/{roomle-dependency-injection-d9e85799.nomodule.js.map → roomle-dependency-injection-060afa00.nomodule.js.map} +1 -1
- package/lib/{roomle-dependency-injection-20969d78.js → roomle-dependency-injection-0cc14c18.js} +3 -3
- package/lib/{roomle-dependency-injection-20969d78.js.map → roomle-dependency-injection-0cc14c18.js.map} +1 -1
- package/lib/{roomle-sdk-9fc48465.js → roomle-sdk-3b717a78.js} +2 -2
- package/lib/roomle-sdk-3b717a78.js.map +1 -0
- package/lib/roomle-sdk.nomodule.js +1 -1
- package/lib/{scene-manager-19e7c190.js → scene-manager-0f5dd0fa.js} +2 -2
- package/lib/{scene-manager-19e7c190.js.map → scene-manager-0f5dd0fa.js.map} +1 -1
- package/lib/{scene-manager-6d47a2f1.nomodule.js → scene-manager-3a514c10.nomodule.js} +2 -2
- package/lib/{scene-manager-6d47a2f1.nomodule.js.map → scene-manager-3a514c10.nomodule.js.map} +1 -1
- package/lib/{script-loader-8a080585.js → script-loader-0084221c.js} +2 -2
- package/lib/script-loader-0084221c.js.map +1 -0
- package/lib/{script-loader-e2790dda.nomodule.js → script-loader-3a6923e6.nomodule.js} +2 -2
- package/lib/script-loader-3a6923e6.nomodule.js.map +1 -0
- package/lib/{stats-helper-d85d87df.js → stats-helper-64bb8bcc.js} +2 -2
- package/lib/stats-helper-64bb8bcc.js.map +1 -0
- package/lib/{stats-helper-e4b510db.nomodule.js → stats-helper-a51e47f8.nomodule.js} +2 -2
- package/lib/stats-helper-a51e47f8.nomodule.js.map +1 -0
- package/lib/{tools-core-227b7723.js → tools-core-0d5266d1.js} +2 -2
- package/lib/tools-core-0d5266d1.js.map +1 -0
- package/lib/{tools-core-c0e0eda8.nomodule.js → tools-core-e629a47f.nomodule.js} +2 -2
- package/lib/tools-core-e629a47f.nomodule.js.map +1 -0
- package/package.json +2 -2
- package/lib/component-dimensioning-1f3f5178.nomodule.js.map +0 -1
- package/lib/component-dimensioning-c6c9d3b5.js.map +0 -1
- package/lib/component-raycast-helper-7a555961.nomodule.js.map +0 -1
- package/lib/component-raycast-helper-a2f853c7.js.map +0 -1
- package/lib/configurator-2275a6e4.js.map +0 -1
- package/lib/configurator-70c9acbd.nomodule.js.map +0 -1
- package/lib/configurator-main-b0c6d90b.js +0 -2
- package/lib/configurator-main-b0c6d90b.js.map +0 -1
- package/lib/continuous-drawing-helper-6cd36367.nomodule.js.map +0 -1
- package/lib/continuous-drawing-helper-f474e3dd.js.map +0 -1
- package/lib/default-light-setting-48c85a32.js.map +0 -1
- package/lib/default-light-setting-a8790464.nomodule.js.map +0 -1
- package/lib/glb-viewer-main-3fbdc933.js +0 -2
- package/lib/glb-viewer-main-3fbdc933.js.map +0 -1
- package/lib/legacy/component-dimensioning-0a99aa7e.legacy.js.map +0 -1
- package/lib/legacy/component-raycast-helper-862a6ca5.legacy.js.map +0 -1
- package/lib/legacy/configurator-b7377779.legacy.js.map +0 -1
- package/lib/legacy/continuous-drawing-helper-57fd5629.legacy.js.map +0 -1
- package/lib/legacy/default-light-setting-6c24385e.legacy.js.map +0 -1
- package/lib/legacy/material-viewer-1e8ce900.legacy.js.map +0 -1
- package/lib/legacy/roomle-configurator-a69d9037.legacy.js.map +0 -1
- package/lib/legacy/script-loader-0299c701.legacy.js.map +0 -1
- package/lib/legacy/stats-helper-e9d97596.legacy.js.map +0 -1
- package/lib/legacy/tools-core-95abe8b2.legacy.js.map +0 -1
- package/lib/material-viewer-0d23a214.js.map +0 -1
- package/lib/material-viewer-c0200255.nomodule.js.map +0 -1
- package/lib/material-viewer-main-73c9ec6c.js +0 -2
- package/lib/material-viewer-main-73c9ec6c.js.map +0 -1
- package/lib/planner-main-0b1e2240.js +0 -2
- package/lib/planner-main-0b1e2240.js.map +0 -1
- package/lib/roomle-configurator-0ab58fdb.js.map +0 -1
- package/lib/roomle-configurator-c692dc25.nomodule.js.map +0 -1
- package/lib/roomle-sdk-9fc48465.js.map +0 -1
- package/lib/script-loader-8a080585.js.map +0 -1
- package/lib/script-loader-e2790dda.nomodule.js.map +0 -1
- package/lib/stats-helper-d85d87df.js.map +0 -1
- package/lib/stats-helper-e4b510db.nomodule.js.map +0 -1
- package/lib/tools-core-227b7723.js.map +0 -1
- package/lib/tools-core-c0e0eda8.nomodule.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
System.register(["./main-thread-to-worker-f0c51758.nomodule.js"],(function(e,t){var n,r,i,s,a,o,l,h,d,c,u,p,m,g,f,_,v,w,b,y,x,C,S,M,T,P,A,E,R,I,D,O,L,k,U,F,N,B,j,G,H,z,V,W,K,q,X,Q,Y,Z,J,$,ee,te,ne,re,ie,se,ae,oe,le,he,de,ce,ue,pe,me,ge,fe,_e,ve,we,be,ye,xe,Ce,Se,Me,Te,Pe,Ae,Ee,Re,Ie,De,Oe,Le,ke,Ue,Fe,Ne,Be,je,Ge,He,ze,Ve,We,Ke,qe,Xe,Qe,Ye,Ze,Je,$e,et,tt,nt,rt,it,st,at,ot,lt,ht,dt,ct,ut,pt,mt,gt,ft,_t,vt,wt,bt,yt,xt,Ct,St,Mt,Tt,Pt,At,Et,Rt,It,Dt,Ot,Lt,kt,Ut,Ft,Nt,Bt,jt,Gt,Ht,zt;return{setters:[function(e){n=e.g,r=e.A,i=e.D,s=e.V,a=e.a,o=e.R,l=e.S,h=e.C,d=e.M,c=e.B,u=e.b,p=e.T,m=e.c,g=e.d,f=e.L,_=e.e,v=e.F,w=e.f,b=e.P,y=e.h,x=e.i,C=e.j,S=e.k,M=e.Q,T=e.I,P=e.l,A=e.O,E=e.m,R=e.n,I=e.o,D=e.p,O=e.q,L=e.r,k=e.s,U=e.t,F=e.u,N=e.v,B=e.w,j=e.x,G=e.y,H=e.z,z=e.E,V=e.G,W=e.H,K=e.J,q=e.K,X=e.N,Q=e.U,Y=e.W,Z=e.X,J=e.Y,$=e.Z,ee=e._,te=e.$,ne=e.a0,re=e.a1,ie=e.a2,se=e.a3,ae=e.a4,oe=e.a5,le=e.a6,he=e.a7,de=e.a8,ce=e.a9,ue=e.aa,pe=e.ab,me=e.ac,ge=e.ad,fe=e.ae,_e=e.af,ve=e.ag,we=e.ah,be=e.ai,ye=e.aj,xe=e.ak,Ce=e.al,Se=e.am,Me=e.an,Te=e.ao,Pe=e.ap,Ae=e.aq,Ee=e.ar,Re=e.as,Ie=e.at,De=e.au,Oe=e.av,Le=e.aw,ke=e.ax,Ue=e.ay,Fe=e.az,Ne=e.aA,Be=e.aB,je=e.aC,Ge=e.aD,He=e.aE,ze=e.aF,Ve=e.aG,We=e.aH,Ke=e.aI,qe=e.aJ,Xe=e.aK,Qe=e.aL,Ye=e.aM,Ze=e.aN,Je=e.aO,$e=e.aP,et=e.aQ,tt=e.aR,nt=e.aS,rt=e.aT,it=e.aU,st=e.aV,at=e.aW,ot=e.aX,lt=e.aY,ht=e.aZ,dt=e.a_,ct=e.a$,ut=e.b0,pt=e.b1,mt=e.b2,gt=e.b3,ft=e.b4,_t=e.b5,vt=e.b6,wt=e.b7,bt=e.b8,yt=e.b9,xt=e.ba,Ct=e.bb,St=e.bc,Mt=e.bd,Tt=e.be,Pt=e.bf,At=e.bg,Et=e.bh,Rt=e.bi,It=e.bj,Dt=e.bk,Ot=e.bl,Lt=e.bm,kt=e.bn,Ut=e.bo,Ft=e.bp,Nt=e.bq,Bt=e.br,jt=e.bs,Gt=e.bt,Ht=e.bu,zt=e.bv}],execute:function(){e({_:tn,i:rn,r:va});class Vt{constructor(){this._context=new Map,this._lookups=new Map,this._singletons=new Map}getContext(e){if(this._context.has(e)){const t=this._context.get(e);return this._context.set(e,t+1),e+t}return this._context.set(e,1),e+0}addDependencyInjectionAssignments(e){e.forEach(e=>{this._lookups.set(e.className,e)})}lookup(e,t){if(!this._lookups.has(e))return null;const n=this._lookups.get(e);if(1===n.type&&void 0===t){const t="Dependency "+e+" has definition context but no context was defined!";return console.trace(t),console.error(t),null}let r=t&&1===n.type?t:"global";if(r+="_"+e,2===n.type)return new n.classDefinition;if(this._singletons.has(r))return this._singletons.get(r);const i=new n.classDefinition(t);return this._singletons.set(r,i),i}cleanUp(e){if(e){let t=[];this._singletons.forEach((n,r)=>{r.startsWith(e)&&t.push(r)}),t.forEach(e=>{this._singletons.delete(e)})}else this._singletons.clear(),this._singletons=new Map}}class Wt{constructor(e,t,n){this.className=e,this.classDefinition=t,this.type=void 0===n?0:n}}e("D",Wt);const Kt={JPG:".jpg",JPEG:".jpeg",PNG:".png",GIF:".gif"};class qt{_base64toBlob(e,t){t=t||"";const n=atob(e),r=n.length,i=Math.ceil(r/1024),s=new Array(i);for(let e=0;e<i;++e){let t=1024*e,i=Math.min(t+1024,r);const a=new Array(i-t);for(let e=t,r=0;e<i;++r,++e)a[r]=n[e].charCodeAt(0);s[e]=new Uint8Array(a)}return new Blob(s,{type:t})}_createFormData(e,t,n,r){const i=new FormData;-1!==e.indexOf(",")&&(e=e.substr(e.indexOf(",")+1));const s=-1===Object.keys(Kt).map(e=>Kt[e]).indexOf(n)?"application":"image",a=this._base64toBlob(e,s+"/"+n.substr(1));return i.append(r,a,t+n),i}create(e,t,n,r){return this._createFormData(e,t,n,r)}}const Xt=e("l",{SOFA:"sofa",SHELF:"shelf",SHELF_FRONT:"shelf_front",BAKED:"baked",CAMERA:"camera",EQUAL:"equal"});class Qt{static createDynamicLightSettingSource(e,t){let r={};if(e)r.url=e;else if(t)switch(t){case Xt.SHELF:r.url=n()+"static/shelf-2975dd3f2fa9c763.json";break;case Xt.SHELF_FRONT:r.url=n()+"static/shelf_front-8c9566a4512f0de8.json";break;case Xt.SOFA:r.url=n()+"static/sofa-997b116bc5f2e92e.json";break;case Xt.BAKED:r.url=n()+"static/baked-6485a2b1daeb69e8.json";break;case Xt.CAMERA:r.url=n()+"static/camera-05824b47cdb951e4.json";break;case Xt.EQUAL:r.url=n()+"static/equal-319f6b83c827913f.json";break;default:r.url=n()+"static/camera-05824b47cdb951e4.json"}else r=null;return r}parse(e){let t=JSON.parse(e);return t.lights?this.load(t):[]}load(e){let t=[];return e.lights?(e.lights.forEach(e=>{let n;switch(e.type){case"ambient":n=this._parseAmbientLight(e);break;case"rectarea":n=this._parseRectAreaLight(e);break;case"spot":n=this._parseSpotLight(e);break;case"directional":n=this._parseDirectionalLight(e)}n&&t.push(n)}),t):[]}_parseAmbientLight(e){let t=new r;return this._parseCommon(t,e),t}_parseRectAreaLight(e){let{intensity:t,castShadow:n,target:r,width:l,height:h}=e,d=null;if(n&&Qt.rectAreaLightReplacement){const n=new i;this._parseCommon(n,e),d=n,n.castShadow=!0,n.shadow.camera.near=.1,n.shadow.camera.far=100,n.shadow.mapSize=new s(1024,1024),n.shadow.bias=-5e-5,n.shadow.normalBias=.01,n.intensity=t?t/100:1,n.lookAt(r?new a(r.x,r.y,r.z):new a(0,0,0))}else{const n=new o;this._parseCommon(n,e),d=n,n.width=l||.8,n.height=h||.8,n.castShadow=!1,n.matrixAutoUpdate=!0,n.intensity=(t||240)/((l||.8)*(h||.8)),n.lookAt(r?new a(r.x,r.y,r.z):new a(0,0,0)),Qt.rectAreaLightLoadingListener&&Qt.rectAreaLightLoadingListener(n)}return d}_parseSpotLight(e){let t=new l;this._parseCommon(t,e);let{angle:n,penumbra:r,target:i,castShadow:o}=e;return t.angle=(n||100)*Math.PI/180,t.penumbra=r||.5,t.lookAt(i?new a(i.x,i.y,i.z):new a(0,0,0)),t.shadow.camera.near=.1,t.shadow.camera.far=10,t.shadow.mapSize=new s(1024,1024),t.castShadow=o||!1,t}_parseDirectionalLight(e){let t=new i;this._parseCommon(t,e);let{target:n,castShadow:r}=e;return t.castShadow=r||!1,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize=new s(1024,1024),t.shadow.bias=-5e-5,t.lookAt(n?new a(n.x,n.y,n.z):new a(0,0,0)),t}_parseCommon(e,t){let{name:n,intensity:r,color:i,position:s,movesWithCamera:o}=t;e.name=n||"",e.intensity=r||1,e.color=new h(i||"#ffffff"),e.position.copy(s?new a(s.x,s.y,s.z):new a(0,0,0)),e.visible=!0,e.layers.set(1),e.userData.movesWithCamera=o}}e("k",Qt),Qt.rectAreaLightReplacement=!0;const Yt=["127.0.0.1","localhost","0.0.0.0"],Zt=(e("x",(function(e){return!(!e||"string"!=typeof e||e.split(":").length>2)})),e("w",e=>{if(!e||"string"!=typeof e)return null;const t=e.split(":");return t.length<2?null:t[0]})),Jt=({articleNr:e,componentId:t})=>e&&""!==e?t.split(":")[0]+":"+e:null,$t=(e,t)=>null!=e?"string"==typeof e?"true"===e:!0===e:("string"==typeof t&&(t=parseInt(t,10)),t>=200&&t<300);class en{constructor(){this._queue=[],this._pendingRequests=0}_nextSlot(){if(this._pendingRequests-=1,!this._queue.length)return;const{request:e,resolve:t,reject:n}=this._queue.shift();this._fetch(e).then(t,n)}_fetch(e,t={},n={}){return this._pendingRequests+=1,new Promise((r,i)=>{self.fetch(e,t).then(async function(e){this._nextSlot();const t=!n.checkResponse||!1!==await n.checkResponse(e);if($t(e.ok,e.status)&&t)r(...arguments);else{const t=(null==e?void 0:e.url)||"URL unknown";i(new Error(e.statusText||'Http error "'+(e&&e.status?e.status:"unknown")+'", for "'+t+'"'))}}.bind(this),e=>{this._nextSlot(),i(e)})})}fetch(e,t={},n={}){return this._pendingRequests>=40?new Promise((t,n)=>this._queue.push({request:e,resolve:t,reject:n})):this._fetch(e,t,n)}}function tn(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}"function"==typeof SuppressedError&&SuppressedError;const nn=function(e){return e.startsWith("_")&&(e=e.substr(1)),e.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(function(e,t){return(t>0?"-":"")+e.toLowerCase()}))};function rn(e,t){const n=Symbol("property-cache");Object.defineProperty(e,t,{get(){if(!this[n]){const e=window.__RML__DI__.lookup(nn(t),this._creator_);e?this[n]=e:console.error("Dependency "+nn(t)+" not found! Add dependency to /utils/injectables.ts")}return this[n]}})}class sn{info(...e){console}log(...e){console}warn(...e){console.warn.apply(console,e)}error(...e){console.warn.apply(console,e)}}e("L",sn);class an extends sn{constructor(e){super(),this._creator_=e}setMeta(e){this._meta=e}get meta(){return this._meta?this._meta:{}}throw(e){const t="[Kernel Exception]: "+e;this._globalCallback.onKernelMsg("exception",e,this.meta),this.error(t)}error(e){this._globalCallback.onKernelMsg("error",e,this.meta),super.error(e)}warn(e){this._globalCallback.onKernelMsg("warning",e,this.meta),super.warn(e)}}tn([rn],an.prototype,"_globalCallback",void 0);const on=new Map,ln=new Map,hn=new Map,dn=new Map;class cn{constructor(e){this._bootCallbacks=[],this._isStarted=!1,this._isStarting=!1,this._alwaysUseCache=!1,this._creator_=e}start(e){return this._configuratorUiCallbacks.onSyncStarted(),this._startWorker().then(()=>this._handleCatalog(e)).then(()=>{const{typeChangeTag:e,floorMaterialsTag:t}=this._initData;Promise.all([this._syncFloorTag(t),this._syncTypeChangeTag(e)]).then(()=>{dn.set(e,!0),this._configuratorUiCallbacks.onSyncDone()})})}syncCatalog(e){return this._startWorker().then(()=>this._handleCatalog(e))}syncFloorTag(e){return this._startWorker().then(()=>this._syncFloorTag(e))}syncTypeChangeTag(e){return this._startWorker().then(()=>this._syncTypeChangeTag(e))}_syncFloorTag(e){const t=[];return e&&!hn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{t.push(this._handleMaterialsAndTextures(e))}),this._singlePromiseFactory.create(1,e,n=>{Promise.all(t).then(()=>{hn.set(e,!0),n()},e=>this._softReject(n,'_syncFloorTag error: "'+e+'"'))})):Promise.resolve()}_syncTypeChangeTag(e){const t=[];return e&&!dn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{this._rapiAccess.getItems(e.items).then(e=>{e.forEach(e=>{this.getIsCatalogSynced(e.catalog)&&t.push(this._handleCatalog(e.catalog))})})}),this._singlePromiseFactory.create(2,e,n=>{Promise.all(t).then(()=>{hn.set(e,!0),n()},e=>this._softReject(n,'_syncTypeChangeTag error: "'+e+'"'))})):Promise.resolve()}getIsCatalogSynced(e){return!!ln.get(e)}_startWorker(){return new Promise((e,t)=>{if(this._isStarted)return e();this._bootCallbacks.push({resolve:e,reject:t}),this._isStarting||(this._worker=new Worker(n()+"static/asset-loader.worker-1735a5fb1e401244.js"),this._mainThreadToWorker=new d(this,this._worker),this._isStarting=!0,this._mainThreadToWorker.sendToWorker(1))})}onCommand(e,t,n){switch(e){case 4:this._isStarted=!0,this._bootCallbacks.forEach(({resolve:e})=>e());break;case 3:this._mainThreadToWorker.resolvePromises(t,n)}}_handleCatalog(e){return this._singlePromiseFactory.create(0,e,t=>this.getIsCatalogSynced(e)?t():this._rapiAccess.getCatalog(e).then(e=>Promise.all([this._handleContentWithAssets(this._rapiAccess.getComponentsOf(e),["perspectiveImage"]),this._handleItemsAndAdditionalContents(e),this._handleMaterialsAndTextures(e),this._handleExternalMeshes(e),this._handleTags(e.tags)])).then(()=>{ln.set(e,!0),t()},e=>this._softReject(t,'Catalog sync error: "'+e+'"')))}_handleTags(e){return this._handleContentWithAssets(this._rapiAccess.getTags(e),["pngIcon","svgIcon"])}_handleExternalMeshes(e){return new Promise(t=>{this._rapiAccess.getMeshesOfCatalog(e.id).then(e=>{const n=[];e.forEach(e=>{n.push(this._handleContentWithAssets(Promise.all([this._rapiAccess.getMesh(e.id)]),["url"]))}),Promise.all(n).then(t,e=>this._softReject(t,'Sync crt files error: "'+e+'"'))},e=>this._softReject(t,'getMeshesOfCatalog error: "'+e+'"'))})}_handleItemsAndAdditionalContents(e){return new Promise(t=>{this._rapiAccess.getItemsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["perspectiveImage"])),this._rapiAccess.getAdditionalContentsOfItems(e).then(e=>{const t=e.filter(e=>-1!==[5,6,4].indexOf(e.type));n.push(this._handleContentWithAssets(Promise.resolve(t),["content"]))},e=>this._softReject(t,'getAdditionalContentsOfItems error: "'+e+'"')),Promise.all(n).then(t,e=>this._softReject(t,'AdditionalContent image sync error:"'+e+'"'))})})}_handleMaterialsAndTextures(e){return new Promise(t=>{this._rapiAccess.getMaterialsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["thumbnail"])),e.forEach(e=>{n.push(this._handleContentWithAssets(this._rapiAccess.getTexturesOf(e),["image"]))}),Promise.all(n).then(t,e=>this._softReject(t,'getTexturesOf error: "'+e+'"'))},e=>this._softReject(t,'getMaterialsOf error: "'+e+'"'))})}_handleContentWithAssets(e,t){return new Promise(n=>e.then(e=>this._fetchAssets(e,t).then(n,e=>this._softReject(n,'_handleContentWithAssets error: "'+e+'"')),e=>this._softReject(n,'_handleContentWithAssets promise error: "'+e+'"')))}_fetchAssets(e,t){const n=[];e||(e=[]);for(let r=0,i=e.length;r<i;r++){const i=e[r];t.forEach(e=>{const t=i[e];t&&n.push(this._preCacheAsset(t))})}return Promise.all(n)}_preCacheAsset(e){return new Promise(t=>{if(on.get(e))return t();this._assetUrlToBase64(e).then(n=>{on.set(e,n),t()},e=>this._softReject(t,'_preCacheAsset error: "'+e+'"'))})}_assetUrlToBase64(e){return new Promise(t=>{this._mainThreadToWorker.sendToWorker(5,e,t,e=>this._softReject(t,'_assetUrlToBase64 error: "'+e+'"'))})}_softReject(e,t){this._errorHandler.softReject(e,t,2)}requestAsset(e,t=!1){return navigator.onLine&&!this._alwaysUseCache?e:on.get(e)||(t?e:null)}setAlwaysUseCache(e){this._alwaysUseCache=e}preFillAssetCache(e,t){on.set(e,t)}}e("a",cn),tn([rn],cn.prototype,"_rapiAccess",void 0),tn([rn],cn.prototype,"_singlePromiseFactory",void 0),tn([rn],cn.prototype,"_errorHandler",void 0),tn([rn],cn.prototype,"_configuratorUiCallbacks",void 0),tn([rn],cn.prototype,"_initData",void 0);class un{constructor(e){this.info=e,this._init()}_init(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){e&&this._resolve(e),this._resolve()}reject(e){this._reject(e)}wait(){return this._promise}reset(){this._init()}}function pn(e){let t,n,r,i=-1,s=0;for(let a=0;a<e.length;++a){const o=e[a];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===r&&(r=o.normalized),r!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===i&&(i=o.gpuType),i!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.array.length}const a=new t(s);let o=0;for(let t=0;t<e.length;++t)a.set(e[t].array,o),o+=e[t].array.length;const l=new u(a,n,r);return void 0!==i&&(l.gpuType=i),l}function mn(e,t){if(t===p)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===m||t===g){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(t===m)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}e("ae",un);class gn extends f{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new yn(e)})),this.register((function(e){return new En(e)})),this.register((function(e){return new Rn(e)})),this.register((function(e){return new In(e)})),this.register((function(e){return new Cn(e)})),this.register((function(e){return new Sn(e)})),this.register((function(e){return new Mn(e)})),this.register((function(e){return new Tn(e)})),this.register((function(e){return new bn(e)})),this.register((function(e){return new Pn(e)})),this.register((function(e){return new xn(e)})),this.register((function(e){return new An(e)})),this.register((function(e){return new vn(e)})),this.register((function(e){return new Dn(e)})),this.register((function(e){return new On(e)}))}load(e,t,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},a={},o=new TextDecoder;if("string"==typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Ln){try{s[_n.KHR_BINARY_GLTF]=new kn(e)}catch(e){return void(r&&r(e))}i=JSON.parse(s[_n.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new rr(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[t.name]=t,s[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){const t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case _n.KHR_MATERIALS_UNLIT:s[t]=new wn;break;case _n.KHR_DRACO_MESH_COMPRESSION:s[t]=new Un(i,this.dracoLoader);break;case _n.KHR_TEXTURE_TRANSFORM:s[t]=new Fn;break;case _n.KHR_MESH_QUANTIZATION:s[t]=new Nn;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function fn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const _n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vn{constructor(e){this.parser=e,this.name=_n.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const s=t.json,a=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const d=new h(16777215);void 0!==a.color&&d.setRGB(a.color[0],a.color[1],a.color[2],w);const c=void 0!==a.range?a.range:0;switch(a.type){case"directional":o=new i(d),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new b(d),o.distance=c;break;case"spot":o=new l(d),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),o.decay=2,Zn(o,a),void 0!==a.intensity&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class wn{constructor(){this.name=_n.KHR_MATERIALS_UNLIT}getMaterialType(){return y}extendParams(e,t,n){const r=[];e.color=new h(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],w),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,x))}return Promise.all(r)}}class bn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class yn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],a=r.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){const e=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new s(e,e)}return Promise.all(i)}}class xn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Cn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],w)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,x)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Sn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class Mn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=(new h).setRGB(a[0],a[1],a[2],w),Promise.all(i)}}class Tn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Pn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=(new h).setRGB(a[0],a[1],a[2],w),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,x)),Promise.all(i)}}class An{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?C:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class En{constructor(e){this.parser=e,this.name=_n.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class Rn{constructor(e){this.parser=e,this.name=_n.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class In{constructor(e){this.parser=e,this.name=_n.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Dn{constructor(e){this.name=_n.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(s*a);return i.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class On{constructor(e){this.name=_n.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==Hn.TRIANGLES&&e.mode!==Hn.TRIANGLE_STRIP&&e.mode!==Hn.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,s=[],o={};for(const e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(const e of n){const t=new S,n=new a,s=new M,l=new a(1,1,1),h=new T(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&s.fromBufferAttribute(o.ROTATION,e),o.SCALE&&l.fromBufferAttribute(o.SCALE,e),h.setMatrixAt(e,t.compose(n,s,l));for(const t in o)if("_COLOR_0"===t){const e=o[t];h.instanceColor=new P(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);A.prototype.copy.call(h,e),this.parser.assignFinalMaterial(h),i.push(h)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}}const Ln="glTF";class kn{constructor(e){this.name=_n.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ln)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,i=new DataView(e,12);let s=0;for(;s<r;){const t=i.getUint32(s,!0);s+=4;const r=i.getUint32(s,!0);if(s+=4,1313821514===r){const r=new Uint8Array(e,12+s,t);this.content=n.decode(r)}else if(5130562===r){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Un{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_n.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},l={};for(const e in s){const t=qn[e]||e.toLowerCase();a[t]=s[e]}for(const t in e.attributes){const r=qn[t]||t.toLowerCase();if(void 0!==s[t]){const i=n.accessors[e.attributes[t]],s=zn[i.componentType];l[r]=s.name,o[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=o[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l)}))}))}}class Fn{constructor(){this.name=_n.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Nn{constructor(){this.name=_n.KHR_MESH_QUANTIZATION}}class Bn extends _e{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=r-t,d=(n-t)/h,c=d*d,u=c*d,p=e*l,m=p-l,g=-2*u+3*c,f=u-c,_=1-g,v=f-c+d;for(let e=0;e!==a;e++){const t=s[m+e+a],n=s[m+e+o]*h,r=s[p+e+a],l=s[p+e]*h;i[e]=_*t+v*n+g*r+f*l}return i}}const jn=new M;class Gn extends Bn{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return jn.fromArray(i).normalize().toArray(i),i}}const Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},zn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Vn={9728:ne,9729:D,9984:re,9985:ie,9986:se,9987:O},Wn={33071:ae,33648:oe,10497:L},Kn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qn={CUBICSPLINE:void 0,LINEAR:ee,STEP:le};function Yn(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function Zn(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Jn(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $n(e){let t;const n=e.extensions&&e.extensions[_n.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+er(n.attributes):e.indices+":"+er(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,r=e.targets.length;n<r;n++)t+=":"+er(e.targets[n]);return t}function er(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function tr(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const nr=new S;class rr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,i=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=navigator.userAgent.indexOf("Firefox")>-1,i=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new E(this.options.manager):this.textureLoader=new R(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Yn(i,s,r),Zn(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[_n.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(_.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Kn[r.type],t=zn[r.componentType],n=!0===r.normalized,i=new t(r.count*e);return Promise.resolve(new u(i,e,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=Kn[r.type],a=zn[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,h=r.byteOffset||0,d=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,c=!0===r.normalized;let p,m;if(d&&d!==l){const e=Math.floor(h/d),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(p=new a(i,e*d,r.count*d/o),l=new I(p,d/o),t.cache.add(n,l)),m=new de(l,s,h%d/o,c)}else p=null===i?new a(r.count*s):new a(i,h,r.count*s),m=new u(p,s,c);if(void 0!==r.sparse){const t=Kn.SCALAR,n=zn[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,h=new n(e[1],o,r.sparse.count*t),d=new a(e[2],l,r.sparse.count*s);null!==i&&(m=new u(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*s]),s>=2&&m.setY(t,d[e*s+1]),s>=3&&m.setZ(t,d[e*s+2]),s>=4&&m.setW(t,d[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],a=i.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=Vn[n.magFilter]||D,t.minFilter=Vn[n.minFilter]||O,t.wrapS=Wn[n.wrapS]||L,t.wrapT=Wn[n.wrapT]||L,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=n.images[e],s=self.URL||self.webkitURL;let a=i.uri||"",o=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:i.mimeType});return a=s.createObjectURL(t),a}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new ce(e);t.needsUpdate=!0,n(t)}),t.load(_.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===o&&s.revokeObjectURL(a),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[_n.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[_n.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[_n.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new k,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new F,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return N}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let a;const o={},l=[];if((i.extensions||{})[_n.KHR_MATERIALS_UNLIT]){const e=r[_n.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new h(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],w),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,x)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=B);const d=i.alphaMode||"OPAQUE";if("BLEND"===d?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===d&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==y&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new s(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&a!==y&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==y){const e=i.emissiveFactor;o.emissive=(new h).setRGB(e[0],e[1],e[2],w)}return void 0!==i.emissiveTexture&&a!==y&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,x)),Promise.all(l).then((function(){const n=new a(o);return i.name&&(n.name=i.name),Zn(n,i),t.associations.set(n,{materials:e}),i.extensions&&Yn(r,n,i),n}))}createUniqueName(e){const t=j.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[_n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return ir(n,e,t)}))}const s=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],o=$n(a),l=r[o];if(l)s.push(l.promise);else{let e;e=a.extensions&&a.extensions[_n.KHR_DRACO_MESH_COMPRESSION]?i(a):ir(new c,a,t),r[o]={primitive:a,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,a=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new N({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:he})),o.DefaultMaterial):this.getDependency("material",s[e].material);a.push(t)}var o;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],d=s[n];let c;const u=a[n];if(d.mode===Hn.TRIANGLES||d.mode===Hn.TRIANGLE_STRIP||d.mode===Hn.TRIANGLE_FAN||void 0===d.mode)c=!0===i.isSkinnedMesh?new G(h,u):new H(h,u),!0===c.isSkinnedMesh&&c.normalizeSkinWeights(),d.mode===Hn.TRIANGLE_STRIP?c.geometry=mn(c.geometry,g):d.mode===Hn.TRIANGLE_FAN&&(c.geometry=mn(c.geometry,m));else if(d.mode===Hn.LINES)c=new z(h,u);else if(d.mode===Hn.LINE_STRIP)c=new V(h,u);else if(d.mode===Hn.LINE_LOOP)c=new W(h,u);else{if(d.mode!==Hn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);c=new K(h,u)}Object.keys(c.geometry.morphAttributes).length>0&&Jn(c,i),c.name=t.createUniqueName(i.name||"mesh_"+e),Zn(c,i),d.extensions&&Yn(r,c,d),t.assignFinalMaterial(c),l.push(c)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return i.extensions&&Yn(r,l[0],i),l[0];const h=new q;i.extensions&&Yn(r,h,i),t.associations.set(h,{meshes:e});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new X(Q.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new Y(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Zn(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),r=e,i=[],s=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){i.push(a);const t=new S;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Z(i,s)}))}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],i=r.name?r.name:"animation_"+e,s=[],a=[],o=[],l=[],h=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],n=r.samplers[t.sampler],i=t.target,d=i.node,c=void 0!==r.parameters?r.parameters[n.input]:n.input,u=void 0!==r.parameters?r.parameters[n.output]:n.output;void 0!==i.node&&(s.push(this.getDependency("node",d)),a.push(this.getDependency("accessor",c)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(i))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(e){const t=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],h=r[e],d=s[e],c=a[e],u=o[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=n._createAnimationTracks(i,h,d,c,u);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}return new J(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),i=[],s=n.children||[];for(let e=0,n=s.length;e<n;e++)i.push(t.getDependency("node",s[e]));const a=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),a]).then((function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,nr)}));for(let e=0,r=n.length;e<r;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"",a=[],o=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&a.push(o),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){a.push(e)})),this.nodeCache[e]=Promise.all(a).then((function(t){let a;if(a=!0===i.isBone?new $:t.length>1?new q:1===t.length?t[0]:new A,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=s),Zn(a,i),i.extensions&&Yn(n,a,i),void 0!==i.matrix){const e=new S;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,i=new q;n.name&&(i.name=r.createUniqueName(n.name)),Zn(i,n),n.extensions&&Yn(t,i,n);const s=n.nodes||[],a=[];for(let e=0,t=s.length;e<t;e++)a.push(r.getDependency("node",s[e]));return Promise.all(a).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof U||e instanceof ce)&&t.set(e,n);return e.traverse(e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i}))}_createAnimationTracks(e,t,n,r,i){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(Xn[i.path]===Xn.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),Xn[i.path]){case Xn.weights:l=pe;break;case Xn.rotation:l=me;break;case Xn.position:case Xn.scale:l=ue;break;default:switch(n.itemSize){case 1:l=pe;break;case 2:case 3:default:l=ue}}const h=void 0!==r.interpolation?Qn[r.interpolation]:ee,d=this._getArrayFromAccessor(n);for(let e=0,n=o.length;e<n;e++){const n=new l(o[e]+"."+Xn[i.path],t.array,d,h);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=tr(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Gn:Bn)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ir(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=qn[t]||t.toLowerCase();n in e.attributes||i.push(s(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return te.workingColorSpace!==w&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${te.workingColorSpace}" not supported.`),Zn(e,t),function(e,t,n){const r=t.attributes,i=new ge;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new a(t[0],t[1],t[2]),new a(s[0],s[1],s[2])),e.normalized){const t=tr(zn[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new a,t=new a;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const e=tr(zn[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new fe;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const a=[],o=[],l=[];for(let h=0,d=t.length;h<d;h++){const d=t[h];if(r){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const sr=new WeakMap;class ar extends f{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const i=new v(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,r)},n,r)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,x).catch(n)}decodeDracoFile(e,t,n,r,i=w){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){const n=JSON.stringify(t);if(sr.has(e)){const t=sr.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(i,s).then(n=>(r=n,new Promise((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return a.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),sr.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new c;e.index&&t.setIndex(new u(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,s=r.array,a=r.itemSize,o=new u(s,a);"color"===i&&(this._assignVertexColorSpace(o,r.vertexColorSpace),o.normalized=s instanceof Float32Array==0),t.setAttribute(i,o)}return t}_assignVertexColorSpace(e,t){if(t!==x)return;const n=new h;for(let t=0,r=e.count;t<r;t++)n.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,r)=>{n.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=or.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){this.workerPool.map(e=>e._taskLoad)}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function or(){let e,t;function n(e,t,n,r,i,s){const a=s.num_components(),o=n.num_points()*a,l=o*i.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,h,l,d);const c=new i(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:r,array:c,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,s=i.taskConfig;t.then(e=>{const t=e.draco,a=new t.Decoder;try{const e=function(e,t,r,i){const s=i.attributeIDs,a=i.attributeTypes;let o,l;const h=t.GetEncodedGeometryType(r);if(h===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(r,r.byteLength,o);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(r,r.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const r in s){const l=self[a[r]];let h,c;if(i.useUniqueIDs)c=s[r],h=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[s[r]]),-1===c)continue;h=t.GetAttribute(o,c)}const u=n(e,t,o,r,l,h);"color"===r&&(u.vertexColorSpace=i.vertexColorSpace),d.attributes.push(u)}return h===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const r=3*n.num_faces(),i=4*r,s=e._malloc(i);t.GetTrianglesUInt32Array(n,i,s);const a=new Uint32Array(e.HEAPF32.buffer,s,r).slice();return e._free(s),{array:a,itemSize:1}}(e,t,o)),e.destroy(o),d}(t,a,new Int8Array(r),s),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(a)}})}}}const lr={"draco_wasm_wrapper.js":"static/draco_wasm_wrapper-6263f3a4b71cdf3b.js","draco_decoder.wasm":"static/draco_decoder-b048235474cbf09e.wasm","draco_decoder.js":"static/draco_decoder-dc7f397e2a2ebac4.js"};class hr{constructor(e){this._context_=e}getStore(e="rml_default"){return this._localStorage.getItem(e)||{entries:[]}}saveStore(e,t){this._localStorage.setItem(e,t)}addItem(e,t,n="rml_default",r=5){const i=this.getStore(n),s=i.entries.find(t=>t.id===e);if(s?(s.payload=t,s.date=Date.now()):i.entries.push({id:e,date:Date.now(),payload:t}),i.entries.length>r)for(i.entries.sort((e,t)=>t.date-e.date);i.entries.length>r;)i.entries.pop();this.saveStore(n,i)}getItem(e,t="rml_default"){const n=this.getStore(t).entries.find(t=>t.id===e);return n?n.payload:null}}tn([rn],hr.prototype,"_localStorage",void 0);const dr=e("t",(function(e){return e*(Math.PI/180)})),cr=e("s",(function(e){return e*(180/Math.PI)})),ur=(e("q",(function(e,t,n,r,i,s){e=Math.sqrt(e*e+n*n);const a=i/s,o=2*Math.atan(Math.tan(r*Math.PI/180/2)*a)*180/Math.PI,l=dr(r),h=t/2/Math.tan(l/2),d=e/(2*Math.atan(Math.PI*o/360));return Math.max(h,d)})),function(e){return Math.round(1e3*e)/1e3}),pr=(e("T",(function(e,t){return Math.abs(e.y-t.y)+Math.abs(e.x-t.x)})),e("a5",e=>new a(e.x/1e3,e.z/1e3,e.y/-1e3))),mr=e=>new a(e.x/1e3,e.z/1e3,e.y/1e3),gr=e("c",e=>({x:Math.round(1e3*e.x),y:Math.round(-1e3*e.z),z:Math.round(1e3*e.y)})),fr=e=>decodeURIComponent(encodeURIComponent(e)),_r=e("G",e=>{if(!e){const t=typeof e;return"number"===t||"boolean"===t?e:null}if(!e.hasOwnProperty("size")&&e.size&&"function"==typeof e.size){let t=vr(e);for(let e=0;e<t.length;e++)t[e]=_r(t[e]);return"string"==typeof t?fr(t):t}if("object"==typeof e)for(let t in e)e.hasOwnProperty(t)&&(e[t]=_r(e[t]));return"string"==typeof e?fr(e):e}),vr=e=>{let t=[];if(e){let n=e.size();for(let r=0;r<n;r++)t.push(e.get(r))}return t},wr=e=>{let t=new S,n=_r(e);return t.fromArray(n),t.transpose(),(e=>{let t=new S;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),t.scale(new a(.001,.001,.001));let n=new S;return n.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),n.scale(new a(1e3,1e3,1e3)),t.multiply(e).multiply(n)})(t)};function br(e,t){var n=e.__state.conversionName.toString(),r=Math.round(e.r),i=Math.round(e.g),s=Math.round(e.b),a=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var d=e.hex.toString(16);d.length<6;)d="0"+d;return"#"+d}return"CSS_RGB"===n?"rgb("+r+","+i+","+s+")":"CSS_RGBA"===n?"rgba("+r+","+i+","+s+","+a+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+r+","+i+","+s+"]":"RGBA_ARRAY"===n?"["+r+","+i+","+s+","+a+"]":"RGB_OBJ"===n?"{r:"+r+",g:"+i+",b:"+s+"}":"RGBA_OBJ"===n?"{r:"+r+",g:"+i+",b:"+s+",a:"+a+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+a+"}":"unknown format"}var yr=Array.prototype.forEach,xr=Array.prototype.slice,Cr={BREAK:{},extend:function(e){return this.each(xr.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(xr.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=xr.call(arguments);return function(){for(var t=xr.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(yr&&e.forEach&&e.forEach===yr)e.forEach(t,n);else if(e.length===e.length+0){var r,i=void 0;for(i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===this.BREAK)return}else for(var s in e)if(t.call(n,e[s],s)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var r=void 0;return function(){var i=this,s=arguments;function a(){r=null,n||e.apply(i,s)}var o=n||!r;clearTimeout(r),r=setTimeout(a,t),o&&e.apply(i,s)}},toArray:function(e){return e.toArray?e.toArray():xr.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},Sr=[{litmus:Cr.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:br},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:br},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:br},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:br}}},{litmus:Cr.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Cr.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:Cr.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Cr.isNumber(e.r)&&Cr.isNumber(e.g)&&Cr.isNumber(e.b)&&Cr.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(Cr.isNumber(e.r)&&Cr.isNumber(e.g)&&Cr.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(Cr.isNumber(e.h)&&Cr.isNumber(e.s)&&Cr.isNumber(e.v)&&Cr.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(Cr.isNumber(e.h)&&Cr.isNumber(e.s)&&Cr.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],Mr=void 0,Tr=void 0,Pr=function(){Tr=!1;var e=arguments.length>1?Cr.toArray(arguments):arguments[0];return Cr.each(Sr,(function(t){if(t.litmus(e))return Cr.each(t.conversions,(function(t,n){if(Mr=t.read(e),!1===Tr&&!1!==Mr)return Tr=Mr,Mr.conversionName=n,Mr.conversion=t,Cr.BREAK})),Cr.BREAK})),Tr},Ar=void 0,Er={hsv_to_rgb:function(e,t,n){var r=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),s=n*(1-t),a=n*(1-i*t),o=n*(1-(1-i)*t),l=[[n,o,s],[a,n,s],[s,n,o],[s,a,n],[o,s,n],[n,s,a]][r];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var r=Math.min(e,t,n),i=Math.max(e,t,n),s=i-r,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=e===i?(t-n)/s:t===i?2+(n-e)/s:4+(e-t)/s,(a/=6)<0&&(a+=1),{h:360*a,s:s/i,v:i/255})},rgb_to_hex:function(e,t,n){var r=this.hex_with_component(0,2,e);return r=this.hex_with_component(r,1,t),this.hex_with_component(r,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Ar=8*t)|e&~(255<<Ar)}},Rr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ir=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Dr=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Or=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,n,r)}if("value"in i)return i.value;var a=i.get;return void 0!==a?a.call(r):void 0},Lr=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},kr=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},Ur=function(){function e(){if(Ir(this,e),this.__state=Pr.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Dr(e,[{key:"toString",value:function(){return br(this)}},{key:"toHexString",value:function(){return br(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function Fr(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Ur.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Ur.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function Nr(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Ur.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Ur.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Ur.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=Er.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Cr.extend(e.__state,Er.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Ur.recalculateHSV=function(e){var t=Er.rgb_to_hsv(e.r,e.g,e.b);Cr.extend(e.__state,{s:t.s,v:t.v}),Cr.isNaN(t.h)?Cr.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},Ur.COMPONENTS=["r","g","b","h","s","v","hex","a"],Fr(Ur.prototype,"r",2),Fr(Ur.prototype,"g",1),Fr(Ur.prototype,"b",0),Nr(Ur.prototype,"h"),Nr(Ur.prototype,"s"),Nr(Ur.prototype,"v"),Object.defineProperty(Ur.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Ur.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=Er.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Br=function(){function e(t,n){Ir(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return Dr(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),jr={};Cr.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){Cr.each(e,(function(e){jr[e]=t}))}));var Gr=/(\d+(\.\d+)?)px/;function Hr(e){if("0"===e||Cr.isUndefined(e))return 0;var t=e.match(Gr);return Cr.isNull(t)?0:parseFloat(t[1])}var zr={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var r=n,i=t;Cr.isUndefined(i)&&(i=!0),Cr.isUndefined(r)&&(r=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),r&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,r){var i=n||{},s=jr[t];if(!s)throw new Error("Event type "+t+" not supported.");var a=document.createEvent(s);switch(s){case"MouseEvents":var o=i.x||i.clientX||0,l=i.y||i.clientY||0;a.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var h=a.initKeyboardEvent||a.initKeyEvent;Cr.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:a.initEvent(t,i.bubbles||!1,i.cancelable||!0)}Cr.defaults(a,r),e.dispatchEvent(a)},bind:function(e,t,n,r){var i=r||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),zr},unbind:function(e,t,n,r){var i=r||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),zr},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return zr},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),r=n.indexOf(t);-1!==r&&(n.splice(r,1),e.className=n.join(" "))}else e.className=void 0;return zr},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Hr(t["border-left-width"])+Hr(t["border-right-width"])+Hr(t["padding-left"])+Hr(t["padding-right"])+Hr(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Hr(t["border-top-width"])+Hr(t["border-bottom-width"])+Hr(t["padding-top"])+Hr(t["padding-bottom"])+Hr(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Vr=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=r;return r.__prev=r.getValue(),r.__checkbox=document.createElement("input"),r.__checkbox.setAttribute("type","checkbox"),zr.bind(r.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),r.domElement.appendChild(r.__checkbox),r.updateDisplay(),r}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Br),Wr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r,a=i;if(i.__select=document.createElement("select"),Cr.isArray(s)){var o={};Cr.each(s,(function(e){o[e]=e})),s=o}return Cr.each(s,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),a.__select.appendChild(n)})),i.updateDisplay(),zr.bind(i.__select,"change",(function(){var e=this.options[this.selectedIndex].value;a.setValue(e)})),i.domElement.appendChild(i.__select),i}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return zr.isActive(this.__select)?this:(this.__select.value=this.getValue(),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(Br),Kr=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=r;function s(){i.setValue(i.__input.value)}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),zr.bind(r.__input,"keyup",s),zr.bind(r.__input,"change",s),zr.bind(r.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),zr.bind(r.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){return zr.isActive(this.__input)||(this.__input.value=this.getValue()),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Br);function qr(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var Xr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r||{};return i.__min=s.min,i.__max=s.max,i.__step=s.step,Cr.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=qr(i.__impliedStep),i}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=qr(e),this}}]),t}(Br),Qr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));i.__truncationSuspended=!1;var s=i,a=void 0;function o(){s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function l(e){var t=a-e.clientY;s.setValue(s.getValue()+t*s.__impliedStep),a=e.clientY}function h(){zr.unbind(window,"mousemove",l),zr.unbind(window,"mouseup",h),o()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),zr.bind(i.__input,"change",(function(){var e=parseFloat(s.__input.value);Cr.isNaN(e)||s.setValue(e)})),zr.bind(i.__input,"blur",(function(){o()})),zr.bind(i.__input,"mousedown",(function(e){zr.bind(window,"mousemove",l),zr.bind(window,"mouseup",h),a=e.clientY})),zr.bind(i.__input,"keydown",(function(e){13===e.keyCode&&(s.__truncationSuspended=!0,this.blur(),s.__truncationSuspended=!1,o())})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e,n,r;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,r=Math.pow(10,n),Math.round(e*r)/r),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Xr);function Yr(e,t,n,r,i){return r+(e-t)/(n-t)*(i-r)}var Zr=function(e){function t(e,n,r,i,s){Ir(this,t);var a=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:r,max:i,step:s})),o=a;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(Yr(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){zr.unbind(window,"mousemove",l),zr.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function d(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(Yr(t,n.left,n.right,o.__min,o.__max))}function c(){zr.unbind(window,"touchmove",d),zr.unbind(window,"touchend",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),zr.bind(a.__background,"mousedown",(function(e){document.activeElement.blur(),zr.bind(window,"mousemove",l),zr.bind(window,"mouseup",h),l(e)})),zr.bind(a.__background,"touchstart",(function(e){1===e.touches.length&&(zr.bind(window,"touchmove",d),zr.bind(window,"touchend",c),d(e))})),zr.addClass(a.__background,"slider"),zr.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Xr),Jr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===r?"Fire":r,zr.bind(i.__button,"click",(function(e){return e.preventDefault(),s.fire(),!1})),zr.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return Lr(t,e),Dr(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Br),$r=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));r.__color=new Ur(r.getValue()),r.__temp=new Ur(0);var i=r;r.domElement=document.createElement("div"),zr.makeSelectable(r.domElement,!1),r.__selector=document.createElement("div"),r.__selector.className="selector",r.__saturation_field=document.createElement("div"),r.__saturation_field.className="saturation-field",r.__field_knob=document.createElement("div"),r.__field_knob.className="field-knob",r.__field_knob_border="2px solid ",r.__hue_knob=document.createElement("div"),r.__hue_knob.className="hue-knob",r.__hue_field=document.createElement("div"),r.__hue_field.className="hue-field",r.__input=document.createElement("input"),r.__input.type="text",r.__input_textShadow="0 1px 1px ",zr.bind(r.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),zr.bind(r.__input,"blur",c),zr.bind(r.__selector,"mousedown",(function(){zr.addClass(this,"drag").bind(window,"mouseup",(function(){zr.removeClass(i.__selector,"drag")}))})),zr.bind(r.__selector,"touchstart",(function(){zr.addClass(this,"drag").bind(window,"touchend",(function(){zr.removeClass(i.__selector,"drag")}))}));var s,a=document.createElement("div");function o(e){p(e),zr.bind(window,"mousemove",p),zr.bind(window,"touchmove",p),zr.bind(window,"mouseup",h),zr.bind(window,"touchend",h)}function l(e){m(e),zr.bind(window,"mousemove",m),zr.bind(window,"touchmove",m),zr.bind(window,"mouseup",d),zr.bind(window,"touchend",d)}function h(){zr.unbind(window,"mousemove",p),zr.unbind(window,"touchmove",p),zr.unbind(window,"mouseup",h),zr.unbind(window,"touchend",h),u()}function d(){zr.unbind(window,"mousemove",m),zr.unbind(window,"touchmove",m),zr.unbind(window,"mouseup",d),zr.unbind(window,"touchend",d),u()}function c(){var e=Pr(this.value);!1!==e?(i.__color.__state=e,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function u(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,r=n.clientX,s=n.clientY,a=(r-t.left)/(t.right-t.left),o=1-(s-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),a>1?a=1:a<0&&(a=0),i.__color.v=o,i.__color.s=a,i.setValue(i.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return Cr.extend(r.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Cr.extend(r.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:r.__field_knob_border+(r.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Cr.extend(r.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Cr.extend(r.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Cr.extend(a.style,{width:"100%",height:"100%",background:"none"}),ti(a,"top","rgba(0,0,0,0)","#000"),Cr.extend(r.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(s=r.__hue_field).style.background="",s.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",s.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Cr.extend(r.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:r.__input_textShadow+"rgba(0,0,0,0.7)"}),zr.bind(r.__saturation_field,"mousedown",o),zr.bind(r.__saturation_field,"touchstart",o),zr.bind(r.__field_knob,"mousedown",o),zr.bind(r.__field_knob,"touchstart",o),zr.bind(r.__hue_field,"mousedown",l),zr.bind(r.__hue_field,"touchstart",l),r.__saturation_field.appendChild(a),r.__selector.appendChild(r.__field_knob),r.__selector.appendChild(r.__saturation_field),r.__selector.appendChild(r.__hue_field),r.__hue_field.appendChild(r.__hue_knob),r.domElement.appendChild(r.__input),r.domElement.appendChild(r.__selector),r.updateDisplay(),r}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e=Pr(this.getValue());if(!1!==e){var t=!1;Cr.each(Ur.COMPONENTS,(function(n){if(!Cr.isUndefined(e[n])&&!Cr.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Cr.extend(this.__color.__state,e)}Cr.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,r=255-n;Cr.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,ti(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Cr.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+r+","+r+","+r+",.7)"})}}]),t}(Br),ei=["-moz-","-o-","-webkit-","-ms-",""];function ti(e,t,n,r){e.style.background="",Cr.each(ei,(function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+r+" 100%); "}))}var ni='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',ri=function(e,t){var n=e[t];return Cr.isArray(arguments[2])||Cr.isObject(arguments[2])?new Wr(e,t,arguments[2]):Cr.isNumber(n)?Cr.isNumber(arguments[2])&&Cr.isNumber(arguments[3])?Cr.isNumber(arguments[4])?new Zr(e,t,arguments[2],arguments[3],arguments[4]):new Zr(e,t,arguments[2],arguments[3]):Cr.isNumber(arguments[4])?new Qr(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Qr(e,t,{min:arguments[2],max:arguments[3]}):Cr.isString(n)?new Kr(e,t):Cr.isFunction(n)?new Jr(e,t,""):Cr.isBoolean(n)?new Vr(e,t):null},ii=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},si=function(){function e(){Ir(this,e),this.backgroundElement=document.createElement("div"),Cr.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),zr.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Cr.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;zr.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Dr(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Cr.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",zr.unbind(e.domElement,"webkitTransitionEnd",t),zr.unbind(e.domElement,"transitionend",t),zr.unbind(e.domElement,"oTransitionEnd",t)};zr.bind(this.domElement,"webkitTransitionEnd",t),zr.bind(this.domElement,"transitionend",t),zr.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-zr.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-zr.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=document,r=document.createElement("style");r.type="text/css",r.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(r)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var ai=function(){try{return!!window.localStorage}catch(e){return!1}}(),oi=void 0,li=!0,hi=void 0,di=!1,ci=[],ui=function e(t){var n=this,r=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),zr.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],r=Cr.defaults(r,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),r=Cr.defaults(r,{resizable:r.autoPlace,hideable:r.autoPlace}),Cr.isUndefined(r.load)?r.load={preset:"Default"}:r.preset&&(r.load.preset=r.preset),Cr.isUndefined(r.parent)&&r.hideable&&ci.push(this),r.resizable=Cr.isUndefined(r.parent)&&r.resizable,r.autoPlace&&Cr.isUndefined(r.scrollable)&&(r.scrollable=!0);var i,s=ai&&"true"===localStorage.getItem(vi(0,"isLocal")),a=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return r.parent}},scrollable:{get:function(){return r.scrollable}},autoPlace:{get:function(){return r.autoPlace}},closeOnTop:{get:function(){return r.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:r.load.preset},set:function(e){n.parent?n.getRoot().preset=e:r.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return r.width},set:function(e){r.width=e,Ci(n,e)}},name:{get:function(){return r.name},set:function(e){r.name=e,o&&(o.innerHTML=r.name)}},closed:{get:function(){return r.closed},set:function(t){r.closed=t,r.closed?zr.addClass(n.__ul,e.CLASS_CLOSED):zr.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return r.load}},useLocalStorage:{get:function(){return s},set:function(e){ai&&(s=e,e?zr.bind(window,"unload",a):zr.unbind(window,"unload",a),localStorage.setItem(vi(0,"isLocal"),e))}}}),Cr.isUndefined(r.parent)){if(this.closed=r.closed||!1,zr.addClass(this.domElement,e.CLASS_MAIN),zr.makeSelectable(this.domElement,!1),ai&&s){n.useLocalStorage=!0;var l=localStorage.getItem(vi(0,"gui"));l&&(r.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,zr.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),r.closeOnTop?(zr.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(zr.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),zr.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===r.closed&&(r.closed=!0);var h=document.createTextNode(r.name);zr.addClass(h,"controller-name"),o=pi(n,h),zr.addClass(this.__ul,e.CLASS_CLOSED),zr.addClass(o,"title"),zr.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),r.closed||(this.closed=!1)}r.autoPlace&&(Cr.isUndefined(r.parent)&&(li&&(hi=document.createElement("div"),zr.addClass(hi,"dg"),zr.addClass(hi,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(hi),li=!1),hi.appendChild(this.domElement),zr.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||Ci(n,r.width)),this.__resizeHandler=function(){n.onResizeDebounced()},zr.bind(window,"resize",this.__resizeHandler),zr.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),zr.bind(this.__ul,"transitionend",this.__resizeHandler),zr.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),r.resizable&&xi(this),a=function(){ai&&"true"===localStorage.getItem(vi(0,"isLocal"))&&localStorage.setItem(vi(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=a,r.parent||((i=n.getRoot()).width+=1,Cr.defer((function(){i.width-=1})))};function pi(e,t,n){var r=document.createElement("li");return t&&r.appendChild(t),n?e.__ul.insertBefore(r,n):e.__ul.appendChild(r),e.onResize(),r}function mi(e){zr.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&zr.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function gi(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function fi(e,t){var n=e.getRoot(),r=n.__rememberedObjects.indexOf(t.object);if(-1!==r){var i=n.__rememberedObjectIndecesToControllers[r];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[r]=i),i[t.property]=t,n.load&&n.load.remembered){var s=n.load.remembered,a=void 0;if(s[e.preset])a=s[e.preset];else{if(!s.Default)return;a=s.Default}if(a[r]&&void 0!==a[r][t.property]){var o=a[r][t.property];t.initialValue=o,t.setValue(o)}}}}function _i(e,t,n,r){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(r.color)i=new $r(t,n);else{var s=[t,n].concat(r.factoryArgs);i=ri.apply(e,s)}r.before instanceof Br&&(r.before=r.before.__li),fi(e,i),zr.addClass(i.domElement,"c");var a=document.createElement("span");zr.addClass(a,"property-name"),a.innerHTML=i.property;var o=document.createElement("div");o.appendChild(a),o.appendChild(i.domElement);var l=pi(e,o,r.before);return zr.addClass(l,ui.CLASS_CONTROLLER_ROW),i instanceof $r?zr.addClass(l,"color"):zr.addClass(l,Rr(i.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,Cr.extend(n,{options:function(t){if(arguments.length>1){var r=n.__li.nextElementSibling;return n.remove(),_i(e,n.object,n.property,{before:r,factoryArgs:[Cr.toArray(arguments)]})}if(Cr.isArray(t)||Cr.isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),_i(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof Zr){var r=new Qr(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Cr.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],i=r[e];n[e]=r[e]=function(){var e=Array.prototype.slice.call(arguments);return i.apply(r,e),t.apply(n,e)}})),zr.addClass(t,"has-slider"),n.domElement.insertBefore(r.domElement,n.domElement.firstElementChild)}else if(n instanceof Qr){var i=function(t){if(Cr.isNumber(n.__min)&&Cr.isNumber(n.__max)){var r=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var s=_i(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return s.name(r),i&&s.listen(),s}return t};n.min=Cr.compose(i,n.min),n.max=Cr.compose(i,n.max)}else n instanceof Vr?(zr.bind(t,"click",(function(){zr.fakeEvent(n.__checkbox,"click")})),zr.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof Jr?(zr.bind(t,"click",(function(){zr.fakeEvent(n.__button,"click")})),zr.bind(t,"mouseover",(function(){zr.addClass(n.__button,"hover")})),zr.bind(t,"mouseout",(function(){zr.removeClass(n.__button,"hover")}))):n instanceof $r&&(zr.addClass(t,"color"),n.updateDisplay=Cr.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Cr.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&gi(e.getRoot(),!0),t}),n.setValue)}(e,l,i),e.__controllers.push(i),i}function vi(e,t){return document.location.href+"."+t}function wi(e,t,n){var r=document.createElement("option");r.innerHTML=t,r.value=t,e.__preset_select.appendChild(r),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function bi(e,t){t.style.display=e.useLocalStorage?"block":"none"}function yi(e){var t=e.__save_row=document.createElement("li");zr.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),zr.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",zr.addClass(n,"button gears");var r=document.createElement("span");r.innerHTML="Save",zr.addClass(r,"button"),zr.addClass(r,"save");var i=document.createElement("span");i.innerHTML="New",zr.addClass(i,"button"),zr.addClass(i,"save-as");var s=document.createElement("span");s.innerHTML="Revert",zr.addClass(s,"button"),zr.addClass(s,"revert");var a=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Cr.each(e.load.remembered,(function(t,n){wi(e,n,n===e.preset)})):wi(e,"Default",!1),zr.bind(a,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(a),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(s),ai){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(vi(0,"isLocal"))&&l.setAttribute("checked","checked"),bi(e,o),zr.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,bi(e,o)}))}var h=document.getElementById("dg-new-constructor");zr.bind(h,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||oi.hide()})),zr.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),oi.show(),h.focus(),h.select()})),zr.bind(r,"click",(function(){e.save()})),zr.bind(i,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),zr.bind(s,"click",(function(){e.revert()}))}function xi(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function r(){zr.removeClass(e.__closeButton,ui.CLASS_DRAG),zr.unbind(window,"mousemove",n),zr.unbind(window,"mouseup",r)}function i(i){return i.preventDefault(),t=i.clientX,zr.addClass(e.__closeButton,ui.CLASS_DRAG),zr.bind(window,"mousemove",n),zr.bind(window,"mouseup",r),!1}e.__resize_handle=document.createElement("div"),Cr.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),zr.bind(e.__resize_handle,"mousedown",i),zr.bind(e.__closeButton,"mousedown",i),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Ci(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Si(e,t){var n={};return Cr.each(e.__rememberedObjects,(function(r,i){var s={},a=e.__rememberedObjectIndecesToControllers[i];Cr.each(a,(function(e,n){s[n]=t?e.initialValue:e.getValue()})),n[i]=s})),n}ui.toggleHide=function(){di=!di,Cr.each(ci,(function(e){e.domElement.style.display=di?"none":""}))},ui.CLASS_AUTO_PLACE="a",ui.CLASS_AUTO_PLACE_CONTAINER="ac",ui.CLASS_MAIN="main",ui.CLASS_CONTROLLER_ROW="cr",ui.CLASS_TOO_TALL="taller-than-window",ui.CLASS_CLOSED="closed",ui.CLASS_CLOSE_BUTTON="close-button",ui.CLASS_CLOSE_TOP="close-top",ui.CLASS_CLOSE_BOTTOM="close-bottom",ui.CLASS_DRAG="drag",ui.DEFAULT_WIDTH=245,ui.TEXT_CLOSED="Close Controls",ui.TEXT_OPEN="Open Controls",ui._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||ui.toggleHide()},zr.bind(window,"keydown",ui._keydownHandler,!1),Cr.extend(ui.prototype,{add:function(e,t){return _i(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return _i(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Cr.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&hi.removeChild(this.domElement);var e=this;Cr.each(this.__folders,(function(t){e.removeFolder(t)})),zr.unbind(window,"keydown",ui._keydownHandler,!1),mi(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new ui(t);this.__folders[e]=n;var r=pi(this,n.domElement);return zr.addClass(r,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],mi(e);var t=this;Cr.each(e.__folders,(function(t){e.removeFolder(t)})),Cr.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=zr.getOffset(e.__ul).top,n=0;Cr.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=zr.getHeight(t))})),window.innerHeight-t-20<n?(zr.addClass(e.domElement,ui.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(zr.removeClass(e.domElement,ui.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Cr.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Cr.debounce((function(){this.onResize()}),50),remember:function(){if(Cr.isUndefined(oi)&&((oi=new si).domElement.innerHTML=ni),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Cr.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&yi(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&Ci(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Si(this)),e.folders={},Cr.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Si(this),gi(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=Si(this,!0)),this.load.remembered[e]=Si(this),this.preset=e,wi(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Cr.each(this.__controllers,(function(t){this.getRoot().load.remembered?fi(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Cr.each(this.__folders,(function(e){e.revert(e)})),e||gi(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ii.call(window,(function(){e(t)})),Cr.each(t,(function(e){e.updateDisplay()}))}(this.__listening)},updateDisplay:function(){Cr.each(this.__controllers,(function(e){e.updateDisplay()})),Cr.each(this.__folders,(function(e){e.updateDisplay()}))}});var Mi=ui;class Ti{static createMeshPhysicalMaterial(e){return new C(e)}static createMeshStandardMaterial(e){return new N(e)}}e("M",Ti),e("g",(e,t,n,r)=>{if(!e||!t||0===n||0===r)return new a;let i=e.clone(),s=n/2,o=r/2;return i.project(t),i.x=Math.floor(i.x*s+s),i.y=Math.floor(-i.y*o+o),i.z=e.distanceTo(t.position),i});const Pi=e("ab",(e,t)=>{t||(t=new a(0,0,0));let n=new a(e.size.x/1e3,e.size.z/1e3,e.size.y/1e3),r=new a(e.origin.x/1e3,e.origin.z/1e3,e.origin.y/-1e3),i=new a(0,0,-n.z).add(r).sub(t),s=new a(n.x,n.y,0).add(r).add(t);return new ge(i,s)});e("H",(e,t)=>{let n=ur(e.x),r=ur(e.y),i=ur(e.z),s=ur(t.x),a=ur(t.y),o=ur(t.z);return n===s&&r===a&&i===o}),e("S",(e,t)=>{let n=ur(e.w),r=ur(e.x),i=ur(e.y),s=ur(e.z),a=ur(t.w),o=ur(t.x),l=ur(t.y),h=ur(t.z);return n===a&&r===o&&i===l&&s===h}),e("J",(e,t)=>{let n=ur(e.x),r=ur(e.y),i=ur(t.x),s=ur(t.y);return n===i&&r===s});let Ai=null;const Ei=()=>{if(Ai)return Ai;const e=new Uint8Array(4);for(let t=0;t<1;t++){const n=4*t;e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255}const t=new ye(e,1,1,be);return t.needsUpdate=!0,t},Ri=(e,t,n,r)=>{const i=new Uint8Array(4),s=Math.floor(255*e),a=Math.floor(255*t),o=Math.floor(255*n),l=Math.floor(255*r);for(let e=0;e<4;e++){const t=4*e;i[t]=s,i[t+1]=a,i[t+2]=o,i[t+3]=l}const h=new ye(i,1,1,be);return h.needsUpdate=!0,h},Ii=e("N",e=>Di(null,e)),Di=e("aq",(e,t)=>{e||(e=Oi()),e.name=t.id?t.id.toString():"",void 0!==t.shading.metallic&&(e.metalness=1===t.shading.metallic?1:.5,e.reflectivity=xe(t.shading.metallic,.5));let n=!1;if(t.shading.transmission&&t.shading.transmission>0?(e.opacity=1-t.shading.transmission,e.transparent=!0,e.depthWrite=!1,e.metalness=0,n=!0):void 0!==t.shading.alpha&&t.shading.alpha<1&&(e.transparent=t.shading.alpha<1,e.opacity=t.shading.alpha,e.depthWrite=t.shading.alpha>=1,e.metalness=.5*Math.max(0,t.shading.alpha),n=!0),e.aoMapIntensity=xe(t.shading.occlusion,1),e.roughness=xe(t.shading.roughness,.5),e.alphaTest=xe(t.shading.alphaCutoff,0),void 0!==t.shading.basecolor){const n=new h(t.shading.basecolor.r,t.shading.basecolor.g,t.shading.basecolor.b);e.color.copy(n.convertSRGBToLinear())}return n||t.shading.doubleSided?e.side=B:e.side=he,e.map||(Ai||(Ai=Ei()),e.map=Ai),e}),Oi=()=>Ti.createMeshPhysicalMaterial({});e("ar",e=>{let t=e.color.clone().convertLinearToSRGB(),n={alpha:e.opacity,metallic:e.reflectivity,basecolor:{r:t.r,g:t.g,b:t.b},roughness:e.roughness,doubleSided:e.side===B,alphaCutoff:e.alphaTest,transmission:e.transmission};return 1===e.metalness?n.metallic=1:n.metallic=e.reflectivity,n});let Li=null;const ki=e("O",(e,t,n,r,i,s,a=16)=>(Li||(Li=new E,Li.crossOrigin=""),new Promise((o,l)=>{if(!e)return console.warn("trying to add a texture without image",t),void o();Li.load(e,e=>{Ui(e,t,n,r,i,s,a),o()},l)}))),Ui=e("as",(e,t,n,r,i,s,a=16)=>{e.anisotropy=r,e.wrapS=L,e.wrapT=L,"ORM"===t.mapping&&a<=8?console.warn("ORM maps are not supported on devices with only "+a+" texture units"):(e.repeat.set(i,s),"XYZ"===t.mapping?(n.normalMap=e,n.map===Ei()&&(n.map=null)):"ORM"===t.mapping?(n.aoMap=e,n.roughnessMap=e,n.metalnessMap=e):(e.colorSpace=x,n.map=e),"RGBA"===t.mapping&&(n.transparent=!0,n.name.includes("glow")&&(n.emissiveIntensity=.5,n.emissive=new h(16777215),n.emissiveMap=n.map)),n.needsUpdate=!0)}),Fi=e("Q",(e=!0)=>(window.__RML_GUI__||(window.__RML_GUI__=new Mi({autoPlace:e})),window.__RML_GUI__)),Ni=(e("ah",(e,t)=>{let n=!1;for(const r of t){const t=r.getKernelObject();let i;if(2===t.wallType.value&&(i=pr(t.rightNormal)),1===t.wallType.value&&(i=pr(t.leftNormal)),!i)continue;let s=pr(r.getPlanElement().getCenter());s=s.applyMatrix4(e.matrixWorldInverse),i=i.transformDirection(e.matrixWorldInverse);const a=s.dot(i)>=0;a!==r.getContainer().visible&&(n=!0),a?r.show():r.isSelected||r.hide()}return n}),e("ak",(e,t,n=!0)=>{if(!e.userData.tween)if(t)if(e.transparent=!0,n){let t={opacity:1};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:.2},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.userData.tween=!1}).start()}else e.opacity=.2;else if(n){let t={opacity:.2};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:1},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.transparent=!1,e.userData.tween=!1}).start()}else e.opacity=1,e.transparent=!1}),e("a0",(e,t)=>{e.traverse(e=>{if(e instanceof H&&TWEEN){const n=e.material;e.userData.tween&&e.userData.tween.stop();const r={opacity:n.opacity};t.transparent&&(n.transparent=t.transparent),e.userData.tween=new TWEEN.Tween(r).to(t,250).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{n.opacity=r.opacity}).onStop(()=>{t.transparent||(n.transparent=t.transparent),n.opacity=t.opacity,n.needsUpdate=!0,e.userData.tween=void 0}).onComplete(()=>{t.transparent||(n.transparent=t.transparent),n.needsUpdate=!0,e.userData.tween=void 0}).start()}})}),e("ai",e=>{e.traverse(e=>{if(e instanceof H&&TWEEN){let t=e.material;if(0===t.opacity)return;let n={opacity:0,transparent:!0},r={opacity:t.opacity,transparent:t.transparent};t.transparent=n.transparent,t.opacity=n.opacity,new TWEEN.Tween(n).to(r,500).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{t.opacity=n.opacity}).onComplete(()=>{t.transparent=r.transparent}).start()}})})),Bi=e("o",e=>{"Mesh"===e.type?Gi(e):ji(e)}),ji=e=>{e&&e.children&&0!==e.children.length&&e.children.forEach(e=>{Gi(e)})},Gi=e("d",e=>{e&&(e.material&&zi(e.material),e.geometry&&Hi(e.geometry),e.children&&e.children.length>0&&ji(e))}),Hi=e=>{e&&e.dispose()},zi=e=>{e&&(e.map&&e.map.dispose(),e.normalMap&&e.normalMap.dispose(),e.dispose())};let Vi;e("v",e=>0===e.x&&0===e.y&&0===e.z);const Wi=(e,t)=>{let n="";return e||""===e?(e.materialId&&""!==e.materialId?n=e.materialId:e.catalogItemId&&""!==e.catalogItemId?n=e.catalogItemId:e.rgbValue>0?n="rgb"+JSON.stringify(e.rgbValue):e.length>0?n=e:t&&1===t.value?n="default_wall_material_"+e.getSourceType().value:t&&7===t.value&&(n="default_ceiling_material_"+e.getSourceType().value),n):null},Ki=(e("p",e=>{let t=e.getWorldDirection(new a).clone();t.y=0,t.lengthSq()<.01&&(t=new a(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}),e("K",(e,t)=>{if(!e||!t)return 0;const n=e.clone().expandByScalar(.001).containsBox(t),r=t.clone().expandByScalar(.001).containsBox(e);return r&&n||!r&&!n?0:!0===n?1:-1}),e("al",(e,t,n,r=1)=>{const i=t>n,s=i?15:0,o=i?0:10,l=e.getSize(new a),h=e.getCenter(new a);let d=l.x>2*s?l.x/2:s,c=l.z>2*o?l.z/2:o;return d*=r,c*=r,new ge(new a(h.x-d,h.y,h.z-c),new a(h.x+d,h.y,h.z+c))}),e("ad",e=>{const{x:t,y:n}=e;return{x:t,y:n}})),qi=e=>{const{x:t,y:n,z:r}=e;return{x:t,y:n,z:r}};e("aj",(e,t,n)=>(new a).setFromSphericalCoords(e,Math.PI*(1-n),2*Math.PI*(1-t))),e("n",e=>{const t=new Ce;return t.environment=e.environment.clone(),t.userData.environmentDefinition=e.userData.environmentDefinition.clone(),t.userData.shadowFromEnvironment=e.userData.shadowFromEnvironment,t});const Xi=e("h",{CAMERA_2D:"2D",CAMERA_3D:"3D",CAMERA_FP:"FP"});e("X",e=>{if(!e)return Xi.CAMERA_3D;let t=e.toUpperCase();return-1===Object.values(Xi).indexOf(t)&&(t=Xi.CAMERA_3D),t});var Qi=e("$","static/default_256-f1c66a2764f88cc0.exr");class Yi{constructor(e){this.autoQuality=!1,this.colors=Se,this.unit=null,this.unitStringType=null,this.meshSelection=!0,this.stats=!1,this._measureTraffic=!1,this.disableDebugGUI=!1,this.disableEnvMap=!1,this.envMapUrl=Qi,this.envMapIntensity=1.5,this.envMapRotation=0,this.maxLightSources=-1,this.legacyLight=!1,this.sceneLight=!1,this.restrictionLevel=0,this.e2e=!1,this.highlighting=Me.SMART,this.dls=null,this.ls=null,this.cameraSpacing=0,this.transparentHighlighting=!0,this.featureFlags={pulsePreview:!1,reDock:!1},this.mode=Xi.CAMERA_3D,this.edit=!1,this.moc=!1,this.callbacksOnlyIfGeometryIsReady=!0,this._creator_=e}setOverrides(e){Te(this,e)}}e("ax",Yi);const Zi=["language","browserLanguage","userLanguage","systemLanguage"];e("a4",/^((?!chrome|android).)*safari/i.test(navigator.userAgent));class Ji{constructor(e){this.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,n=Zi.length;e<n;e++){const n=t[Zi[e]];if(n)return n.substr(0,2)}return"en"})()||"en",this.overrideCountry=null,this._creator_=e}setOverrides(e){Te(this,e)}}e("aw",Ji);class $i{_setMute(e){Pe(this,"_isMute",!0),this._isMute=e,Pe(this,"_isMute",!1)}mute(){this._setMute(!0)}unmute(){this._setMute(!1)}constructor(e){return this._isMute=!1,this.cameraStartsMoving=()=>{},this._creator_=e,Ae(this,"_isMute",{enumerable:!1,writable:!1}),Ae($i.prototype,"_setMute",{enumerable:!1,writable:!1}),Ae($i.prototype,"mute",{enumerable:!1,writable:!1}),Ae($i.prototype,"unmute",{enumerable:!1,writable:!1}),new Proxy(this,this)}get(e,t){return this._isMute&&"function"==typeof this[t]&&"on"===t.substr(0,2)?()=>{}:this[t]}}e("at",$i);class es extends $i{constructor(){super(...arguments),this.onNetworkRequest=(e,t,n)=>{},this.onKernelMsg=(e,t,n={})=>{},this.onCheckExternalCache=async(e,t)=>Promise.resolve(null),this.onValidateNetworkResponse=(e,t)=>Promise.resolve(!0)}}e("av",es),e("e",{HSC:"rml-configurator",HSP:"rml-hsp",GLB:"rml-glb",RMV:"rml-mv"});class ts{get element(){return this._container}constructor(e){this._creator_=e,this._lifeCycleManager.addEventListener(this)}setDomElement(e){if(!this._container){this._container=document.createElement("div"),this._container.classList.add("rml-threejs-canvas-container"),this._container.setAttribute("ondragover","return false"),this._container.style.position="relative",this._container.style.width="100%",this._container.style.height="100%";const t=document.createElement("style");t.innerText=".rml-threejs-canvas-container canvas{position:absolute;top:0;left:0;right:0;bottom:0;z-index:100; opacity:1;}",this._container.appendChild(t),e.appendChild(this._container)}this._element=e}getClientDimensions(){return new s(this._element.clientWidth,this._element.clientHeight)}_removeDomElement(e){if(!e)return;const t=e.parentElement;t&&t.removeChild(e)}reset(){this._element=null,this._removeDomElement(this._container),this._container=null}pause(){this.reset()}resume(){}destroy(){}}tn([rn],ts.prototype,"_lifeCycleManager",void 0),e("az",class{constructor(e){this._creator_=e}setScene(e){}setUiScene(e){}updateBounds(e){}clearScene(e,t){}moveCameraEnd(e){}moveCameraStart(e){}needsUiScene(){return!1}});class ns{constructor(e){this._plugins=[],this._creator_=e}async init(e,n,r){this._scene=e,this._uiScene=n,this._cameraPosition=r;const{bananaForScale:i}=this._initData;i&&await t.import("./banana-for-scale-381d6064.nomodule.js").then(({default:e})=>this._plugins.push(new e(this._creator_))),this._plugins.forEach(e=>e.setScene(this._scene)),this._plugins.forEach(e=>e.setUiScene(this._uiScene)),this._plugins.forEach(e=>e.updateBounds(this._bounds)),this._plugins.forEach(e=>e.moveCameraEnd(this._cameraPosition))}addPlugin(e){this._plugins.push(e),e.setScene(this._scene),e.setUiScene(this._uiScene),e.updateBounds(this._bounds),e.moveCameraEnd(this._cameraPosition)}updateBounds(e){this._bounds=e,this._plugins.forEach(t=>t.updateBounds(e))}clearScene(e,t){this._plugins.forEach(n=>n.clearScene(e,t))}getActivePlugins(){return this._plugins}getPlugin(e){for(let t of this._plugins)if(t instanceof e)return t;return null}moveCameraEnd(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraEnd(e))}moveCameraStart(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraStart(e))}needsUiScene(){return this._plugins.map(e=>e.needsUiScene()).reduce((e,t)=>e||t,!1)}}tn([rn],ns.prototype,"_initData",void 0);class rs{constructor(e,t){this._waitingPromises=[],this._finishPromiseExecutor=[],this._errorCallback=()=>{},Promise.allSettled=Promise.allSettled||(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),e&&this.registerCallback(e),t&&(this._errorCallback=t)}push(e){this._waitingPromises.push(e),Promise.all(this._waitingPromises).then(e=>{e.length===this._waitingPromises.length&&(this._callback&&this._callback(e),this._waitingPromises=[])},this._errorCallback)}finished(e=!1){return new Promise((t,n)=>{this._finishPromiseExecutor.push({resolve:t,reject:n});const r=e?"allSettled":"all";Promise[r](this._waitingPromises).then(e=>{if("allSettled"===r){const t=[];e.forEach(({value:e,status:n})=>{"fulfilled"===n&&t.push(e)}),this._resolveAllExecutors(t)}else this._resolveAllExecutors(e)},e=>{this._rejectAllExecutors(e)})})}registerCallback(e){this._callback=e}unregisterCallback(){this._callback=null}_resolveAllExecutors(e){this._finishPromiseExecutor.forEach(({resolve:t})=>t(e)),this._finishPromiseExecutor=[]}_rejectAllExecutors(e){this._finishPromiseExecutor.forEach(({reject:t})=>t(e)),this._finishPromiseExecutor=[]}clear(){const e=this._waitingPromises.length>0;this._waitingPromises=[],e?this._rejectAllExecutors(new Error("Promise queue has been cleared")):this._resolveAllExecutors([])}get length(){return this._waitingPromises.length}}class is{constructor(e){this.materialQueue=new rs,this._geometryComponentMaterialCache=new Map,this._maxAnisotropy=1,this._maxTextures=16,this._textureLoader=new E,this._configuratorPreviewMaterial=Ti.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:1,roughness:1,envMap:null,polygonOffset:!0,polygonOffsetFactor:-1}),this._creator_=e,this._previewMaterial=Ti.createMeshStandardMaterial({color:"#DDDDDD",roughness:1,metalness:0})}getGeometry(e){return e&&this._cacheHolder.geometryCache.has(e)?this._cacheHolder.geometryCache.get(e):null}_generateGeometry(e,t,n,r,i){let s;return e&&this._cacheHolder.geometryCache.has(e)?s=this._cacheHolder.geometryCache.get(e):(s=new c,s.setIndex(new Ee(n,1)),s.setAttribute("position",new Re(t,3)),s.setAttribute("normal",new Re(i,3)),s.setAttribute("uv",new Re(r,2)),s.scale(.001,.001,.001),s.rotateX(-Math.PI/2),e&&this._cacheHolder.geometryCache.set(e,s)),s}changeMaterialOfMesh(e,t,n){e&&t?(e.material=t,e.material.transparent||0===e.material.opacity||e.material.transmission>0?(e.castShadow=!1,e.receiveShadow=!1):(e.castShadow=!0,e.receiveShadow=!0),e.material.needsUpdate=!0,this._materialLoaded&&this._materialLoaded(t),this._updateMaterialProperties(e,n)):console.warn("could not assign material to mesh",{mesh:e},{material:t})}_updateMaterialProperties(e,t){var n;if(t&&Object.keys(t).length>0&&e.material instanceof N){const r=e.material.clone();r.userData.materialAttributes=t,t.color&&(r.color=new h(t.color)),t.alpha&&(r.opacity=parseFloat(t.alpha)),t.roughness&&(r.roughness=parseFloat(t.roughness)),t.metallic&&(r.metalness=parseFloat(t.metallic)),r instanceof C&&t.transmission&&(r.transmission=parseFloat(t.transmission)),r.transparent=r.opacity<1;const i=e.material;e.material=r,(null===(n=i.userData)||void 0===n?void 0:n.materialAttributes)&&i.dispose()}}_createMaterial(e,t,n,r,i){if(this._cacheHolder.materialCache.has(e))t();else if(e.startsWith("benchmarkMaterial")){let s=Ie(e),a=Ii(s);this._loadBenchmarkTextures(s,a,r,i).then(t,n)}else this._rapiAccess.getMaterial(e).then(e=>{let s=Ii(e);this._loadTextures(e,s,r,i).then(t,n)},n)}_loadBenchmarkTextures(e,t,n=1,r=1){return new Promise((i,s)=>{const a=De(e.id);ki(this._dataSyncer.requestAsset(a.image,!0),a,t,this._maxAnisotropy,n/(0===a.mmWidth?1:a.mmWidth),r/(0===a.mmHeight?1:a.mmHeight),this._maxTextures).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},s)})}_loadTextures(e,t,n=1,r=1){return new Promise((i,s)=>{if(!e.textures||e.textures&&0===e.textures.length)return this._cacheHolder.materialCache.set(e.id,t),i();this._rapiAccess.getTexturesOf(e).then(a=>{let o=[];a.forEach(e=>{o.push(ki(this._dataSyncer.requestAsset(e.image,!0),e,t,this._maxAnisotropy,n/(0===e.mmWidth?1:e.mmWidth),r/(0===e.mmHeight?1:e.mmHeight),this._maxTextures))}),Promise.all(o).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},s)})})}_loadMaterial(e,t,n){return new Promise((r,i)=>{this._singlePromiseFactory.create(6,e,(r,i)=>this._createMaterial(e,r,i,t,n)).then(()=>{setTimeout(()=>r(this._cacheHolder.materialCache.get(e)),0)},i)})}_assignMaterial(e,t,n){return this._cacheHolder.materialCache.has(t)?(this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t),n),Promise.resolve()):new Promise((r,i)=>{this._loadMaterial(t).then(i=>{e.userData.materialId===t&&this.changeMaterialOfMesh(e,i,n),r()},i)})}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy=e}get maxTextures(){return this._maxTextures}set maxTextures(e){this._maxTextures=e}clear(){this._cacheHolder.clear()}_assignRGB(e,t){return new Promise(n=>{let r,i="rgb"+JSON.stringify(t);this._cacheHolder.materialCache.has(i)?r=this._cacheHolder.materialCache.get(i):(r=Ti.createMeshPhysicalMaterial({color:t}),this._cacheHolder.materialCache.set(i,r)),this.changeMaterialOfMesh(e,r),setTimeout(()=>n(),0)})}_assignItem(e,t){return new Promise((n,r)=>{if(this._cacheHolder.materialCache.has(t))return this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t)),void n();this._rapiAccess.getItem(t).then(i=>{if(i.topImage)this._textureLoader.load(i.topImage,r=>{r.anisotropy=this._maxAnisotropy,r.wrapS=L,r.wrapT=L;let a=new s(1,1);i.width>0&&(a.x=1/i.width),i.depth>0&&(a.y=1/i.depth),r.repeat.set(a.x,a.y);const o=Ti.createMeshPhysicalMaterial({map:r,roughness:.5,metalness:.1});this._cacheHolder.materialCache.set(t,o),this.changeMaterialOfMesh(e,o),setTimeout(()=>n(),0)});else{const e="can not set material, catalog item top image is not set";console.warn(e),r(e)}},r)})}setMaterialLoadedListener(e){this._materialLoaded=e}removeMaterialLoadedListener(){this._materialLoaded=void 0}_createMesh(e,t,n){if(e&&t){const r=this._getComponentMeshId(e,t);if(this._geometryComponentMaterialCache.has(r)){const e=this._geometryComponentMaterialCache.get(r);if(this._cacheHolder.materialCache.has(e)){const t=this._cacheHolder.materialCache.get(e);return new H(n,t)}}}return new H(n,this._configuratorPreviewMaterial.clone())}_getComponentMeshId(e,t){return e+"_"+t}}tn([rn],is.prototype,"_initData",void 0),tn([rn],is.prototype,"_rapiAccess",void 0),tn([rn],is.prototype,"_dataSyncer",void 0),tn([rn],is.prototype,"_singlePromiseFactory",void 0),tn([rn],is.prototype,"_cacheHolder",void 0),tn([rn],is.prototype,"_plannerMeshGenerator",void 0);class ss extends is{constructor(e){super(e)}generateMesh(e=0,t=null,n,r,i,s,a,o=!1,l){let h;h=o?this._generateGeometry(t,r,i,s,a).clone():this._generateGeometry(t,r,i,s,a);const d=this._createMesh(e,t,h);return d.userData.materialId=n,d.layers.set(4),n&&this.materialQueue.push(this._assignMaterial(d,n,l).then(()=>{e&&t&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n)})),d}setMaterial(e,t,n,r){return this._assignMaterial(e,t,r)}loadMaterial(e,t,n){return super._loadMaterial(e,t,n)}loadTextures(e,t,n,r){return super._loadTextures(e,t,n,r)}}e("au",ss);class as{constructor(){this._listeners={},this._disabled=!1}_addEventListener(e,t,n){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push({callback:t,scope:n})}addEventListener(e,t,n){this._addEventListener(e,t,n)}dispatchEvent(e,t){if(!this._listeners[e]||this._disabled)return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++){const r=n[e];t?r.callback.apply(r.scope,[t]):r.callback.call(r.scope)}}removeEventListener(e,t){const n=this._listeners[e];if(n)for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t)return void n.splice(e,1)}enableEvents(){this._disabled=!1}disableEvents(){this._disabled=!0}}e("E",as);const os={SCROLL:"scroll",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_LEAVE:"mouseleave",MOUSE_ENTER:"mouseenter",MOUSE_WHEEL:"wheel",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend",CONTEXT_MENU:"contextmenu",DOUBLE_CLICK:"dblclick"};e("a8",{DRAG:50});class ls{constructor(e,t,n,r,i){this.position=e,this.positionRelative=t,this.type=n,this.rotation=r,this.event=i}}const hs=e("U",5*window.devicePixelRatio),ds=3*window.devicePixelRatio;class cs extends as{constructor(e){super(),this._elementHit=!1,this._delta=-1,this._state=0,this._pinchDistance=-1,this._rotationAngle=-1,this._lastMouseWheelEvent=null,this._lastTouchEvent=null,this._events=Object.keys(os).map(e=>os[e]),this._boundingClientRectInvalid=!0,this._creator_=e,this._downPosition={x:0,y:0},this._downPositionRelative={x:0,y:0},this._boundingClientRect=this._getBoundingClientRect()}enableDragIn(e){this._setState(1),this._dragEnabled=!0,e&&(this._dragMV=this._dragM.bind(this),this._dragEV=this._dragE.bind(this),this._dragTarget=e.currentTarget||e.target,this._delta=-1,this._dragMVName="drag",this._dragEVName="dragend",window.TouchEvent&&e instanceof TouchEvent?(this._dragMVName="touchmove",this._dragEVName="touchend"):e.dataTransfer&&e.dataTransfer.setData&&e.dataTransfer.setData("text/plain"," "),this._firefoxDragPosition={x:0,y:0},document.ondragover=e=>{e=e||window.event,this._firefoxDragPosition.x=e.pageX,this._firefoxDragPosition.y=e.pageY},this._dragTarget.addEventListener(this._dragMVName,this._dragMV,!1),this._dragTarget.addEventListener(this._dragEVName,this._dragEV,!1))}isMouseUp(){return 0===this._state}_dragM(e){let t=e,n=null,r=null;window.TouchEvent&&e instanceof TouchEvent?(n=this._getTouchPosition(t),r=this._getTouchPositionRelative(t)):(n=this._getMousePosition(t),r=this._getMousePositionRelative(t)),n.x>0&&n.y>0&&this._move(n,r)}_dragE(e){let t=e;document.ondragover=null,this._firefoxDragPosition=null,this._dragTarget.removeEventListener(this._dragMVName,this._dragMV),this._dragTarget.removeEventListener(this._dragEVName,this._dragEV),window.TouchEvent&&e instanceof TouchEvent?this._onUp(this._getTouchPosition(t),this._getTouchPositionRelative(t),2):this._onUp(this._getMousePosition(t),this._getMousePositionRelative(t),1)}addEvents(e){this._events.forEach(t=>e.addEventListener(t,this,!1)),null===window||void 0===window||window.addEventListener("scroll",this,!1)}removeEvents(e){this._events.forEach(t=>e.removeEventListener(t,this)),null===window||void 0===window||window.removeEventListener("scroll",this)}_move2(e){if(this._lastTouchEvent&&e.timeStamp-this._lastTouchEvent.timeStamp<16)return;const t=e.touches[0],n=e.touches[1],r=t.pageX-n.pageX,i=t.pageY-n.pageY,s=Math.abs(r)+Math.abs(i);this._pinchDistance>-1&&(s>this._pinchDistance+ds?(this._setState(3),this.dispatchEvent(7,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):s<this._pinchDistance-ds?(this._setState(3),this.dispatchEvent(8,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):s<=this._pinchDistance+ds&&s>=this._pinchDistance-ds&&(this._setState(5),this.dispatchEvent(11,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e))))),this._pinchDistance=s,this._lastTouchEvent=e}_setState(e){this._state=e}_move(e,t,n,r){void 0===n&&(n=0),void 0===this._dragEnabled&&(this._dragEnabled=!1),1===this._state&&this._canDrag(n)&&(this._delta=this._getDelta(e),(this._delta>hs||this._elementHit)&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new ls(this._downPosition,this._downPositionRelative)))),2===this._state&&this.dispatchEvent(1,new ls(e,t)),this.dispatchEvent(6,new ls(e,t,n,null,r))}_longClick(e){2!==e&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new ls(this._downPosition,this._downPositionRelative)),this.dispatchEvent(1,new ls(this._downPosition,this._downPositionRelative))),this.dispatchEvent(14,new ls(this._downPosition,this._downPositionRelative,2))}_onUp(e,t,n){this.dispatchEvent(4,new ls(e,t,n)),this._getDelta(e)<=hs&&this.dispatchEvent(5,new ls(e,t)),2===this._state&&this.dispatchEvent(2,new ls(e,t)),4===this._state&&(this.dispatchEvent(10,new ls(e,t)),this._rotationAngle=-1),3===this._state&&(this._pinchDistance=-1),this._lastTouchEvent=null,this._setState(0),this._dragTarget=null,this._elementHit=!1,this._longClickTimer&&clearTimeout(this._longClickTimer)}_getTouchPosition(e){if(e.touches.length){let{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>1){const r=e.touches[1],i=r.clientX,s=r.clientY;t=(t+i)/2,n=(n+s)/2}return{x:t,y:n}}const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}_getTouchPositionRelative(e){const t=this._getBoundingClientRect(),{clientWidth:n,clientHeight:r}=this._domHelper.element;if(e.touches.length){const{clientX:i,clientY:s}=e.touches[0];return{x:(i-t.left)/n*2-1,y:-(s-t.top)/r*2+1}}const i=e.changedTouches[0];return{x:(i.clientX-t.left)/n*2-1,y:-(i.clientY-t.top)/r*2+1}}_getMousePosition(e){if(0!==e.clientX&&0!==e.clientY)return{x:e.clientX,y:e.clientY};{let{x:t,y:n}=this._getFireFoxMousePosition(e);return{x:t,y:n}}}_getFireFoxMousePosition(e){let{x:t,y:n}=this._domHelper.getClientDimensions();return{x:t-(t+e.offsetX),y:n-(n+e.offsetY)}}_getMousePositionRelative(e){const t=this._getBoundingClientRect();return 0!==e.clientX&&0!==e.clientY?{x:(e.clientX-t.left)/this._domHelper.element.clientWidth*2-1,y:-(e.clientY-t.top)/this._domHelper.element.clientHeight*2+1}:this._firefoxDragPosition&&0!==this._firefoxDragPosition.x&&0!==this._firefoxDragPosition.y?{x:(this._firefoxDragPosition.x-t.left)/this._domHelper.element.clientWidth*2-1,y:-(this._firefoxDragPosition.y-t.top)/this._domHelper.element.clientHeight*2+1}:{x:0,y:0}}_getDelta(e){return Math.abs(this._downPosition.y-e.y)+Math.abs(this._downPosition.x-e.x)}setDragEnabled(e){this._dragEnabled=e}handleEvent(e){switch(e.type){case os.SCROLL:this._boundingClientRectInvalid=!0;break;case os.MOUSE_MOVE:this._onMouseMove(e);break;case os.DOUBLE_CLICK:this._onDoubleClick(e);break;case os.MOUSE_DOWN:this._onMouseDown(e);break;case os.MOUSE_UP:this._onMouseUp(e);break;case os.MOUSE_LEAVE:this._onMouseLeave(e);break;case os.MOUSE_ENTER:this._onMouseEnter(e);break;case os.MOUSE_WHEEL:this._onMouseWheel(e);break;case os.TOUCH_MOVE:this._onTouchMove(e);break;case os.TOUCH_START:this._onTouchStart(e);break;case os.TOUCH_END:this._onTouchEnd(e);break;case os.CONTEXT_MENU:this._onContextMenu(e)}}_onMouseDown(e){if(e.preventDefault(),2===e.detail)return;let{x:t,y:n}=this._getMousePosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getMousePositionRelative(e),this.dispatchEvent(3,new ls({x:t,y:n},this._downPositionRelative,1)),this._setState(1)}_onMouseUp(e){e.preventDefault(),2!==e.detail&&this._onUp(this._getMousePosition(e),this._getMousePositionRelative(e),1)}_onMouseMove(e){e.preventDefault(),this._move(this._getMousePosition(e),this._getMousePositionRelative(e),1,e)}_onDoubleClick(e){e.preventDefault(),this.dispatchEvent(12,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1))}_onMouseLeave(e){var t;this._delta=-1,(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest('[data-rml-sdk="ignore-mouse-leave"]'))||this._onMouseUp(e)}_onMouseEnter(e){e.preventDefault()}_onMouseWheel(e){if(this._lastMouseWheelEvent&&e.timeStamp-this._lastMouseWheelEvent.timeStamp<40)return e.preventDefault(),void e.stopPropagation();e.deltaY<0?this.dispatchEvent(7,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)):this.dispatchEvent(8,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)),this._lastMouseWheelEvent=e}_onTouchMove(e){if(e.preventDefault(),!this._dragTarget)if(1===e.touches.length)this._move(this._getTouchPosition(e),this._getTouchPositionRelative(e),2);else if(2===e.touches.length)if(this._elementHit||4===this._state){const r=e.touches[0],i=e.touches[1],s=function(e){let t=cr(e);return t<0&&(t=180+(180+t)),t}((t={x:r.pageX,y:r.pageY},n={x:i.pageX,y:i.pageY},Math.atan2(n.y-t.y,n.x-t.x)));this._rotationAngle<0&&(this._rotationAngle=s);const a=s-this._rotationAngle;this._rotationAngle=s,this.dispatchEvent(9,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e),2,dr(a))),this._setState(4)}else this._move2(e);var t,n}_onTouchStart(e){if(e.preventDefault(),1===e.touches.length){let{x:t,y:n}=this._getTouchPosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getTouchPositionRelative(e),this.dispatchEvent(3,new ls({x:t,y:n},this._downPositionRelative,2)),this._setState(1),this._longClickTimer=window.setTimeout(this._longClick.bind(this,2),350)}else 2===e.touches.length&&(1!==this._state&&2!==this._state||this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2),this._setState(3))}_onTouchEnd(e){e.preventDefault(),e.touches.length>1&&5===this._state||3===this._state||(this.dispatchEvent(13,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)),this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2))}_onContextMenu(e){e.preventDefault()}_canDrag(e){return this._dragEnabled}onElementHit(){this._elementHit=!0}_getBoundingClientRect(){return this._boundingClientRectInvalid&&(this._boundingClientRect=this._domHelper.element.getBoundingClientRect(),this._boundingClientRectInvalid=!1),this._boundingClientRect}updateSize(){this._boundingClientRectInvalid=!0}}e("ao",cs),tn([rn],cs.prototype,"_domHelper",void 0);class us{constructor(e){const{component:t,resetCamera:n,consecutive:r}=e;this.component=t,this.resetCamera=void 0===n||n,this.consecutive=void 0===r||r}}class ps extends f{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new v(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(e){const n=i.parse(JSON.parse(e));t&&t(n)}),n,r)}parse(e){return new ms(e)}}class ms{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],r=function(e,t,n){const r=Array.from(e),i=t/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,a=[];let o=0,l=0;for(let e=0;e<r.length;e++){const t=r[e];if("\n"===t)o=0,l-=s;else{const e=gs(t,i,o,l,n);o+=e.offsetX,a.push(e.path)}}return a}(e,t,this.data);for(let e=0,t=r.length;e<t;e++)n.push(...r[e].toShapes());return n}}function gs(e,t,n,r,i){const s=i.glyphs[e]||i.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+i.familyName+".");const a=new Oe;let o,l,h,d,c,u,p,m;if(s.o){const e=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let i=0,s=e.length;i<s;)switch(e[i++]){case"m":o=e[i++]*t+n,l=e[i++]*t+r,a.moveTo(o,l);break;case"l":o=e[i++]*t+n,l=e[i++]*t+r,a.lineTo(o,l);break;case"q":h=e[i++]*t+n,d=e[i++]*t+r,c=e[i++]*t+n,u=e[i++]*t+r,a.quadraticCurveTo(c,u,h,d);break;case"b":h=e[i++]*t+n,d=e[i++]*t+r,c=e[i++]*t+n,u=e[i++]*t+r,p=e[i++]*t+n,m=e[i++]*t+r,a.bezierCurveTo(c,u,p,m,h,d)}}return{offsetX:s.ha*t,path:a}}const fs=new Map,_s=new Map;class vs{static loadFont(e){if(_s.has(e))return new Promise(t=>{t(_s.get(e))});if(fs.has(e))return new Promise((t,n)=>{fs.get(e).push({resolve:t,reject:n})});let t=new ps;return new Promise((r,i)=>{fs.set(e,[{resolve:r,reject:i}]),t.load(n()+e,t=>{_s.set(e,t),vs._resolveAll(e,t)})})}static _resolveAll(e,t){fs.has(e)&&fs.get(e).forEach(e=>e.resolve(t)),fs.delete(e)}}e("ay",vs);class ws{constructor(e){this._activeComponents=[],this._componentDimensioningsExist=new Map,this._creator_=e}setCamera(e){this._camera=e}add(e){if(this._componentDimensioningsExist.has(e.runtimeId)&&!this._componentDimensioningsExist.get(e.runtimeId))return!1;const n=this._plannerKernelAccess.kernelInstance.getComponent(e.runtimeId),r=n.dimensionings;if(this._componentDimensioningsExist.set(e.runtimeId,r.length>0),!r||0===r.length||this._camera.position.z<0)return!1;const i=Pi(n.boxForMeasurement),s={x:this._camera.position.x,y:this._camera.position.z};return t.import("./component-dimensioning-1f3f5178.nomodule.js").then(t=>{vs.loadFont("static/rubik_regular-bc008a7de2daee79.json").then(n=>{r.forEach(r=>{var a;e.add(new t.default(((a=r).from=a.from/1e3,a.to=a.to/1e3,1===a.type.value?(a.type={value:2},a.from*=-1,a.to*=-1):2===a.type.value&&(a.type={value:1}),a),i,n,s))})})}),this._activeComponents.push(e),!0}remove(e,n=!0){return new Promise(r=>{t.import("./component-dimensioning-1f3f5178.nomodule.js").then(t=>{let i=[];e.children.forEach(e=>{e instanceof t.default&&i.push(e)}),i.forEach(t=>{e.remove(t),Bi(t)}),n&&Le(this._activeComponents,e),r()})})}hasComponentDimensions(){return this._activeComponents.length>0}async reset(){for(const e of this._activeComponents)await this.remove(e);this._activeComponents=[]}invalidateDimensioningsCache(e){e?this._componentDimensioningsExist.delete(e):this._componentDimensioningsExist.clear()}}tn([rn],ws.prototype,"_plannerKernelAccess",void 0);class bs{constructor(){this._promiseExecutors=[]}create(){return new Promise((e,t)=>{this._promiseExecutors.push({resolve:e,reject:t})})}resolve(e){return new Promise(t=>{this._promiseExecutors.forEach(t=>t.resolve(e)),this._promiseExecutors=[],t(e)})}reject(e){return new Promise((t,n)=>{this._promiseExecutors.forEach(t=>t.reject(e)),this._promiseExecutors=[],n(e)})}}class ys extends class{constructor(e){this._coreReference=e.clone()}clearReference(){this._coreReference.delete(),this._coreReference=null}getKernelObject(){return this._coreReference}}{constructor(e){super(e),this._objectWaiter=new bs,this._topView=!1;const t=pr(e.getCenter());this._container=new A,this._container.position.copy(t),this._boundingBox=this._generateBoundingBox(),Ni(this._boundingBox),this._container.add(this._boundingBox),2!==this.getPlanElement().getType().value&&(this._object=new A,this._container.add(this._object))}getSize(){return this._object?(new ge).setFromObject(this._object).getSize(new a):new a}update(){this._container.position.copy(pr(this.getPlanElement().getMeshCenter())),this._boundingBox&&this._updateBoundingBox()}_updateBoundingBox(){const e=this.getSize();this._boundingBox.geometry=new ke(e.x,e.y,e.z),this._boundingBox.position.y=e.y/2}getPosition(){return this._container.position}getRotation(){return this._container.rotation.y}getBounds(){let e;return this.getPlanElement().boxForMeasurement?(e=Pi(this.getPlanElement().boxForMeasurement),e.applyMatrix4(this.getContainer().matrix)):(e=new ge,e.setFromObject(this._container)),e}getBoundingBox(){return this._boundingBox}getPlanElement(){return this._coreReference}setObject(e){this._object=e,this._objectWaiter.resolve(e)}getObject(){return this._object}async getObjectAsync(){return this._object?Promise.resolve(this._object):this._objectWaiter.create()}addMesh(e){this._object.add(e),this.hidePreviewBox()}getMesh(e){if(!this._object||0===this._object.children.length)return null;const t=Wi(e,this.getPlanElement().getType());return this._object.children.find(e=>e.userData.material===t)}getContainer(){return this._container}getId(){return this.getPlanElement().getId()}clear(){Bi(this._container),this._selectionMesh&&Bi(this._selectionMesh)}remove(){var e;null===(e=this._container.parent)||void 0===e||e.remove(this._container),this.clear()}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material=(Vi||(Vi=new y,Vi.visible=!1),Vi))}_generateBoundingBox(){const e=this.getSize(),t=new ke(e.x,e.y,e.z);let n=new h("#DDDDDD");const r=this.getPlanElement().customColor;r>0&&(n=(e=>{let t=new h;return t.setRGB((e>>16)/255,(e>>8&255)/255,(e>>0&255)/255),t})(r));let i=Ti.createMeshStandardMaterial({color:n,opacity:1,transparent:!0}),s=new H(t,i);return s.name="bounding box",s.position.y=e.y/2,s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),s}select(){this._isSelected=!0,this._selectionMesh&&this._container.add(this._selectionMesh)}deselect(){this._isSelected=!1,this._selectionMesh&&this._container.remove(this._selectionMesh)}hoverOn(){}hoverOff(){}setTopView(e){this._topView=e}}class xs extends ys{constructor(e){super(e),this._initDone=!1,this._initFailed=null,this._initWaiter=new bs,this._container.rotation.y=e.rotation}finishInit(){return this._initDone=!0,this._initFailed=null,this._initWaiter.resolve()}failInit(e){return this._initFailed=e,this._initDone=!1,this._initWaiter.reject(this._initFailed)}isInitDone(){return this._initDone?Promise.resolve():this._initFailed?Promise.reject(this._initFailed):this._initWaiter.create()}getPlanObject(){return this.getPlanElement()}getSize(){return mr(this.getPlanObject().size)}update(){super.update(),this._container.rotation.y=this.getPlanObject().rotation}}class Cs extends xs{constructor(e){super(e),this._container.name="Configurable "+this._container.name}addRootComponent(e){this.setObject(e),this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId,this._container.add(this.getObject())}getConfigurationRuntimeId(){return this.getPlanObject().getConfigurationRuntimeId()}getRootComponentId(){return this._rootComponentId}getRootComponentRuntimeId(){return this._rootComponentRuntimeId}finishConstruction(){return this.finishInit()}failConstruction(){return this.failInit(new Error("Construction of configuration failed"))}}e("a6",Cs);let Ss=JSON.parse(JSON.stringify({isProduction:!0,isUnitTesting:!1,environment:"production",detailEnvironment:"development",features:{},APP:{RAPI:{server:"/api/v2",localReverseProxy:"https://www.roomle.com/api/v2",liveServer:"https://www.roomle.com/api/v2",testServer:"https://www.test.roomle.com/api/v2",headers:{apiKey:"roomle_portal_v2",currentTenant:9,locale:"en",language:"en",device:1,token:"anonymous",platform:"web"},itemHeaders:{assetRevision:"glb",assetFileFormat:"glb"}},SHORTENER_URL:"http://rml.co/"},environments:{PRODUCTION:"production",DEVELOPMENT:"development",TEST:"test",TEST_SERVER:"test_server",ALPHA:"alpha"}}));Ss.isUnitTesting=!1,void 0!==t&&t.exports||(window.IS_DEBUG=!0);const Ms={ENV_DEBUG:function(e=!1){if(e){let e=JSON.parse(JSON.stringify(Ss));const t={...e.APP,SHORTENER_URL:"http://localhost:4747/?isItem=false&id="},n={...e.features};return{...e,isProduction:!1,APP:t,features:n}}}(),ENV_PRODUCTION:JSON.parse(JSON.stringify(Ss))};var Ts=e("f",Ms.ENV_PRODUCTION);class Ps extends xs{constructor(e){super(e),this._originalSize=new a,this._container.name="Static "+this._container.name}setRapiItem(e){return this._rapiItem?Promise.resolve():this._addStaticItem(e)}async _addStaticItem(e){this._rapiItem=e;let t=this.getPlanObject();if(this._glbUrl=Ue(e),!this._glbUrl)return Promise.reject("No glb url found");let n=e.scaleable?mr(t.size):void 0,r=new a(1,1,1);t.flipX&&(r.x*=-1),t.flipY&&(r.z*=-1);try{const i=await this._staticItemLoader.loadGLB(this._glbUrl,void 0,void 0,n,r,t.customColor,e.colorable);this._originalSize.copy(i.boundingBox.getSize(new a)),i.scene.name=e.label,this.setObject(i.scene),((e,t)=>{let n=(new ge).setFromObject(e),r=n.getSize(new a),i=Math.min(r.x,r.y,r.z),s=!0;i>5&&(console.warn("GLB seems to be too big ("+i+")",t),s=!1),n.min.y<-.01&&(console.warn("GLB seems to be under the floor ("+n.min.y+"): ",t),s=!1)})(i.scene,this._glbUrl),Ni(i.scene),this._container.add(this.getObject()),this.hidePreviewBox(),await this.finishInit()}catch(e){await this.failInit(e)}}getRapiItem(){return this._rapiItem}needsRapiItem(){return!this._glbUrl}getGLBUrl(){return this._glbUrl}update(){const e=mr(this.getPlanElement().size),t=this.getObject();if(!t)return;if(e){const{x:n,y:r,z:i}=this._originalSize;let s=new a(e.x/n,e.y/r,e.z/i);t.scale.copy(s)}this.getPlanElement().flipX&&(t.scale.x*=-1),this.getPlanElement().flipY&&(t.scale.z*=-1);const n=this.getPlanElement().customColor;t.traverse(e=>{if(e instanceof H&&e.material instanceof N){const t=e.material;if(this._rapiItem.colorable&&n&&n>0){let e=new h(n);t.color=e.copySRGBToLinear(e)}t.needsUpdate=!0}}),super.update()}}let As;e("a7",Ps),tn([rn],Ps.prototype,"_staticItemLoader",void 0),e("am",e=>{const{id:t,textRotation:n,length:r,lengthFormatted:i}=e;return{id:t,fromWithoutPadding:qi(e.fromWithoutPadding),toWithoutPadding:qi(e.toWithoutPadding),fromPosition3d:qi(e.fromPosition3d),toPosition3d:qi(e.toPosition3d),textPosition3d:qi(e.textPosition3d),fromPosition2d:Ki(e.fromPosition2d),toPosition2d:Ki(e.toPosition2d),textPosition2d:Ki(e.textPosition2d),textDirection:qi(e.textDirection),textRotation:n,length:r,lengthFormatted:i}});const Es=()=>(As||(As=Ti.createMeshPhysicalMaterial({color:0})),As);class Rs extends ys{constructor(e){super(e),this._container.name="Wall Plan Element"}get isSelected(){return this._isSelected}getWallDimension(e){const t=this.getPlanElement(),n=pr(t.getCenter()),r=t.getPreferredSide();let i,s;0===r.value?(i=pr(t.getCornerFromLeft()),s=pr(t.getCornerToLeft())):1===r.value&&(i=pr(t.getCornerFromRight()),s=pr(t.getCornerToRight()));const o=i.clone().add(s).divideScalar(2),l=i.clone().sub(s),h=l.clone().cross(new a(0,1,0)).normalize();h.clone().dot(o.clone().sub(n))<0&&h.multiplyScalar(-1);const d={maxZoomedIn:Math.max(.7,e),maxZoomedOut:.01,minPadding:.05,maxPadding:.25},c=Fe(e,d.maxZoomedIn,d.maxZoomedOut,d.minPadding,d.maxPadding),u=h.clone().multiplyScalar(c/2),p=i.clone().add(u),m=s.clone().add(u),g=h.multiplyScalar(c),f=i.add(g),_=s.add(g),v=l.clone();l.dot(new a(1,0,0))<0&&v.multiplyScalar(-1);const w=Math.atan2(v.z,v.x),b=f.clone().add(_).divideScalar(2);return{id:t.getId(),fromPosition3d:f,toPosition3d:_,textPosition3d:b,textDirection:v,textRotation:w,length:t.getLength(r.value),fromWithoutPadding:p,toWithoutPadding:m}}addMesh(e){e.traverse(e=>{this._setMaterial(e)}),e.layers.set(9),super.addMesh(e);const t=(new ge).setFromObject(this.getObject()).getSize(new a);this._boundingBox.geometry=new ke(t.x,t.y,t.z),this._boundingBox.position.y=t.y/2}show(){var e,t;this.getContainer().visible=!0,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.set(9)}),null===(t=this.getBoundingBox())||void 0===t||t.layers.set(6)}hide(){var e,t;this.getContainer().visible=!1,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.disableAll()}),null===(t=this.getBoundingBox())||void 0===t||t.layers.disableAll()}_enableTopView(){this._container.traverse(e=>{this._setTopMaterial(e)})}_setTopMaterial(e){e instanceof H&&!e.userData.originalMaterial&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial=e.material,e.material=Es())}_disableTopView(){this._container.traverse(e=>{e instanceof H&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial)})}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView()}getKernelObject(){return super.getKernelObject()}_setMaterial(e){e instanceof H&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),this._topView&&this._isSelected?e.material=new y({color:10526880,side:B}):this._topView&&!this._isSelected?e.material=Es():(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial))}select(){super.select(),this._container.traverse(e=>{this._setMaterial(e)})}deselect(){super.deselect(),this._container.traverse(e=>{this._setMaterial(e)})}}e("a1",Rs);class Is extends ys{constructor(e){super(e),this._container.name="Floor Plan Element"}addMesh(e){this.getObject().clear(),super.addMesh(e),e.layers.set(9),e.castShadow=!1,e.position.y=-.001}}e("a2",Is);class Ds extends ys{constructor(e){super(e),this._container.name="Ceiling Plan Element"}addMesh(e){super.addMesh(e),e.castShadow=!1;const t=(new ge).setFromObject(this.getObject()).getSize(new a);this._boundingBox.geometry=new ke(t.x,.01,t.z)}}e("aa",Ds);const Os=new Map;class Ls{static start(e){if(!window.performance||!window.performance.getEntriesByName)return"";let t=window.performance.getEntriesByName(e).length++,n="";t<100&&(n="0"),t<10&&(n="0"+n);const r=t>0?e+"_"+n+t:e,i=r+"_start";return window.performance.mark(i),r}static addMeta(e,t){const n=Ls.getMeta(e);Os.set(e,Object.assign(n,t))}static getMeta(e){return Os.get(e)||{}}static end(e){}static getMeasure(e){return[]}static showBenchmarks(e){const t=window.performance.getEntriesByType("measure");t.sort((function(e,t){return e.startTime-t.startTime}));const n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];e&&-1===i.name.indexOf(e)||n.push({Start:parseFloat(i.startTime.toFixed(2)),Name:i.name,Duration:parseFloat(i.duration.toFixed(2))})}console.table(n)}}e("B",Ls);class ks{static init(e={}){const{kernelInstance:t,kernelContainer:n,planObjectId:r}=e;ks.kernelInstance=t,ks.kernelContainer=n,ks.planObjectId=r}static cleanUp(){ks.useHDGeometry=!1,ks.kernelInstance=null,ks.kernelContainer=null,ks.planObjectId=null}}e("A",ks),ks.useHDGeometry=!1,ks.kernelInstance=null,ks.kernelContainer=null,ks.planObjectId=null;const Us=new Map,Fs=function(e,t,n){let r=Us.get(e);if(r){const i=n?[n]:void 0;r.forEach(({resolve:e,reject:n})=>t?e.apply(e,i):n.apply(n,i)),Us.delete(e)}};class Ns{static finishOperation(e,t){Fs(e,!0,t)}static failOperation(e,t){Fs(e,!1,t)}static waitFor(e,t){return new Promise((n,r)=>{let i=Us.get(e);i||(Us.set(e,[]),i=Us.get(e)),i.push({resolve:n,reject:r}),"function"==typeof t&&t.apply(t)})}}e("y",Ns);const Bs=e("z",(function(e){return e.validRange&&"string"==typeof e.validRange.type})),js=function(e){return e.validValues&&e.validValues.length>0},Gs=e("F",(function(e){return"Material"===e.type}));let Hs,zs,Vs,Ws,Ks;const qs={WASM:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-43c82d370b8f8956.wasm",LOADER:"static/ConfiguratorKernel-ea213aa201ba840d.js"},PLANNER:{URL:"static/RoomleCore-f73eeb183e5a1083.wasm",LOADER:"static/RoomleCore-d31ce9bf62e9202f.js"}},WASM_MODERN:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-da91d76a6e28da63.wasm",LOADER:"static/ConfiguratorKernel-5c4fcff0d630e61b.js"},PLANNER:{URL:"static/RoomleCore-ce88bd5bf57f7e9e.wasm",LOADER:"static/RoomleCore-c9e8fbc848d32a0e.js"}},ASM:{CONFIGURATOR:{MEM_URL:"static/ConfiguratorKernelJs-a2fcb551f73ce77d.mem",LOADER:"static/ConfiguratorKernelJs-567985cbba145249.js"},PLANNER:{MEM_URL:"static/RoomleCoreJs-a388d2a4f4f35743.mem",LOADER:"static/RoomleCoreJs-55a97bc3952d59d2.js"}}},Xs=!!window.WebAssembly;class Qs{_utilityToLongArray(e){const t=new this._kernelContainer.LongArray;return e.forEach(e=>t.push_back(e)),t}constructor(e){this._requestedItemIds=[],this._requestedMaterialIds=[],this._configuratorKernelCallbackListener=new Set,this._cachedGroupIds=[],this._waitingForGroups=!1,this._subComponentsWaiters=new Map,this._shouldWait=!0,this._creator_=e,window.KernelCallback={isReady:this.isReady.bind(this)},this._lifeCycleManager.addEventListener(this)}init(e){this._kernelType=e,this._setupKernelPaths(e),this._setupEmsModule(e),this._useWASM=Xs,this._kernelPath=Xs?Vs:Ws}_initKernel(){const{restrictionLevel:e}=this._initData,t=!1!==this._initData.callbacksOnlyIfGeometryIsReady;this._kernelInstance.setUpdateCallbacksOnlyIfGeometryIsReady(t),this._kernelInstance.setLevel(e),this._unitFormatter.init(this._kernelContainer),this._kernelInstance.setEnvironmentVariable("unit",this._unitFormatter._actualUnitString||"cm"),this._kernelInstance.setEnvironmentVariable("unitString","short"),this._kernelInstance.useEnvironmentGeometry(1===this._kernelType);const{overrideCountry:n,locale:r}=this._globalInitData;n&&(this._kernelInstance.resetPriceListIds(),this._kernelInstance.addPriceList(n)),this._kernelInstance.setEnvironmentVariable("language",r)}get kernelContainer(){return this._kernelContainer}get kernelInstance(){return this._kernelInstance}get configurationExporter(){return this._configurationExporter||(this._configurationExporter=this._kernelContainer.newConfigurationExporter()),this._configurationExporter}_setupKernelPaths(e){const t=0===e?"PLANNER":"CONFIGURATOR";Hs=qs.ASM[t].MEM_URL,Ws=qs.ASM[t].LOADER,WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11]))?(zs=qs.WASM_MODERN[t].URL,Vs=qs.WASM_MODERN[t].LOADER):(zs=qs.WASM[t].URL,Vs=qs.WASM[t].LOADER),Ks=!0}_setupEmsModule(e){const t=this;this._kernelContainer={locateFile(t){const r=0===e?/RoomleCoreJs[\-a-z0-9]*\.js\.mem/:/ConfiguratorKernelJs[\-a-z0-9]*\.js\.mem/;return t.match(r)?n()+Hs:t},wasmBinaryFile:n()+zs,preRun:[],postRun:[],setStatus:null,print(e){t._kernelIo.log(e)},printErr(e){t._kernelIo.error(e)},quit(e){0!==e&&t._kernelIo.throw(e&&e.toString?e.toString():"Unknown error while C/C++ main executes")}},Ks&&Xs&&(this._kernelContainer.instantiateWasm=function(e,t){return((e,t,r)=>{const i="function"==typeof WebAssembly.instantiateStreaming;Ls.addMeta("kernel_is_ready",{cachedInIndexedDB:!1});let s=null;i?(Ls.start("kernel_stream_compile"),s=WebAssembly.instantiateStreaming(fetch(n()+e),t)):(Ls.start("kernel_legacy_compile"),s=fetch(n()+e).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,t))),Ls.addMeta("kernel_is_ready",{instantiateStreaming:i}),s.then(e=>{r(e.instance)},e=>console.error(e))})(zs,e,t),{}})}_passSubComponentsToKernel(e,t){const n=e.id,r=t.get(n);if(r)for(let t=0,i=r.length;t<i;t++){const{parentId:i,partId:s}=r[t];this._kernelIo.setMeta({componentId:n}),this._kernelInstance.loadedSubComponent(i,s,n,e.configuration)}}_fetchSubComponents(e){let t=[...e.keys()];t.length&&this._rapiAccess.getComponents(t).then(t=>{for(let n=0,r=t.length;n<r;n++)this._passSubComponentsToKernel(t[n],e);this._flushSubComponentsWaiters()})}_flushSubComponentsWaiters(){this._fetchSubComponents(this._subComponentsWaiters),this._subComponentsWaiters=new Map,this._shouldWait=!1}isReady(){this._kernelContainer.setExternalHelpers(this._kernelIo,{convertCObject:_r}),Ts.isProduction||Ts.isUnitTesting||this.addDebugInfo(),window.KernelCallback&&(window.KernelCallback=null,delete window.KernelCallback)}addDebugInfo(){const e=function(t,n=[]){const r=Object.getPrototypeOf(t),i=r?Object.getOwnPropertyNames(r):[],s=t?Object.getOwnPropertyNames(t):[];return r?e(r,[...n,...s,...i]):[...s,...i,...n]},t=e(this),n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf"];[...new Set(t)].forEach(e=>{if(!e.startsWith("_")&&"function"==typeof this[e]&&-1===n.indexOf(e))try{const t=this[e].bind(this);this[e]=function(...n){return this._kernelIo.log("[ KernelCommunication ]: "+e),t(...n)}}catch(e){}})}getConfigurationData(e){return new Promise(t=>{var n;const r=this.kernelInstance.getPlanObject(e),i=(new Date).toISOString(),s=this.kernelInstance.getComponentId(e),a=Zt(s),o=(null===(n=r.boxForMeasurement)||void 0===n?void 0:n.size)||r.bounds;t({created:i,lastAccess:i,configuration:this.kernelInstance.getSerializedConfiguration(e),configurationHash:this.kernelInstance.getHashOfConfiguration(e),parts:JSON.stringify(this.kernelInstance.getPartList(e)),rootComponentId:s,width:o.x,height:o.z,depth:o.y,catalog:a,orderable:!1,requestable:!1})})}loadComponent(e,t,n){this._rapiAccess.getComponent(t.componentId).then(r=>{var i;let s=r.configuration;s||(s="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[t.componentId],message:t.componentId+" has no configuration"})),this._kernelIo.setMeta({componentId:t.componentId}),this._kernelInstance.loadComponent(e,s,t,n),this._flushSubComponentsWaiters()},r=>{var i;this._kernelInstance.loadComponent(e,"error",t,n),this.onLoadComponentError(r,t.componentId),null===(i=this._configuratorUiCallbacks)||void 0===i||i.onError(new Error(`Component with id "${t.componentId}" can not be loaded. "${r}"`)),this._flushSubComponentsWaiters()})}loadSubComponent(e,t,n){if(this._shouldWait){let r=this._subComponentsWaiters.get(n);r||this._subComponentsWaiters.set(n,[]),r=this._subComponentsWaiters.get(n),r.push({parentId:e,partId:t}),this._subComponentsWaiters.set(n,r)}else this._rapiAccess.getComponent(n).then(r=>{var i;let s=r.configuration;s||(s="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[n],message:"SubComponent "+n+" has no configuration"})),this._kernelIo.setMeta({componentId:n,parentId:e}),this._kernelInstance.loadedSubComponent(e,t,n,s)})}async loadItemConfigurations(e,t){let n=Array.isArray(t)?t:[t];if(this._requestedItemIds.push(...n),await Ne(0),!this._requestedItemIds.length)return;const r=[...this._requestedItemIds];this._requestedItemIds=[],(await this._rapiAccess.getItems(r)).forEach(t=>{this._kernelInstance.loadedItemConfiguration(e,t.id,t.configuration)})}requestDeleteComponent(e){var t,n;e&&((null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)?this._kernelInstance.deletePlanComponent(e):this._kernelInstance.deleteComponent(e))}dockComponentWithPosition(e,t,n,r,i){var s;this._kernelInstance.dockComponentWithPosition(n,r,e,t,i);const a=this._kernelInstance.getComponentId(n),o=this._kernelInstance.getComponentId(e);null===(s=this._configuratorUiCallbacks)||void 0===s||s.onUserInitiatedDockDone(a,r,o,t,i)}Editor3dAddBakedMesh(e,t,n,r,i,s,a,o){this._configuratorKernelCallbackListener.forEach(l=>l.Editor3dAddBakedMesh(e,t,n,r,i,s,a,o))}Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c){this._configuratorKernelCallbackListener.forEach(u=>u.Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c))}Editor3ChangedNamedMesh(e,t,n,r,i,s,a){this._configuratorKernelCallbackListener.forEach(o=>o.Editor3ChangedNamedMesh(e,t,n,r,i,s,a))}Editor3dRemoveNamedMesh(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dRemoveNamedMesh(e,t))}Editor3dBeginConstruction(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dBeginConstruction(e,t))}Editor3dEndConstruction(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dEndConstruction(e))}Editor3dComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!1))}Editor3dComponentDocked(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,t,n,r))}Editor3dGeometryReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryReady(e)),this.requestPlanComponentConstruction(e),this._configuratorUiCallbacks.onGeometryReady(e)}Editor3dGeometryNotReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryNotReady(e)),this._configuratorUiCallbacks.onGeometryNotReady(e)}componentDeleted(e){this._configuratorKernelCallbackListener.forEach(t=>t.componentDeleted(e))}componentMetaUpdated(e){let t=this._kernelInstance.getComponent(e);this._configuratorKernelCallbackListener.forEach(e=>e.componentMetaUpdated(t))}sceneCleared(){this._configuratorKernelCallbackListener.forEach(e=>e.sceneCleared())}requestMaterialsInGroup(e){(Array.isArray(e)?e:[e]).forEach(e=>{-1===this._cachedGroupIds.indexOf(e)&&this._cachedGroupIds.push(e)}),this._waitingForGroups||(this._waitingForGroups=!0,Ns.waitFor(4).then(()=>{this._rapiAccess.getMaterialsByGroup(this._cachedGroupIds).then(e=>{let t=[];e.forEach(e=>{const n=[];e.materials.forEach(e=>n.push(e.id));const r=e.legacyId||e.id;e.legacyId||console.warn("Material group has no legacy id, please check content why this is the case"),t.push({group:r,materials:n})}),t.length&&this._kernelInstance.setMaterialsInGroup(t),this._cachedGroupIds=[]},e=>{var t;console.error(e),null===(t=this._configuratorUiCallbacks)||void 0===t||t.onError(new Error(`Material group with ids "${this._cachedGroupIds.join(",")}" can not be loaded. "${e}"`)),this._cachedGroupIds=[]})}))}requestPlanComponentConstruction(e,t=!0){t?this._kernelInstance.requestDeltaPlanComponentConstruction(e):this._kernelInstance.requestPlanComponentConstruction(e)}addConfiguratorListener(e){this._configuratorKernelCallbackListener.add(e)}removeConfiguratorListener(e){this._configuratorKernelCallbackListener.delete(e)}cleanUpCallbacks(){"function"==typeof this._kernelContainer.unregisterConfiguratorCallback&&this._kernelContainer.unregisterConfiguratorCallback(this)}async requestMaterialProperties(e){let t=Array.isArray(e)?e:[e];if(this._requestedMaterialIds.push(...t),await Ne(0),!this._requestedMaterialIds.length)return;const n=[...this._requestedMaterialIds];this._requestedMaterialIds=[];const r=await this._rapiAccess.getMaterials(n);let i=[];r.forEach(e=>{const t=new this._kernelContainer.StringStringMap,n=e.properties||{};for(let e in n)n.hasOwnProperty(e)&&t.set(e,n[e]);t.size()&&i.push({id:e.id,properties:t})}),i.length&&this._kernelInstance.setMaterialProperties(i)}registerCallbacks(){this._kernelContainer.registerConfiguratorCallback(this)}pause(){this.cleanUpCallbacks()}resume(){this.cleanUpCallbacks(),this.registerCallbacks()}destroy(){}_handleCortoMesh(e,t,n){var r;try{this._kernelInstance.addMeshCorto(t,n,new Uint8Array(e))}catch(e){console.error(e),null===(r=this._configuratorUiCallbacks)||void 0===r||r.onMemoryCorruption()}}_handleInvalidMesh(e){try{this._kernelInstance.setExternalMeshInvalid(e)}catch(e){console.error(e)}}calcPartsPriceSum(e){return this._calcPrice(e)}_calcPrice(e){const t=new Map;e||(e=this._kernelInstance.getFullPartList());const n=!!e&&!!e.fullList&&!!e.fullList.length;if(this._initData.useRoomlePrice&&n){const n=e.fullList[0].currencySymbol,r=e.fullList.reduce((e,t)=>e+(t.count?t.count:0)*(t.price?t.price:0),0),i=je(r,2);return this._configuratorUiCallbacks.onUpdatePrice(n,i),Promise.resolve({totalSum:i,partMap:t})}if(this._initData.usePriceService&&n){const n=e.fullList.reduce((e,n)=>{const r=Jt(n);return r&&(t.set(r,n),e.push(r)),e},[]);return new Promise((r,i)=>{this._rapiAccess.getPrices(n).then(n=>{if(!n.length)return i(new Error("prices are empty"));let s=0;const a=Be(n,"priceId");for(const t of e.fullList){const e=Jt(t);if(!a.has(e)){console.warn("PriceId: "+e+" has no corresponding kernel-part");continue}const{price:n,currencySymbol:r}=a.get(e);t.price=n,t.currencySymbol=r,s+=n*t.count}return s=je(s,2),this._configuratorUiCallbacks.onUpdatePrice(n[0].currencySymbol,s),r({totalSum:s,partMap:t})},e=>{console.error(e),i(e)})})}return Promise.resolve({totalSum:0,partMap:t})}async addUiDataAndPriceToPartList(e,t){const{fullList:n,originPart:r}=e,i=e.perMainComponent;let s;this.addUiDataToPartList(n,t);try{const t=await this._calcPrice(e);s=t.partMap}catch(e){console.error(e),s=new Map}const a=this._initData.usePriceService||this._initData.useRoomlePrice,o=e=>{a||(e.price=null,e.currencySymbol=null);const t=Jt(e);if(!t)return;if(!s.has(t))return;const{price:n,currencySymbol:r}=s.get(t);"number"==typeof n&&(e.price=n,e.currencySymbol=r)};return n.forEach(o),i.forEach(({fullList:e,perMainComponent:n})=>{n.length>0&&console.error("Not implemented! perMainComponent is deeper than one level"),this.addUiDataToPartList(e,t),e.forEach(o)}),{fullList:n,perMainComponent:i,originPart:r}}addUiDataToPartList(e,t){const n=[];return e.forEach(e=>{const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label),e.parameters.forEach(e=>{if(this._unitFormatter.formatPartListParameter(e),Gs(e)){const t=this._rapiAccess.peekMaterial(e.value);t?e.valueLabel=t.label||t.name||e.value:-1===n.indexOf(e.value)&&n.push(e.value)}})}),n.length&&this._rapiAccess.getMaterials(n).then(e=>{const n=this._lastPartListHash!==t;Array.isArray(e)&&e.length&&n&&(this._lastPartListHash=t,this.requestPartListAndUpdatePricesOfParts())}),e}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const r=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(r,btoa(e))}}tn([rn],Qs.prototype,"_rapiAccess",void 0),tn([rn],Qs.prototype,"_scriptLoader",void 0),tn([rn],Qs.prototype,"_kernelIo",void 0),tn([rn],Qs.prototype,"_dataSyncer",void 0),tn([rn],Qs.prototype,"_lifeCycleManager",void 0),tn([rn],Qs.prototype,"_configuratorUiCallbacks",void 0),tn([rn],Qs.prototype,"_globalCallback",void 0),tn([rn],Qs.prototype,"_initData",void 0),tn([rn],Qs.prototype,"_unitFormatter",void 0),tn([rn],Qs.prototype,"_configuratorContext",void 0),tn([rn],Qs.prototype,"_globalInitData",void 0);const{APP:Ys}=Ts,{RAPI:Zs}=Ys,Js=Zs.headers,$s=Zs.itemHeaders,ea=Js.token,ta=e("an",e=>e.startsWith("ps_")),na=Ge();let ra=new Map,ia=new Map,sa=new Map,aa=new Map,oa=new Map,la=new Map,ha=new Map,da=new Map,ca=new Map;const ua=e=>ra.get(e)||ra.get(na+e),pa=e=>e&&e.tags&&e.tags.length,ma=e=>!pa(e)&&e.group;class ga{constructor(e){this._itemLoaded=!1,this._currentToken=null,this._creator_=e,window.addEventListener("online",this._flushOfflineQueue.bind(this))}getPreloadForItem(e){return this._getPreload(e,!0)}getPreloadForConfiguration(e){return this._getPreload(e,!1)}_getPreload(e,t){return new Promise((n,r)=>{if(!navigator.onLine)return n();if(this._dataSyncer.getIsCatalogSynced(Zt(e)))return n();if(ha.get(e))return n();const i=t?"?itemId=":"?configurationId=";this._get("/preloads/components/"+i+e,"preloads/components").then(t=>{if(ha.get(e))return n();t.forEach(e=>{this._prepareData(e,"components")}),ha.set(e,!0),n()},r)})}changeUseOfHDGeometry(){const e=aa.get("components");ha.clear(),la.clear(),e&&aa.delete("components")}getHSCPackage(e){return new Promise((t,n)=>{if(la.get(e))return t();this._get("/catalogs/"+e+"/package","package").then(n=>{if(la.get(e))return t(n);n.components.forEach(e=>{this._prepareData(e,"components")}),n.materials.forEach(e=>{this._prepareData(e,"materials"),this._prepareGroups(e)}),n.textures.forEach(e=>{this._prepareData(e,"textures")}),la.set(e,!0),t(n)},n)})}getComponent(e){return this._getById(e,"components")}getConfiguration(e){return this._getById(e,"configurations")}getConfigurations(e){return this._getByIds(e,"configurations")}getItem(e){return this._getById(e,"items",{additionalHeaders:$s})}getComponents(e){return this._getByIds(e,"components")}getItems(e){return this._getByIds(e,"items",{additionalHeaders:$s})}getTag(e){return this._getById(e,"tags")}getTags(e){return this._getByIds(e,"tags")}getTexture(e){return this._getById(e,"textures")}getCatalog(e){return this._getById(e,"catalogs")}getMesh(e,t="crt",n=50){return this._getById(e,"meshes",{pathSuffix:"/data?format="+t+"&targetQuality="+n.toString()})}getMeshesOfCatalog(e){return new Promise((t,n)=>{const r=oa.get(e);r?t(r):this._get("/meshes?catalog="+e,"catalogMeshes").then(n=>{oa.set(e,n),t(n)},n)})}getTexturesOf(e){return this._getRelationData(e,{rapiPath:"textures"})}getItemsOf(e){return this._getRelationData(e,{rapiPath:"items"})}async getMaterialsOf(e){return(await this._getRelationData(e,{rapiPath:"materials"},{embed:["textures"]})).filter(e=>e.active)}getComponentsOf(e){return this._getRelationData(e,{rapiPath:"components"})}getAdditionalContentsOfItems(e){const t=[],n=[];return e.forEach(e=>{const r=ia.get(e.id.toString());r?n.push(...r):t.push(e.id.toString())}),new Promise((e,r)=>{0!==t.length?this._getByIdsPackets(t,"itemAdditionalContents",{filterKey:"itemIds"}).then(t=>{t.forEach(e=>{let t=ia.get(e.itemId);t||(t=[]);for(let n=0,r=t.length;n<r;n++)if(t[n].id===e.id)return;t.push(e),ia.set(e.itemId,t)}),e([...t,...n])},r):e(n)})}getMaterial(e){return this._getById(e,"materials",{embed:["textures"]})}peekMaterial(e){return this._peekData(e,"materials")}peekComponent(e){return this._peekData(e,"components")}peekItem(e){return this._peekData(e,"items")}peekConfiguration(e){return this._peekData(e,"configurations")}async getMaterials(e){return(await this._getByIds(e,"materials",{embed:["textures"]})).filter(e=>e.active)}getPlan(e){return this._getById(e,"plans")}getPlanSnapshot(e){return this._getById(e,"planSnapshots")}static clearCaches(){ra=new Map,sa=new Map,aa=new Map,la=new Map,ha=new Map,da=new Map,ia=new Map}cleanUp(){ga.clearCaches()}getMaterialsByGroup(e){const t=e.slice(),n=[];let r=t.length;for(let e=0;e<r;e++){const i=ua(t[e]);if(i){const s=i.length;for(let e=0;e<s;e++){const t=this._getCache("materials").get(i[e]);n.push(t)}t.splice(e,1),r--,e--}}return new Promise((e,r)=>{0!==t.length&&navigator.onLine?this._getByIdsPackets(t,"materials",{filterKey:"groups",embed:["textures"]}).then(t=>{e(this.combineMaterialsToGroups([...t,...n]))},r):e(this.combineMaterialsToGroups(n))})}_flushOfflineQueue(){return new Promise((e,t)=>{const n=this._localStorage.getItem("hsc_configurations_offline_queue_v1"),r=[];for(let e in n)if(n.hasOwnProperty(e)){const t=n[e];r.push(new Promise((e,n)=>{this.saveConfiguration(t.data).then(r=>{const i=[];t.perspectiveImage&&!r.perspectiveImage&&i.push(this.savePerspectiveImage(r,t.perspectiveImage)),t.topImage&&!r.topImage&&i.push(this.savePerspectiveImage(r,t.topImage)),Promise.all(i).then(e,n)},n)}))}Promise.all(r).then(()=>{this._localStorage.setItem("hsc_configurations_offline_queue_v1",{}),e()},t)})}_setQueuedConfiguration(e,t={}){const n=e.configurationHash,{perspectiveImage:r,topImage:i}=t;let s=this._localStorage.getItem("hsc_configurations_offline_queue_v1")||{},a=s[n]||{};a.data=e,a.perspectiveImage=r,a.topImage=i,s[n]=a,this._localStorage.setItem("hsc_configurations_offline_queue_v1",s)}async saveConfiguration(e){return navigator.onLine?await this._save("/configurations",{configuration:e},"configurations",{accept:"application/json",contentType:"application/json; charset=UTF-8"}):(e.perspectiveImage=null,e.topImage=null,this._setQueuedConfiguration(e),this._markConfigurationAsLocally(e),Promise.resolve(e))}saveTopImage(e,t){return this._saveConfigurationImage(e,t,"topImage")}savePerspectiveImage(e,t){return this._saveConfigurationImage(e,t,"perspectiveImage")}savePlanSnapshotTopImage(e,t){return this._savePlanSnapshotImage(e,t,"topImage")}savePlanSnapshotPerspectiveImage(e,t){return this._savePlanSnapshotImage(e,t,"perspectiveImage")}getShortUrl(e,t){return new Promise((n,r)=>this._fetchJson("/shortIds","shortIds",{method:"POST",resolve:n,reject:r,data:JSON.stringify({shortId:{type:t,referencedId:e}}),accept:"application/json",contentType:"application/json; charset=UTF-8"}))}_peekData(e,t){const n=aa.get(t);return n&&n.get(e)||null}_saveConfigurationImage(e,t,n){if(!navigator.onLine){const r={};return r[n]=t,this._setQueuedConfiguration(e,r),this._markConfigurationAsLocally(e),e[n]=t.image,Promise.resolve(e)}const r=this._formDataUtil.create(t.image,e.configurationHash,Kt.PNG,n);return this._save("/configurations/"+e.id+"/"+n,r,"configurations",{accept:"application/json"})}_savePlanSnapshotImage(e,t,n){const r=this._formDataUtil.create(t.image,e.id,Kt.PNG,"file");return r.append("type",n),this._save("/planSnapshots/"+e.id,r,"planSnapshots",{accept:"application/json",method:"PUT"})}_markConfigurationAsLocally(e){e.isLocally=!0,e.id=e.configurationHash}_save(e,t,n,r={}){const i=t instanceof FormData?t:JSON.stringify(t);return new Promise((t,s)=>{const a={method:r.method||"POST",data:i,resolve:t,reject:s};r.contentType&&(a.contentType=r.contentType),r.accept&&(a.accept=r.accept),this._fetchJson(e,n,a)})}combineMaterialsToGroups(e){return new Promise((t,n)=>{const r=new Map,i={id:null,label:null,materials:[]},s=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],a=n.tags&&n.tags.length?n.tags.map(e=>({isTag:!0,id:e})):[];n.group&&a.push({isTag:!1,id:na+n.group,legacyId:n.group}),a.length||a.push({isTag:!1,id:null}),n.tags&&n.tags.length&&n.tags.forEach(e=>-1===s.indexOf(e)?s.push(e):null),a.forEach(({isTag:e,id:t,legacyId:s})=>{const a=n.id;let o=t?ua(t):[];o||(ra.set(t,[]),o=ua(t)),-1===o.indexOf(a.toString())&&o.push(a.toString());const l=pa(n),h=l&&e,d=ma(n);if(h||d&&!e||!l&&!d&&!t){let e=t?r.get(t):i;e||(r.set(t,{id:t,label:n.groupLabel,legacyId:s,materials:[]}),e=r.get(t)),e.materials.push(n)}})}const a=i.materials.length?[i]:[];this.getTags(s).then(e=>{const n=e.reduce((e,t)=>(e[t.id]=t,e),{});return r.forEach((e,t)=>{a.push({id:t,label:n[t]?n[t].label:e.label,materials:e.materials,legacyId:e.legacyId,sort:n[t]?n[t].sort:void 0})}),t(a)},n)})}_getByIds(e,t,n={}){const r=this._getCache(t),i=this._getErrorCache(t),s=[],a=[...new Set(e)];let o=a.length;if(r&&r.size){const e=(new Date).getTime();for(let t=0;t<o;t++){const n=a[t],l=r.get(n),h=i.get(n);let d=!1;null!=l?(s.push(l),d=!0):d=void 0!==h&&(e-h.timestamp<6e4||!1===navigator.onLine),d&&(a.splice(t,1),o--,t--)}}return new Promise((e,r)=>{0!==a.length&&navigator.onLine?this._getByIdsPackets(a,t,n).then(t=>{e([...t,...s])},r):e(s)})}_getByIdsPackets(e,t,n={}){const r=n.filterKey||"ids";let i,s="/"+t+"/",a="?",o=[];const l=e.length;if(!l)return new Promise(e=>e([]));let h=!0,d=[];for(i=0;i<l;i++){h=!1;const n=e[i],l=a+r+"[]="+n,c=l.length+s.length;d.push(n),a="&",c<=1500?s+=l:(c>1500&&(d.pop(),i--),o.push({url:s,ids:d}),h=!0,s="/"+t+"/",a="?",d=[])}h||o.push({url:s,ids:d});const c=[];return o.forEach(e=>c.push(this._getByIdsSingle(e.ids,e.url,t,n))),new Promise((e,t)=>{Promise.all(c).then(t=>{const n=[];t.length&&t.forEach(e=>n.push(...e)),e(n)},t)})}_getByIdsSingle(e,t,n,r={}){return new Promise((i,s)=>{this._get(t,n,r).then(t=>{for(let n=0,i=t.length;n<i;n++){const i=r&&r.cacheKey?t[n][r.cacheKey]:t[n].id,s=e.indexOf(i.toString());-1!==s&&e.splice(s,1)}const s=e.length;if(s){const t=this._getCache(n),r=this._getErrorCache(n),i=(new Date).getTime();for(let n=0;n<s;n++)r.set(e[n],{code:0,timestamp:i}),t.delete(e[n]);this._errorHandler.dispatch(2,[n,e.map(e=>'"'+e+'"').join(",")])}i(t)},s)})}_getById(e,t,n={}){if(!e||""===e||"string"!=typeof e)return console.error("no id passed to _getById"),Promise.reject(new Error("no id passed to _getById"));const r=this._getCache(t).get(e);if(r)return new Promise(e=>e(r));if(!navigator.onLine)return Promise.reject("Nothing cached but tried to fetch in offline mode");const i={...n,id:e},s=n.pathSuffix||"";return this._get("/"+t+"/"+e+s,t,i)}_get(e,t,n={}){const r=ks.useHDGeometry?"includeGeometryHD=true":"";let i=-1===e.indexOf("?")?"?":"&";return""!==r&&(e+=i+r),n.embed&&Array.isArray(n.embed)&&n.embed.forEach(t=>{e+=i+"embed"+(t[0].toUpperCase()+t.substr(1))+"=true",i="&"}),new Promise((r,i)=>{const s=da.get(e);Array.isArray(s)&&s.length>0?s.push({resolve:r,reject:i}):(da.set(e,[{resolve:r,reject:i}]),this._fetchJson(e,t,n))})}_fetchJson(e,t,n={}){this._fetch(e,n).then(He.bind(this)).then(this._handleJson(e,t,n).bind(this)).catch(this._handleError(e,n).bind(this))}async _fetch(e,t){const n={method:t.method?t.method:"GET",headers:this._createHeaders(t),mode:"cors",cache:"default"};t.data&&(n.body=t.data);let r=Zs.server;const i=this._globalInitData.overrideRapi;i&&(r="live"===i?Zs.liveServer:Zs.testServer),(this._globalInitData.customApiUrl||""===this._globalInitData.customApiUrl)&&(r=this._globalInitData.customApiUrl);const s=new Request(r+e,n);this._globalCallback.onNetworkRequest(e,n,t);const a=await this._globalCallback.onCheckExternalCache(e,n);return a?{headers:{get:()=>"application/json"},json:()=>Promise.resolve(a)}:this._networkLayer.fetch(s,{},{checkResponse:e=>this._globalCallback.onValidateNetworkResponse("rapi-access",e)})}_createHeaders(e={}){const t={...Js};this._globalInitData.overrideTenant&&(t.currentTenant=this._globalInitData.overrideTenant),this._globalInitData.overrideCountry&&(t.country=this._globalInitData.overrideCountry);const n=this._globalInitData.locale||"en";t.language=n,t.locale=n;const{contentType:r,accept:i,additionalHeaders:s,data:a}=e;if(r&&(t["content-type"]=e.contentType),i&&(t.accept=e.accept),s)for(let e in s)s.hasOwnProperty(e)&&(t[e]=s[e]);this._globalInitData.configuratorId&&(t.configurator=this._globalInitData.configuratorId);const o=this._currentToken||ea;t.token="03-"+window.btoa((new Date).toISOString()+";"+o+";"+Js.apiKey);const l=new Headers(t);return a instanceof FormData&&l.delete("content-type"),l}_handleJson(e,t,n={}){return r=>{let i=null,s=null;"number"==typeof r&&(i=r);for(let e in r)"meta"!==e&&r.hasOwnProperty(e)&&(i=r[e],s=e);if("error"===s)return this._handleError(e,n)(new Error(JSON.stringify(i)));if(!i)throw new TypeError("RAPI returned empty JSON");if(Array.isArray(i))for(let e=0,r=i.length;e<r;e++)this._prepareData(i[e],t,n),this._prepareEmbeddedData(i[e],t,n);else this._prepareData(i,t,n),this._prepareEmbeddedData(i,t,n);n.resolve?n.resolve(i):this._notifyWaiters(e,null,i)}}_prepareEmbeddedData(e,t,n={}){n.embed&&Array.isArray(n.embed)&&n.embed.forEach(r=>{const i=e[r.slice(0,-1)+"Objects"];if(Array.isArray(i)){for(let e=0,t=i.length;e<t;e++)this._prepareData(i[e],r,n);this._prepareRelationalData(t,r,e.id,i)}else i&&(this._prepareData(i,r,n),this._prepareRelationalData(t,r,e.id,[i]))})}_getCache(e){return this._getCacheFrom(e,aa)}_getErrorCache(e){return this._getCacheFrom(e,ca)}_getCacheFrom(e,t){let n=t.get(e);return n||(t.set(e,new Map),n=t.get(e)),n}_setCache(e,t,n){n.set(e.toString(),t)}_prepareData(e,t,n=null){let r=this._getCache(t);const i=n&&n.cacheKey?e[n.cacheKey]:e.id;if(i||n&&n.id||"tenants/me"===t)if("tenants/me"!==t){{const t=i||n.id;this._setCache(t,e,r)}e.__rapi_path__=t}else this._setCache("0",e,r);else"shortIds"!==t&&console.error("Can not cache because there is no ID!")}_getRelationsCacheFor(e,t,n){let r=sa.get(t);if(!r){const i=new Map,s=new Map;s.set(n,void 0),i.set(e,s),sa.set(t,i),r=sa.get(t)}let i=r.get(e);if(!i){const t=new Map;t.set(n,void 0),r.set(e,t),i=r.get(e)}return i.get(n)}_prepareGroups(e){const t=e.group,n=e.id;let r=ua(t);r||(ra.set(t,[]),r=ua(t)),-1===r.indexOf(n.toString())&&r.push(n.toString())}_handleError(e,t={}){return n=>{navigator.onLine?(n.rmlErrorCode=1,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(1,[n])):(n.rmlErrorCode=0,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(0,[n])),t.reject?t.reject(n):this._notifyWaiters(e,n,null)}}_getRelationData(e,t,n={}){const r=e.id;if(!r)return Promise.resolve([]);const i=e.__rapi_path__,s=t.rapiPath;let a=this._getCache(s),o=this._getRelationsCacheFor(r.toString(),i,s),l=[];return o?(o.forEach(e=>l.push(a.get(e))),new Promise(e=>e(l))):navigator.onLine?new Promise((e,t)=>{this._get("/"+i+"/"+r+"/"+s,s,n).then(t=>{this._prepareRelationalData(i,s,r,t),e(t)},t)}):Promise.resolve([])}_prepareRelationalData(e,t,n,r){sa.has(e)||sa.set(e,new Map);let i=sa.get(e);const s=n.toString();i.has(s)||i.set(s,new Map);let a=i.get(s),o=this._getCache(t),l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=t.id.toString();l.push(n),o.set(n,t)}a.set(t,l)}_notifyWaiters(e,t,n){const r=da.get(e);if(r&&r.length){for(let e=0,i=r.length;e<i;e++)t?r[e].reject(t):r[e].resolve(n);da.delete(e)}}_tenantMe(){return new Promise((e,t)=>{const n=this._getCache("tenants/me"),r=this._globalInitData.overrideTenant?this._globalInitData.overrideTenant:n.get("0");if(r)return e(r);this._fetchJson("/tenants/me","tenants/me",{resolve:t=>e(t),reject:t})})}async getTenant(e){return e||(e=await this._tenantMe()),this._getById(e.toString(),"tenants")}getCurrentSkin(){return this._tenantMe().then(e=>this._getById(e.toString(),"tenants").then(e=>this._getById(e.skin.toString(),"skins")))}getPrices(e){return this._getByIds(e,"prices",{filterKey:"priceIds",cacheKey:"priceId"})}async getConfiguratorSettings(e){const t=await this._getById(e,"configurators");return t.allowedHosts||(t.allowedHosts=[]),t.allowedHosts&&!Array.isArray(t.allowedHosts)&&(t.allowedHosts=t.allowedHosts.split(" ")),t}sendUserAction(e){return this._save("/userActions",{userAction:e},"userActions",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}_share(e,t,n,r){const i="/"+r+"/"+e+"/shares",s=new FormData;return s.append("email",t),s.append("type",n.toString()),new Promise((e,t)=>{const n={method:"POST",data:s,resolve:e,reject:t,accept:"application/json",contentType:"application/json; charset=UTF-8"};this._fetch(i,n).then(n.resolve,n.reject)})}shareConfiguration(e,t,n){return this._share(e,t,n,"configurations")}sharePlanSnapshot(e,t,n){return this._share(e,t,n,"planSnapshots")}export3D(e,t,n,r={}){const i="/"+(ta(e)?"planSnapshots":"configurations")+"/"+e+"/3d-exports",s={formats:[{file_format:n,pack_external_data:!0,...r}]},a=JSON.stringify(s),o=new FormData;return o.append("email",t),o.append("settings",a),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t};this._fetch(i,n).then(n.resolve,n.reject)})}async trackView(e){if(this._itemLoaded||(t=(()=>{var e;const t=(()=>{if(window.__RML__ENV__&&window.__RML__ENV__.skipIframeCheck)return!1;try{return window.self!==window.top}catch(e){return!0}})();let n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href;if(!n)return null;if(t){if(!document.referrer)return null;n=document.referrer}const{hostname:r}=new URL(n);return r})())&&(Yt.includes(t)||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")||t.endsWith("codesandbox.io")||t.endsWith("stackblitz.com")||/^(admin.*.roomle.com)$/.test(t)))return;var t;const{configuratorId:n}=this._globalInitData,r={module:3,action:1,actionId:e,actionLabel:n};await this.sendUserAction(r),this._itemLoaded=!0}signinUser(e,t){return new Promise((n,r)=>{const i={method:"POST",accept:"application/json",contentType:"application/json; charset=UTF-8",data:JSON.stringify({identification:e,passwordMD5:t}),cacheKey:"token",resolve:n,reject:r};this._fetchJson("/auth/signin","auth",i)})}async signoutUser(e){const t=this._currentToken;t!==e&&this.setCurrentToken(e),await this._fetch("/auth/signout",{}),t&&t!==e?this.setCurrentToken(t):this.removeCurrentToken()}async savePlan(e){const t=e.id?"/plans/"+e.id:"/plans";return this._save(t,{plan:e},"plans",{method:e.id?"PUT":"POST",accept:"application/json",contentType:"application/json; charset=UTF-8"})}async savePlanSnapshot(e){return this._save("/planSnapshots",{planSnapshot:e},"planSnapshots",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}setCurrentToken(e){this._currentToken=e}removeCurrentToken(){this._currentToken=null}createNewPlan(){return{name:"",description:"",changeDate:(new Date).toISOString(),created:(new Date).toISOString(),draftId:null,thumbnail:"data:image/png;base64,missing",planObjects:null,active:!0,open:0,planDirectory:0,changed:0,version:2,floorLevel:0,visibility:9,user:null,tenant:null,assets:[],parent:null,setting:null}}}e("R",ga),tn([rn],ga.prototype,"_formDataUtil",void 0),tn([rn],ga.prototype,"_errorHandler",void 0),tn([rn],ga.prototype,"_dataSyncer",void 0),tn([rn],ga.prototype,"_networkLayer",void 0),tn([rn],ga.prototype,"_localStorage",void 0),tn([rn],ga.prototype,"_globalInitData",void 0),tn([rn],ga.prototype,"_globalCallback",void 0);const fa=e("j",1500),_a=e("P",5);function va(){class e extends A{static _generateOutline(e,t){let n=new z(new Ve(e),new We({color:"#000000",dashSize:.03,gapSize:.01,linewidth:1}));return n.translateOnAxis(t,1),n.userData.ignoreComponentRaycast=!0,n}static cloneDockLine(e,t){let n=new z(e.geometry,e.material);return n.translateOnAxis(t.getCenter(new a),1),n.name="dockline",n.layers.set(5),n.userData.ignoreComponentRaycast=!0,n}_setValues(e,t,n,r){e&&(this.runtimeId=e,this.name=e.toString()),t&&(this.roomlePosition=Object.assign({},t)),n&&(this.roomleRotation=Object.assign({},n)),r&&(this.parentObjectId=r)}constructor(e,t,n,r){super(),this._selected=!1,this.geometryChanged=!0,this.meshes=[],this.castShadow=!1,this.receiveShadow=!0,this._setValues(e,t,n,r)}get loadingMesh(){return this._loadingMesh}get boundingBoxMesh(){return this._boundingBoxMesh}get boundingBox(){return this._boundingBox}set roomlePosition(e){this._roomlePosition=e,e&&this.position.set(e.x/1e3,e.z/1e3,e.y/-1e3)}get roomlePosition(){return this._roomlePosition}set roomleRotation(e){this._roomleRotation=e,e&&this.rotation.set(e.x,e.z,-e.y)}get roomleRotation(){return this._roomleRotation}replaceMeshes(e){this.removeAllMeshes(),e.forEach(e=>{this.addMesh(new H(e.geometry,e.material))})}addMesh(e,t){e.renderOrder=2,e.userData.meshType=0,t&&e.applyMatrix4(wr(t)),this.add(e),this.meshes.push(e)}getMeshById(e){return this.meshes.find(t=>t.userData.meshId===e)}removeMeshById(e){const t=this.getMeshById(e);t?this.removeMesh(t):console.warn("Could not remove mesh with id "+e,this.runtimeId,this.meshes)}removeMesh(e){const t=this.meshes.indexOf(e);this.remove(e),Gi(e),t<0||this.meshes.splice(t,1)}removeAllMeshes(e=!0){this.meshes.forEach(t=>{this.remove(t),e&&Gi(t)}),this.meshes=[],this._removeLoadingMesh(),this.remove(this._boundingBoxMesh),Gi(this._boundingBoxMesh),this._boundingBoxMesh=null}_hideAllMeshes(){this.meshes.forEach(e=>e.visible=!1)}_showAllMeshes(){this.meshes.forEach(e=>e.visible=!0)}select(){this._selected=!0}loading(){if(!this._kernelBoundingBox)return void console.warn("Bounding box (box for measurements) for component "+this.runtimeId+" not set, can not show external mesh loading box!");this._removeLoadingMesh(),this._hideAllMeshes();const{x:e,y:t,z:n}=this._kernelBoundingBox.getSize(new a);let r=new ke(e,t,n);this._loadingMesh=new H(r,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#DDDDDD")})),this._loadingMesh.name="loading mesh",this._loadingMesh.receiveShadow=!1,this._loadingMesh.castShadow=!1,this._loadingMesh.layers.set(5),this._loadingMesh.translateOnAxis(this._kernelBoundingBox.getCenter(new a),1),this._loadingMesh.renderOrder=3,this.add(this._loadingMesh)}_removeLoadingMesh(){this._loadingMesh&&(this.remove(this._loadingMesh),Gi(this._loadingMesh),this._loadingMesh=null)}loadingFinished(){this._removeLoadingMesh(),this._showAllMeshes()}deselect(){this._selected=!1}hoverOn(){ze("pointer")}hoverOff(){ze("default")}removeFromParent(){return this.parent&&(this.parent.remove(this),this.removeAllMeshes()),this}computeBoundingBox(t,n=!1){if(this._boundingBoxMesh&&this.remove(this._boundingBoxMesh),!n&&t&&0===t.size.x&&0===t.size.y&&0===t.size.z)return;let r;if(!t||n){this._boundingBox=new ge;let e=new a;this.meshes.forEach(t=>{if(t.geometry instanceof c){let n=t.geometry.attributes.position;if(void 0!==n)for(let r=0,i=n.count;r<i;r++)e.fromBufferAttribute(n,r).applyMatrix4(t.matrix),this._boundingBox.expandByPoint(e)}}),this._kernelBoundingBox=this._boundingBox.clone();let t=this._boundingBox.max.x-this._boundingBox.min.x,n=this._boundingBox.max.y-this._boundingBox.min.y,i=this._boundingBox.max.z-this._boundingBox.min.z;r=new ke(t,n,i)}else{this._kernelBoundingBox=Pi(t),this._boundingBox=this._kernelBoundingBox.clone();let{x:e,y:n,z:i}=this._boundingBox.getSize(new a);r=new ke(e,n,i)}this._boundingBoxMesh=new H(r,Ti.createMeshStandardMaterial({color:"#FFFFFF",transparent:!0,opacity:0,polygonOffset:!0,polygonOffsetFactor:-1,visible:!1})),this._boundingBoxMesh.name="bounding box mesh";let i=this._boundingBox.getCenter(new a);this._boundingBoxMesh.position.add(i),this._boundingBoxMesh.layers.set(5),this._boundingBoxMesh.renderOrder=3,this._boundingBoxMesh.castShadow=!1,this._boundingBoxMesh.receiveShadow=!1,this.add(this._boundingBoxMesh),this._dockline=e._generateOutline(r,i),this._dockline.name="bounding box outline",this._dockline.layers.set(5),this._selected&&this.add(this._dockline)}recursiveMeshes(){let t=this.meshes.slice();return this.children.forEach(n=>{n instanceof e&&t.push(...n.recursiveMeshes())}),t}isChild(t){let n=!1;return this.children.forEach(r=>{r instanceof e&&!n&&(n=r.runtimeId===t||r.isChild(t))}),n}getKernelPosition(e){let t=this.parent.localToWorld(this.position);return gr(e.worldToLocal(t))}}class t extends e{constructor(e,t){super(e,null,null,null),this.glbUrl=t}}class n extends e{constructor(e,t,n,r,i){super(t,n,r,i),this._stringId=null,this.receivedPointAssociation=!1,this.castShadow=!1,this.receiveShadow=!1,this._creator_=e}get stringId(){return this._stringId?this._stringId:this.runtimeId.toString()}addMesh(e,t){super.addMesh(e,t),e.material instanceof N&&(e.material.opacity=.8,e.material.roughness=1,e.material.metalness=0,e.material.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)),e.renderOrder=1,e.castShadow=!1,e.receiveShadow=!1}startPulsating(){var e,t;if(null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.pulsePreview)for(const e of this.meshes){const t={opacity:.8},n={opacity:.3};new TWEEN.Tween(t).to(n,fa).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.material.opacity=t.opacity}).yoyo(!0).repeat(_a).start()}}hoverOn(){this.remove(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.9,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),ze("pointer")}hoverOff(){this.add(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.8,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),ze("default")}clonePreview(t){const r=new n(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId);return r._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof H&&0===e.userData.meshType&&r.meshes.push(e.clone(!0))}),r.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),r.add(e)}),this._dockline&&(r._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(r._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(r._boundingBox=this._boundingBox.clone()),r}preparePreview(){this.add(this._dockline),this.add(this._boundingBoxMesh)}}tn([rn],n.prototype,"_initData",void 0);class r extends n{constructor(e,t,n,r,i,s){super(e,t,n,r,i),s&&(this._stringId=this.runtimeId+"_has_additional_dock_point_copy")}set roomleLineFrom(e){this._roomleLineFrom=e,this.lineFrom=pr(e)}get roomleLineFrom(){return this._roomleLineFrom}set roomleLineTo(e){this._roomleLineTo=e;let t=pr(e);t.equals(this.lineFrom)&&(console.warn("lineFrom and lineTo are equal!"),t.add(new a(0,.01,0))),this.lineTo=t}get roomleLineTo(){return this._roomleLineTo}set roomlePositionFrom(e){this._roomlePositionFrom=e,this.positionFrom=pr(e)}get roomlePositionFrom(){return this._roomlePositionFrom}set roomlePositionTo(e){this._roomlePositionTo=e;let t=pr(e);t.equals(this.positionFrom)&&(console.warn("positionFrom and positionTo are equal!"),t.add(new a(0,.01,0))),this.positionTo=t}get roomlePositionTo(){return this._roomlePositionTo}addMesh(e,t){super.addMesh(e,t),e.visible=!1,e.renderOrder=3}hoverOn(){this._dockline.visible=!0,ze("pointer")}hoverOff(){this._dockline.visible=!1,ze("default")}preparePreview(){super.preparePreview(),this._dockline.visible=!1;let e=this.lineTo.clone(),t=this.lineFrom.clone();const n=(new a).subVectors(e,t);let r=n.length(),i=n.normalize(),s=new Ke(i,t),o=new qe(.01,.01,r,16,1);this.lineMesh=new H(o,Ti.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:.4})),this.lineMesh.name="line mesh";const l=(new M).setFromEuler(s.rotation);this.lineMesh.quaternion.multiply(l),this.lineMesh.renderOrder=1;let h=(new a).addVectors(e,t).multiplyScalar(.5);this.lineMesh.position.copy((new a).subVectors(h,this.position.clone())),this.add(this.lineMesh);let d=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation),c=null,u=0,p=Math.abs(i.x),m=Math.abs(i.y),g=Math.abs(i.z);p>=m&&p>=g?(c=new a(d.x,0,0),u=Math.sqrt(d.y*d.y+d.z*d.z)):m>=p&&m>=g?(c=new a(0,d.y,0),u=Math.sqrt(d.x*d.x+d.z*d.z)):g>=m&&g>=p&&(c=new a(0,0,d.z),u=Math.sqrt(d.y*d.y+d.x*d.x)),u=u>0?u:.01;let f=(new a).subVectors(this.positionTo.clone(),this.positionFrom.clone()).length()+c.length(),_=new qe(1.1*u,1.1*u,f,32,1);this.boundingLineMesh=new H(_,Ti.createMeshStandardMaterial({color:"#ffffff",transparent:!0,opacity:0})),this.boundingLineMesh.name="bounding line mesh",this.boundingLineMesh.userData.ignoreComponentRaycast=!0,this.boundingLineMesh.layers.set(5);let v=this.positionTo.clone(),w=this.positionFrom.clone(),b=(new a).subVectors(v,w).normalize(),y=new Ke(b,w);const x=(new M).setFromEuler(y.rotation);this.boundingLineMesh.quaternion.multiply(x),this.boundingLineMesh.renderOrder=3;let C=(new a).addVectors(this.positionTo.clone(),this.positionFrom.clone()).multiplyScalar(.5).add(d);this.boundingLineMesh.position.copy((new a).subVectors(C,this.position.clone())),this.add(this.boundingLineMesh)}clonePreviewLine(t){let n=new r(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.receivedPointAssociation);return n._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof H&&0===e.userData.meshType&&n.meshes.push(e.clone(!0))}),n.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),n.add(e)}),this._dockline&&(n._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(n._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(n._boundingBox=this._boundingBox.clone()),n}getPositionForIntersectionPoint(e){let t=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation),n=this.positionTo.clone().add(t),r=this.positionFrom.clone().add(t),i=new Xe(r,n).closestPointToPoint(e,!0,new a);return(isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&i.copy(e),i.sub(t)}updatePreviewPosition(e){let t=this.getPositionForIntersectionPoint(e),n=this.parent.localToWorld(t);this._newPosition=this.worldToLocal(n);let r=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation);this._dockline.position.copy((new a).addVectors(this._newPosition,r)),this._dockline.rotation.copy(this.docklineRotation)}hideSelectionLine(){this._dockline.visible=!1}getKernelPosition(e){if(this._newPosition){let t=this.localToWorld(this._newPosition);return gr(e.worldToLocal(t))}return super.getKernelPosition(e)}}class i extends Y{constructor(e,t,n,r,i,s,a){super(e,t,n,r,i,s),a||(a={left:0,top:1,right:1,bottom:0}),this.offset=a}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}_calculateProjectionMatrix(){const e=this._calculate2DPlanes();if(this._offset.left>=this._offset.right||this._offset.bottom>this._offset.top)return(new S).makeOrthographic(e.left,e.right,e.top,e.bottom,this.near,this.far);const t=this._scaleRange(e.left,e.right,this._offset.left,this._offset.right);let n=t.from,r=t.to;const i=this._scaleRange(e.bottom,e.top,this._offset.bottom,this._offset.top);let s=i.from,a=i.to;const o=(e.right-e.left)/(e.top-e.bottom),l=(r-n)/(a-s);if(l>o){const e=(s+a)/2,t=(a-s)*l/o;s=e-t/2,a=e+t/2}else{const e=(n+r)/2,t=(r-n)*o/l;n=e-t/2,r=e+t/2}return(new S).makeOrthographic(n,r,a,s,this.near,this.far)}_scaleRange(e,t,n,r){const i=(t-e)/(r-n);return{from:e-i*n,to:t+i*(1-r)}}_calculate2DPlanes(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,s=n+e,a=r+t,o=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,s=i+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}return{left:i,right:s,top:a,bottom:o}}}class o extends X{constructor(e,t,n,r,i){super(e,t,n,r),i||(i={left:0,top:1,right:1,bottom:0}),this.offset=i}copy(e,t){return super.copy(e,t),this._offset=e._offset,this}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}_calculateProjectionMatrix(){let e,t,n,r,i=this.fov*(2*Math.PI/360)/2;n=Math.tan(i),r=-n;let a=Math.atan(this.aspect*Math.tan(i));t=Math.tan(a),e=-t;let o=this._offset.left,l=this._offset.right,h=this._offset.top,d=this._offset.bottom,c=new s(l-o,h-d),u=new s(o+c.x/2,d+c.y/2);if(c.x<c.y){let i=(1-u.x)/(c.x/2),s=u.x/(c.x/2);t*=i,e*=s;let a=(i+s)/2;n*=a,r*=a}else{let i=(1-u.y)/(c.y/2),s=u.y/(c.y/2);n*=i,r*=s;let a=(s+i)/2;e*=a,t*=a}e*=this.near,t*=this.near,n*=this.near,r*=this.near;let p=this.near*Math.tan(Math.PI/180*.5*this.fov)/this.zoom*2,m=this.aspect*p;return this.view&&this.view.enabled&&(e+=this.view.offsetX*m/this.view.fullWidth,n-=this.view.offsetY*p/this.view.fullHeight,t+=this.view.offsetX*m/this.view.fullWidth,r-=this.view.offsetY*p/this.view.fullHeight),(new S).makePerspective(e,t,n,r,this.near,this.far)}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}}return{create:function(t,n,r,i){return new e(t,n,r,i)},createPreview:function(e,t,r){return new n(r,e,{x:0,y:0,z:0},{x:0,y:0,z:0},t)},createStatic:function(e,n){return new t(e,n)},createPreviewLine:function(e,t){let n=new r(t,e.id,e.roomlePosition,e.roomleRotation,e.parentObjectId,e.receivedPointAssociation);return e.meshes.forEach(e=>{let t=e.clone();t.material=e.material.clone(),t.geometry=e.geometry.clone(),n.addMesh(t)}),n.computeBoundingBox(),n},isPreview:function(e){return e instanceof n},isPreviewLine:function(e){return e instanceof r},createPerspectiveCamera:function(e,t,n,r,i){return new o(e,t,n,r,i)},createOrthographicCamera:function(e,t,n,r,s,a,o){return new i(e,t,n,r,s,a,o)}}}const wa=e("u",9);class ba{constructor(e){this._mergeThreshold=3,this._componentsToMerge=new ya,this._mergeInProgress=!1,this._components=new Map,this._previews=new Map,this._componentNumberOfPossibleChildren=new Map,this._creator_=e,this._getKernelAccess().addConfiguratorListener(this),this._componentFactory=va()}get materialQueue(){return this.getMeshGenerator().materialQueue}_getKernelAccess(){return th.lookup("planner-kernel-access",this._creator_)}_applyMeshTransform(e,t,n,r,i){if(n){const r=e.userData.transform=wr(n);t&&(e.userData.transform=r),e.applyMatrix4(r)}this._applyMeshUVTransform(e,t,r,i)}_applyMeshUVTransform(e,t,n,r){if(6!==(null==n?void 0:n.length)||(e=>1===e[0]&&0===e[1]&&0===e[2]&&1===e[3]&&0===e[4]&&0===e[5])(n))t&&(t.uvTransform=void 0),r&&(e.geometry=r);else{const i=(e=>{const t=new S;return t.set(e[0],e[2],0,e[4],e[1],e[3],0,e[5],0,0,1,0,0,0,0,1),t})(n);t&&(t.uvTransform=i);const s=null!=r?r:e.geometry;if(s&&s.attributes.uv){const t=s.clone();t.attributes.uv.applyMatrix4(i),e.geometry=t}}}_addMeshToSubPart(e,t,n,r,i,s,a,o,l,h){const d=this._generateMesh(e,t,n,s,a,o,l,void 0,void 0,h);this._applyMeshTransform(d,null,r,i),this._subPartObject.add(d)}_addMeshToComponent(e,t,n,r,i,s,a,o,l,h,d,c){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._addMeshToSubPart(e,null,r,null,null,a,o,l,h,c);const u=this.getComponent(e);if(!u)return;const p=this._componentFactory.isPreview(u),m=this._generateMesh(e,n,p?null:r,a,o,l,h,void 0,void 0,c);m.userData.meshId=t,m.userData.geometryId=n,m.userData.materialId=r,this._applyMeshTransform(m,m.userData,i,s),p&&m.layers.set(5),u&&u.addMesh(m),u.meshes.length>this._mergeThreshold&&this._componentsToMerge.set(e,u.meshes.length)}_changeMeshOfComponent(e,t,n,r,i,s,a){const o=this.getComponent(e);if(!o)return;const l=o.getMeshById(t);if(l){l.userData.geometryId!==n&&console.warn("Geometry of mesh has changed!"),l.userData.materialId=r,l.userData.materialAttributes=a;const e=l.material.clone();this._configuratorMeshGenerator.setMaterial(l,r,void 0,a).then(()=>{this._requestRenderSceneUpdateCallback&&this._requestRenderSceneUpdateCallback()}),e.opacity!==l.material.opacity&&this._requestRenderCallback&&this._requestRenderCallback(),i&&(l.position.set(0,0,0),l.scale.set(1,1,1),l.rotation.set(0,0,0));const t=this._configuratorMeshGenerator.getGeometry(n);this._applyMeshTransform(l,l.userData,i,s,t)}}_removeMeshFromComponent(e,t){const n=this.getComponent(e);n&&n.removeMeshById(t)}getComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:(console.warn("component not found!",e),null)}getNumberOfPossibleChildrenForComponent(e){if(this._componentNumberOfPossibleChildren.has(e))return this._componentNumberOfPossibleChildren.get(e);const t=this._getKernelAccess().kernelInstance.getPlanComponentPossibleChildren(e).length;return this._componentNumberOfPossibleChildren.set(e,t),t}tryToMergeComponents(){this._initData.moc||this._mergeInProgress||(this._mergeInProgress=!0,this._componentsToMerge.size,this._requestMergeComponents())}_requestMergeComponents(){window.requestIdleCallback(this._mergeNextComponent.bind(this))}_mergeNextComponent(){if(this._componentsToMerge.size>0){const e=this._componentsToMerge.largestValue();this._componentsToMerge.delete(e),this._mergeComponent(e),this._requestMergeComponents()}else this._mergeInProgress=!1,this._geometriesMerged&&this._geometriesMerged(),this._components.forEach(e=>{e.loadingMesh&&console.warn("component still has loading mesh: ",e.hash)})}_mergeComponent(e){const t=this._components.get(e);if(t&&!(t.meshes.length<=this._mergeThreshold))if(this._cacheHolder.componentCache.has(t.hash)){const e=this._cacheHolder.componentCache.get(t.hash).meshes;t.replaceMeshes(e)}else{const e=new Map,n=[],r=[];t.meshes.forEach(t=>{const i=t.userData.materialId;if(!i)return void console.warn("mesh has no material id set");if(!e.has(i)){const r=new H(new c,t.material);r.userData.materialId=i,r.receiveShadow=!0,r.castShadow=!0,r.layers.set(3),this._setMaterial(r,i),n.push(r),e.set(i,r)}const s=e.get(i),a=s.geometry;t.userData.transform&&t.geometry.applyMatrix4(t.userData.transform),s.geometry=function(e,t=!1){const n=null!==e[0].index,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new c;let h=0;for(let d=0;d<e.length;++d){const c=e[d];let u=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in c.attributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[e]&&(s[e]=[]),s[e].push(c.attributes[e]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in c.morphAttributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[e]&&(a[e]=[]),a[e].push(c.morphAttributes[e])}if(t){let e;if(n)e=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;e=c.attributes.position.count}l.addGroup(h,e,d),h+=e}}if(n){let t=0;const n=[];for(let r=0;r<e.length;++r){const i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}l.setIndex(n)}for(const e in s){const t=pn(s[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in a){const t=a[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let r=0;r<a[e].length;++r)t.push(a[e][r][n]);const r=pn(t);if(!r)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(r)}}return l}([a,t.geometry]),r.push(t)}),n.forEach(e=>t.addMesh(e)),r.forEach(e=>t.removeMesh(e)),this._cacheHolder.componentCache.set(t.hash,t)}}_addRootComponent(e){this._listener&&this._listener.display(e)}removeDockingComponent(){this._getKernelAccess().requestDeleteComponent(this._configuratorContext.dockingRootComponentId),this._configuratorContext.dockingRootComponentId=null}dockComponent(e,t,n,r){let i=this._components.get(t),s=this._components.get(e);s&&(s.roomlePosition=n,s.roomleRotation=r,i&&i.add(s))}dockComponentWithPosition(e,t){let n,r=this._components.get(e.parentId);n=t?t.getKernelPosition(r):e.getKernelPosition(r),Ls.start("dock_component_with_position_"+e.childId),this._getKernelAccess().dockComponentWithPosition(e.parentId,e.parentDockId,e.childId,e.childDockId,n),this._configuratorContext.dockingRootComponentId=null}removePreviews(){this._previews.size>0&&(this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear())}_updatePlanObject(e){const t=this._components.get(e.rootPlanComponentId);let n=!0;t&&(n=t.geometryChanged),this._listener&&this._listener.planObjectUpdated(e,n)}Editor3dAddBakedMesh(e,t,n,r,i,s,a,o){this._addMeshToComponent(e,null,null,t,null,null,n,r,i,s,a,o)}Editor3dAddDockPreview(e,t){const n=this._componentFactory.createPreview(t,e,this._creator_);this._previews.set(t.toString(),n)}Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c){this._addMeshToComponent(e,t,n,r,i,d,s,a,o,l,h,c)}Editor3ChangedNamedMesh(e,t,n,r,i,s,a){this._changeMeshOfComponent(e,t,n,r,i,s,a)}Editor3dRemoveNamedMesh(e,t){this._removeMeshFromComponent(e,t)}Editor3dBeginConstruction(e,t){if(!t){const t=this._components.get(e);t&&t.removeAllMeshes()}this._subPartGuard&&e===this._subPartGuard.info&&(this._subPartObject=new A)}Editor3dComponentCreated(e,t,n,r,i){i&&(this._configuratorContext.rootComponentId=e);let s=null;this._components.has(e)?(s=this._components.get(e),s.removeAllMeshes()):(s=this._componentFactory.create(e,t,n,r),s.layers.set(3)),this._components.set(e,s),i&&this._addRootComponent(s)}Editor3dComponentDocked(e,t,n,r){this.dockComponent(e,t,n,r)}Editor3dEndConstruction(e){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._subPartGuard.resolve(this._subPartObject);const t=this._getKernelAccess().kernelInstance.getComponent(e),n=this._components.get(e);n&&(n.computeBoundingBox(t.boxForMeasurement),n.boundingBoxMesh&&this._listener&&this._listener.addComponentHandlers(n));let r=this._previews.get(e.toString());r&&r.computeBoundingBox(t.boxForMeasurement,!0)}Editor3dGeometryReady(e){const t=this._components.get(e);t&&t.loadingFinished()}Editor3dGeometryNotReady(e){const t=this._components.get(e);t&&t.loading()}Editor3dPlanObjectConstructionDone(e){const t=this._getKernelAccess().kernelInstance.getPlanObject(e),n=[t,this._getKernelAccess().kernelInstance.getFullPartList(),this._getKernelAccess().kernelInstance.getHashOfConfiguration(e),this._getKernelAccess().kernelInstance.getComponentId(t.rootPlanComponentId)];Ns.finishOperation(2,n),this._updatePlanObject(t),this._listener&&this._listener.planObjectConstructionDone(t)}Editor3dPreviewConstructionDone(e,t){let n=!1;this._previews.forEach(e=>{null!==e.parent&&(this._listener&&(this._componentFactory.isPreviewLine(e)?this._listener.addPreviewLineHandlers(e):this._listener.addPreviewHandlers(e)),n=!0)}),this._listener&&this._listener.previewConstructionDone(this._components.get(e),n)}Editor3dSetPreviewLineAssociations(e,t){let n=this._previews.get(t.toString());if(n.clear(),!n)return;let r=this._componentFactory.createPreviewLine(n,this._creator_),i=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let n;n=0===t?r:r.clonePreviewLine(t),n.name="Preview Line",n.parentDockId=e[t].parentDockId,n.parentId=e[t].parentId,n.childDockId=e[t].childDockId,n.childId=e[t].childId,n.docklineRotation=(s=e[t].rotation,new ve(s.x,s.z,-s.y)),n.roomlePosition=e[t].position,e[t].lineFrom.x>e[t].lineTo.x||e[t].lineFrom.y>e[t].lineTo.y||e[t].lineFrom.z>e[t].lineTo.z?(n.roomleLineFrom=e[t].lineTo,n.roomleLineTo=e[t].lineFrom):(n.roomleLineFrom=e[t].lineFrom,n.roomleLineTo=e[t].lineTo),e[t].positionFrom.x>e[t].positionTo.x||e[t].positionFrom.y>e[t].positionTo.y||e[t].positionFrom.z>e[t].positionTo.z?(n.roomlePositionFrom=e[t].positionTo,n.roomlePositionTo=e[t].positionFrom):(n.roomlePositionFrom=e[t].positionFrom,n.roomlePositionTo=e[t].positionTo),i.add(n),n.preparePreview(),this._previews.set(n.stringId,n)}var s}Editor3dSetPreviewPointAssociations(e,t){let n=this._previews.get(t.toString());if(!n)return;let r=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let i;0===t?i=n:(i=n.clonePreview(t),this._previews.set(i.stringId,i)),i.name="Preview Point",i.parentDockId=e[t].parentDockId,i.parentId=e[t].parentId,i.childDockId=e[t].childDockId,i.childId=e[t].childId,i.preparePreview(),i.receivedPointAssociation=!0,i.userData.ignoreComponentRaycast=!0,r.add(i),i.roomlePosition=e[t].position,i.roomleRotation=e[t].rotation,i.startPulsating()}}componentDeleted(e){const t=this._components.get(e);t&&(this._listener&&this._listener.componentDeleted(t),t.removeFromParent(),t.removeAllMeshes(),this._components.delete(e))}componentMetaUpdated(e){const t=this._getRuntimeComponent(e.id);t&&(t.hash=e.hash,t.roomlePosition=e.position,t.roomleRotation=e.rotation,e.boxForMeasurement&&t.computeBoundingBox(e.boxForMeasurement),this._listener&&this._listener.componentUpdated(t,e))}componentConfigurationUpdated(e,t){const n=this._getRuntimeComponent(e);n&&(n.geometryChanged=t)}_getRuntimeComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:null}configurationLoaded(e,t,n,r,i){10===e&&(this._configuratorContext.dockingRootComponentId=n);let s=0===t;s?this._getKernelAccess().kernelInstance.requestPlanComponentConstructionRecursive(n):this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(t);let a=this._getKernelAccess().kernelInstance.getComponent(n),o=this._components.get(n);o&&(o.computeBoundingBox(a.boxForMeasurement),o.hash=a.hash),this._listener&&this._listener.configurationLoaded(o,s&&void 0!==o.boundingBoxMesh)}finishParameterChange(e,t){this.materialQueue.registerCallback(e)}planObjectConfigurationUpdated(e,t,n){let r=this._getKernelAccess().kernelInstance.getPlanObject(e);this._updatePlanObject(r)}planObjectCreated(e,t){this._configuratorContext.planObjectId=t,this._listener&&this._listener.clearScene()}planObjectUpdated(e){this._updatePlanObject(e)}sceneCleared(){this._components.forEach((function(e){e.removeFromParent(),e.removeAllMeshes()})),this._components.clear(),this._componentNumberOfPossibleChildren.clear(),this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear()}setListener(e){this._listener=e}getBoundingBox(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxForMeasurement)return Pi(e.boxForMeasurement)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxWithPreviews(){const e=this._components.get(this._configuratorContext.rootComponentId);return e?(new ge).setFromObject(e):null}hasPreviews(){return this._previews.size>0}clearRootComponent(){var e;null===(e=this._components.get(this._configuratorContext.rootComponentId))||void 0===e||e.hoverOff()}debugSceneGraph(e){e?this._components.has(e)?this._components.get(e):this._previews.has(e.toString())&&this._previews.get(e.toString()):this._configuratorContext}getComponentsForIds(e){let t=[];return e.forEach(e=>{const n=this._components.get(e);n&&t.push(n)}),t}getComponents(){return Array.from(this._components.values())}getPreviews(){return Array.from(this._previews.values())}hasPreviewLines(){for(const e of this._previews.values())if(this._componentFactory.isPreviewLine(e))return!0;return!1}isPreviewLine(e){return this._componentFactory.isPreviewLine(e)}isPreview(e){return this._componentFactory.isPreview(e)}setGeometriesMergedListener(e){this._geometriesMerged=e}removeGeometriesMergedListener(){this._geometriesMerged=void 0}setMergeThreshold(e){this._mergeThreshold=e}_generateMesh(e=0,t=null,n,r,i,s,a,o,l,h){return this._configuratorMeshGenerator.generateMesh(e,t,n,r,i,s,a,!1,h)}_setMaterial(e,t,n){this._configuratorMeshGenerator.setMaterial(e,t)}constructComponents(e){this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(e)}requestSubPartConstruction(e){return this._subPartGuard=new un(e),this._getKernelAccess().requestPlanComponentConstruction(e,!1),this._subPartGuard.wait()}getMeshGenerator(){return this._configuratorMeshGenerator}setRequestRenderCallback(e){this._requestRenderCallback=e}setRequestRenderSceneUpdateCallback(e){this._requestRenderSceneUpdateCallback=e}}e("C",ba),tn([rn],ba.prototype,"_configuratorMeshGenerator",void 0),tn([rn],ba.prototype,"_configuratorContext",void 0),tn([rn],ba.prototype,"_cacheHolder",void 0),tn([rn],ba.prototype,"_initData",void 0);class ya extends Map{largestValue(){let e=this.entries().next().value[0],t=0;return this.forEach((n,r)=>{n>t&&(e=r,t=n)}),e}}const xa=["material"];class Ca extends Qs{constructor(e){super(e),this.externalMeshQueue=new rs,this.muteKernelCallbacks=!1,this.listOfVariants=(e,t)=>{}}init(e){super.init(e),Ls.addMeta("kernel_is_ready",{isWasm:this._useWASM}),ks.kernelInstance?(this._kernelContainer=ks.kernelContainer,setTimeout(()=>this._loadSuccess(),0)):this._scriptLoader.fetch(this._kernelPath,{id:"kernel"}).then(this._loadSuccess.bind(this),this._loadError.bind(this))}_loadSuccess(){Ls.start("kernel_is_ready"),window.ConfiguratorKernel&&(ks.kernelInstance?setTimeout(()=>this.isReady(),0):(window.ConfiguratorKernel(this._kernelContainer),window.ConfiguratorKernel=null))}_loadError(){this._configuratorKernelAccessCallback.loadError()}selectedComponent(e){this._updateComponentDependencies(e)}uiRequestConfiguration(e){const t=this._kernelInstance.getSerializedConfiguration(e);Ns.finishOperation(1,t)}_updateComponentParameters(e){let t=this._kernelInstance.getComponentParameters(e);const n=this._kernelInstance.getComponent(e);this._configuratorKernelAccessCallback.updateParameters(t,n.parameterGroups,e,1)}selectionChange(e,t){let n=!1,r=[];if(e){let t=this._kernelInstance.getComponent(e);t.componentId=this._kernelInstance.getComponentId(e),t&&t.childIds&&t.childIds.length>0&&(n=!0),r.push(t)}this._configuratorUiCallbacks.onSelectionChange("standard",t,n,r)}multiSelectionChange(e,t){this._updateCommonComponentDependencies(e);let n=!1,r=!1,i=[];e&&e.forEach(e=>{let s=this._kernelInstance.getComponent(e);s.componentId=this._kernelInstance.getComponentId(e),s&&s.childIds&&s.childIds.length>0&&(n=!0),s.id===t&&(r=!0),i.push(s)}),this._configuratorUiCallbacks.onSelectionChange("multiselect",r,n,i)}_updateCommonComponentDependencies(e){const{parameters:t,parameterGroups:n}=this._kernelInstance.getCommonPlanComponentParameters(this._utilityToLongArray(e));this._configuratorKernelAccessCallback.updateParameters(t,n,e,2)}_updateComponentChildren(e){const t=this._kernelInstance.getPlanComponentPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,1)}_updateComponentDependencies(e){this._updateComponentParameters(e),this._updateComponentChildren(e)}_updatePlanObjectParameters(e){let t,n=this._kernelInstance.getPlanObjectParameters(e);if(0===n.length){let r=this._kernelInstance.getRootPlanComponentIdFromObjectId(e);n=this._kernelInstance.getComponentParameters(r),this._enableRootComponentParametersAsGlobal(),t=this._kernelInstance.getComponent(r)}else this._configuratorContext.rootComponentParametersAsGlobal=!1,t=this._kernelInstance.getPlanObject(e);this._configuratorKernelAccessCallback.updateParameters(n,t.parameterGroups,e,0)}_enableRootComponentParametersAsGlobal(){this._configuratorContext.selectedRuntimeComponentId||(this._configuratorContext.rootComponentParametersAsGlobal=!0)}_updatePlanObjectChildren(e){const t=this._kernelInstance.getPlanObjectPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,0)}updatePlanObjectDependencies(e){this._updatePlanObjectParameters(e),this._updatePlanObjectChildren(e)}_updateConfigurationHasChildren(e,t=null){t||(t=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)));const n=t.childIds.size?t.childIds.size():t.childIds.length;this._configuratorUiCallbacks.onConfigurationHasChildren(n>0)}dockComponent(e,t,n,r){const i=this._kernelInstance.getComponentId(n),s=this._kernelInstance.getComponentId(e);this._kernelInstance.dockComponent(n,r,e,t),this._configuratorUiCallbacks.onUserInitiatedDockDone(i,r,s,t,null)}changeUseOfHDGeometry(e,t){this._rapiAccess.changeUseOfHDGeometry();const n=e.planObjectId,r=e.lastLoadedRapiId?e.lastLoadedRapiId:this._kernelInstance.getComponentId(n),i=this._kernelInstance.getSerializedConfiguration(n);this._kernelInstance.clearAll(),this._kernelInstance.useHDGeometry(t),Ns.finishOperation(3,[i,r])}webGlPreviewDockings(e,t){Ns.waitFor(4).then(({componentId:n})=>{t&&this.requestPlanComponentConstruction(n),this._kernelInstance.requestPreviewGeometry(n,e.planObjectId)}),e.lastPossibleChild&&e.lastPossibleChild.isComponent&&(this._kernelIo.setMeta({componentId:e.lastPossibleChild.id}),this._kernelInstance.loadPlainComponent(10,e.lastPossibleChild.id,e.lastPossibleChild.configuration)),e.lastPossibleChild&&e.lastPossibleChild.isItem&&this._kernelInstance.loadFreeFlyingConfiguration(10,e.lastPossibleChild.configuration)}previewDockingsWithDrag(e,t){this._kernelInstance.requestPreviewGeometry(e,t)}loadConfiguration(e){this._initData.id?this._memoryManager.loadingConfiguration(this._initData.id):this._memoryManager.loadingConfigurationString(),this._memoryManager.shouldHardReset()?this._kernelInstance.clearAll():this._kernelInstance.clearScene(),this._kernelInstance.loadConfiguration(wa,e,{x:0,y:0,z:0})}changeCommonComponentParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setPlanComponentParameters(this._utilityToLongArray(e),t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s),this._updateCommonComponentDependencies(e)}changeComponentParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setComponentParameter(e,t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s),this._updateComponentDependencies(e)}changePlanObjectParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setPlanObjectParameter(e,t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s)}_finishParameterChange(e,t,n){-1===xa.indexOf(e)?setTimeout(()=>t(),0):this._configuratorKernelCallbackListener.forEach(e=>e.finishParameterChange(t,n))}requestDeleteComponents(e){e&&this._kernelInstance.deletePlanComponents(this._utilityToLongArray(e))}requestDeletePlanComponent(e){var t,n;e&&(null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)&&this._kernelInstance.deletePlanComponent(e)}loadComponentIntoKernel(e,t){this._kernelIo.setMeta({componentId:t}),this._kernelInstance.loadComponentDefinition(10,e)}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const r=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(r,btoa(e))}requestSync(e,t){this.planObjectCreated(e,t),this._kernelInstance.syncPlanObjectToView(e,t)}getGlobalParameters(e,t){return new Promise(n=>{let r=this._kernelInstance.getPlanObjectParameters,i=e;t&&(r=this._kernelInstance.getComponentParameters,i=this._kernelInstance.getRootPlanComponentIdFromObjectId(e)),n(r.apply(this._kernelInstance,[i]))})}getPartList(){return new Promise(e=>{e(this._kernelInstance.getFullPartList())})}getConfigurationHash(e){return new Promise(t=>t(this._kernelInstance.getHashOfConfiguration(e.planObjectId)))}requestPlanObjectConstruction(e){this._kernelInstance.requestPlanObjectConstruction(e)}isReady(){super.isReady(),this._setupKernel(),Ts.isProduction||(window.__RML__DEBUG__.Kernel=this._kernelInstance,window.__RML__DEBUG__.KernelContainer=this._kernelContainer,window.__RML__DEBUG__.Helper={convertCObject:_r}),this._configuratorKernelAccessCallback.isReady(),this._configuratorUiCallbacks.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),ks.planObjectId&&this.planObjectCreated(-1,ks.planObjectId)}_setupKernel(){1===this._kernelType&&(Ls.start("kernel_create_instance"),ks.kernelInstance?this._kernelInstance=ks.kernelInstance:this._kernelInstance=new this._kernelContainer.Kernel),this._initKernel()}onLoadComponentError(e,t){this._configuratorUiCallbacks.onComponentLoadError(e,t)}configurationLoaded(e,t,n,r,i,s){Ns.finishOperation(4,{conversationId:e,objectId:t,componentId:n,hash:r,errors:_r(i)}),this._configuratorKernelCallbackListener.forEach(s=>s.configurationLoaded(e,t,n,r,i))}componentDefinitionLoaded(e,t){Ns.finishOperation(0,t)}componentDefinitionLoadingError(e,t){this._kernelIo.error(t),Ns.failOperation(0,new Error(t))}configurationLoadingError(e,t){let n="Configuration loading error";if(t){const e=_r(t);Array.isArray(e)&&(n=e.join("\n"),e.forEach(e=>this._kernelIo.error(e)))}Ns.failOperation(4,new Error(n)),Ns.failOperation(2,new Error(n))}componentConfigurationUpdated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.componentConfigurationUpdated(e,t)),this._kernelInstance.requestDeltaPlanComponentConstruction(e)}setActiveGroupInView(e){this._kernelInstance.setActiveGroupInView(e)}setActiveGroupInViewForPlanObject(e,t){this._kernelInstance.setActiveGroupInViewForPlanObject(e,t||this._configuratorContext.planObjectId)}componentParameters(){}requestComponentDimensions(){}planObjectCreated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.planObjectCreated(e,t))}planObjectUpdated(e){const t=this._kernelInstance.getPlanObject(e);this._onBoundsUpdate(t),this._configuratorKernelCallbackListener.forEach(e=>e.planObjectUpdated(t))}planObjectConfigurationUpdated(e,t,n,r,i){this.updatePlanObjectDependencies(e);let s=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e));this._configuratorKernelCallbackListener.forEach(r=>r.planObjectConfigurationUpdated(e,t,n));const a=this._kernelInstance.getPlanObject(e);return this._onBoundsUpdate(a),this._configuratorHistory.push(t),this._updateConfigurationHasChildren(e,s),this.requestPartListAndUpdatePricesOfParts(n)}_onBoundsUpdate(e){if(!e.boxForMeasurement)return;const t={width:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.x),height:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.z),depth:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.y),kernelBounds:e.boxForMeasurement};this._configuratorUiCallbacks.onBoundsUpdate(t)}planObjectDeleted(){}requestPlanObjectDimensions(){}async requestExternalMesh(e,t){let n=()=>{};const r=new Promise((e,t)=>{n=e});let i;this.externalMeshQueue.push(r),this._configuratorUiCallbacks.onRequestExternalMesh(e,t);try{i=await this._rapiAccess.getMesh(e,"crt",t)}catch(t){return this._handleInvalidMesh(e),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" can not be loaded. "${t}"`)),void console.error(t)}try{const r=await fetch(new Request(this._dataSyncer.requestAsset(i.url,!0))),s=await r.arrayBuffer();this._handleCortoMesh(s,e,t),n()}catch(t){return this._handleInvalidMesh(e),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" breaks. "${t}"`)),void console.error(t)}}Editor3dComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!1)),r&&r>0&&this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,r,t,n))}Editor3dRootComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!0))}Editor3dPlanObjectConstructionDone(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dPlanObjectConstructionDone(e)),this.updatePlanObjectDependencies(e),this._updateConfigurationHasChildren(e),this._initData.moc||this._calcPrice()}Editor3dBeginGroup(){}Editor3dEndGroup(){}Editor3dSetMaterial(){}Editor3dLoadMaterial(){}Editor3dAddDockPreview(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dAddDockPreview(e,t))}Editor3dSetPreviewPointAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewPointAssociations(e,t))}Editor3dSetPreviewLineAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewLineAssociations(e,t))}Editor3dPreviewConstructionDone(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dPreviewConstructionDone(e,t))}Editor3dTranslateBy(){}Editor3dRotateBy(){}Editor3dRotateAround(){}Editor3dAddCube(){}Editor3dAddCubeUVMod(){}Editor3dAddSphere(){}Editor3dAddSphereUVMod(){}Editor3dAddRectangle(){}Editor3dAddRectangleUVMod(){}Editor3dAddMesh(){}Editor3dAddMeshUVMod(){}Editor3dAddMeshUVCoord(){}Editor3dAddCylinder(){}Editor3dAddCylinderUVMod(){}Editor3dAddPrism(){}Editor3dAddPrismUVMod(){}Editor3dAddFittingPoint(){}Editor3dAddFittingLine(){}Editor3dSelectObject(){}Editor3dCopy(){}Editor3dUpdatePlanObjectPosition(){}Editor3dUpdatePlanObjectRotation(){}Editor3dUpdatePlanObjectTransform(){}Editor3dUpdatePlanComponentPosition(){}Editor3dUpdatePlanComponentRotation(){}Editor3dUpdatePlanComponentTransform(){}getRuntimeComponentIdOfRootComponent(e){return this._kernelInstance?this._kernelInstance.getRootPlanComponentIdFromObjectId(e):(console.warn("this._kernelInstance not ready now"),0)}getRuntimeComponentId(e){return this._kernelInstance.getComponentId(e)}getParameterGroups(){if(!this._configuratorContext.planObjectId)return[];const e=this._kernelInstance.getRootPlanComponentIdFromObjectId(this._configuratorContext.planObjectId);return this._kernelInstance.getComponent(e).parameterGroups}resume(){this.muteKernelCallbacks||super.resume()}getSerializedConfiguration(e){return this._kernelInstance.getSerializedConfiguration(e)}createNewSerializedConfiguration(e){return this._kernelInstance.createNewSerializedConfiguration(e)}getCurrentConfigurationHash(e){return this._kernelInstance.getHashOfConfiguration(e)}listOfVariantsError(e,t){this._kernelIo.setMeta({rapiId:e}),this._kernelIo.error(t)}}tn([rn],Ca.prototype,"_memoryManager",void 0),tn([rn],Ca.prototype,"_configuratorKernelAccessCallback",void 0),tn([rn],Ca.prototype,"_initData",void 0),tn([rn],Ca.prototype,"_configuratorHistory",void 0);class Sa extends ys{constructor(e){super(e);const t=this.getPlanElement().getMaxWallHeight();this._container.position.y=(t<0?2800:t)/1e3+.01,this._container.name="Node Plan Element",this.addMesh(this._nodeUiMesh)}update(){super.update(),this._container.position.y=this.getPlanElement().getMaxWallHeight()/1e3+.01}_initNodeMesh(){if(this._nodeUiMesh)return;const e=new Qe(.05,32),t=new y({color:16777215});this._sphere=new H(e,t);const n=new Ye(.05,.07,32),r=new y({color:0,side:B});this._innerRingMesh=new H(n,r),this._innerRingMesh.rotation.set(Math.PI/2,0,0);const i=new Ye(.07,.08,32),s=new y({color:16777215,side:B});this._outerRingMesh=new H(i,s),this._outerRingMesh.rotation.set(Math.PI/2,0,0),this._nodeUiMesh=new H,this._nodeUiMesh.add(this._sphere),this._nodeUiMesh.add(this._innerRingMesh),this._nodeUiMesh.add(this._outerRingMesh)}setTopView(e){super.setTopView(e),e||(this._nodeUiMesh.visible=!1)}getSize(){return this._initNodeMesh(),(new ge).setFromObject(this._nodeUiMesh).getSize(new a)}show(){this._nodeUiMesh.visible=this._topView}hide(){this._nodeUiMesh.visible=!1}select(){this._innerRingMesh.material=new y({color:10526880,side:B}),super.select()}deselect(){this._innerRingMesh.material=new y({color:0,side:B}),super.deselect()}hoverOn(){this._sphere.geometry=new Qe(.07,32),this._innerRingMesh.geometry=new Ye(.07,.07+.02,32),this._outerRingMesh.geometry=new Ye(.07+.02,.1,32),super.hoverOn()}hoverOff(){this._sphere.geometry=new Qe(.05,32),this._innerRingMesh.geometry=new Ye(.05,.07,32),this._outerRingMesh.geometry=new Ye(.07,.08,32),super.hoverOff()}_generateBoundingBox(){const e=super._generateBoundingBox();return e.layers.set(9),e}addMesh(e){super.addMesh(e)}}e("a3",Sa);class Ma extends Ps{constructor(e){super(e),this._container.name="Construction "+this._container.name}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView(),this._updateBoundingBox()}_enableTopView(){if(!this._topViewContainer){this._topViewContainer=new q;const e=this.getPlanElement(),{x:t,z:n}=mr(e.size),r=new ke(t,.01,n);if(this._topGreyMesh=new H(r,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:11645361})),this._topViewContainer.add(this._topGreyMesh),"window"===e.getObjectType()){const e=new ke(t,.02,.05);this._topBlackMesh=new H(e,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:0})),this._topViewContainer.add(this._topBlackMesh)}this._topViewContainer.position.y=5,this._container.add(this._topViewContainer)}this._topViewContainer.visible=!0}_disableTopView(){this._topViewContainer&&(this._topViewContainer.visible=!1)}getPlanElement(){return super.getPlanElement()}_generateBoundingBox(){const e=super._generateBoundingBox(),t=this.getSize();return e.geometry=new ke(t.x,this._topView?5:t.y,t.z),e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new ke(e.x,this._topView?5:e.y,e.z)}getTopViewContainer(){return this._topViewContainer}update(){if(super.update(),!this._topGreyMesh)return;const{x:e,z:t}=mr(this.getPlanElement().size);this._topGreyMesh.geometry=new ke(e,.01,t),this._topBlackMesh&&(this._topBlackMesh.geometry=new ke(e,.02,.05))}}e("a9",Ma);class Ta extends Ca{get kernelContainer(){return this._kernelContainer}constructor(e){super(e),this._plannerKernelCallbackListener=new Set}_loadSuccess(){super._loadSuccess(),window.RoomleCore&&window.RoomleCore(this._kernelContainer)}_loadError(){super._loadError(),console.error("kernel load error")}_createPlanInteractionHandler(){this._planInteractionHandler=new this._kernelContainer.PlanInteractionHandler,this._planInteractionHandler.init(this._planInteractionHandler,1,50,!!this._initData.snappingEnabled,!0,this._kernelContainer.DrawingType.CLICK_PER_CLICK),this._roomlePlannerUiCallback.onPlanInteractionHandlerCreated(this._planInteractionHandler)}addPlannerListener(e){this._plannerKernelCallbackListener.add(e)}removePlannerListener(e){this._plannerKernelCallbackListener.delete(e)}isReady(){super.isReady(),this.registerCallbacks(),this._roomlePlannerUiCallback.onPlannerKernelIsReady(this._kernelContainer),this._roomlePlannerUiCallback.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Ts.isProduction||(window.__RML__DEBUG__.ConfiguratorKernel=this._kernelInstance,window.__RML__DEBUG__.PlannerKernelContainer=this._kernelContainer),this._kernelAccessCallback.isReady()}_setupKernel(){0===this._kernelType&&(this._createPlanInteractionHandler(),ks.kernelInstance?this._kernelInstance=ks.kernelInstance:this._kernelInstance=this._planInteractionHandler.getConfiguratorKernel()),super._setupKernel()}get callbacks(){return this._roomlePlannerUiCallback}get planInteractionHandler(){return this._planInteractionHandler}get planModelViewHelper(){return this._kernelContainer.PlanModelViewHelper}catalogItemLoaded(e){const t=this._rapiItemToKernelItem(e);this._kernelContainer.catalogItemLoaded(t)}async insertItems(e){this.planInteractionHandler.startInteraction();let t=new this._kernelContainer.CatalogItemPtrList;e.forEach(e=>{let n=e.count||1;for(let r=0;r<n;r++)e.count||(e.count=0),t.push_back(this._rapiItemToKernelItem(e))});const n=this.planInteractionHandler.getPlan().extRef.jsObject,r=n.getPlanObjectViewModelsFromRapiId().reduce((e,t)=>(e[t.getId()]=!0,e),{});this.planInteractionHandler.addPlanObjects(t,!0),await Promise.allSettled([Promise.allSettled(n.getStaticPlanObjectViewModels().map(async e=>{if(e.needsRapiItem()){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}})),Promise.allSettled(n.getConfigurablePlanObjectViewModels().map(e=>e.isInitDone()))]);const i=n.getPlanObjectViewModelsFromRapiId().map(e=>e.getId()).filter(e=>!r[e]);return this.planInteractionHandler.endInteraction(),i}duplicateItems(e){const t=new this.kernelContainer.PlanObjectPtrList;return e.forEach(e=>{t.push_back(e)}),this.planInteractionHandler.duplicatePlanObjects(t,1,!0)}_rapiItemToKernelItem(e){let t=new this._kernelContainer.CatalogItem(e.id),n=t.size;return n.x=e.width||0,n.y=e.depth||0,n.z=e.height||0,t.size=n,t.flipable=e.flipable,e.layer&&(t.layer=e.layer),t.orderable=e.orderable,t.scaleable=e.scaleable,t.type=e.type||"other",t.detailType=e.detailType||t.type||"other",t.configuration=e.configuration||"",t}planObjectDeleted(){}requestPlanObjectDimensions(){}cleanUpCallbacks(){var e;super.cleanUpCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.unregisterPlannerCallback)&&this._kernelContainer.unregisterPlannerCallback(this)}registerCallbacks(){var e;super.registerCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.registerPlannerCallback)&&this._kernelContainer.registerPlannerCallback(this)}planElementRemoved(e){this._plannerKernelCallbackListener.forEach(t=>t.planElementRemoved(e)),this._plannerKernelCallbackListener.forEach(t=>t.removePlanObjectFromScene(e.extRef.jsObject)),this._decoupleReferences(e)}handlerSwitchedPlans(e,t){this._decoupleReferences(e),t&&this._plannerKernelCallbackListener.forEach(n=>n.handlerSwitchedPlans(e,t))}planBoundsChanged(){this._plannerKernelCallbackListener.forEach(e=>e.planBoundsChanged())}planCleared(){this._plannerKernelCallbackListener.forEach(e=>e.planCleared())}planCompletelyLoaded(e){this._plannerKernelCallbackListener.forEach(t=>t.planCompletelyLoaded(e))}planElement3dMeshChanged(e,t){if(t.extRef){const e=t.extRef.jsObject;for(let t=e.getObject().children.length-1;t>=0;t--)e.getObject().remove(e.getObject().children[t])}this.planModelViewHelper.requestMesh3d(t)}async _onStaticItemAdded(e,t){let n;n=this.isConstructionPlanElement(t)?new Ma(t):new Ps(t),this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n);const r=t.getCatalogItemId();if(r){const e=await this._rapiAccess.getItem(r);n.setRapiItem(e),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}}_onConfigurableItemAdded(e,t){const n=new Cs(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}async planElementAdded(e,t){if(e&&e.extRef)if(t.getType()===this._kernelContainer.PlanElementType.OBJECT)t.hasConfiguration()?this._onConfigurableItemAdded(e,t):await this._onStaticItemAdded(e,t);else{const n=t;let r;if(t.getType()===this._kernelContainer.PlanElementType.WALL?r=new Rs(n):t.getType()===this._kernelContainer.PlanElementType.FLOOR?r=new Is(n):t.getType()===this._kernelContainer.PlanElementType.CEILING?r=new Ds(n):t.getType()===this._kernelContainer.PlanElementType.NODE&&(r=new Sa(n)),!r)return;this.coupleReferences(r,n),e.extRef.jsObject.addPlanElementViewModel(r),this.planModelViewHelper.requestMesh3d(t),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(null))}}planElementChanged(e,t){if(t.extRef){let n=t.extRef.jsObject;n.update(),this._plannerKernelCallbackListener.forEach(t=>t.planElementChanged(e,n))}}planHistoryStateChanged(){this.planInteractionHandler&&(this._plannerKernelCallbackListener.forEach(e=>e.planHistoryStateChanged()),this._roomlePlannerUiCallback.onHistoryChange(this.planInteractionHandler.isUndoPossible(),this.planInteractionHandler.isRedoPossible()))}planObjectConfigurationCreated(e,t){}planObjectConfigurationLoaded(e,t,n){e&&e.extRef&&t&&t.extRef&&t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId()>0&&this._plannerKernelCallbackListener.forEach(r=>r.planObjectConfigurationLoaded(e,t,n))}requestCatalogItem(e){}startedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.startedDrawing())}stoppedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.stoppedDrawing())}updateMesh2d(){}beginConstruction(){}addMesh(e,t,n,r,i,s){this._plannerKernelCallbackListener.forEach(a=>a.addMesh(e,t,n,r,i,s))}endConstruction(){}beginPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.beginPlanConstruction(e))}addPlanMesh(e,t,n,r,i,s,a){this._plannerKernelCallbackListener.forEach(o=>o.addPlanMesh(e,t,n,r,i,s,a))}endPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.endPlanConstruction(e))}async addPlanObjectFromItem(e,t,n){if(!t&&!n){const t=await this.insertItems([e]);if(1!==t.length)throw new Error("It was expected that 1 element is added but"+t.length+"were added");return t[0]}n=n||0===n?n:0,t=t||{x:0,y:0,z:0};const r=this._planInteractionHandler.addPlanObjectFromItem(this._rapiItemToKernelItem(e),t,n,!1),i=this._planInteractionHandler.getPlan().extRef.jsObject;let s;return r.hasConfiguration()?(s=i.getConfigurablePlanObjectForId(r.getId()),s||console.warn("Could not find configuration")):(s=i.getStaticPlanObjectViewModelForId(r.getId()),s?await s.setRapiItem(e):console.warn("Could not find static item")),await s.isInitDone(),s.getId()}coupleReferences(e,t){let n=new this._kernelContainer.EMSReference;n.jsObject=e,t.extRef=n}_decoupleReferences(e){e&&e.extRef&&(e.extRef.jsObject.clearReference(),e.extRef.jsObject=null,e.extRef.delete(),e.extRef=null)}isConstructionPlanElement(e){return e instanceof this.kernelContainer.ConstructionObject}}e("ac",Ta),tn([rn],Ta.prototype,"_kernelAccessCallback",void 0),tn([rn],Ta.prototype,"_roomlePlannerUiCallback",void 0);class Pa extends is{constructor(e){super(e),this._wallMeshes=[],this._defaultMaterial=Ti.createMeshPhysicalMaterial({color:"#ffffff",side:B})}generateGeometry(e=null,t,n,r,i,s=!1){let a;return a=s?this._generateGeometry(e,t,n,r,i).clone():this._generateGeometry(e,t,n,r,i),a}generateMesh(e=0,t=null,n,r,i,s,a,o,l=!1,h){let d;d=l?this._generateGeometry(t,r,i,s,a).clone():this._generateGeometry(t,r,i,s,a);const c=this._createMesh(e,t,d);return c.userData.materialId=n,c.layers.set(4),n&&this.setMaterial(c,n,o,h).then(()=>{e&&t&&n&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n);const r=o&&3===o.value,i=o&&1===o.value;c.castShadow=!r&&!i}),this._checkWallMaterial(c,o),c}async setMaterial(e,t,n,r){if(e.userData.materialId=Wi(t,n),Ze(t))t?await this._assignMaterial(e,t,r):(console.warn("Used default material because material is empty"),this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)));else{if(!t)return void this.changeMaterialOfMesh(e,this._configuratorPreviewMaterial);2===(t=t).getSourceType().value?await this._assignMaterial(e,t.materialId,r):1===t.getSourceType().value?await this._assignItem(e,t.catalogItemId):3===t.getSourceType().value?await this._assignRGB(e,t.rgbValue):0===t.getSourceType().value?this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)):(this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)),1!==n.value&&7!==n.value&&3!==n.value&&console.warn("Used default material because material is not supported",t))}}_getDefaultMaterial(e){return 3===(null==e?void 0:e.value)?this._defaultMaterialFloor:this._defaultMaterial}set maxAnisotropy(e){this._maxAnisotropy=e}_checkWallMaterial(e,t){t&&1===t.value&&(e.renderOrder=5,this._wallMeshes.push(e))}clear(){super.clear(),this.clearWallMeshes()}clearWallMeshes(){this._wallMeshes.forEach(e=>{Gi(e)}),this._wallMeshes=[]}get wallMeshes(){return this._wallMeshes}}e("ap",Pa);let Aa={InchFeet:null,Feet:null,MM:null,CM:null,Inch:null},Ea={NoUnitString:null,LongUnitString:null,ShortUnitString:null};const Ra=["mm","cm","feet"],Ia=["inch","inchfeet"];class Da{constructor(e){this._formatter=null,this._precision=0,this._creator_=e}init(e){const t=new e.UnitMeasureFormatter;Aa=e.Unit,Ea=e.UnitStringType,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType();const{precisionCm:n,precisionInch:r}=this._initData;this._actualUnit===Aa.InchFeet?this._precision=void 0!==r?parseInt(r,10):2:this._actualUnit===Aa.CM&&(this._precision=void 0!==n?parseInt(n,10):1),t.init("mm","cm","'","ft",'"',"inch","m²","sqft",!0,this._precision,!0),this._formatter=t}_initMeasurementSystemType(){let{measurementSystem:e,unit:t}=this._initData;if(this._actualMeasurementString=e,e||!t){if("metric"===e){t||(t="cm");const e=Ra.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not a metric unit, using CM"),this._actualUnit=Aa.CM,this._actualUnitString="cm")}if("imperial"===e){t||(t="inch");const e=Ia.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not an imperial unit, using Inches"),this._actualUnit=Aa.Inch,this._actualUnitString="inch")}}else{this._actualUnitString=t;const e=Ra.find(e=>e===t);this._actualMeasurementString=e?"metric":"imperial"}}_initActualUnit(){const{unit:e}=this._initData;this._actualUnit=this._getKernelUnitEnum(e)}_getKernelUnitEnum(e){switch(e){case"cm":return Aa.CM;case"mm":return Aa.MM;case"inchfeet":return Aa.InchFeet;case"feet":return Aa.Feet;case"inch":return Aa.Inch;default:return Aa.CM}}_initActualUnitStringType(){const{unitStringType:e}=this._initData;e&&"short"!==e&&console.warn("Only short unit strings is supported at the moment"),this._actualUnitStringType=Ea.ShortUnitString}_isFormatterReady(){return!!this._formatter||(console.warn("Formatter is not ready..."),!1)}formatAngleValueToUnitString(e,t){const n="Integer"===t.type?0:2;return e.toFixed(n)+"°"}parseAngleValueFromUnitString(e){return e.replace("°","").replace(/\s/g,"")}parseValue(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?e:"length"===t.unitType?this.parseMMValueFromUnitString(e,t.unitType):"angle"===t.unitType||"area"===t.unitType?this.parseAngleValueFromUnitString(e):e}formatValueToUnitString(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?"Integer"===t.type?e.toString():parseFloat(e.toString()).toFixed(2):"length"===t.unitType?this.formatMMValueToUnitString(e,t.unitType):"angle"===t.unitType?this.formatAngleValueToUnitString(e,t):"area"===t.unitType?this.formatSquareMMValueToUnitString(e):e}isParseableNumber(e){return this._isFormatterReady()?this._formatter.isParseableNumber(e):null}isParseableUnitString(e,t){return this._isFormatterReady()?"angle"===t.unitType?this._formatter.isParseableUnitString(this.parseAngleValueFromUnitString(e),this._actualUnit):this._formatter.isParseableUnitString(e,this._actualUnit):null}parseMMValueFromUnitString(e,t){return this._isFormatterReady()?"count"===t?parseFloat(e):this._formatter.parseMMValueFromUnitString(e,this._actualUnit):null}parseNumber(e){return this._isFormatterReady()?this._formatter.parseNumber(e):null}formatNumber(e,t=0){return this._isFormatterReady()?this._formatter.formatNumber(e,t):null}formatSquareMMValueToUnitString(e){return this._isFormatterReady()?this._formatter.formatSquareMMValueToUnitString(e,this._actualUnit):null}formatMMValueToUnitString(e,t){return this._isFormatterReady()?"count"===t?e.toString():this._formatter.formatMMValueToUnitString(e,this._actualUnit,this._actualUnitStringType):null}formatMMValueWithReqMaxLength(e,t){return this._isFormatterReady()?this._formatter.formatMMValueWithReqMaxLength(e,this._actualUnit,t):null}_formatParameterValue(e,t){return"length"===t?this.formatMMValueToUnitString(parseFloat(e)):"area"===t?this.formatSquareMMValueToUnitString(parseFloat(e)):e}formatPartListParameter(e){(function(e){return"length"===e.unitType||"area"===e.unitType})(e)&&(e.valueLabel=this._formatParameterValue(e.value,e.unitType))}formatParameter(e){if(e.valueLabel=this._formatParameterValue(e.value,e.unitType),Gs(e))e.uiType="Material";else if(function(e){return"Boolean"===e.type}(e))e.uiType="Boolean";else if(Bs(e)){e.uiType="Range";const t=null!==e.validRange.valueFrom?e.validRange.valueFrom:Number.MIN_SAFE_INTEGER,n=null!==e.validRange.valueTo?e.validRange.valueTo:Number.MAX_SAFE_INTEGER;e.validRangeLabels={valueFrom:this._formatParameterValue(t.toString(),e.unitType),valueTo:this._formatParameterValue(n.toString(),e.unitType),type:e.validRange.type}}else js(e)?(e.uiType="Options",function(e){return!!js(e)&&Array.isArray(e.validValues)&&e.validValues.length>0&&"string"==typeof e.validValues[0].thumbnail}(e)&&(e.uiType="Thumbnails")):(console.error("Could not detect uiType of param"),e.uiType=null)}isInch(){return this._actualUnit===Aa.InchFeet}getActualUnitString(){return this._actualUnitString}getActualMeasurementString(){return this._actualMeasurementString}getUnitStringType(){return this._initData.unitStringType}getPrecision(){return this._precision}getAllowedDelta(){const e=1/Math.pow(10,this._precision);return this.isInch()?25.4*e:e}setUnitInitData(e,t=""){this._initData.unit=e,this._initData.measurementSystem=t,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType(),this._plannerKernelAccess.kernelInstance.setEnvironmentVariable("unit",this._actualUnitString)}}tn([rn],Da.prototype,"_initData",void 0),tn([rn],Da.prototype,"_plannerKernelAccess",void 0);class Oa{constructor(e){this._history=[],this._index=0,this._creator_=e}undo(){if(!this.canUndo())return null;this._index++;const[e]=this._history.slice(this._index);return this._index===this._history.length-1?this._configuratorUiCallbacks.onHistoryChange(!1,!0):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}redo(){if(!this.canRedo())return null;this._index--;const[e]=this._history.slice(this._index);return 0===this._index?this._configuratorUiCallbacks.onHistoryChange(!0,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}push(e){const[t]=this._history.slice(this._index);t!==e&&(this._history=this._history.slice(this._index),this._history.unshift(e),this._index=0,1===this._history.length?this._configuratorUiCallbacks.onHistoryChange(!1,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!1))}canUndo(){return this._index!==this._history.length-1}canRedo(){return 0!==this._index}getHistory(){return this._history}clearHistory(){this._history=[],this._index=0}}tn([rn],Oa.prototype,"_configuratorUiCallbacks",void 0),e("ag",{ADDED:"added",CHANGED:"changed",REMOVED:"removed"});class La{constructor(e){this._kernelCallbacks={isReady:()=>{},throw:e=>console.error("Kernel exception",e),log:e=>{},error:(e,t,n,r)=>{},message:e=>{this._analyzeComponentCallback&&this._analyzeComponentCallback(e)}},this._creator_=e}async init(){if(this._toolsCoreInstance)return Promise.resolve();const e=this,t={locateFile:e=>"RoomleToolsCore.wasm"===e?n()+"static/RoomleToolsCore-0000327e9e7afae4.wasm":e,wasmBinaryFile:n()+"static/RoomleToolsCore-0000327e9e7afae4.wasm",preRun:[],postRun:[],setStatus:null,print(t){e._kernelIo.log(t)},printErr(t){e._kernelIo.error(t)},quit(t){0!==t&&e._kernelIo.throw(t&&t.toString?t.toString():"Unknown error while C/C++ main executes")}};await this._scriptLoader.fetch("static/RoomleToolsCore-09b8f5cc8e93df5f.js",{id:"core-tool"});const r=await window.RoomleToolsCore(t);r.setContext(this._kernelCallbacks),this._toolsCoreInstance=new r.ToolsCore}analyzeComponent(e,t){const n=[];return this._analyzeComponentCallback=e=>{n.push(e)},this._toolsCoreInstance.analyzeComponent(e,t),this._analyzeComponentCallback=null,Promise.resolve(n)}}tn([rn],La.prototype,"_scriptLoader",void 0),tn([rn],La.prototype,"_kernelIo",void 0);
|
|
1
|
+
System.register(["./main-thread-to-worker-f0c51758.nomodule.js"],(function(e,t){var n,r,i,s,a,o,l,h,d,c,u,p,m,g,f,_,v,w,b,y,x,S,C,M,T,P,A,E,R,I,D,O,L,k,U,F,N,B,j,G,H,z,V,W,K,q,X,Q,Y,Z,J,$,ee,te,ne,re,ie,se,ae,oe,le,he,de,ce,ue,pe,me,ge,fe,_e,ve,we,be,ye,xe,Se,Ce,Me,Te,Pe,Ae,Ee,Re,Ie,De,Oe,Le,ke,Ue,Fe,Ne,Be,je,Ge,He,ze,Ve,We,Ke,qe,Xe,Qe,Ye,Ze,Je,$e,et,tt,nt,rt,it,st,at,ot,lt,ht,dt,ct,ut,pt,mt,gt,ft,_t,vt,wt,bt,yt,xt,St,Ct,Mt,Tt,Pt,At,Et,Rt,It,Dt,Ot,Lt,kt,Ut,Ft,Nt,Bt,jt,Gt,Ht,zt;return{setters:[function(e){n=e.g,r=e.A,i=e.D,s=e.V,a=e.a,o=e.R,l=e.S,h=e.C,d=e.M,c=e.B,u=e.b,p=e.T,m=e.c,g=e.d,f=e.L,_=e.e,v=e.F,w=e.f,b=e.P,y=e.h,x=e.i,S=e.j,C=e.k,M=e.Q,T=e.I,P=e.l,A=e.O,E=e.m,R=e.n,I=e.o,D=e.p,O=e.q,L=e.r,k=e.s,U=e.t,F=e.u,N=e.v,B=e.w,j=e.x,G=e.y,H=e.z,z=e.E,V=e.G,W=e.H,K=e.J,q=e.K,X=e.N,Q=e.U,Y=e.W,Z=e.X,J=e.Y,$=e.Z,ee=e._,te=e.$,ne=e.a0,re=e.a1,ie=e.a2,se=e.a3,ae=e.a4,oe=e.a5,le=e.a6,he=e.a7,de=e.a8,ce=e.a9,ue=e.aa,pe=e.ab,me=e.ac,ge=e.ad,fe=e.ae,_e=e.af,ve=e.ag,we=e.ah,be=e.ai,ye=e.aj,xe=e.ak,Se=e.al,Ce=e.am,Me=e.an,Te=e.ao,Pe=e.ap,Ae=e.aq,Ee=e.ar,Re=e.as,Ie=e.at,De=e.au,Oe=e.av,Le=e.aw,ke=e.ax,Ue=e.ay,Fe=e.az,Ne=e.aA,Be=e.aB,je=e.aC,Ge=e.aD,He=e.aE,ze=e.aF,Ve=e.aG,We=e.aH,Ke=e.aI,qe=e.aJ,Xe=e.aK,Qe=e.aL,Ye=e.aM,Ze=e.aN,Je=e.aO,$e=e.aP,et=e.aQ,tt=e.aR,nt=e.aS,rt=e.aT,it=e.aU,st=e.aV,at=e.aW,ot=e.aX,lt=e.aY,ht=e.aZ,dt=e.a_,ct=e.a$,ut=e.b0,pt=e.b1,mt=e.b2,gt=e.b3,ft=e.b4,_t=e.b5,vt=e.b6,wt=e.b7,bt=e.b8,yt=e.b9,xt=e.ba,St=e.bb,Ct=e.bc,Mt=e.bd,Tt=e.be,Pt=e.bf,At=e.bg,Et=e.bh,Rt=e.bi,It=e.bj,Dt=e.bk,Ot=e.bl,Lt=e.bm,kt=e.bn,Ut=e.bo,Ft=e.bp,Nt=e.bq,Bt=e.br,jt=e.bs,Gt=e.bt,Ht=e.bu,zt=e.bv}],execute:function(){e({_:tn,i:rn,r:va});class Vt{constructor(){this._context=new Map,this._lookups=new Map,this._singletons=new Map}getContext(e){if(this._context.has(e)){const t=this._context.get(e);return this._context.set(e,t+1),e+t}return this._context.set(e,1),e+0}addDependencyInjectionAssignments(e){e.forEach(e=>{this._lookups.set(e.className,e)})}lookup(e,t){if(!this._lookups.has(e))return null;const n=this._lookups.get(e);if(1===n.type&&void 0===t){const t="Dependency "+e+" has definition context but no context was defined!";return console.trace(t),console.error(t),null}let r=t&&1===n.type?t:"global";if(r+="_"+e,2===n.type)return new n.classDefinition;if(this._singletons.has(r))return this._singletons.get(r);const i=new n.classDefinition(t);return this._singletons.set(r,i),i}cleanUp(e){if(e){let t=[];this._singletons.forEach((n,r)=>{r.startsWith(e)&&t.push(r)}),t.forEach(e=>{this._singletons.delete(e)})}else this._singletons.clear(),this._singletons=new Map}}class Wt{constructor(e,t,n){this.className=e,this.classDefinition=t,this.type=void 0===n?0:n}}e("D",Wt);const Kt={JPG:".jpg",JPEG:".jpeg",PNG:".png",GIF:".gif"};class qt{_base64toBlob(e,t){t=t||"";const n=atob(e),r=n.length,i=Math.ceil(r/1024),s=new Array(i);for(let e=0;e<i;++e){let t=1024*e,i=Math.min(t+1024,r);const a=new Array(i-t);for(let e=t,r=0;e<i;++r,++e)a[r]=n[e].charCodeAt(0);s[e]=new Uint8Array(a)}return new Blob(s,{type:t})}_createFormData(e,t,n,r){const i=new FormData;-1!==e.indexOf(",")&&(e=e.substr(e.indexOf(",")+1));const s=-1===Object.keys(Kt).map(e=>Kt[e]).indexOf(n)?"application":"image",a=this._base64toBlob(e,s+"/"+n.substr(1));return i.append(r,a,t+n),i}create(e,t,n,r){return this._createFormData(e,t,n,r)}}const Xt=e("l",{SOFA:"sofa",SHELF:"shelf",SHELF_FRONT:"shelf_front",BAKED:"baked",CAMERA:"camera",EQUAL:"equal"});class Qt{static createDynamicLightSettingSource(e,t){let r={};if(e)r.url=e;else if(t)switch(t){case Xt.SHELF:r.url=n()+"static/shelf-2975dd3f2fa9c763.json";break;case Xt.SHELF_FRONT:r.url=n()+"static/shelf_front-8c9566a4512f0de8.json";break;case Xt.SOFA:r.url=n()+"static/sofa-997b116bc5f2e92e.json";break;case Xt.BAKED:r.url=n()+"static/baked-6485a2b1daeb69e8.json";break;case Xt.CAMERA:r.url=n()+"static/camera-05824b47cdb951e4.json";break;case Xt.EQUAL:r.url=n()+"static/equal-319f6b83c827913f.json";break;default:r.url=n()+"static/camera-05824b47cdb951e4.json"}else r=null;return r}parse(e){let t=JSON.parse(e);return t.lights?this.load(t):[]}load(e){let t=[];return e.lights?(e.lights.forEach(e=>{let n;switch(e.type){case"ambient":n=this._parseAmbientLight(e);break;case"rectarea":n=this._parseRectAreaLight(e);break;case"spot":n=this._parseSpotLight(e);break;case"directional":n=this._parseDirectionalLight(e)}n&&t.push(n)}),t):[]}_parseAmbientLight(e){let t=new r;return this._parseCommon(t,e),t}_parseRectAreaLight(e){let{intensity:t,castShadow:n,target:r,width:l,height:h}=e,d=null;if(n&&Qt.rectAreaLightReplacement){const n=new i;this._parseCommon(n,e),d=n,n.castShadow=!0,n.shadow.camera.near=.1,n.shadow.camera.far=100,n.shadow.mapSize=new s(1024,1024),n.shadow.bias=-5e-5,n.shadow.normalBias=.01,n.intensity=t?t/100:1,n.lookAt(r?new a(r.x,r.y,r.z):new a(0,0,0))}else{const n=new o;this._parseCommon(n,e),d=n,n.width=l||.8,n.height=h||.8,n.castShadow=!1,n.matrixAutoUpdate=!0,n.intensity=(t||240)/((l||.8)*(h||.8)),n.lookAt(r?new a(r.x,r.y,r.z):new a(0,0,0)),Qt.rectAreaLightLoadingListener&&Qt.rectAreaLightLoadingListener(n)}return d}_parseSpotLight(e){let t=new l;this._parseCommon(t,e);let{angle:n,penumbra:r,target:i,castShadow:o}=e;return t.angle=(n||100)*Math.PI/180,t.penumbra=r||.5,t.lookAt(i?new a(i.x,i.y,i.z):new a(0,0,0)),t.shadow.camera.near=.1,t.shadow.camera.far=10,t.shadow.mapSize=new s(1024,1024),t.castShadow=o||!1,t}_parseDirectionalLight(e){let t=new i;this._parseCommon(t,e);let{target:n,castShadow:r}=e;return t.castShadow=r||!1,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize=new s(1024,1024),t.shadow.bias=-5e-5,t.lookAt(n?new a(n.x,n.y,n.z):new a(0,0,0)),t}_parseCommon(e,t){let{name:n,intensity:r,color:i,position:s,movesWithCamera:o}=t;e.name=n||"",e.intensity=r||1,e.color=new h(i||"#ffffff"),e.position.copy(s?new a(s.x,s.y,s.z):new a(0,0,0)),e.visible=!0,e.layers.set(1),e.userData.movesWithCamera=o}}e("k",Qt),Qt.rectAreaLightReplacement=!0;const Yt=["127.0.0.1","localhost","0.0.0.0"],Zt=(e("x",(function(e){return!(!e||"string"!=typeof e||e.split(":").length>2)})),e("w",e=>{if(!e||"string"!=typeof e)return null;const t=e.split(":");return t.length<2?null:t[0]})),Jt=({articleNr:e,componentId:t})=>e&&""!==e?t.split(":")[0]+":"+e:null,$t=(e,t)=>null!=e?"string"==typeof e?"true"===e:!0===e:("string"==typeof t&&(t=parseInt(t,10)),t>=200&&t<300);class en{constructor(){this._queue=[],this._pendingRequests=0}_nextSlot(){if(this._pendingRequests-=1,!this._queue.length)return;const{request:e,resolve:t,reject:n}=this._queue.shift();this._fetch(e).then(t,n)}_fetch(e,t={},n={}){return this._pendingRequests+=1,new Promise((r,i)=>{self.fetch(e,t).then(async function(e){this._nextSlot();const t=!n.checkResponse||!1!==await n.checkResponse(e);if($t(e.ok,e.status)&&t)r(...arguments);else{const t=(null==e?void 0:e.url)||"URL unknown";i(new Error(e.statusText||'Http error "'+(e&&e.status?e.status:"unknown")+'", for "'+t+'"'))}}.bind(this),e=>{this._nextSlot(),i(e)})})}fetch(e,t={},n={}){return this._pendingRequests>=40?new Promise((t,n)=>this._queue.push({request:e,resolve:t,reject:n})):this._fetch(e,t,n)}}function tn(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}"function"==typeof SuppressedError&&SuppressedError;const nn=function(e){return e.startsWith("_")&&(e=e.substr(1)),e.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(function(e,t){return(t>0?"-":"")+e.toLowerCase()}))};function rn(e,t){const n=Symbol("property-cache");Object.defineProperty(e,t,{get(){if(!this[n]){const e=window.__RML__DI__.lookup(nn(t),this._creator_);e?this[n]=e:console.error("Dependency "+nn(t)+" not found! Add dependency to /utils/injectables.ts")}return this[n]}})}class sn{info(...e){console}log(...e){console}warn(...e){console.warn.apply(console,e)}error(...e){console.warn.apply(console,e)}}e("L",sn);class an extends sn{constructor(e){super(),this._creator_=e}setMeta(e){this._meta=e}get meta(){return this._meta?this._meta:{}}throw(e){const t="[Kernel Exception]: "+e;this._globalCallback.onKernelMsg("exception",e,this.meta),this.error(t)}error(e){this._globalCallback.onKernelMsg("error",e,this.meta),super.error(e)}warn(e){this._globalCallback.onKernelMsg("warning",e,this.meta),super.warn(e)}}tn([rn],an.prototype,"_globalCallback",void 0);const on=new Map,ln=new Map,hn=new Map,dn=new Map;class cn{constructor(e){this._bootCallbacks=[],this._isStarted=!1,this._isStarting=!1,this._alwaysUseCache=!1,this._creator_=e}start(e){return this._configuratorUiCallbacks.onSyncStarted(),this._startWorker().then(()=>this._handleCatalog(e)).then(()=>{const{typeChangeTag:e,floorMaterialsTag:t}=this._initData;Promise.all([this._syncFloorTag(t),this._syncTypeChangeTag(e)]).then(()=>{dn.set(e,!0),this._configuratorUiCallbacks.onSyncDone()})})}syncCatalog(e){return this._startWorker().then(()=>this._handleCatalog(e))}syncFloorTag(e){return this._startWorker().then(()=>this._syncFloorTag(e))}syncTypeChangeTag(e){return this._startWorker().then(()=>this._syncTypeChangeTag(e))}_syncFloorTag(e){const t=[];return e&&!hn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{t.push(this._handleMaterialsAndTextures(e))}),this._singlePromiseFactory.create(1,e,n=>{Promise.all(t).then(()=>{hn.set(e,!0),n()},e=>this._softReject(n,'_syncFloorTag error: "'+e+'"'))})):Promise.resolve()}_syncTypeChangeTag(e){const t=[];return e&&!dn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{this._rapiAccess.getItems(e.items).then(e=>{e.forEach(e=>{this.getIsCatalogSynced(e.catalog)&&t.push(this._handleCatalog(e.catalog))})})}),this._singlePromiseFactory.create(2,e,n=>{Promise.all(t).then(()=>{hn.set(e,!0),n()},e=>this._softReject(n,'_syncTypeChangeTag error: "'+e+'"'))})):Promise.resolve()}getIsCatalogSynced(e){return!!ln.get(e)}_startWorker(){return new Promise((e,t)=>{if(this._isStarted)return e();this._bootCallbacks.push({resolve:e,reject:t}),this._isStarting||(this._worker=new Worker(n()+"static/asset-loader.worker-1735a5fb1e401244.js"),this._mainThreadToWorker=new d(this,this._worker),this._isStarting=!0,this._mainThreadToWorker.sendToWorker(1))})}onCommand(e,t,n){switch(e){case 4:this._isStarted=!0,this._bootCallbacks.forEach(({resolve:e})=>e());break;case 3:this._mainThreadToWorker.resolvePromises(t,n)}}_handleCatalog(e){return this._singlePromiseFactory.create(0,e,t=>this.getIsCatalogSynced(e)?t():this._rapiAccess.getCatalog(e).then(e=>Promise.all([this._handleContentWithAssets(this._rapiAccess.getComponentsOf(e),["perspectiveImage"]),this._handleItemsAndAdditionalContents(e),this._handleMaterialsAndTextures(e),this._handleExternalMeshes(e),this._handleTags(e.tags)])).then(()=>{ln.set(e,!0),t()},e=>this._softReject(t,'Catalog sync error: "'+e+'"')))}_handleTags(e){return this._handleContentWithAssets(this._rapiAccess.getTags(e),["pngIcon","svgIcon"])}_handleExternalMeshes(e){return new Promise(t=>{this._rapiAccess.getMeshesOfCatalog(e.id).then(e=>{const n=[];e.forEach(e=>{n.push(this._handleContentWithAssets(Promise.all([this._rapiAccess.getMesh(e.id)]),["url"]))}),Promise.all(n).then(t,e=>this._softReject(t,'Sync crt files error: "'+e+'"'))},e=>this._softReject(t,'getMeshesOfCatalog error: "'+e+'"'))})}_handleItemsAndAdditionalContents(e){return new Promise(t=>{this._rapiAccess.getItemsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["perspectiveImage"])),this._rapiAccess.getAdditionalContentsOfItems(e).then(e=>{const t=e.filter(e=>-1!==[5,6,4].indexOf(e.type));n.push(this._handleContentWithAssets(Promise.resolve(t),["content"]))},e=>this._softReject(t,'getAdditionalContentsOfItems error: "'+e+'"')),Promise.all(n).then(t,e=>this._softReject(t,'AdditionalContent image sync error:"'+e+'"'))})})}_handleMaterialsAndTextures(e){return new Promise(t=>{this._rapiAccess.getMaterialsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["thumbnail"])),e.forEach(e=>{n.push(this._handleContentWithAssets(this._rapiAccess.getTexturesOf(e),["image"]))}),Promise.all(n).then(t,e=>this._softReject(t,'getTexturesOf error: "'+e+'"'))},e=>this._softReject(t,'getMaterialsOf error: "'+e+'"'))})}_handleContentWithAssets(e,t){return new Promise(n=>e.then(e=>this._fetchAssets(e,t).then(n,e=>this._softReject(n,'_handleContentWithAssets error: "'+e+'"')),e=>this._softReject(n,'_handleContentWithAssets promise error: "'+e+'"')))}_fetchAssets(e,t){const n=[];e||(e=[]);for(let r=0,i=e.length;r<i;r++){const i=e[r];t.forEach(e=>{const t=i[e];t&&n.push(this._preCacheAsset(t))})}return Promise.all(n)}_preCacheAsset(e){return new Promise(t=>{if(on.get(e))return t();this._assetUrlToBase64(e).then(n=>{on.set(e,n),t()},e=>this._softReject(t,'_preCacheAsset error: "'+e+'"'))})}_assetUrlToBase64(e){return new Promise(t=>{this._mainThreadToWorker.sendToWorker(5,e,t,e=>this._softReject(t,'_assetUrlToBase64 error: "'+e+'"'))})}_softReject(e,t){this._errorHandler.softReject(e,t,2)}requestAsset(e,t=!1){return navigator.onLine&&!this._alwaysUseCache?e:on.get(e)||(t?e:null)}setAlwaysUseCache(e){this._alwaysUseCache=e}preFillAssetCache(e,t){on.set(e,t)}}e("a",cn),tn([rn],cn.prototype,"_rapiAccess",void 0),tn([rn],cn.prototype,"_singlePromiseFactory",void 0),tn([rn],cn.prototype,"_errorHandler",void 0),tn([rn],cn.prototype,"_configuratorUiCallbacks",void 0),tn([rn],cn.prototype,"_initData",void 0);class un{constructor(e){this.info=e,this._init()}_init(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){e&&this._resolve(e),this._resolve()}reject(e){this._reject(e)}wait(){return this._promise}reset(){this._init()}}function pn(e){let t,n,r,i=-1,s=0;for(let a=0;a<e.length;++a){const o=e[a];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===r&&(r=o.normalized),r!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===i&&(i=o.gpuType),i!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.array.length}const a=new t(s);let o=0;for(let t=0;t<e.length;++t)a.set(e[t].array,o),o+=e[t].array.length;const l=new u(a,n,r);return void 0!==i&&(l.gpuType=i),l}function mn(e,t){if(t===p)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===m||t===g){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(t===m)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}e("ae",un);class gn extends f{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new yn(e)})),this.register((function(e){return new En(e)})),this.register((function(e){return new Rn(e)})),this.register((function(e){return new In(e)})),this.register((function(e){return new Sn(e)})),this.register((function(e){return new Cn(e)})),this.register((function(e){return new Mn(e)})),this.register((function(e){return new Tn(e)})),this.register((function(e){return new bn(e)})),this.register((function(e){return new Pn(e)})),this.register((function(e){return new xn(e)})),this.register((function(e){return new An(e)})),this.register((function(e){return new vn(e)})),this.register((function(e){return new Dn(e)})),this.register((function(e){return new On(e)}))}load(e,t,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},a={},o=new TextDecoder;if("string"==typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Ln){try{s[_n.KHR_BINARY_GLTF]=new kn(e)}catch(e){return void(r&&r(e))}i=JSON.parse(s[_n.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new rr(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[t.name]=t,s[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){const t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case _n.KHR_MATERIALS_UNLIT:s[t]=new wn;break;case _n.KHR_DRACO_MESH_COMPRESSION:s[t]=new Un(i,this.dracoLoader);break;case _n.KHR_TEXTURE_TRANSFORM:s[t]=new Fn;break;case _n.KHR_MESH_QUANTIZATION:s[t]=new Nn;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function fn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const _n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vn{constructor(e){this.parser=e,this.name=_n.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const s=t.json,a=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const d=new h(16777215);void 0!==a.color&&d.setRGB(a.color[0],a.color[1],a.color[2],w);const c=void 0!==a.range?a.range:0;switch(a.type){case"directional":o=new i(d),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new b(d),o.distance=c;break;case"spot":o=new l(d),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),o.decay=2,Zn(o,a),void 0!==a.intensity&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class wn{constructor(){this.name=_n.KHR_MATERIALS_UNLIT}getMaterialType(){return y}extendParams(e,t,n){const r=[];e.color=new h(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],w),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,x))}return Promise.all(r)}}class bn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class yn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],a=r.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){const e=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new s(e,e)}return Promise.all(i)}}class xn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Sn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],w)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,x)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Cn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class Mn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=(new h).setRGB(a[0],a[1],a[2],w),Promise.all(i)}}class Tn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Pn{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=(new h).setRGB(a[0],a[1],a[2],w),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,x)),Promise.all(i)}}class An{constructor(e){this.parser=e,this.name=_n.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?S:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class En{constructor(e){this.parser=e,this.name=_n.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class Rn{constructor(e){this.parser=e,this.name=_n.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class In{constructor(e){this.parser=e,this.name=_n.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Dn{constructor(e){this.name=_n.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(s*a);return i.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class On{constructor(e){this.name=_n.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==Hn.TRIANGLES&&e.mode!==Hn.TRIANGLE_STRIP&&e.mode!==Hn.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,s=[],o={};for(const e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(const e of n){const t=new C,n=new a,s=new M,l=new a(1,1,1),h=new T(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&s.fromBufferAttribute(o.ROTATION,e),o.SCALE&&l.fromBufferAttribute(o.SCALE,e),h.setMatrixAt(e,t.compose(n,s,l));for(const t in o)if("_COLOR_0"===t){const e=o[t];h.instanceColor=new P(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);A.prototype.copy.call(h,e),this.parser.assignFinalMaterial(h),i.push(h)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}}const Ln="glTF";class kn{constructor(e){this.name=_n.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ln)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,i=new DataView(e,12);let s=0;for(;s<r;){const t=i.getUint32(s,!0);s+=4;const r=i.getUint32(s,!0);if(s+=4,1313821514===r){const r=new Uint8Array(e,12+s,t);this.content=n.decode(r)}else if(5130562===r){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Un{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_n.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},l={};for(const e in s){const t=qn[e]||e.toLowerCase();a[t]=s[e]}for(const t in e.attributes){const r=qn[t]||t.toLowerCase();if(void 0!==s[t]){const i=n.accessors[e.attributes[t]],s=zn[i.componentType];l[r]=s.name,o[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=o[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l)}))}))}}class Fn{constructor(){this.name=_n.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Nn{constructor(){this.name=_n.KHR_MESH_QUANTIZATION}}class Bn extends _e{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=r-t,d=(n-t)/h,c=d*d,u=c*d,p=e*l,m=p-l,g=-2*u+3*c,f=u-c,_=1-g,v=f-c+d;for(let e=0;e!==a;e++){const t=s[m+e+a],n=s[m+e+o]*h,r=s[p+e+a],l=s[p+e]*h;i[e]=_*t+v*n+g*r+f*l}return i}}const jn=new M;class Gn extends Bn{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return jn.fromArray(i).normalize().toArray(i),i}}const Hn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},zn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Vn={9728:ne,9729:D,9984:re,9985:ie,9986:se,9987:O},Wn={33071:ae,33648:oe,10497:L},Kn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qn={CUBICSPLINE:void 0,LINEAR:ee,STEP:le};function Yn(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function Zn(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Jn(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $n(e){let t;const n=e.extensions&&e.extensions[_n.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+er(n.attributes):e.indices+":"+er(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,r=e.targets.length;n<r;n++)t+=":"+er(e.targets[n]);return t}function er(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function tr(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const nr=new C;class rr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,i=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=navigator.userAgent.indexOf("Firefox")>-1,i=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||r&&i<98?this.textureLoader=new E(this.options.manager):this.textureLoader=new R(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Yn(i,s,r),Zn(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[_n.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(_.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Kn[r.type],t=zn[r.componentType],n=!0===r.normalized,i=new t(r.count*e);return Promise.resolve(new u(i,e,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=Kn[r.type],a=zn[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,h=r.byteOffset||0,d=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,c=!0===r.normalized;let p,m;if(d&&d!==l){const e=Math.floor(h/d),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(p=new a(i,e*d,r.count*d/o),l=new I(p,d/o),t.cache.add(n,l)),m=new de(l,s,h%d/o,c)}else p=null===i?new a(r.count*s):new a(i,h,r.count*s),m=new u(p,s,c);if(void 0!==r.sparse){const t=Kn.SCALAR,n=zn[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,h=new n(e[1],o,r.sparse.count*t),d=new a(e[2],l,r.sparse.count*s);null!==i&&(m=new u(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*s]),s>=2&&m.setY(t,d[e*s+1]),s>=3&&m.setZ(t,d[e*s+2]),s>=4&&m.setW(t,d[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],a=i.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=Vn[n.magFilter]||D,t.minFilter=Vn[n.minFilter]||O,t.wrapS=Wn[n.wrapS]||L,t.wrapT=Wn[n.wrapT]||L,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=n.images[e],s=self.URL||self.webkitURL;let a=i.uri||"",o=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:i.mimeType});return a=s.createObjectURL(t),a}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new ce(e);t.needsUpdate=!0,n(t)}),t.load(_.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===o&&s.revokeObjectURL(a),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[_n.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[_n.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[_n.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new k,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new F,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return N}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let a;const o={},l=[];if((i.extensions||{})[_n.KHR_MATERIALS_UNLIT]){const e=r[_n.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new h(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],w),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,x)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=B);const d=i.alphaMode||"OPAQUE";if("BLEND"===d?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===d&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==y&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new s(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&a!==y&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==y){const e=i.emissiveFactor;o.emissive=(new h).setRGB(e[0],e[1],e[2],w)}return void 0!==i.emissiveTexture&&a!==y&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,x)),Promise.all(l).then((function(){const n=new a(o);return i.name&&(n.name=i.name),Zn(n,i),t.associations.set(n,{materials:e}),i.extensions&&Yn(r,n,i),n}))}createUniqueName(e){const t=j.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[_n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return ir(n,e,t)}))}const s=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],o=$n(a),l=r[o];if(l)s.push(l.promise);else{let e;e=a.extensions&&a.extensions[_n.KHR_DRACO_MESH_COMPRESSION]?i(a):ir(new c,a,t),r[o]={primitive:a,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,a=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new N({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:he})),o.DefaultMaterial):this.getDependency("material",s[e].material);a.push(t)}var o;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],d=s[n];let c;const u=a[n];if(d.mode===Hn.TRIANGLES||d.mode===Hn.TRIANGLE_STRIP||d.mode===Hn.TRIANGLE_FAN||void 0===d.mode)c=!0===i.isSkinnedMesh?new G(h,u):new H(h,u),!0===c.isSkinnedMesh&&c.normalizeSkinWeights(),d.mode===Hn.TRIANGLE_STRIP?c.geometry=mn(c.geometry,g):d.mode===Hn.TRIANGLE_FAN&&(c.geometry=mn(c.geometry,m));else if(d.mode===Hn.LINES)c=new z(h,u);else if(d.mode===Hn.LINE_STRIP)c=new V(h,u);else if(d.mode===Hn.LINE_LOOP)c=new W(h,u);else{if(d.mode!==Hn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);c=new K(h,u)}Object.keys(c.geometry.morphAttributes).length>0&&Jn(c,i),c.name=t.createUniqueName(i.name||"mesh_"+e),Zn(c,i),d.extensions&&Yn(r,c,d),t.assignFinalMaterial(c),l.push(c)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return i.extensions&&Yn(r,l[0],i),l[0];const h=new q;i.extensions&&Yn(r,h,i),t.associations.set(h,{meshes:e});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new X(Q.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new Y(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Zn(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),r=e,i=[],s=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){i.push(a);const t=new C;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Z(i,s)}))}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],i=r.name?r.name:"animation_"+e,s=[],a=[],o=[],l=[],h=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],n=r.samplers[t.sampler],i=t.target,d=i.node,c=void 0!==r.parameters?r.parameters[n.input]:n.input,u=void 0!==r.parameters?r.parameters[n.output]:n.output;void 0!==i.node&&(s.push(this.getDependency("node",d)),a.push(this.getDependency("accessor",c)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(i))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(e){const t=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],h=r[e],d=s[e],c=a[e],u=o[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=n._createAnimationTracks(i,h,d,c,u);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}return new J(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),i=[],s=n.children||[];for(let e=0,n=s.length;e<n;e++)i.push(t.getDependency("node",s[e]));const a=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),a]).then((function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,nr)}));for(let e=0,r=n.length;e<r;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"",a=[],o=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&a.push(o),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){a.push(e)})),this.nodeCache[e]=Promise.all(a).then((function(t){let a;if(a=!0===i.isBone?new $:t.length>1?new q:1===t.length?t[0]:new A,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=s),Zn(a,i),i.extensions&&Yn(n,a,i),void 0!==i.matrix){const e=new C;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,i=new q;n.name&&(i.name=r.createUniqueName(n.name)),Zn(i,n),n.extensions&&Yn(t,i,n);const s=n.nodes||[],a=[];for(let e=0,t=s.length;e<t;e++)a.push(r.getDependency("node",s[e]));return Promise.all(a).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof U||e instanceof ce)&&t.set(e,n);return e.traverse(e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i}))}_createAnimationTracks(e,t,n,r,i){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(Xn[i.path]===Xn.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),Xn[i.path]){case Xn.weights:l=pe;break;case Xn.rotation:l=me;break;case Xn.position:case Xn.scale:l=ue;break;default:switch(n.itemSize){case 1:l=pe;break;case 2:case 3:default:l=ue}}const h=void 0!==r.interpolation?Qn[r.interpolation]:ee,d=this._getArrayFromAccessor(n);for(let e=0,n=o.length;e<n;e++){const n=new l(o[e]+"."+Xn[i.path],t.array,d,h);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=tr(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Gn:Bn)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ir(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=qn[t]||t.toLowerCase();n in e.attributes||i.push(s(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return te.workingColorSpace!==w&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${te.workingColorSpace}" not supported.`),Zn(e,t),function(e,t,n){const r=t.attributes,i=new ge;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new a(t[0],t[1],t[2]),new a(s[0],s[1],s[2])),e.normalized){const t=tr(zn[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new a,t=new a;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const e=tr(zn[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new fe;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const a=[],o=[],l=[];for(let h=0,d=t.length;h<d;h++){const d=t[h];if(r){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const sr=new WeakMap;class ar extends f{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const i=new v(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,r)},n,r)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,x).catch(n)}decodeDracoFile(e,t,n,r,i=w){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){const n=JSON.stringify(t);if(sr.has(e)){const t=sr.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(i,s).then(n=>(r=n,new Promise((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return a.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),sr.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new c;e.index&&t.setIndex(new u(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,s=r.array,a=r.itemSize,o=new u(s,a);"color"===i&&(this._assignVertexColorSpace(o,r.vertexColorSpace),o.normalized=s instanceof Float32Array==0),t.setAttribute(i,o)}return t}_assignVertexColorSpace(e,t){if(t!==x)return;const n=new h;for(let t=0,r=e.count;t<r;t++)n.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,r)=>{n.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=or.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){this.workerPool.map(e=>e._taskLoad)}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function or(){let e,t;function n(e,t,n,r,i,s){const a=s.num_components(),o=n.num_points()*a,l=o*i.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,h,l,d);const c=new i(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:r,array:c,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,s=i.taskConfig;t.then(e=>{const t=e.draco,a=new t.Decoder;try{const e=function(e,t,r,i){const s=i.attributeIDs,a=i.attributeTypes;let o,l;const h=t.GetEncodedGeometryType(r);if(h===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(r,r.byteLength,o);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(r,r.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const r in s){const l=self[a[r]];let h,c;if(i.useUniqueIDs)c=s[r],h=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[s[r]]),-1===c)continue;h=t.GetAttribute(o,c)}const u=n(e,t,o,r,l,h);"color"===r&&(u.vertexColorSpace=i.vertexColorSpace),d.attributes.push(u)}return h===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const r=3*n.num_faces(),i=4*r,s=e._malloc(i);t.GetTrianglesUInt32Array(n,i,s);const a=new Uint32Array(e.HEAPF32.buffer,s,r).slice();return e._free(s),{array:a,itemSize:1}}(e,t,o)),e.destroy(o),d}(t,a,new Int8Array(r),s),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(a)}})}}}const lr={"draco_wasm_wrapper.js":"static/draco_wasm_wrapper-6263f3a4b71cdf3b.js","draco_decoder.wasm":"static/draco_decoder-b048235474cbf09e.wasm","draco_decoder.js":"static/draco_decoder-dc7f397e2a2ebac4.js"};class hr{constructor(e){this._context_=e}getStore(e="rml_default"){return this._localStorage.getItem(e)||{entries:[]}}saveStore(e,t){this._localStorage.setItem(e,t)}addItem(e,t,n="rml_default",r=5){const i=this.getStore(n),s=i.entries.find(t=>t.id===e);if(s?(s.payload=t,s.date=Date.now()):i.entries.push({id:e,date:Date.now(),payload:t}),i.entries.length>r)for(i.entries.sort((e,t)=>t.date-e.date);i.entries.length>r;)i.entries.pop();this.saveStore(n,i)}getItem(e,t="rml_default"){const n=this.getStore(t).entries.find(t=>t.id===e);return n?n.payload:null}}tn([rn],hr.prototype,"_localStorage",void 0);const dr=e("t",(function(e){return e*(Math.PI/180)})),cr=e("s",(function(e){return e*(180/Math.PI)})),ur=(e("q",(function(e,t,n,r,i,s){e=Math.sqrt(e*e+n*n);const a=i/s,o=2*Math.atan(Math.tan(r*Math.PI/180/2)*a)*180/Math.PI,l=dr(r),h=t/2/Math.tan(l/2),d=e/(2*Math.atan(Math.PI*o/360));return Math.max(h,d)})),function(e){return Math.round(1e3*e)/1e3}),pr=(e("T",(function(e,t){return Math.abs(e.y-t.y)+Math.abs(e.x-t.x)})),e("a5",e=>new a(e.x/1e3,e.z/1e3,e.y/-1e3))),mr=e=>new a(e.x/1e3,e.z/1e3,e.y/1e3),gr=e("c",e=>({x:Math.round(1e3*e.x),y:Math.round(-1e3*e.z),z:Math.round(1e3*e.y)})),fr=e=>decodeURIComponent(encodeURIComponent(e)),_r=e("G",e=>{if(!e){const t=typeof e;return"number"===t||"boolean"===t?e:null}if(!e.hasOwnProperty("size")&&e.size&&"function"==typeof e.size){let t=vr(e);for(let e=0;e<t.length;e++)t[e]=_r(t[e]);return"string"==typeof t?fr(t):t}if("object"==typeof e)for(let t in e)e.hasOwnProperty(t)&&(e[t]=_r(e[t]));return"string"==typeof e?fr(e):e}),vr=e=>{let t=[];if(e){let n=e.size();for(let r=0;r<n;r++)t.push(e.get(r))}return t},wr=e=>{let t=new C,n=_r(e);return t.fromArray(n),t.transpose(),(e=>{let t=new C;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),t.scale(new a(.001,.001,.001));let n=new C;return n.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),n.scale(new a(1e3,1e3,1e3)),t.multiply(e).multiply(n)})(t)};function br(e,t){var n=e.__state.conversionName.toString(),r=Math.round(e.r),i=Math.round(e.g),s=Math.round(e.b),a=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var d=e.hex.toString(16);d.length<6;)d="0"+d;return"#"+d}return"CSS_RGB"===n?"rgb("+r+","+i+","+s+")":"CSS_RGBA"===n?"rgba("+r+","+i+","+s+","+a+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+r+","+i+","+s+"]":"RGBA_ARRAY"===n?"["+r+","+i+","+s+","+a+"]":"RGB_OBJ"===n?"{r:"+r+",g:"+i+",b:"+s+"}":"RGBA_OBJ"===n?"{r:"+r+",g:"+i+",b:"+s+",a:"+a+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+a+"}":"unknown format"}var yr=Array.prototype.forEach,xr=Array.prototype.slice,Sr={BREAK:{},extend:function(e){return this.each(xr.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(xr.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=xr.call(arguments);return function(){for(var t=xr.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(yr&&e.forEach&&e.forEach===yr)e.forEach(t,n);else if(e.length===e.length+0){var r,i=void 0;for(i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===this.BREAK)return}else for(var s in e)if(t.call(n,e[s],s)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var r=void 0;return function(){var i=this,s=arguments;function a(){r=null,n||e.apply(i,s)}var o=n||!r;clearTimeout(r),r=setTimeout(a,t),o&&e.apply(i,s)}},toArray:function(e){return e.toArray?e.toArray():xr.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},Cr=[{litmus:Sr.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:br},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:br},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:br},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:br}}},{litmus:Sr.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Sr.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:Sr.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Sr.isNumber(e.r)&&Sr.isNumber(e.g)&&Sr.isNumber(e.b)&&Sr.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(Sr.isNumber(e.r)&&Sr.isNumber(e.g)&&Sr.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(Sr.isNumber(e.h)&&Sr.isNumber(e.s)&&Sr.isNumber(e.v)&&Sr.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(Sr.isNumber(e.h)&&Sr.isNumber(e.s)&&Sr.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],Mr=void 0,Tr=void 0,Pr=function(){Tr=!1;var e=arguments.length>1?Sr.toArray(arguments):arguments[0];return Sr.each(Cr,(function(t){if(t.litmus(e))return Sr.each(t.conversions,(function(t,n){if(Mr=t.read(e),!1===Tr&&!1!==Mr)return Tr=Mr,Mr.conversionName=n,Mr.conversion=t,Sr.BREAK})),Sr.BREAK})),Tr},Ar=void 0,Er={hsv_to_rgb:function(e,t,n){var r=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),s=n*(1-t),a=n*(1-i*t),o=n*(1-(1-i)*t),l=[[n,o,s],[a,n,s],[s,n,o],[s,a,n],[o,s,n],[n,s,a]][r];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var r=Math.min(e,t,n),i=Math.max(e,t,n),s=i-r,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=e===i?(t-n)/s:t===i?2+(n-e)/s:4+(e-t)/s,(a/=6)<0&&(a+=1),{h:360*a,s:s/i,v:i/255})},rgb_to_hex:function(e,t,n){var r=this.hex_with_component(0,2,e);return r=this.hex_with_component(r,1,t),this.hex_with_component(r,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Ar=8*t)|e&~(255<<Ar)}},Rr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ir=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Dr=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),Or=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,n,r)}if("value"in i)return i.value;var a=i.get;return void 0!==a?a.call(r):void 0},Lr=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},kr=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},Ur=function(){function e(){if(Ir(this,e),this.__state=Pr.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Dr(e,[{key:"toString",value:function(){return br(this)}},{key:"toHexString",value:function(){return br(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function Fr(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Ur.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Ur.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function Nr(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Ur.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Ur.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Ur.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=Er.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Sr.extend(e.__state,Er.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Ur.recalculateHSV=function(e){var t=Er.rgb_to_hsv(e.r,e.g,e.b);Sr.extend(e.__state,{s:t.s,v:t.v}),Sr.isNaN(t.h)?Sr.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},Ur.COMPONENTS=["r","g","b","h","s","v","hex","a"],Fr(Ur.prototype,"r",2),Fr(Ur.prototype,"g",1),Fr(Ur.prototype,"b",0),Nr(Ur.prototype,"h"),Nr(Ur.prototype,"s"),Nr(Ur.prototype,"v"),Object.defineProperty(Ur.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Ur.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=Er.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Br=function(){function e(t,n){Ir(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return Dr(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),jr={};Sr.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){Sr.each(e,(function(e){jr[e]=t}))}));var Gr=/(\d+(\.\d+)?)px/;function Hr(e){if("0"===e||Sr.isUndefined(e))return 0;var t=e.match(Gr);return Sr.isNull(t)?0:parseFloat(t[1])}var zr={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var r=n,i=t;Sr.isUndefined(i)&&(i=!0),Sr.isUndefined(r)&&(r=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),r&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,r){var i=n||{},s=jr[t];if(!s)throw new Error("Event type "+t+" not supported.");var a=document.createEvent(s);switch(s){case"MouseEvents":var o=i.x||i.clientX||0,l=i.y||i.clientY||0;a.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var h=a.initKeyboardEvent||a.initKeyEvent;Sr.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:a.initEvent(t,i.bubbles||!1,i.cancelable||!0)}Sr.defaults(a,r),e.dispatchEvent(a)},bind:function(e,t,n,r){var i=r||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),zr},unbind:function(e,t,n,r){var i=r||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),zr},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return zr},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),r=n.indexOf(t);-1!==r&&(n.splice(r,1),e.className=n.join(" "))}else e.className=void 0;return zr},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Hr(t["border-left-width"])+Hr(t["border-right-width"])+Hr(t["padding-left"])+Hr(t["padding-right"])+Hr(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Hr(t["border-top-width"])+Hr(t["border-bottom-width"])+Hr(t["padding-top"])+Hr(t["padding-bottom"])+Hr(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Vr=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=r;return r.__prev=r.getValue(),r.__checkbox=document.createElement("input"),r.__checkbox.setAttribute("type","checkbox"),zr.bind(r.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),r.domElement.appendChild(r.__checkbox),r.updateDisplay(),r}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Br),Wr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r,a=i;if(i.__select=document.createElement("select"),Sr.isArray(s)){var o={};Sr.each(s,(function(e){o[e]=e})),s=o}return Sr.each(s,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),a.__select.appendChild(n)})),i.updateDisplay(),zr.bind(i.__select,"change",(function(){var e=this.options[this.selectedIndex].value;a.setValue(e)})),i.domElement.appendChild(i.__select),i}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return zr.isActive(this.__select)?this:(this.__select.value=this.getValue(),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(Br),Kr=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=r;function s(){i.setValue(i.__input.value)}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),zr.bind(r.__input,"keyup",s),zr.bind(r.__input,"change",s),zr.bind(r.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),zr.bind(r.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){return zr.isActive(this.__input)||(this.__input.value=this.getValue()),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Br);function qr(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var Xr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=r||{};return i.__min=s.min,i.__max=s.max,i.__step=s.step,Sr.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=qr(i.__impliedStep),i}return Lr(t,e),Dr(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=qr(e),this}}]),t}(Br),Qr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));i.__truncationSuspended=!1;var s=i,a=void 0;function o(){s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function l(e){var t=a-e.clientY;s.setValue(s.getValue()+t*s.__impliedStep),a=e.clientY}function h(){zr.unbind(window,"mousemove",l),zr.unbind(window,"mouseup",h),o()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),zr.bind(i.__input,"change",(function(){var e=parseFloat(s.__input.value);Sr.isNaN(e)||s.setValue(e)})),zr.bind(i.__input,"blur",(function(){o()})),zr.bind(i.__input,"mousedown",(function(e){zr.bind(window,"mousemove",l),zr.bind(window,"mouseup",h),a=e.clientY})),zr.bind(i.__input,"keydown",(function(e){13===e.keyCode&&(s.__truncationSuspended=!0,this.blur(),s.__truncationSuspended=!1,o())})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e,n,r;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,r=Math.pow(10,n),Math.round(e*r)/r),Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Xr);function Yr(e,t,n,r,i){return r+(e-t)/(n-t)*(i-r)}var Zr=function(e){function t(e,n,r,i,s){Ir(this,t);var a=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:r,max:i,step:s})),o=a;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(Yr(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){zr.unbind(window,"mousemove",l),zr.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function d(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(Yr(t,n.left,n.right,o.__min,o.__max))}function c(){zr.unbind(window,"touchmove",d),zr.unbind(window,"touchend",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),zr.bind(a.__background,"mousedown",(function(e){document.activeElement.blur(),zr.bind(window,"mousemove",l),zr.bind(window,"mouseup",h),l(e)})),zr.bind(a.__background,"touchstart",(function(e){1===e.touches.length&&(zr.bind(window,"touchmove",d),zr.bind(window,"touchend",c),d(e))})),zr.addClass(a.__background,"slider"),zr.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Or(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Xr),Jr=function(e){function t(e,n,r){Ir(this,t);var i=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===r?"Fire":r,zr.bind(i.__button,"click",(function(e){return e.preventDefault(),s.fire(),!1})),zr.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return Lr(t,e),Dr(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Br),$r=function(e){function t(e,n){Ir(this,t);var r=kr(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));r.__color=new Ur(r.getValue()),r.__temp=new Ur(0);var i=r;r.domElement=document.createElement("div"),zr.makeSelectable(r.domElement,!1),r.__selector=document.createElement("div"),r.__selector.className="selector",r.__saturation_field=document.createElement("div"),r.__saturation_field.className="saturation-field",r.__field_knob=document.createElement("div"),r.__field_knob.className="field-knob",r.__field_knob_border="2px solid ",r.__hue_knob=document.createElement("div"),r.__hue_knob.className="hue-knob",r.__hue_field=document.createElement("div"),r.__hue_field.className="hue-field",r.__input=document.createElement("input"),r.__input.type="text",r.__input_textShadow="0 1px 1px ",zr.bind(r.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),zr.bind(r.__input,"blur",c),zr.bind(r.__selector,"mousedown",(function(){zr.addClass(this,"drag").bind(window,"mouseup",(function(){zr.removeClass(i.__selector,"drag")}))})),zr.bind(r.__selector,"touchstart",(function(){zr.addClass(this,"drag").bind(window,"touchend",(function(){zr.removeClass(i.__selector,"drag")}))}));var s,a=document.createElement("div");function o(e){p(e),zr.bind(window,"mousemove",p),zr.bind(window,"touchmove",p),zr.bind(window,"mouseup",h),zr.bind(window,"touchend",h)}function l(e){m(e),zr.bind(window,"mousemove",m),zr.bind(window,"touchmove",m),zr.bind(window,"mouseup",d),zr.bind(window,"touchend",d)}function h(){zr.unbind(window,"mousemove",p),zr.unbind(window,"touchmove",p),zr.unbind(window,"mouseup",h),zr.unbind(window,"touchend",h),u()}function d(){zr.unbind(window,"mousemove",m),zr.unbind(window,"touchmove",m),zr.unbind(window,"mouseup",d),zr.unbind(window,"touchend",d),u()}function c(){var e=Pr(this.value);!1!==e?(i.__color.__state=e,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function u(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,r=n.clientX,s=n.clientY,a=(r-t.left)/(t.right-t.left),o=1-(s-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),a>1?a=1:a<0&&(a=0),i.__color.v=o,i.__color.s=a,i.setValue(i.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return Sr.extend(r.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Sr.extend(r.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:r.__field_knob_border+(r.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Sr.extend(r.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Sr.extend(r.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Sr.extend(a.style,{width:"100%",height:"100%",background:"none"}),ti(a,"top","rgba(0,0,0,0)","#000"),Sr.extend(r.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(s=r.__hue_field).style.background="",s.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",s.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Sr.extend(r.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:r.__input_textShadow+"rgba(0,0,0,0.7)"}),zr.bind(r.__saturation_field,"mousedown",o),zr.bind(r.__saturation_field,"touchstart",o),zr.bind(r.__field_knob,"mousedown",o),zr.bind(r.__field_knob,"touchstart",o),zr.bind(r.__hue_field,"mousedown",l),zr.bind(r.__hue_field,"touchstart",l),r.__saturation_field.appendChild(a),r.__selector.appendChild(r.__field_knob),r.__selector.appendChild(r.__saturation_field),r.__selector.appendChild(r.__hue_field),r.__hue_field.appendChild(r.__hue_knob),r.domElement.appendChild(r.__input),r.domElement.appendChild(r.__selector),r.updateDisplay(),r}return Lr(t,e),Dr(t,[{key:"updateDisplay",value:function(){var e=Pr(this.getValue());if(!1!==e){var t=!1;Sr.each(Ur.COMPONENTS,(function(n){if(!Sr.isUndefined(e[n])&&!Sr.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Sr.extend(this.__color.__state,e)}Sr.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,r=255-n;Sr.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,ti(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Sr.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+r+","+r+","+r+",.7)"})}}]),t}(Br),ei=["-moz-","-o-","-webkit-","-ms-",""];function ti(e,t,n,r){e.style.background="",Sr.each(ei,(function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+r+" 100%); "}))}var ni='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',ri=function(e,t){var n=e[t];return Sr.isArray(arguments[2])||Sr.isObject(arguments[2])?new Wr(e,t,arguments[2]):Sr.isNumber(n)?Sr.isNumber(arguments[2])&&Sr.isNumber(arguments[3])?Sr.isNumber(arguments[4])?new Zr(e,t,arguments[2],arguments[3],arguments[4]):new Zr(e,t,arguments[2],arguments[3]):Sr.isNumber(arguments[4])?new Qr(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Qr(e,t,{min:arguments[2],max:arguments[3]}):Sr.isString(n)?new Kr(e,t):Sr.isFunction(n)?new Jr(e,t,""):Sr.isBoolean(n)?new Vr(e,t):null},ii=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},si=function(){function e(){Ir(this,e),this.backgroundElement=document.createElement("div"),Sr.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),zr.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Sr.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;zr.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Dr(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Sr.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",zr.unbind(e.domElement,"webkitTransitionEnd",t),zr.unbind(e.domElement,"transitionend",t),zr.unbind(e.domElement,"oTransitionEnd",t)};zr.bind(this.domElement,"webkitTransitionEnd",t),zr.bind(this.domElement,"transitionend",t),zr.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-zr.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-zr.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=document,r=document.createElement("style");r.type="text/css",r.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(r)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var ai=function(){try{return!!window.localStorage}catch(e){return!1}}(),oi=void 0,li=!0,hi=void 0,di=!1,ci=[],ui=function e(t){var n=this,r=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),zr.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],r=Sr.defaults(r,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),r=Sr.defaults(r,{resizable:r.autoPlace,hideable:r.autoPlace}),Sr.isUndefined(r.load)?r.load={preset:"Default"}:r.preset&&(r.load.preset=r.preset),Sr.isUndefined(r.parent)&&r.hideable&&ci.push(this),r.resizable=Sr.isUndefined(r.parent)&&r.resizable,r.autoPlace&&Sr.isUndefined(r.scrollable)&&(r.scrollable=!0);var i,s=ai&&"true"===localStorage.getItem(vi(0,"isLocal")),a=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return r.parent}},scrollable:{get:function(){return r.scrollable}},autoPlace:{get:function(){return r.autoPlace}},closeOnTop:{get:function(){return r.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:r.load.preset},set:function(e){n.parent?n.getRoot().preset=e:r.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return r.width},set:function(e){r.width=e,Si(n,e)}},name:{get:function(){return r.name},set:function(e){r.name=e,o&&(o.innerHTML=r.name)}},closed:{get:function(){return r.closed},set:function(t){r.closed=t,r.closed?zr.addClass(n.__ul,e.CLASS_CLOSED):zr.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return r.load}},useLocalStorage:{get:function(){return s},set:function(e){ai&&(s=e,e?zr.bind(window,"unload",a):zr.unbind(window,"unload",a),localStorage.setItem(vi(0,"isLocal"),e))}}}),Sr.isUndefined(r.parent)){if(this.closed=r.closed||!1,zr.addClass(this.domElement,e.CLASS_MAIN),zr.makeSelectable(this.domElement,!1),ai&&s){n.useLocalStorage=!0;var l=localStorage.getItem(vi(0,"gui"));l&&(r.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,zr.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),r.closeOnTop?(zr.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(zr.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),zr.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===r.closed&&(r.closed=!0);var h=document.createTextNode(r.name);zr.addClass(h,"controller-name"),o=pi(n,h),zr.addClass(this.__ul,e.CLASS_CLOSED),zr.addClass(o,"title"),zr.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),r.closed||(this.closed=!1)}r.autoPlace&&(Sr.isUndefined(r.parent)&&(li&&(hi=document.createElement("div"),zr.addClass(hi,"dg"),zr.addClass(hi,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(hi),li=!1),hi.appendChild(this.domElement),zr.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||Si(n,r.width)),this.__resizeHandler=function(){n.onResizeDebounced()},zr.bind(window,"resize",this.__resizeHandler),zr.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),zr.bind(this.__ul,"transitionend",this.__resizeHandler),zr.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),r.resizable&&xi(this),a=function(){ai&&"true"===localStorage.getItem(vi(0,"isLocal"))&&localStorage.setItem(vi(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=a,r.parent||((i=n.getRoot()).width+=1,Sr.defer((function(){i.width-=1})))};function pi(e,t,n){var r=document.createElement("li");return t&&r.appendChild(t),n?e.__ul.insertBefore(r,n):e.__ul.appendChild(r),e.onResize(),r}function mi(e){zr.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&zr.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function gi(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function fi(e,t){var n=e.getRoot(),r=n.__rememberedObjects.indexOf(t.object);if(-1!==r){var i=n.__rememberedObjectIndecesToControllers[r];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[r]=i),i[t.property]=t,n.load&&n.load.remembered){var s=n.load.remembered,a=void 0;if(s[e.preset])a=s[e.preset];else{if(!s.Default)return;a=s.Default}if(a[r]&&void 0!==a[r][t.property]){var o=a[r][t.property];t.initialValue=o,t.setValue(o)}}}}function _i(e,t,n,r){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(r.color)i=new $r(t,n);else{var s=[t,n].concat(r.factoryArgs);i=ri.apply(e,s)}r.before instanceof Br&&(r.before=r.before.__li),fi(e,i),zr.addClass(i.domElement,"c");var a=document.createElement("span");zr.addClass(a,"property-name"),a.innerHTML=i.property;var o=document.createElement("div");o.appendChild(a),o.appendChild(i.domElement);var l=pi(e,o,r.before);return zr.addClass(l,ui.CLASS_CONTROLLER_ROW),i instanceof $r?zr.addClass(l,"color"):zr.addClass(l,Rr(i.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,Sr.extend(n,{options:function(t){if(arguments.length>1){var r=n.__li.nextElementSibling;return n.remove(),_i(e,n.object,n.property,{before:r,factoryArgs:[Sr.toArray(arguments)]})}if(Sr.isArray(t)||Sr.isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),_i(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof Zr){var r=new Qr(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Sr.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],i=r[e];n[e]=r[e]=function(){var e=Array.prototype.slice.call(arguments);return i.apply(r,e),t.apply(n,e)}})),zr.addClass(t,"has-slider"),n.domElement.insertBefore(r.domElement,n.domElement.firstElementChild)}else if(n instanceof Qr){var i=function(t){if(Sr.isNumber(n.__min)&&Sr.isNumber(n.__max)){var r=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var s=_i(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return s.name(r),i&&s.listen(),s}return t};n.min=Sr.compose(i,n.min),n.max=Sr.compose(i,n.max)}else n instanceof Vr?(zr.bind(t,"click",(function(){zr.fakeEvent(n.__checkbox,"click")})),zr.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof Jr?(zr.bind(t,"click",(function(){zr.fakeEvent(n.__button,"click")})),zr.bind(t,"mouseover",(function(){zr.addClass(n.__button,"hover")})),zr.bind(t,"mouseout",(function(){zr.removeClass(n.__button,"hover")}))):n instanceof $r&&(zr.addClass(t,"color"),n.updateDisplay=Sr.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Sr.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&gi(e.getRoot(),!0),t}),n.setValue)}(e,l,i),e.__controllers.push(i),i}function vi(e,t){return document.location.href+"."+t}function wi(e,t,n){var r=document.createElement("option");r.innerHTML=t,r.value=t,e.__preset_select.appendChild(r),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function bi(e,t){t.style.display=e.useLocalStorage?"block":"none"}function yi(e){var t=e.__save_row=document.createElement("li");zr.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),zr.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",zr.addClass(n,"button gears");var r=document.createElement("span");r.innerHTML="Save",zr.addClass(r,"button"),zr.addClass(r,"save");var i=document.createElement("span");i.innerHTML="New",zr.addClass(i,"button"),zr.addClass(i,"save-as");var s=document.createElement("span");s.innerHTML="Revert",zr.addClass(s,"button"),zr.addClass(s,"revert");var a=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Sr.each(e.load.remembered,(function(t,n){wi(e,n,n===e.preset)})):wi(e,"Default",!1),zr.bind(a,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(a),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(s),ai){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(vi(0,"isLocal"))&&l.setAttribute("checked","checked"),bi(e,o),zr.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,bi(e,o)}))}var h=document.getElementById("dg-new-constructor");zr.bind(h,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||oi.hide()})),zr.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),oi.show(),h.focus(),h.select()})),zr.bind(r,"click",(function(){e.save()})),zr.bind(i,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),zr.bind(s,"click",(function(){e.revert()}))}function xi(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function r(){zr.removeClass(e.__closeButton,ui.CLASS_DRAG),zr.unbind(window,"mousemove",n),zr.unbind(window,"mouseup",r)}function i(i){return i.preventDefault(),t=i.clientX,zr.addClass(e.__closeButton,ui.CLASS_DRAG),zr.bind(window,"mousemove",n),zr.bind(window,"mouseup",r),!1}e.__resize_handle=document.createElement("div"),Sr.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),zr.bind(e.__resize_handle,"mousedown",i),zr.bind(e.__closeButton,"mousedown",i),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Si(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Ci(e,t){var n={};return Sr.each(e.__rememberedObjects,(function(r,i){var s={},a=e.__rememberedObjectIndecesToControllers[i];Sr.each(a,(function(e,n){s[n]=t?e.initialValue:e.getValue()})),n[i]=s})),n}ui.toggleHide=function(){di=!di,Sr.each(ci,(function(e){e.domElement.style.display=di?"none":""}))},ui.CLASS_AUTO_PLACE="a",ui.CLASS_AUTO_PLACE_CONTAINER="ac",ui.CLASS_MAIN="main",ui.CLASS_CONTROLLER_ROW="cr",ui.CLASS_TOO_TALL="taller-than-window",ui.CLASS_CLOSED="closed",ui.CLASS_CLOSE_BUTTON="close-button",ui.CLASS_CLOSE_TOP="close-top",ui.CLASS_CLOSE_BOTTOM="close-bottom",ui.CLASS_DRAG="drag",ui.DEFAULT_WIDTH=245,ui.TEXT_CLOSED="Close Controls",ui.TEXT_OPEN="Open Controls",ui._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||ui.toggleHide()},zr.bind(window,"keydown",ui._keydownHandler,!1),Sr.extend(ui.prototype,{add:function(e,t){return _i(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return _i(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Sr.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&hi.removeChild(this.domElement);var e=this;Sr.each(this.__folders,(function(t){e.removeFolder(t)})),zr.unbind(window,"keydown",ui._keydownHandler,!1),mi(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new ui(t);this.__folders[e]=n;var r=pi(this,n.domElement);return zr.addClass(r,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],mi(e);var t=this;Sr.each(e.__folders,(function(t){e.removeFolder(t)})),Sr.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=zr.getOffset(e.__ul).top,n=0;Sr.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=zr.getHeight(t))})),window.innerHeight-t-20<n?(zr.addClass(e.domElement,ui.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(zr.removeClass(e.domElement,ui.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Sr.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Sr.debounce((function(){this.onResize()}),50),remember:function(){if(Sr.isUndefined(oi)&&((oi=new si).domElement.innerHTML=ni),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Sr.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&yi(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&Si(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Ci(this)),e.folders={},Sr.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Ci(this),gi(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=Ci(this,!0)),this.load.remembered[e]=Ci(this),this.preset=e,wi(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Sr.each(this.__controllers,(function(t){this.getRoot().load.remembered?fi(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Sr.each(this.__folders,(function(e){e.revert(e)})),e||gi(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ii.call(window,(function(){e(t)})),Sr.each(t,(function(e){e.updateDisplay()}))}(this.__listening)},updateDisplay:function(){Sr.each(this.__controllers,(function(e){e.updateDisplay()})),Sr.each(this.__folders,(function(e){e.updateDisplay()}))}});var Mi=ui;class Ti{static createMeshPhysicalMaterial(e){return new S(e)}static createMeshStandardMaterial(e){return new N(e)}}e("M",Ti),e("g",(e,t,n,r)=>{if(!e||!t||0===n||0===r)return new a;let i=e.clone(),s=n/2,o=r/2;return i.project(t),i.x=Math.floor(i.x*s+s),i.y=Math.floor(-i.y*o+o),i.z=e.distanceTo(t.position),i});const Pi=e("ab",(e,t)=>{t||(t=new a(0,0,0));let n=new a(e.size.x/1e3,e.size.z/1e3,e.size.y/1e3),r=new a(e.origin.x/1e3,e.origin.z/1e3,e.origin.y/-1e3),i=new a(0,0,-n.z).add(r).sub(t),s=new a(n.x,n.y,0).add(r).add(t);return new ge(i,s)});e("H",(e,t)=>{let n=ur(e.x),r=ur(e.y),i=ur(e.z),s=ur(t.x),a=ur(t.y),o=ur(t.z);return n===s&&r===a&&i===o}),e("S",(e,t)=>{let n=ur(e.w),r=ur(e.x),i=ur(e.y),s=ur(e.z),a=ur(t.w),o=ur(t.x),l=ur(t.y),h=ur(t.z);return n===a&&r===o&&i===l&&s===h}),e("J",(e,t)=>{let n=ur(e.x),r=ur(e.y),i=ur(t.x),s=ur(t.y);return n===i&&r===s});let Ai=null;const Ei=()=>{if(Ai)return Ai;const e=new Uint8Array(4);for(let t=0;t<1;t++){const n=4*t;e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255}const t=new ye(e,1,1,be);return t.needsUpdate=!0,t},Ri=(e,t,n,r)=>{const i=new Uint8Array(4),s=Math.floor(255*e),a=Math.floor(255*t),o=Math.floor(255*n),l=Math.floor(255*r);for(let e=0;e<4;e++){const t=4*e;i[t]=s,i[t+1]=a,i[t+2]=o,i[t+3]=l}const h=new ye(i,1,1,be);return h.needsUpdate=!0,h},Ii=e("N",e=>Di(null,e)),Di=e("aq",(e,t)=>{e||(e=Oi()),e.name=t.id?t.id.toString():"",void 0!==t.shading.metallic&&(e.metalness=1===t.shading.metallic?1:.5,e.reflectivity=xe(t.shading.metallic,.5));let n=!1;if(t.shading.transmission&&t.shading.transmission>0?(e.opacity=1-t.shading.transmission,e.transparent=!0,e.depthWrite=!1,e.metalness=0,n=!0):void 0!==t.shading.alpha&&t.shading.alpha<1&&(e.transparent=t.shading.alpha<1,e.opacity=t.shading.alpha,e.depthWrite=t.shading.alpha>=1,e.metalness=.5*Math.max(0,t.shading.alpha),n=!0),e.aoMapIntensity=xe(t.shading.occlusion,1),e.roughness=xe(t.shading.roughness,.5),e.alphaTest=xe(t.shading.alphaCutoff,0),void 0!==t.shading.basecolor){const n=new h(t.shading.basecolor.r,t.shading.basecolor.g,t.shading.basecolor.b);e.color.copy(n.convertSRGBToLinear())}return n||t.shading.doubleSided?e.side=B:e.side=he,e.map||(Ai||(Ai=Ei()),e.map=Ai),e}),Oi=()=>Ti.createMeshPhysicalMaterial({});e("ar",e=>{let t=e.color.clone().convertLinearToSRGB(),n={alpha:e.opacity,metallic:e.reflectivity,basecolor:{r:t.r,g:t.g,b:t.b},roughness:e.roughness,doubleSided:e.side===B,alphaCutoff:e.alphaTest,transmission:e.transmission};return 1===e.metalness?n.metallic=1:n.metallic=e.reflectivity,n});let Li=null;const ki=e("O",(e,t,n,r,i,s,a=16)=>(Li||(Li=new E,Li.crossOrigin=""),new Promise((o,l)=>{if(!e)return console.warn("trying to add a texture without image",t),void o();Li.load(e,e=>{Ui(e,t,n,r,i,s,a),o()},l)}))),Ui=e("as",(e,t,n,r,i,s,a=16)=>{e.anisotropy=r,e.wrapS=L,e.wrapT=L,"ORM"===t.mapping&&a<=8?console.warn("ORM maps are not supported on devices with only "+a+" texture units"):(e.repeat.set(i,s),"XYZ"===t.mapping?(n.normalMap=e,n.map===Ei()&&(n.map=null)):"ORM"===t.mapping?(n.aoMap=e,n.roughnessMap=e,n.metalnessMap=e):(e.colorSpace=x,n.map=e),"RGBA"===t.mapping&&(n.transparent=!0,n.name.includes("glow")&&(n.emissiveIntensity=.5,n.emissive=new h(16777215),n.emissiveMap=n.map)),n.needsUpdate=!0)}),Fi=e("Q",(e=!0)=>(window.__RML_GUI__||(window.__RML_GUI__=new Mi({autoPlace:e})),window.__RML_GUI__)),Ni=(e("ah",(e,t)=>{let n=!1;for(const r of t){const t=r.getKernelObject();let i;if(2===t.wallType.value&&(i=pr(t.rightNormal)),1===t.wallType.value&&(i=pr(t.leftNormal)),!i)continue;let s=pr(r.getPlanElement().getCenter());s=s.applyMatrix4(e.matrixWorldInverse),i=i.transformDirection(e.matrixWorldInverse);const a=s.dot(i)>=0;a!==r.getContainer().visible&&(n=!0),a?r.show():r.isSelected||r.hide()}return n}),e("ak",(e,t,n=!0)=>{if(!e.userData.tween)if(t)if(e.transparent=!0,n){let t={opacity:1};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:.2},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.userData.tween=!1}).start()}else e.opacity=.2;else if(n){let t={opacity:.2};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:1},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.transparent=!1,e.userData.tween=!1}).start()}else e.opacity=1,e.transparent=!1}),e("a0",(e,t)=>{e.traverse(e=>{if(e instanceof H&&TWEEN){const n=e.material;e.userData.tween&&e.userData.tween.stop();const r={opacity:n.opacity};t.transparent&&(n.transparent=t.transparent),e.userData.tween=new TWEEN.Tween(r).to(t,250).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{n.opacity=r.opacity}).onStop(()=>{t.transparent||(n.transparent=t.transparent),n.opacity=t.opacity,n.needsUpdate=!0,e.userData.tween=void 0}).onComplete(()=>{t.transparent||(n.transparent=t.transparent),n.needsUpdate=!0,e.userData.tween=void 0}).start()}})}),e("ai",e=>{e.traverse(e=>{if(e instanceof H&&TWEEN){let t=e.material;if(0===t.opacity)return;let n={opacity:0,transparent:!0},r={opacity:t.opacity,transparent:t.transparent};t.transparent=n.transparent,t.opacity=n.opacity,new TWEEN.Tween(n).to(r,500).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{t.opacity=n.opacity}).onComplete(()=>{t.transparent=r.transparent}).start()}})})),Bi=e("o",e=>{"Mesh"===e.type?Gi(e):ji(e)}),ji=e=>{e&&e.children&&0!==e.children.length&&e.children.forEach(e=>{Gi(e)})},Gi=e("d",e=>{e&&(e.material&&zi(e.material),e.geometry&&Hi(e.geometry),e.children&&e.children.length>0&&ji(e))}),Hi=e=>{e&&e.dispose()},zi=e=>{e&&(e.map&&e.map.dispose(),e.normalMap&&e.normalMap.dispose(),e.dispose())};let Vi;e("v",e=>0===e.x&&0===e.y&&0===e.z);const Wi=(e,t)=>{let n="";return e||""===e?(e.materialId&&""!==e.materialId?n=e.materialId:e.catalogItemId&&""!==e.catalogItemId?n=e.catalogItemId:e.rgbValue>0?n="rgb"+JSON.stringify(e.rgbValue):e.length>0?n=e:t&&1===t.value?n="default_wall_material_"+e.getSourceType().value:t&&7===t.value&&(n="default_ceiling_material_"+e.getSourceType().value),n):null},Ki=(e("p",e=>{let t=e.getWorldDirection(new a).clone();t.y=0,t.lengthSq()<.01&&(t=new a(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}),e("K",(e,t)=>{if(!e||!t)return 0;const n=e.clone().expandByScalar(.001).containsBox(t),r=t.clone().expandByScalar(.001).containsBox(e);return r&&n||!r&&!n?0:!0===n?1:-1}),e("al",(e,t,n,r=1)=>{const i=t>n,s=i?15:0,o=i?0:10,l=e.getSize(new a),h=e.getCenter(new a);let d=l.x>2*s?l.x/2:s,c=l.z>2*o?l.z/2:o;return d*=r,c*=r,new ge(new a(h.x-d,h.y,h.z-c),new a(h.x+d,h.y,h.z+c))}),e("ad",e=>{const{x:t,y:n}=e;return{x:t,y:n}})),qi=e=>{const{x:t,y:n,z:r}=e;return{x:t,y:n,z:r}};e("aj",(e,t,n)=>(new a).setFromSphericalCoords(e,Math.PI*(1-n),2*Math.PI*(1-t))),e("n",e=>{const t=new Se;return t.environment=e.environment.clone(),t.userData.environmentDefinition=e.userData.environmentDefinition.clone(),t.userData.shadowFromEnvironment=e.userData.shadowFromEnvironment,t});const Xi=e("h",{CAMERA_2D:"2D",CAMERA_3D:"3D",CAMERA_FP:"FP"});e("X",e=>{if(!e)return Xi.CAMERA_3D;let t=e.toUpperCase();return-1===Object.values(Xi).indexOf(t)&&(t=Xi.CAMERA_3D),t});var Qi=e("$","static/default_256-f1c66a2764f88cc0.exr");class Yi{constructor(e){this.autoQuality=!1,this.colors=Ce,this.unit=null,this.unitStringType=null,this.meshSelection=!0,this.stats=!1,this._measureTraffic=!1,this.disableDebugGUI=!1,this.disableEnvMap=!1,this.envMapUrl=Qi,this.envMapIntensity=1.5,this.envMapRotation=0,this.maxLightSources=-1,this.legacyLight=!1,this.sceneLight=!1,this.restrictionLevel=0,this.e2e=!1,this.highlighting=Me.SMART,this.dls=null,this.ls=null,this.cameraSpacing=0,this.transparentHighlighting=!0,this.featureFlags={pulsePreview:!1,reDock:!1},this.mode=Xi.CAMERA_3D,this.edit=!1,this.moc=!1,this.callbacksOnlyIfGeometryIsReady=!0,this._creator_=e}setOverrides(e){Te(this,e)}}e("ax",Yi);const Zi=["language","browserLanguage","userLanguage","systemLanguage"];e("a4",/^((?!chrome|android).)*safari/i.test(navigator.userAgent));class Ji{constructor(e){this.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,n=Zi.length;e<n;e++){const n=t[Zi[e]];if(n)return n.substr(0,2)}return"en"})()||"en",this.overrideCountry=null,this._creator_=e}setOverrides(e){Te(this,e)}}e("aw",Ji);class $i{_setMute(e){Pe(this,"_isMute",!0),this._isMute=e,Pe(this,"_isMute",!1)}mute(){this._setMute(!0)}unmute(){this._setMute(!1)}constructor(e){return this._isMute=!1,this.cameraStartsMoving=()=>{},this._creator_=e,Ae(this,"_isMute",{enumerable:!1,writable:!1}),Ae($i.prototype,"_setMute",{enumerable:!1,writable:!1}),Ae($i.prototype,"mute",{enumerable:!1,writable:!1}),Ae($i.prototype,"unmute",{enumerable:!1,writable:!1}),new Proxy(this,this)}get(e,t){return this._isMute&&"function"==typeof this[t]&&"on"===t.substr(0,2)?()=>{}:this[t]}}e("at",$i);class es extends $i{constructor(){super(...arguments),this.onNetworkRequest=(e,t,n)=>{},this.onKernelMsg=(e,t,n={})=>{},this.onCheckExternalCache=async(e,t)=>Promise.resolve(null),this.onValidateNetworkResponse=(e,t)=>Promise.resolve(!0)}}e("av",es),e("e",{HSC:"rml-configurator",HSP:"rml-hsp",GLB:"rml-glb",RMV:"rml-mv"});class ts{get element(){return this._container}constructor(e){this._creator_=e,this._lifeCycleManager.addEventListener(this)}setDomElement(e){if(!this._container){this._container=document.createElement("div"),this._container.classList.add("rml-threejs-canvas-container"),this._container.setAttribute("ondragover","return false"),this._container.style.position="relative",this._container.style.width="100%",this._container.style.height="100%";const t=document.createElement("style");t.innerText=".rml-threejs-canvas-container canvas{position:absolute;top:0;left:0;right:0;bottom:0;z-index:100; opacity:1;}",this._container.appendChild(t),e.appendChild(this._container)}this._element=e}getClientDimensions(){return new s(this._element.clientWidth,this._element.clientHeight)}_removeDomElement(e){if(!e)return;const t=e.parentElement;t&&t.removeChild(e)}reset(){this._element=null,this._removeDomElement(this._container),this._container=null}pause(){this.reset()}resume(){}destroy(){}}tn([rn],ts.prototype,"_lifeCycleManager",void 0),e("az",class{constructor(e){this._creator_=e}setScene(e){}setUiScene(e){}updateBounds(e){}clearScene(e,t){}moveCameraEnd(e){}moveCameraStart(e){}needsUiScene(){return!1}});class ns{constructor(e){this._plugins=[],this._creator_=e}async init(e,n,r){this._scene=e,this._uiScene=n,this._cameraPosition=r;const{bananaForScale:i}=this._initData;i&&await t.import("./banana-for-scale-13824fc9.nomodule.js").then(({default:e})=>this._plugins.push(new e(this._creator_))),this._plugins.forEach(e=>e.setScene(this._scene)),this._plugins.forEach(e=>e.setUiScene(this._uiScene)),this._plugins.forEach(e=>e.updateBounds(this._bounds)),this._plugins.forEach(e=>e.moveCameraEnd(this._cameraPosition))}addPlugin(e){this._plugins.push(e),e.setScene(this._scene),e.setUiScene(this._uiScene),e.updateBounds(this._bounds),e.moveCameraEnd(this._cameraPosition)}updateBounds(e){this._bounds=e,this._plugins.forEach(t=>t.updateBounds(e))}clearScene(e,t){this._plugins.forEach(n=>n.clearScene(e,t))}getActivePlugins(){return this._plugins}getPlugin(e){for(let t of this._plugins)if(t instanceof e)return t;return null}moveCameraEnd(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraEnd(e))}moveCameraStart(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraStart(e))}needsUiScene(){return this._plugins.map(e=>e.needsUiScene()).reduce((e,t)=>e||t,!1)}}tn([rn],ns.prototype,"_initData",void 0);class rs{constructor(e,t){this._waitingPromises=[],this._finishPromiseExecutor=[],this._errorCallback=()=>{},Promise.allSettled=Promise.allSettled||(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),e&&this.registerCallback(e),t&&(this._errorCallback=t)}push(e){this._waitingPromises.push(e),Promise.all(this._waitingPromises).then(e=>{e.length===this._waitingPromises.length&&(this._callback&&this._callback(e),this._waitingPromises=[])},this._errorCallback)}finished(e=!1){return new Promise((t,n)=>{this._finishPromiseExecutor.push({resolve:t,reject:n});const r=e?"allSettled":"all";Promise[r](this._waitingPromises).then(e=>{if("allSettled"===r){const t=[];e.forEach(({value:e,status:n})=>{"fulfilled"===n&&t.push(e)}),this._resolveAllExecutors(t)}else this._resolveAllExecutors(e)},e=>{this._rejectAllExecutors(e)})})}registerCallback(e){this._callback=e}unregisterCallback(){this._callback=null}_resolveAllExecutors(e){this._finishPromiseExecutor.forEach(({resolve:t})=>t(e)),this._finishPromiseExecutor=[]}_rejectAllExecutors(e){this._finishPromiseExecutor.forEach(({reject:t})=>t(e)),this._finishPromiseExecutor=[]}clear(){const e=this._waitingPromises.length>0;this._waitingPromises=[],e?this._rejectAllExecutors(new Error("Promise queue has been cleared")):this._resolveAllExecutors([])}get length(){return this._waitingPromises.length}}class is{constructor(e){this.materialQueue=new rs,this._geometryComponentMaterialCache=new Map,this._maxAnisotropy=1,this._maxTextures=16,this._textureLoader=new E,this._configuratorPreviewMaterial=Ti.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:1,roughness:1,envMap:null,polygonOffset:!0,polygonOffsetFactor:-1}),this._creator_=e,this._previewMaterial=Ti.createMeshStandardMaterial({color:"#DDDDDD",roughness:1,metalness:0})}getGeometry(e){return e&&this._cacheHolder.geometryCache.has(e)?this._cacheHolder.geometryCache.get(e):null}_generateGeometry(e,t,n,r,i){let s;return e&&this._cacheHolder.geometryCache.has(e)?s=this._cacheHolder.geometryCache.get(e):(s=new c,s.setIndex(new Ee(n,1)),s.setAttribute("position",new Re(t,3)),s.setAttribute("normal",new Re(i,3)),s.setAttribute("uv",new Re(r,2)),s.scale(.001,.001,.001),s.rotateX(-Math.PI/2),e&&this._cacheHolder.geometryCache.set(e,s)),s}changeMaterialOfMesh(e,t,n){e&&t?(e.material=t,e.material.transparent||0===e.material.opacity||e.material.transmission>0?(e.castShadow=!1,e.receiveShadow=!1):(e.castShadow=!0,e.receiveShadow=!0),e.material.needsUpdate=!0,this._materialLoaded&&this._materialLoaded(t),this._updateMaterialProperties(e,n)):console.warn("could not assign material to mesh",{mesh:e},{material:t})}_updateMaterialProperties(e,t){var n;if(t&&Object.keys(t).length>0&&e.material instanceof N){const r=e.material.clone();r.userData.materialAttributes=t,t.color&&(r.color=new h(t.color)),t.alpha&&(r.opacity=parseFloat(t.alpha)),t.roughness&&(r.roughness=parseFloat(t.roughness)),t.metallic&&(r.metalness=parseFloat(t.metallic)),r instanceof S&&t.transmission&&(r.transmission=parseFloat(t.transmission)),r.transparent=r.opacity<1;const i=e.material;e.material=r,(null===(n=i.userData)||void 0===n?void 0:n.materialAttributes)&&i.dispose()}}_createMaterial(e,t,n,r,i){if(this._cacheHolder.materialCache.has(e))t();else if(e.startsWith("benchmarkMaterial")){let s=Ie(e),a=Ii(s);this._loadBenchmarkTextures(s,a,r,i).then(t,n)}else this._rapiAccess.getMaterial(e).then(e=>{let s=Ii(e);this._loadTextures(e,s,r,i).then(t,n)},n)}_loadBenchmarkTextures(e,t,n=1,r=1){return new Promise((i,s)=>{const a=De(e.id);ki(this._dataSyncer.requestAsset(a.image,!0),a,t,this._maxAnisotropy,n/(0===a.mmWidth?1:a.mmWidth),r/(0===a.mmHeight?1:a.mmHeight),this._maxTextures).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},s)})}_loadTextures(e,t,n=1,r=1){return new Promise((i,s)=>{if(!e.textures||e.textures&&0===e.textures.length)return this._cacheHolder.materialCache.set(e.id,t),i();this._rapiAccess.getTexturesOf(e).then(a=>{let o=[];a.forEach(e=>{o.push(ki(this._dataSyncer.requestAsset(e.image,!0),e,t,this._maxAnisotropy,n/(0===e.mmWidth?1:e.mmWidth),r/(0===e.mmHeight?1:e.mmHeight),this._maxTextures))}),Promise.all(o).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},s)})})}_loadMaterial(e,t,n){return new Promise((r,i)=>{this._singlePromiseFactory.create(6,e,(r,i)=>this._createMaterial(e,r,i,t,n)).then(()=>{setTimeout(()=>r(this._cacheHolder.materialCache.get(e)),0)},i)})}_assignMaterial(e,t,n){return this._cacheHolder.materialCache.has(t)?(this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t),n),Promise.resolve()):new Promise((r,i)=>{this._loadMaterial(t).then(i=>{e.userData.materialId===t&&this.changeMaterialOfMesh(e,i,n),r()},i)})}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy=e}get maxTextures(){return this._maxTextures}set maxTextures(e){this._maxTextures=e}clear(){this._cacheHolder.clear()}_assignRGB(e,t){return new Promise(n=>{let r,i="rgb"+JSON.stringify(t);this._cacheHolder.materialCache.has(i)?r=this._cacheHolder.materialCache.get(i):(r=Ti.createMeshPhysicalMaterial({color:t}),this._cacheHolder.materialCache.set(i,r)),this.changeMaterialOfMesh(e,r),setTimeout(()=>n(),0)})}_assignItem(e,t){return new Promise((n,r)=>{if(this._cacheHolder.materialCache.has(t))return this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t)),void n();this._rapiAccess.getItem(t).then(i=>{if(i.topImage)this._textureLoader.load(i.topImage,r=>{r.anisotropy=this._maxAnisotropy,r.wrapS=L,r.wrapT=L;let a=new s(1,1);i.width>0&&(a.x=1/i.width),i.depth>0&&(a.y=1/i.depth),r.repeat.set(a.x,a.y);const o=Ti.createMeshPhysicalMaterial({map:r,roughness:.5,metalness:.1});this._cacheHolder.materialCache.set(t,o),this.changeMaterialOfMesh(e,o),setTimeout(()=>n(),0)});else{const e="can not set material, catalog item top image is not set";console.warn(e),r(e)}},r)})}setMaterialLoadedListener(e){this._materialLoaded=e}removeMaterialLoadedListener(){this._materialLoaded=void 0}_createMesh(e,t,n){if(e&&t){const r=this._getComponentMeshId(e,t);if(this._geometryComponentMaterialCache.has(r)){const e=this._geometryComponentMaterialCache.get(r);if(this._cacheHolder.materialCache.has(e)){const t=this._cacheHolder.materialCache.get(e);return new H(n,t)}}}return new H(n,this._configuratorPreviewMaterial.clone())}_getComponentMeshId(e,t){return e+"_"+t}}tn([rn],is.prototype,"_initData",void 0),tn([rn],is.prototype,"_rapiAccess",void 0),tn([rn],is.prototype,"_dataSyncer",void 0),tn([rn],is.prototype,"_singlePromiseFactory",void 0),tn([rn],is.prototype,"_cacheHolder",void 0),tn([rn],is.prototype,"_plannerMeshGenerator",void 0);class ss extends is{constructor(e){super(e)}generateMesh(e=0,t=null,n,r,i,s,a,o=!1,l){let h;h=o?this._generateGeometry(t,r,i,s,a).clone():this._generateGeometry(t,r,i,s,a);const d=this._createMesh(e,t,h);return d.userData.materialId=n,d.layers.set(4),n&&this.materialQueue.push(this._assignMaterial(d,n,l).then(()=>{e&&t&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n)})),d}setMaterial(e,t,n,r){return this._assignMaterial(e,t,r)}loadMaterial(e,t,n){return super._loadMaterial(e,t,n)}loadTextures(e,t,n,r){return super._loadTextures(e,t,n,r)}}e("au",ss);class as{constructor(){this._listeners={},this._disabled=!1}_addEventListener(e,t,n){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push({callback:t,scope:n})}addEventListener(e,t,n){this._addEventListener(e,t,n)}dispatchEvent(e,t){if(!this._listeners[e]||this._disabled)return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++){const r=n[e];t?r.callback.apply(r.scope,[t]):r.callback.call(r.scope)}}removeEventListener(e,t){const n=this._listeners[e];if(n)for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t)return void n.splice(e,1)}enableEvents(){this._disabled=!1}disableEvents(){this._disabled=!0}}e("E",as);const os={SCROLL:"scroll",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_LEAVE:"mouseleave",MOUSE_ENTER:"mouseenter",MOUSE_WHEEL:"wheel",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend",CONTEXT_MENU:"contextmenu",DOUBLE_CLICK:"dblclick"};e("a8",{DRAG:50});class ls{constructor(e,t,n,r,i){this.position=e,this.positionRelative=t,this.type=n,this.rotation=r,this.event=i}}const hs=e("U",5*window.devicePixelRatio),ds=3*window.devicePixelRatio;class cs extends as{constructor(e){super(),this._elementHit=!1,this._delta=-1,this._state=0,this._pinchDistance=-1,this._rotationAngle=-1,this._lastMouseWheelEvent=null,this._lastTouchEvent=null,this._events=Object.keys(os).map(e=>os[e]),this._boundingClientRectInvalid=!0,this._creator_=e,this._downPosition={x:0,y:0},this._downPositionRelative={x:0,y:0},this._boundingClientRect=this._getBoundingClientRect()}enableDragIn(e){this._setState(1),this._dragEnabled=!0,e&&(this._dragMV=this._dragM.bind(this),this._dragEV=this._dragE.bind(this),this._dragTarget=e.currentTarget||e.target,this._delta=-1,this._dragMVName="drag",this._dragEVName="dragend",window.TouchEvent&&e instanceof TouchEvent?(this._dragMVName="touchmove",this._dragEVName="touchend"):e.dataTransfer&&e.dataTransfer.setData&&e.dataTransfer.setData("text/plain"," "),this._firefoxDragPosition={x:0,y:0},document.ondragover=e=>{e=e||window.event,this._firefoxDragPosition.x=e.pageX,this._firefoxDragPosition.y=e.pageY},this._dragTarget.addEventListener(this._dragMVName,this._dragMV,!1),this._dragTarget.addEventListener(this._dragEVName,this._dragEV,!1))}isMouseUp(){return 0===this._state}_dragM(e){let t=e,n=null,r=null;window.TouchEvent&&e instanceof TouchEvent?(n=this._getTouchPosition(t),r=this._getTouchPositionRelative(t)):(n=this._getMousePosition(t),r=this._getMousePositionRelative(t)),n.x>0&&n.y>0&&this._move(n,r)}_dragE(e){let t=e;document.ondragover=null,this._firefoxDragPosition=null,this._dragTarget.removeEventListener(this._dragMVName,this._dragMV),this._dragTarget.removeEventListener(this._dragEVName,this._dragEV),window.TouchEvent&&e instanceof TouchEvent?this._onUp(this._getTouchPosition(t),this._getTouchPositionRelative(t),2):this._onUp(this._getMousePosition(t),this._getMousePositionRelative(t),1)}addEvents(e){this._events.forEach(t=>e.addEventListener(t,this,!1)),null===window||void 0===window||window.addEventListener("scroll",this,!1)}removeEvents(e){this._events.forEach(t=>e.removeEventListener(t,this)),null===window||void 0===window||window.removeEventListener("scroll",this)}_move2(e){if(this._lastTouchEvent&&e.timeStamp-this._lastTouchEvent.timeStamp<16)return;const t=e.touches[0],n=e.touches[1],r=t.pageX-n.pageX,i=t.pageY-n.pageY,s=Math.abs(r)+Math.abs(i);this._pinchDistance>-1&&(s>this._pinchDistance+ds?(this._setState(3),this.dispatchEvent(7,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):s<this._pinchDistance-ds?(this._setState(3),this.dispatchEvent(8,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):s<=this._pinchDistance+ds&&s>=this._pinchDistance-ds&&(this._setState(5),this.dispatchEvent(11,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e))))),this._pinchDistance=s,this._lastTouchEvent=e}_setState(e){this._state=e}_move(e,t,n,r){void 0===n&&(n=0),void 0===this._dragEnabled&&(this._dragEnabled=!1),1===this._state&&this._canDrag(n)&&(this._delta=this._getDelta(e),(this._delta>hs||this._elementHit)&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new ls(this._downPosition,this._downPositionRelative)))),2===this._state&&this.dispatchEvent(1,new ls(e,t)),this.dispatchEvent(6,new ls(e,t,n,null,r))}_longClick(e){2!==e&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new ls(this._downPosition,this._downPositionRelative)),this.dispatchEvent(1,new ls(this._downPosition,this._downPositionRelative))),this.dispatchEvent(14,new ls(this._downPosition,this._downPositionRelative,2))}_onUp(e,t,n){this.dispatchEvent(4,new ls(e,t,n)),this._getDelta(e)<=hs&&this.dispatchEvent(5,new ls(e,t)),2===this._state&&this.dispatchEvent(2,new ls(e,t)),4===this._state&&(this.dispatchEvent(10,new ls(e,t)),this._rotationAngle=-1),3===this._state&&(this._pinchDistance=-1),this._lastTouchEvent=null,this._setState(0),this._dragTarget=null,this._elementHit=!1,this._longClickTimer&&clearTimeout(this._longClickTimer)}_getTouchPosition(e){if(e.touches.length){let{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>1){const r=e.touches[1],i=r.clientX,s=r.clientY;t=(t+i)/2,n=(n+s)/2}return{x:t,y:n}}const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}_getTouchPositionRelative(e){const t=this._getBoundingClientRect(),{clientWidth:n,clientHeight:r}=this._domHelper.element;if(e.touches.length){const{clientX:i,clientY:s}=e.touches[0];return{x:(i-t.left)/n*2-1,y:-(s-t.top)/r*2+1}}const i=e.changedTouches[0];return{x:(i.clientX-t.left)/n*2-1,y:-(i.clientY-t.top)/r*2+1}}_getMousePosition(e){if(0!==e.clientX&&0!==e.clientY)return{x:e.clientX,y:e.clientY};{let{x:t,y:n}=this._getFireFoxMousePosition(e);return{x:t,y:n}}}_getFireFoxMousePosition(e){let{x:t,y:n}=this._domHelper.getClientDimensions();return{x:t-(t+e.offsetX),y:n-(n+e.offsetY)}}_getMousePositionRelative(e){const t=this._getBoundingClientRect();return 0!==e.clientX&&0!==e.clientY?{x:(e.clientX-t.left)/this._domHelper.element.clientWidth*2-1,y:-(e.clientY-t.top)/this._domHelper.element.clientHeight*2+1}:this._firefoxDragPosition&&0!==this._firefoxDragPosition.x&&0!==this._firefoxDragPosition.y?{x:(this._firefoxDragPosition.x-t.left)/this._domHelper.element.clientWidth*2-1,y:-(this._firefoxDragPosition.y-t.top)/this._domHelper.element.clientHeight*2+1}:{x:0,y:0}}_getDelta(e){return Math.abs(this._downPosition.y-e.y)+Math.abs(this._downPosition.x-e.x)}setDragEnabled(e){this._dragEnabled=e}handleEvent(e){switch(e.type){case os.SCROLL:this._boundingClientRectInvalid=!0;break;case os.MOUSE_MOVE:this._onMouseMove(e);break;case os.DOUBLE_CLICK:this._onDoubleClick(e);break;case os.MOUSE_DOWN:this._onMouseDown(e);break;case os.MOUSE_UP:this._onMouseUp(e);break;case os.MOUSE_LEAVE:this._onMouseLeave(e);break;case os.MOUSE_ENTER:this._onMouseEnter(e);break;case os.MOUSE_WHEEL:this._onMouseWheel(e);break;case os.TOUCH_MOVE:this._onTouchMove(e);break;case os.TOUCH_START:this._onTouchStart(e);break;case os.TOUCH_END:this._onTouchEnd(e);break;case os.CONTEXT_MENU:this._onContextMenu(e)}}_onMouseDown(e){if(e.preventDefault(),2===e.detail)return;let{x:t,y:n}=this._getMousePosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getMousePositionRelative(e),this.dispatchEvent(3,new ls({x:t,y:n},this._downPositionRelative,1)),this._setState(1)}_onMouseUp(e){e.preventDefault(),2!==e.detail&&this._onUp(this._getMousePosition(e),this._getMousePositionRelative(e),1)}_onMouseMove(e){e.preventDefault(),this._move(this._getMousePosition(e),this._getMousePositionRelative(e),1,e)}_onDoubleClick(e){e.preventDefault(),this.dispatchEvent(12,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1))}_onMouseLeave(e){var t;this._delta=-1,(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest('[data-rml-sdk="ignore-mouse-leave"]'))||this._onMouseUp(e)}_onMouseEnter(e){e.preventDefault()}_onMouseWheel(e){if(this._lastMouseWheelEvent&&e.timeStamp-this._lastMouseWheelEvent.timeStamp<40)return e.preventDefault(),void e.stopPropagation();e.deltaY<0?this.dispatchEvent(7,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)):this.dispatchEvent(8,new ls(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)),this._lastMouseWheelEvent=e}_onTouchMove(e){if(e.preventDefault(),!this._dragTarget)if(1===e.touches.length)this._move(this._getTouchPosition(e),this._getTouchPositionRelative(e),2);else if(2===e.touches.length)if(this._elementHit||4===this._state){const r=e.touches[0],i=e.touches[1],s=function(e){let t=cr(e);return t<0&&(t=180+(180+t)),t}((t={x:r.pageX,y:r.pageY},n={x:i.pageX,y:i.pageY},Math.atan2(n.y-t.y,n.x-t.x)));this._rotationAngle<0&&(this._rotationAngle=s);const a=s-this._rotationAngle;this._rotationAngle=s,this.dispatchEvent(9,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e),2,dr(a))),this._setState(4)}else this._move2(e);var t,n}_onTouchStart(e){if(e.preventDefault(),1===e.touches.length){let{x:t,y:n}=this._getTouchPosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getTouchPositionRelative(e),this.dispatchEvent(3,new ls({x:t,y:n},this._downPositionRelative,2)),this._setState(1),this._longClickTimer=window.setTimeout(this._longClick.bind(this,2),350)}else 2===e.touches.length&&(1!==this._state&&2!==this._state||this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2),this._setState(3))}_onTouchEnd(e){e.preventDefault(),e.touches.length>1&&5===this._state||3===this._state||(this.dispatchEvent(13,new ls(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)),this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2))}_onContextMenu(e){e.preventDefault()}_canDrag(e){return this._dragEnabled}onElementHit(){this._elementHit=!0}_getBoundingClientRect(){return this._boundingClientRectInvalid&&(this._boundingClientRect=this._domHelper.element.getBoundingClientRect(),this._boundingClientRectInvalid=!1),this._boundingClientRect}updateSize(){this._boundingClientRectInvalid=!0}}e("ao",cs),tn([rn],cs.prototype,"_domHelper",void 0);class us{constructor(e){const{component:t,resetCamera:n,consecutive:r}=e;this.component=t,this.resetCamera=void 0===n||n,this.consecutive=void 0===r||r}}class ps extends f{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new v(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(e){const n=i.parse(JSON.parse(e));t&&t(n)}),n,r)}parse(e){return new ms(e)}}class ms{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],r=function(e,t,n){const r=Array.from(e),i=t/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,a=[];let o=0,l=0;for(let e=0;e<r.length;e++){const t=r[e];if("\n"===t)o=0,l-=s;else{const e=gs(t,i,o,l,n);o+=e.offsetX,a.push(e.path)}}return a}(e,t,this.data);for(let e=0,t=r.length;e<t;e++)n.push(...r[e].toShapes());return n}}function gs(e,t,n,r,i){const s=i.glyphs[e]||i.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+i.familyName+".");const a=new Oe;let o,l,h,d,c,u,p,m;if(s.o){const e=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let i=0,s=e.length;i<s;)switch(e[i++]){case"m":o=e[i++]*t+n,l=e[i++]*t+r,a.moveTo(o,l);break;case"l":o=e[i++]*t+n,l=e[i++]*t+r,a.lineTo(o,l);break;case"q":h=e[i++]*t+n,d=e[i++]*t+r,c=e[i++]*t+n,u=e[i++]*t+r,a.quadraticCurveTo(c,u,h,d);break;case"b":h=e[i++]*t+n,d=e[i++]*t+r,c=e[i++]*t+n,u=e[i++]*t+r,p=e[i++]*t+n,m=e[i++]*t+r,a.bezierCurveTo(c,u,p,m,h,d)}}return{offsetX:s.ha*t,path:a}}const fs=new Map,_s=new Map;class vs{static loadFont(e){if(_s.has(e))return new Promise(t=>{t(_s.get(e))});if(fs.has(e))return new Promise((t,n)=>{fs.get(e).push({resolve:t,reject:n})});let t=new ps;return new Promise((r,i)=>{fs.set(e,[{resolve:r,reject:i}]),t.load(n()+e,t=>{_s.set(e,t),vs._resolveAll(e,t)})})}static _resolveAll(e,t){fs.has(e)&&fs.get(e).forEach(e=>e.resolve(t)),fs.delete(e)}}e("ay",vs);class ws{constructor(e){this._activeComponents=[],this._componentDimensioningsExist=new Map,this._creator_=e}setCamera(e){this._camera=e}add(e){if(this._componentDimensioningsExist.has(e.runtimeId)&&!this._componentDimensioningsExist.get(e.runtimeId))return!1;const n=this._plannerKernelAccess.kernelInstance.getComponent(e.runtimeId),r=n.dimensionings;if(this._componentDimensioningsExist.set(e.runtimeId,r.length>0),!r||0===r.length||this._camera.position.z<0)return!1;const i=Pi(n.boxForMeasurement),s={x:this._camera.position.x,y:this._camera.position.z};return t.import("./component-dimensioning-33a84630.nomodule.js").then(t=>{vs.loadFont("static/rubik_regular-bc008a7de2daee79.json").then(n=>{r.forEach(r=>{var a;e.add(new t.default(((a=r).from=a.from/1e3,a.to=a.to/1e3,1===a.type.value?(a.type={value:2},a.from*=-1,a.to*=-1):2===a.type.value&&(a.type={value:1}),a),i,n,s))})})}),this._activeComponents.push(e),!0}remove(e,n=!0){return new Promise(r=>{t.import("./component-dimensioning-33a84630.nomodule.js").then(t=>{let i=[];e.children.forEach(e=>{e instanceof t.default&&i.push(e)}),i.forEach(t=>{e.remove(t),Bi(t)}),n&&Le(this._activeComponents,e),r()})})}hasComponentDimensions(){return this._activeComponents.length>0}async reset(){for(const e of this._activeComponents)await this.remove(e);this._activeComponents=[]}invalidateDimensioningsCache(e){e?this._componentDimensioningsExist.delete(e):this._componentDimensioningsExist.clear()}}tn([rn],ws.prototype,"_plannerKernelAccess",void 0);class bs{constructor(){this._promiseExecutors=[]}create(){return new Promise((e,t)=>{this._promiseExecutors.push({resolve:e,reject:t})})}resolve(e){return new Promise(t=>{this._promiseExecutors.forEach(t=>t.resolve(e)),this._promiseExecutors=[],t(e)})}reject(e){return new Promise((t,n)=>{this._promiseExecutors.forEach(t=>t.reject(e)),this._promiseExecutors=[],n(e)})}}class ys extends class{constructor(e){this._coreReference=e.clone()}clearReference(){this._coreReference.delete(),this._coreReference=null}getKernelObject(){return this._coreReference}}{constructor(e){super(e),this._objectWaiter=new bs,this._topView=!1;const t=pr(e.getCenter());this._container=new A,this._container.position.copy(t),this._boundingBox=this._generateBoundingBox(),Ni(this._boundingBox),this._container.add(this._boundingBox),2!==this.getPlanElement().getType().value&&(this._object=new A,this._container.add(this._object))}getSize(){return this._object?(new ge).setFromObject(this._object).getSize(new a):new a}update(){this._container.position.copy(pr(this.getPlanElement().getMeshCenter())),this._boundingBox&&this._updateBoundingBox()}_updateBoundingBox(){const e=this.getSize();this._boundingBox.geometry=new ke(e.x,e.y,e.z),this._boundingBox.position.y=e.y/2}getPosition(){return this._container.position}getRotation(){return this._container.rotation.y}getBounds(){let e;return this.getPlanElement().boxForMeasurement?(e=Pi(this.getPlanElement().boxForMeasurement),e.applyMatrix4(this.getContainer().matrix)):(e=new ge,e.setFromObject(this._container)),e}getBoundingBox(){return this._boundingBox}getPlanElement(){return this._coreReference}setObject(e){this._object=e,this._objectWaiter.resolve(e)}getObject(){return this._object}async getObjectAsync(){return this._object?Promise.resolve(this._object):this._objectWaiter.create()}addMesh(e){this._object.add(e),this.hidePreviewBox()}getMesh(e){if(!this._object||0===this._object.children.length)return null;const t=Wi(e,this.getPlanElement().getType());return this._object.children.find(e=>e.userData.material===t)}getContainer(){return this._container}getId(){return this.getPlanElement().getId()}clear(){Bi(this._container),this._selectionMesh&&Bi(this._selectionMesh)}remove(){var e;null===(e=this._container.parent)||void 0===e||e.remove(this._container),this.clear()}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material=(Vi||(Vi=new y,Vi.visible=!1),Vi))}_generateBoundingBox(){const e=this.getSize(),t=new ke(e.x,e.y,e.z);let n=new h("#DDDDDD");const r=this.getPlanElement().customColor;r>0&&(n=(e=>{let t=new h;return t.setRGB((e>>16)/255,(e>>8&255)/255,(e>>0&255)/255),t})(r));let i=Ti.createMeshStandardMaterial({color:n,opacity:1,transparent:!0}),s=new H(t,i);return s.name="bounding box",s.position.y=e.y/2,s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),s}select(){this._isSelected=!0,this._selectionMesh&&this._container.add(this._selectionMesh)}deselect(){this._isSelected=!1,this._selectionMesh&&this._container.remove(this._selectionMesh)}hoverOn(){}hoverOff(){}setTopView(e){this._topView=e}}class xs extends ys{constructor(e){super(e),this._initDone=!1,this._initFailed=null,this._initWaiter=new bs,this._container.rotation.y=e.rotation}finishInit(){return this._initDone=!0,this._initFailed=null,this._initWaiter.resolve()}failInit(e){return this._initFailed=e,this._initDone=!1,this._initWaiter.reject(this._initFailed)}isInitDone(){return this._initDone?Promise.resolve():this._initFailed?Promise.reject(this._initFailed):this._initWaiter.create()}getPlanObject(){return this.getPlanElement()}getSize(){return mr(this.getPlanObject().size)}update(){super.update(),this._container.rotation.y=this.getPlanObject().rotation}}class Ss extends xs{constructor(e){super(e),this._container.name="Configurable "+this._container.name}addRootComponent(e){this.setObject(e),this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId,this._container.add(this.getObject())}getConfigurationRuntimeId(){return this.getPlanObject().getConfigurationRuntimeId()}getRootComponentId(){return this._rootComponentId}getRootComponentRuntimeId(){return this._rootComponentRuntimeId}finishConstruction(){return this.finishInit()}failConstruction(){return this.failInit(new Error("Construction of configuration failed"))}}e("a6",Ss);let Cs=JSON.parse(JSON.stringify({isProduction:!0,isUnitTesting:!1,environment:"production",detailEnvironment:"development",features:{},APP:{RAPI:{server:"/api/v2",localReverseProxy:"https://www.roomle.com/api/v2",liveServer:"https://www.roomle.com/api/v2",testServer:"https://www.test.roomle.com/api/v2",headers:{apiKey:"roomle_portal_v2",currentTenant:9,locale:"en",language:"en",device:1,token:"anonymous",platform:"web"},itemHeaders:{assetRevision:"glb",assetFileFormat:"glb"}},SHORTENER_URL:"http://rml.co/"},environments:{PRODUCTION:"production",DEVELOPMENT:"development",TEST:"test",TEST_SERVER:"test_server",ALPHA:"alpha"}}));Cs.isUnitTesting=!1,void 0!==t&&t.exports||(window.IS_DEBUG=!0);const Ms={ENV_DEBUG:function(e=!1){if(e){let e=JSON.parse(JSON.stringify(Cs));const t={...e.APP,SHORTENER_URL:"http://localhost:4747/?isItem=false&id="},n={...e.features};return{...e,isProduction:!1,APP:t,features:n}}}(),ENV_PRODUCTION:JSON.parse(JSON.stringify(Cs))};var Ts=e("f",Ms.ENV_PRODUCTION);class Ps extends xs{constructor(e){super(e),this._originalSize=new a,this._container.name="Static "+this._container.name}setRapiItem(e){return this._rapiItem?Promise.resolve():this._addStaticItem(e)}async _addStaticItem(e){this._rapiItem=e;let t=this.getPlanObject();if(this._glbUrl=Ue(e),!this._glbUrl)return Promise.reject("No glb url found");let n=e.scaleable?mr(t.size):void 0,r=new a(1,1,1);t.flipX&&(r.x*=-1),t.flipY&&(r.z*=-1);try{const i=await this._staticItemLoader.loadGLB(this._glbUrl,void 0,void 0,n,r,t.customColor,e.colorable);this._originalSize.copy(i.boundingBox.getSize(new a)),i.scene.name=e.label,this.setObject(i.scene),((e,t)=>{let n=(new ge).setFromObject(e),r=n.getSize(new a),i=Math.min(r.x,r.y,r.z),s=!0;i>5&&(console.warn("GLB seems to be too big ("+i+")",t),s=!1),n.min.y<-.01&&(console.warn("GLB seems to be under the floor ("+n.min.y+"): ",t),s=!1)})(i.scene,this._glbUrl),Ni(i.scene),this._container.add(this.getObject()),this.hidePreviewBox(),await this.finishInit()}catch(e){await this.failInit(e)}}getRapiItem(){return this._rapiItem}needsRapiItem(){return!this._glbUrl}getGLBUrl(){return this._glbUrl}update(){const e=mr(this.getPlanElement().size),t=this.getObject();if(!t)return;if(e){const{x:n,y:r,z:i}=this._originalSize;let s=new a(e.x/n,e.y/r,e.z/i);t.scale.copy(s)}this.getPlanElement().flipX&&(t.scale.x*=-1),this.getPlanElement().flipY&&(t.scale.z*=-1);const n=this.getPlanElement().customColor;t.traverse(e=>{if(e instanceof H&&e.material instanceof N){const t=e.material;if(this._rapiItem.colorable&&n&&n>0){let e=new h(n);t.color=e.copySRGBToLinear(e)}t.needsUpdate=!0}}),super.update()}}let As;e("a7",Ps),tn([rn],Ps.prototype,"_staticItemLoader",void 0),e("am",e=>{const{id:t,textRotation:n,length:r,lengthFormatted:i}=e;return{id:t,fromWithoutPadding:qi(e.fromWithoutPadding),toWithoutPadding:qi(e.toWithoutPadding),fromPosition3d:qi(e.fromPosition3d),toPosition3d:qi(e.toPosition3d),textPosition3d:qi(e.textPosition3d),fromPosition2d:Ki(e.fromPosition2d),toPosition2d:Ki(e.toPosition2d),textPosition2d:Ki(e.textPosition2d),textDirection:qi(e.textDirection),textRotation:n,length:r,lengthFormatted:i}});const Es=()=>(As||(As=Ti.createMeshPhysicalMaterial({color:0})),As);class Rs extends ys{constructor(e){super(e),this._container.name="Wall Plan Element"}get isSelected(){return this._isSelected}getWallDimension(e){const t=this.getPlanElement(),n=pr(t.getCenter()),r=t.getPreferredSide();let i,s;0===r.value?(i=pr(t.getCornerFromLeft()),s=pr(t.getCornerToLeft())):1===r.value&&(i=pr(t.getCornerFromRight()),s=pr(t.getCornerToRight()));const o=i.clone().add(s).divideScalar(2),l=i.clone().sub(s),h=l.clone().cross(new a(0,1,0)).normalize();h.clone().dot(o.clone().sub(n))<0&&h.multiplyScalar(-1);const d={maxZoomedIn:Math.max(.7,e),maxZoomedOut:.01,minPadding:.05,maxPadding:.25},c=Fe(e,d.maxZoomedIn,d.maxZoomedOut,d.minPadding,d.maxPadding),u=h.clone().multiplyScalar(c/2),p=i.clone().add(u),m=s.clone().add(u),g=h.multiplyScalar(c),f=i.add(g),_=s.add(g),v=l.clone();l.dot(new a(1,0,0))<0&&v.multiplyScalar(-1);const w=Math.atan2(v.z,v.x),b=f.clone().add(_).divideScalar(2);return{id:t.getId(),fromPosition3d:f,toPosition3d:_,textPosition3d:b,textDirection:v,textRotation:w,length:t.getLength(r.value),fromWithoutPadding:p,toWithoutPadding:m}}addMesh(e){e.traverse(e=>{this._setMaterial(e)}),e.layers.set(9),super.addMesh(e);const t=(new ge).setFromObject(this.getObject()).getSize(new a);this._boundingBox.geometry=new ke(t.x,t.y,t.z),this._boundingBox.position.y=t.y/2}show(){var e,t;this.getContainer().visible=!0,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.set(9)}),null===(t=this.getBoundingBox())||void 0===t||t.layers.set(6)}hide(){var e,t;this.getContainer().visible=!1,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.disableAll()}),null===(t=this.getBoundingBox())||void 0===t||t.layers.disableAll()}_enableTopView(){this._container.traverse(e=>{this._setTopMaterial(e)})}_setTopMaterial(e){e instanceof H&&!e.userData.originalMaterial&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial=e.material,e.material=Es())}_disableTopView(){this._container.traverse(e=>{e instanceof H&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial)})}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView()}getKernelObject(){return super.getKernelObject()}_setMaterial(e){e instanceof H&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),this._topView&&this._isSelected?e.material=new y({color:10526880,side:B}):this._topView&&!this._isSelected?e.material=Es():(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial))}select(){super.select(),this._container.traverse(e=>{this._setMaterial(e)})}deselect(){super.deselect(),this._container.traverse(e=>{this._setMaterial(e)})}}e("a1",Rs);class Is extends ys{constructor(e){super(e),this._container.name="Floor Plan Element"}addMesh(e){this.getObject().clear(),super.addMesh(e),e.layers.set(9),e.castShadow=!1,e.position.y=-.001}}e("a2",Is);class Ds extends ys{constructor(e){super(e),this._container.name="Ceiling Plan Element"}addMesh(e){super.addMesh(e),e.castShadow=!1;const t=(new ge).setFromObject(this.getObject()).getSize(new a);this._boundingBox.geometry=new ke(t.x,.01,t.z)}}e("aa",Ds);const Os=new Map;class Ls{static start(e){if(!window.performance||!window.performance.getEntriesByName)return"";let t=window.performance.getEntriesByName(e).length++,n="";t<100&&(n="0"),t<10&&(n="0"+n);const r=t>0?e+"_"+n+t:e,i=r+"_start";return window.performance.mark(i),r}static addMeta(e,t){const n=Ls.getMeta(e);Os.set(e,Object.assign(n,t))}static getMeta(e){return Os.get(e)||{}}static end(e){}static getMeasure(e){return[]}static showBenchmarks(e){const t=window.performance.getEntriesByType("measure");t.sort((function(e,t){return e.startTime-t.startTime}));const n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];e&&-1===i.name.indexOf(e)||n.push({Start:parseFloat(i.startTime.toFixed(2)),Name:i.name,Duration:parseFloat(i.duration.toFixed(2))})}console.table(n)}}e("B",Ls);class ks{static init(e={}){const{kernelInstance:t,kernelContainer:n,planObjectId:r}=e;ks.kernelInstance=t,ks.kernelContainer=n,ks.planObjectId=r}static cleanUp(){ks.useHDGeometry=!1,ks.kernelInstance=null,ks.kernelContainer=null,ks.planObjectId=null}}e("A",ks),ks.useHDGeometry=!1,ks.kernelInstance=null,ks.kernelContainer=null,ks.planObjectId=null;const Us=new Map,Fs=function(e,t,n){let r=Us.get(e);if(r){const i=n?[n]:void 0;r.forEach(({resolve:e,reject:n})=>t?e.apply(e,i):n.apply(n,i)),Us.delete(e)}};class Ns{static finishOperation(e,t){Fs(e,!0,t)}static failOperation(e,t){Fs(e,!1,t)}static waitFor(e,t){return new Promise((n,r)=>{let i=Us.get(e);i||(Us.set(e,[]),i=Us.get(e)),i.push({resolve:n,reject:r}),"function"==typeof t&&t.apply(t)})}}e("y",Ns);const Bs=e("z",(function(e){return e.validRange&&"string"==typeof e.validRange.type})),js=function(e){return e.validValues&&e.validValues.length>0},Gs=e("F",(function(e){return"Material"===e.type}));let Hs,zs,Vs,Ws,Ks;const qs={WASM:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-43c82d370b8f8956.wasm",LOADER:"static/ConfiguratorKernel-ea213aa201ba840d.js"},PLANNER:{URL:"static/RoomleCore-f73eeb183e5a1083.wasm",LOADER:"static/RoomleCore-d31ce9bf62e9202f.js"}},WASM_MODERN:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-da91d76a6e28da63.wasm",LOADER:"static/ConfiguratorKernel-5c4fcff0d630e61b.js"},PLANNER:{URL:"static/RoomleCore-ce88bd5bf57f7e9e.wasm",LOADER:"static/RoomleCore-c9e8fbc848d32a0e.js"}},ASM:{CONFIGURATOR:{MEM_URL:"static/ConfiguratorKernelJs-a2fcb551f73ce77d.mem",LOADER:"static/ConfiguratorKernelJs-567985cbba145249.js"},PLANNER:{MEM_URL:"static/RoomleCoreJs-a388d2a4f4f35743.mem",LOADER:"static/RoomleCoreJs-55a97bc3952d59d2.js"}}},Xs=!!window.WebAssembly;class Qs{_utilityToLongArray(e){const t=new this._kernelContainer.LongArray;return e.forEach(e=>t.push_back(e)),t}constructor(e){this._requestedItemIds=[],this._requestedMaterialIds=[],this._configuratorKernelCallbackListener=new Set,this._cachedGroupIds=[],this._waitingForGroups=!1,this._subComponentsWaiters=new Map,this._shouldWait=!0,this._creator_=e,window.KernelCallback={isReady:this.isReady.bind(this)},this._lifeCycleManager.addEventListener(this)}init(e){this._kernelType=e,this._setupKernelPaths(e),this._setupEmsModule(e),this._useWASM=Xs,this._kernelPath=Xs?Vs:Ws}_initKernel(){const{restrictionLevel:e}=this._initData,t=!1!==this._initData.callbacksOnlyIfGeometryIsReady;this._kernelInstance.setUpdateCallbacksOnlyIfGeometryIsReady(t),this._kernelInstance.setLevel(e),this._unitFormatter.init(this._kernelContainer),this._kernelInstance.setEnvironmentVariable("unit",this._unitFormatter._actualUnitString||"cm"),this._kernelInstance.setEnvironmentVariable("unitString","short"),this._kernelInstance.useEnvironmentGeometry(1===this._kernelType);const{overrideCountry:n,locale:r}=this._globalInitData;n&&(this._kernelInstance.resetPriceListIds(),this._kernelInstance.addPriceList(n)),this._kernelInstance.setEnvironmentVariable("language",r)}get kernelContainer(){return this._kernelContainer}get kernelInstance(){return this._kernelInstance}get configurationExporter(){return this._configurationExporter||(this._configurationExporter=this._kernelContainer.newConfigurationExporter()),this._configurationExporter}_setupKernelPaths(e){const t=0===e?"PLANNER":"CONFIGURATOR";Hs=qs.ASM[t].MEM_URL,Ws=qs.ASM[t].LOADER,WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11]))?(zs=qs.WASM_MODERN[t].URL,Vs=qs.WASM_MODERN[t].LOADER):(zs=qs.WASM[t].URL,Vs=qs.WASM[t].LOADER),Ks=!0}_setupEmsModule(e){const t=this;this._kernelContainer={locateFile(t){const r=0===e?/RoomleCoreJs[\-a-z0-9]*\.js\.mem/:/ConfiguratorKernelJs[\-a-z0-9]*\.js\.mem/;return t.match(r)?n()+Hs:t},wasmBinaryFile:n()+zs,preRun:[],postRun:[],setStatus:null,print(e){t._kernelIo.log(e)},printErr(e){t._kernelIo.error(e)},quit(e){0!==e&&t._kernelIo.throw(e&&e.toString?e.toString():"Unknown error while C/C++ main executes")}},Ks&&Xs&&(this._kernelContainer.instantiateWasm=function(e,t){return((e,t,r)=>{const i="function"==typeof WebAssembly.instantiateStreaming;Ls.addMeta("kernel_is_ready",{cachedInIndexedDB:!1});let s=null;i?(Ls.start("kernel_stream_compile"),s=WebAssembly.instantiateStreaming(fetch(n()+e),t)):(Ls.start("kernel_legacy_compile"),s=fetch(n()+e).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,t))),Ls.addMeta("kernel_is_ready",{instantiateStreaming:i}),s.then(e=>{r(e.instance)},e=>console.error(e))})(zs,e,t),{}})}_passSubComponentsToKernel(e,t){const n=e.id,r=t.get(n);if(r)for(let t=0,i=r.length;t<i;t++){const{parentId:i,partId:s}=r[t];this._kernelIo.setMeta({componentId:n}),this._kernelInstance.loadedSubComponent(i,s,n,e.configuration)}}_fetchSubComponents(e){let t=[...e.keys()];t.length&&this._rapiAccess.getComponents(t).then(t=>{for(let n=0,r=t.length;n<r;n++)this._passSubComponentsToKernel(t[n],e);this._flushSubComponentsWaiters()})}_flushSubComponentsWaiters(){this._fetchSubComponents(this._subComponentsWaiters),this._subComponentsWaiters=new Map,this._shouldWait=!1}isReady(){this._kernelContainer.setExternalHelpers(this._kernelIo,{convertCObject:_r}),Ts.isProduction||Ts.isUnitTesting||this.addDebugInfo(),window.KernelCallback&&(window.KernelCallback=null,delete window.KernelCallback)}addDebugInfo(){const e=function(t,n=[]){const r=Object.getPrototypeOf(t),i=r?Object.getOwnPropertyNames(r):[],s=t?Object.getOwnPropertyNames(t):[];return r?e(r,[...n,...s,...i]):[...s,...i,...n]},t=e(this),n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf"];[...new Set(t)].forEach(e=>{if(!e.startsWith("_")&&"function"==typeof this[e]&&-1===n.indexOf(e))try{const t=this[e].bind(this);this[e]=function(...n){return this._kernelIo.log("[ KernelCommunication ]: "+e),t(...n)}}catch(e){}})}getConfigurationData(e){return new Promise(t=>{var n;const r=this.kernelInstance.getPlanObject(e),i=(new Date).toISOString(),s=this.kernelInstance.getComponentId(e),a=Zt(s),o=(null===(n=r.boxForMeasurement)||void 0===n?void 0:n.size)||r.bounds;t({created:i,lastAccess:i,configuration:this.kernelInstance.getSerializedConfiguration(e),configurationHash:this.kernelInstance.getHashOfConfiguration(e),parts:JSON.stringify(this.kernelInstance.getPartList(e)),rootComponentId:s,width:o.x,height:o.z,depth:o.y,catalog:a,orderable:!1,requestable:!1})})}loadComponent(e,t,n){this._rapiAccess.getComponent(t.componentId).then(r=>{var i;let s=r.configuration;s||(s="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[t.componentId],message:t.componentId+" has no configuration"})),this._kernelIo.setMeta({componentId:t.componentId}),this._kernelInstance.loadComponent(e,s,t,n),this._flushSubComponentsWaiters()},r=>{var i;this._kernelInstance.loadComponent(e,"error",t,n),this.onLoadComponentError(r,t.componentId),null===(i=this._configuratorUiCallbacks)||void 0===i||i.onError(new Error(`Component with id "${t.componentId}" can not be loaded. "${r}"`)),this._flushSubComponentsWaiters()})}loadSubComponent(e,t,n){if(this._shouldWait){let r=this._subComponentsWaiters.get(n);r||this._subComponentsWaiters.set(n,[]),r=this._subComponentsWaiters.get(n),r.push({parentId:e,partId:t}),this._subComponentsWaiters.set(n,r)}else this._rapiAccess.getComponent(n).then(r=>{var i;let s=r.configuration;s||(s="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[n],message:"SubComponent "+n+" has no configuration"})),this._kernelIo.setMeta({componentId:n,parentId:e}),this._kernelInstance.loadedSubComponent(e,t,n,s)})}async loadItemConfigurations(e,t){let n=Array.isArray(t)?t:[t];if(this._requestedItemIds.push(...n),await Ne(0),!this._requestedItemIds.length)return;const r=[...this._requestedItemIds];this._requestedItemIds=[],(await this._rapiAccess.getItems(r)).forEach(t=>{this._kernelInstance.loadedItemConfiguration(e,t.id,t.configuration)})}requestDeleteComponent(e){var t,n;e&&((null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)?this._kernelInstance.deletePlanComponent(e):this._kernelInstance.deleteComponent(e))}dockComponentWithPosition(e,t,n,r,i){var s;this._kernelInstance.dockComponentWithPosition(n,r,e,t,i);const a=this._kernelInstance.getComponentId(n),o=this._kernelInstance.getComponentId(e);null===(s=this._configuratorUiCallbacks)||void 0===s||s.onUserInitiatedDockDone(a,r,o,t,i)}Editor3dAddBakedMesh(e,t,n,r,i,s,a,o){this._configuratorKernelCallbackListener.forEach(l=>l.Editor3dAddBakedMesh(e,t,n,r,i,s,a,o))}Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c){this._configuratorKernelCallbackListener.forEach(u=>u.Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c))}Editor3ChangedNamedMesh(e,t,n,r,i,s,a){this._configuratorKernelCallbackListener.forEach(o=>o.Editor3ChangedNamedMesh(e,t,n,r,i,s,a))}Editor3dRemoveNamedMesh(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dRemoveNamedMesh(e,t))}Editor3dBeginConstruction(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dBeginConstruction(e,t))}Editor3dEndConstruction(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dEndConstruction(e))}Editor3dComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!1))}Editor3dComponentDocked(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,t,n,r))}Editor3dGeometryReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryReady(e)),this.requestPlanComponentConstruction(e),this._configuratorUiCallbacks.onGeometryReady(e)}Editor3dGeometryNotReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryNotReady(e)),this._configuratorUiCallbacks.onGeometryNotReady(e)}componentDeleted(e){this._configuratorKernelCallbackListener.forEach(t=>t.componentDeleted(e))}componentMetaUpdated(e){let t=this._kernelInstance.getComponent(e);this._configuratorKernelCallbackListener.forEach(e=>e.componentMetaUpdated(t))}sceneCleared(){this._configuratorKernelCallbackListener.forEach(e=>e.sceneCleared())}requestMaterialsInGroup(e){(Array.isArray(e)?e:[e]).forEach(e=>{-1===this._cachedGroupIds.indexOf(e)&&this._cachedGroupIds.push(e)}),this._waitingForGroups||(this._waitingForGroups=!0,Ns.waitFor(4).then(()=>{this._rapiAccess.getMaterialsByGroup(this._cachedGroupIds).then(e=>{let t=[];e.forEach(e=>{const n=[];e.materials.forEach(e=>n.push(e.id));const r=e.legacyId||e.id;e.legacyId||console.warn("Material group has no legacy id, please check content why this is the case"),t.push({group:r,materials:n})}),t.length&&this._kernelInstance.setMaterialsInGroup(t),this._cachedGroupIds=[]},e=>{var t;console.error(e),null===(t=this._configuratorUiCallbacks)||void 0===t||t.onError(new Error(`Material group with ids "${this._cachedGroupIds.join(",")}" can not be loaded. "${e}"`)),this._cachedGroupIds=[]})}))}requestPlanComponentConstruction(e,t=!0){t?this._kernelInstance.requestDeltaPlanComponentConstruction(e):this._kernelInstance.requestPlanComponentConstruction(e)}addConfiguratorListener(e){this._configuratorKernelCallbackListener.add(e)}removeConfiguratorListener(e){this._configuratorKernelCallbackListener.delete(e)}cleanUpCallbacks(){"function"==typeof this._kernelContainer.unregisterConfiguratorCallback&&this._kernelContainer.unregisterConfiguratorCallback(this)}async requestMaterialProperties(e){let t=Array.isArray(e)?e:[e];if(this._requestedMaterialIds.push(...t),await Ne(0),!this._requestedMaterialIds.length)return;const n=[...this._requestedMaterialIds];this._requestedMaterialIds=[];const r=await this._rapiAccess.getMaterials(n);let i=[];r.forEach(e=>{const t=new this._kernelContainer.StringStringMap,n=e.properties||{};for(let e in n)n.hasOwnProperty(e)&&t.set(e,n[e]);t.size()&&i.push({id:e.id,properties:t})}),i.length&&this._kernelInstance.setMaterialProperties(i)}registerCallbacks(){this._kernelContainer.registerConfiguratorCallback(this)}pause(){this.cleanUpCallbacks()}resume(){this.cleanUpCallbacks(),this.registerCallbacks()}destroy(){}_handleCortoMesh(e,t,n){var r;try{this._kernelInstance.addMeshCorto(t,n,new Uint8Array(e))}catch(e){console.error(e),null===(r=this._configuratorUiCallbacks)||void 0===r||r.onMemoryCorruption()}}_handleInvalidMesh(e){try{this._kernelInstance.setExternalMeshInvalid(e)}catch(e){console.error(e)}}calcPartsPriceSum(e){return this._calcPrice(e)}_calcPrice(e){const t=new Map;e||(e=this._kernelInstance.getFullPartList());const n=!!e&&!!e.fullList&&!!e.fullList.length;if(this._initData.useRoomlePrice&&n){const n=e.fullList[0].currencySymbol,r=e.fullList.reduce((e,t)=>e+(t.count?t.count:0)*(t.price?t.price:0),0),i=je(r,2);return this._configuratorUiCallbacks.onUpdatePrice(n,i),Promise.resolve({totalSum:i,partMap:t})}if(this._initData.usePriceService&&n){const n=e.fullList.reduce((e,n)=>{const r=Jt(n);return r&&(t.set(r,n),e.push(r)),e},[]);return new Promise((r,i)=>{this._rapiAccess.getPrices(n).then(n=>{if(!n.length)return i(new Error("prices are empty"));let s=0;const a=Be(n,"priceId");for(const t of e.fullList){const e=Jt(t);if(!a.has(e)){console.warn("PriceId: "+e+" has no corresponding kernel-part");continue}const{price:n,currencySymbol:r}=a.get(e);t.price=n,t.currencySymbol=r,s+=n*t.count}return s=je(s,2),this._configuratorUiCallbacks.onUpdatePrice(n[0].currencySymbol,s),r({totalSum:s,partMap:t})},e=>{console.error(e),i(e)})})}return Promise.resolve({totalSum:0,partMap:t})}async addUiDataAndPriceToPartList(e,t){const{fullList:n,originPart:r}=e,i=e.perMainComponent;let s;this.addUiDataToPartList(n,t);try{const t=await this._calcPrice(e);s=t.partMap}catch(e){console.error(e),s=new Map}const a=this._initData.usePriceService||this._initData.useRoomlePrice,o=e=>{a||(e.price=null,e.currencySymbol=null);const t=Jt(e);if(!t)return;if(!s.has(t))return;const{price:n,currencySymbol:r}=s.get(t);"number"==typeof n&&(e.price=n,e.currencySymbol=r)};return n.forEach(o),i.forEach(({fullList:e,perMainComponent:n})=>{n.length>0&&console.error("Not implemented! perMainComponent is deeper than one level"),this.addUiDataToPartList(e,t),e.forEach(o)}),{fullList:n,perMainComponent:i,originPart:r}}addUiDataToPartList(e,t){const n=[];return e.forEach(e=>{const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label),e.parameters.forEach(e=>{if(this._unitFormatter.formatPartListParameter(e),Gs(e)){const t=this._rapiAccess.peekMaterial(e.value);t?e.valueLabel=t.label||t.name||e.value:-1===n.indexOf(e.value)&&n.push(e.value)}})}),n.length&&this._rapiAccess.getMaterials(n).then(e=>{const n=this._lastPartListHash!==t;Array.isArray(e)&&e.length&&n&&(this._lastPartListHash=t,this.requestPartListAndUpdatePricesOfParts())}),e}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const r=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(r,btoa(e))}}tn([rn],Qs.prototype,"_rapiAccess",void 0),tn([rn],Qs.prototype,"_scriptLoader",void 0),tn([rn],Qs.prototype,"_kernelIo",void 0),tn([rn],Qs.prototype,"_dataSyncer",void 0),tn([rn],Qs.prototype,"_lifeCycleManager",void 0),tn([rn],Qs.prototype,"_configuratorUiCallbacks",void 0),tn([rn],Qs.prototype,"_globalCallback",void 0),tn([rn],Qs.prototype,"_initData",void 0),tn([rn],Qs.prototype,"_unitFormatter",void 0),tn([rn],Qs.prototype,"_configuratorContext",void 0),tn([rn],Qs.prototype,"_globalInitData",void 0);const{APP:Ys}=Ts,{RAPI:Zs}=Ys,Js=Zs.headers,$s=Zs.itemHeaders,ea=Js.token,ta=e("an",e=>e.startsWith("ps_")),na=Ge();let ra=new Map,ia=new Map,sa=new Map,aa=new Map,oa=new Map,la=new Map,ha=new Map,da=new Map,ca=new Map;const ua=e=>ra.get(e)||ra.get(na+e),pa=e=>e&&e.tags&&e.tags.length,ma=e=>!pa(e)&&e.group;class ga{constructor(e){this._itemLoaded=!1,this._currentToken=null,this._creator_=e,window.addEventListener("online",this._flushOfflineQueue.bind(this))}getPreloadForItem(e){return this._getPreload(e,!0)}getPreloadForConfiguration(e){return this._getPreload(e,!1)}_getPreload(e,t){return new Promise((n,r)=>{if(!navigator.onLine)return n();if(this._dataSyncer.getIsCatalogSynced(Zt(e)))return n();if(ha.get(e))return n();const i=t?"?itemId=":"?configurationId=";this._get("/preloads/components/"+i+e,"preloads/components").then(t=>{if(ha.get(e))return n();t.forEach(e=>{this._prepareData(e,"components")}),ha.set(e,!0),n()},r)})}changeUseOfHDGeometry(){const e=aa.get("components");ha.clear(),la.clear(),e&&aa.delete("components")}getHSCPackage(e){return new Promise((t,n)=>{if(la.get(e))return t();this._get("/catalogs/"+e+"/package","package").then(n=>{if(la.get(e))return t(n);n.components.forEach(e=>{this._prepareData(e,"components")}),n.materials.forEach(e=>{this._prepareData(e,"materials"),this._prepareGroups(e)}),n.textures.forEach(e=>{this._prepareData(e,"textures")}),la.set(e,!0),t(n)},n)})}getComponent(e){return this._getById(e,"components")}getConfiguration(e){return this._getById(e,"configurations")}getConfigurations(e){return this._getByIds(e,"configurations")}getItem(e){return this._getById(e,"items",{additionalHeaders:$s})}getComponents(e){return this._getByIds(e,"components")}getItems(e){return this._getByIds(e,"items",{additionalHeaders:$s})}getTag(e){return this._getById(e,"tags")}getTags(e){return this._getByIds(e,"tags")}getTexture(e){return this._getById(e,"textures")}getCatalog(e){return this._getById(e,"catalogs")}getMesh(e,t="crt",n=50){return this._getById(e,"meshes",{pathSuffix:"/data?format="+t+"&targetQuality="+n.toString()})}getMeshesOfCatalog(e){return new Promise((t,n)=>{const r=oa.get(e);r?t(r):this._get("/meshes?catalog="+e,"catalogMeshes").then(n=>{oa.set(e,n),t(n)},n)})}getTexturesOf(e){return this._getRelationData(e,{rapiPath:"textures"})}getItemsOf(e){return this._getRelationData(e,{rapiPath:"items"})}async getMaterialsOf(e){return(await this._getRelationData(e,{rapiPath:"materials"},{embed:["textures"]})).filter(e=>e.active)}getComponentsOf(e){return this._getRelationData(e,{rapiPath:"components"})}getAdditionalContentsOfItems(e){const t=[],n=[];return e.forEach(e=>{const r=ia.get(e.id.toString());r?n.push(...r):t.push(e.id.toString())}),new Promise((e,r)=>{0!==t.length?this._getByIdsPackets(t,"itemAdditionalContents",{filterKey:"itemIds"}).then(t=>{t.forEach(e=>{let t=ia.get(e.itemId);t||(t=[]);for(let n=0,r=t.length;n<r;n++)if(t[n].id===e.id)return;t.push(e),ia.set(e.itemId,t)}),e([...t,...n])},r):e(n)})}getMaterial(e){return this._getById(e,"materials",{embed:["textures"]})}peekMaterial(e){return this._peekData(e,"materials")}peekComponent(e){return this._peekData(e,"components")}peekItem(e){return this._peekData(e,"items")}peekConfiguration(e){return this._peekData(e,"configurations")}async getMaterials(e){return(await this._getByIds(e,"materials",{embed:["textures"]})).filter(e=>e.active)}getPlan(e){return this._getById(e,"plans")}getPlanSnapshot(e){return this._getById(e,"planSnapshots")}static clearCaches(){ra=new Map,sa=new Map,aa=new Map,la=new Map,ha=new Map,da=new Map,ia=new Map}cleanUp(){ga.clearCaches()}getMaterialsByGroup(e){const t=e.slice(),n=[];let r=t.length;for(let e=0;e<r;e++){const i=ua(t[e]);if(i){const s=i.length;for(let e=0;e<s;e++){const t=this._getCache("materials").get(i[e]);n.push(t)}t.splice(e,1),r--,e--}}return new Promise((e,r)=>{0!==t.length&&navigator.onLine?this._getByIdsPackets(t,"materials",{filterKey:"groups",embed:["textures"]}).then(t=>{e(this.combineMaterialsToGroups([...t,...n]))},r):e(this.combineMaterialsToGroups(n))})}_flushOfflineQueue(){return new Promise((e,t)=>{const n=this._localStorage.getItem("hsc_configurations_offline_queue_v1"),r=[];for(let e in n)if(n.hasOwnProperty(e)){const t=n[e];r.push(new Promise((e,n)=>{this.saveConfiguration(t.data).then(r=>{const i=[];t.perspectiveImage&&!r.perspectiveImage&&i.push(this.savePerspectiveImage(r,t.perspectiveImage)),t.topImage&&!r.topImage&&i.push(this.savePerspectiveImage(r,t.topImage)),Promise.all(i).then(e,n)},n)}))}Promise.all(r).then(()=>{this._localStorage.setItem("hsc_configurations_offline_queue_v1",{}),e()},t)})}_setQueuedConfiguration(e,t={}){const n=e.configurationHash,{perspectiveImage:r,topImage:i}=t;let s=this._localStorage.getItem("hsc_configurations_offline_queue_v1")||{},a=s[n]||{};a.data=e,a.perspectiveImage=r,a.topImage=i,s[n]=a,this._localStorage.setItem("hsc_configurations_offline_queue_v1",s)}async saveConfiguration(e){return navigator.onLine?await this._save("/configurations",{configuration:e},"configurations",{accept:"application/json",contentType:"application/json; charset=UTF-8"}):(e.perspectiveImage=null,e.topImage=null,this._setQueuedConfiguration(e),this._markConfigurationAsLocally(e),Promise.resolve(e))}saveTopImage(e,t){return this._saveConfigurationImage(e,t,"topImage")}savePerspectiveImage(e,t){return this._saveConfigurationImage(e,t,"perspectiveImage")}savePlanSnapshotTopImage(e,t){return this._savePlanSnapshotImage(e,t,"topImage")}savePlanSnapshotPerspectiveImage(e,t){return this._savePlanSnapshotImage(e,t,"perspectiveImage")}getShortUrl(e,t){return new Promise((n,r)=>this._fetchJson("/shortIds","shortIds",{method:"POST",resolve:n,reject:r,data:JSON.stringify({shortId:{type:t,referencedId:e}}),accept:"application/json",contentType:"application/json; charset=UTF-8"}))}_peekData(e,t){const n=aa.get(t);return n&&n.get(e)||null}_saveConfigurationImage(e,t,n){if(!navigator.onLine){const r={};return r[n]=t,this._setQueuedConfiguration(e,r),this._markConfigurationAsLocally(e),e[n]=t.image,Promise.resolve(e)}const r=this._formDataUtil.create(t.image,e.configurationHash,Kt.PNG,n);return this._save("/configurations/"+e.id+"/"+n,r,"configurations",{accept:"application/json"})}_savePlanSnapshotImage(e,t,n){const r=this._formDataUtil.create(t.image,e.id,Kt.PNG,"file");return r.append("type",n),this._save("/planSnapshots/"+e.id,r,"planSnapshots",{accept:"application/json",method:"PUT"})}_markConfigurationAsLocally(e){e.isLocally=!0,e.id=e.configurationHash}_save(e,t,n,r={}){const i=t instanceof FormData?t:JSON.stringify(t);return new Promise((t,s)=>{const a={method:r.method||"POST",data:i,resolve:t,reject:s};r.contentType&&(a.contentType=r.contentType),r.accept&&(a.accept=r.accept),this._fetchJson(e,n,a)})}combineMaterialsToGroups(e){return new Promise((t,n)=>{const r=new Map,i={id:null,label:null,materials:[]},s=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],a=n.tags&&n.tags.length?n.tags.map(e=>({isTag:!0,id:e})):[];n.group&&a.push({isTag:!1,id:na+n.group,legacyId:n.group}),a.length||a.push({isTag:!1,id:null}),n.tags&&n.tags.length&&n.tags.forEach(e=>-1===s.indexOf(e)?s.push(e):null),a.forEach(({isTag:e,id:t,legacyId:s})=>{const a=n.id;let o=t?ua(t):[];o||(ra.set(t,[]),o=ua(t)),-1===o.indexOf(a.toString())&&o.push(a.toString());const l=pa(n),h=l&&e,d=ma(n);if(h||d&&!e||!l&&!d&&!t){let e=t?r.get(t):i;e||(r.set(t,{id:t,label:n.groupLabel,legacyId:s,materials:[]}),e=r.get(t)),e.materials.push(n)}})}const a=i.materials.length?[i]:[];this.getTags(s).then(e=>{const n=e.reduce((e,t)=>(e[t.id]=t,e),{});return r.forEach((e,t)=>{a.push({id:t,label:n[t]?n[t].label:e.label,materials:e.materials,legacyId:e.legacyId,sort:n[t]?n[t].sort:void 0})}),t(a)},n)})}_getByIds(e,t,n={}){const r=this._getCache(t),i=this._getErrorCache(t),s=[],a=[...new Set(e)];let o=a.length;if(r&&r.size){const e=(new Date).getTime();for(let t=0;t<o;t++){const n=a[t],l=r.get(n),h=i.get(n);let d=!1;null!=l?(s.push(l),d=!0):d=void 0!==h&&(e-h.timestamp<6e4||!1===navigator.onLine),d&&(a.splice(t,1),o--,t--)}}return new Promise((e,r)=>{0!==a.length&&navigator.onLine?this._getByIdsPackets(a,t,n).then(t=>{e([...t,...s])},r):e(s)})}_getByIdsPackets(e,t,n={}){const r=n.filterKey||"ids";let i,s="/"+t+"/",a="?",o=[];const l=e.length;if(!l)return new Promise(e=>e([]));let h=!0,d=[];for(i=0;i<l;i++){h=!1;const n=e[i],l=a+r+"[]="+n,c=l.length+s.length;d.push(n),a="&",c<=1500?s+=l:(c>1500&&(d.pop(),i--),o.push({url:s,ids:d}),h=!0,s="/"+t+"/",a="?",d=[])}h||o.push({url:s,ids:d});const c=[];return o.forEach(e=>c.push(this._getByIdsSingle(e.ids,e.url,t,n))),new Promise((e,t)=>{Promise.all(c).then(t=>{const n=[];t.length&&t.forEach(e=>n.push(...e)),e(n)},t)})}_getByIdsSingle(e,t,n,r={}){return new Promise((i,s)=>{this._get(t,n,r).then(t=>{for(let n=0,i=t.length;n<i;n++){const i=r&&r.cacheKey?t[n][r.cacheKey]:t[n].id,s=e.indexOf(i.toString());-1!==s&&e.splice(s,1)}const s=e.length;if(s){const t=this._getCache(n),r=this._getErrorCache(n),i=(new Date).getTime();for(let n=0;n<s;n++)r.set(e[n],{code:0,timestamp:i}),t.delete(e[n]);this._errorHandler.dispatch(2,[n,e.map(e=>'"'+e+'"').join(",")])}i(t)},s)})}_getById(e,t,n={}){if(!e||""===e||"string"!=typeof e)return console.error("no id passed to _getById"),Promise.reject(new Error("no id passed to _getById"));const r=this._getCache(t).get(e);if(r)return new Promise(e=>e(r));if(!navigator.onLine)return Promise.reject("Nothing cached but tried to fetch in offline mode");const i={...n,id:e},s=n.pathSuffix||"";return this._get("/"+t+"/"+e+s,t,i)}_get(e,t,n={}){const r=ks.useHDGeometry?"includeGeometryHD=true":"";let i=-1===e.indexOf("?")?"?":"&";return""!==r&&(e+=i+r),n.embed&&Array.isArray(n.embed)&&n.embed.forEach(t=>{e+=i+"embed"+(t[0].toUpperCase()+t.substr(1))+"=true",i="&"}),new Promise((r,i)=>{const s=da.get(e);Array.isArray(s)&&s.length>0?s.push({resolve:r,reject:i}):(da.set(e,[{resolve:r,reject:i}]),this._fetchJson(e,t,n))})}_fetchJson(e,t,n={}){this._fetch(e,n).then(He.bind(this)).then(this._handleJson(e,t,n).bind(this)).catch(this._handleError(e,n).bind(this))}async _fetch(e,t){const n={method:t.method?t.method:"GET",headers:this._createHeaders(t),mode:"cors",cache:"default"};t.data&&(n.body=t.data);let r=Zs.server;const i=this._globalInitData.overrideRapi;i&&(r="live"===i?Zs.liveServer:Zs.testServer),(this._globalInitData.customApiUrl||""===this._globalInitData.customApiUrl)&&(r=this._globalInitData.customApiUrl);const s=new Request(r+e,n);this._globalCallback.onNetworkRequest(e,n,t);const a=await this._globalCallback.onCheckExternalCache(e,n);return a?{headers:{get:()=>"application/json"},json:()=>Promise.resolve(a)}:this._networkLayer.fetch(s,{},{checkResponse:e=>this._globalCallback.onValidateNetworkResponse("rapi-access",e)})}_createHeaders(e={}){const t={...Js};this._globalInitData.overrideTenant&&(t.currentTenant=this._globalInitData.overrideTenant),this._globalInitData.overrideCountry&&(t.country=this._globalInitData.overrideCountry);const n=this._globalInitData.locale||"en";t.language=n,t.locale=n;const{contentType:r,accept:i,additionalHeaders:s,data:a}=e;if(r&&(t["content-type"]=e.contentType),i&&(t.accept=e.accept),s)for(let e in s)s.hasOwnProperty(e)&&(t[e]=s[e]);this._globalInitData.configuratorId&&(t.configurator=this._globalInitData.configuratorId);const o=this._currentToken||ea;t.token="03-"+window.btoa((new Date).toISOString()+";"+o+";"+Js.apiKey);const l=new Headers(t);return a instanceof FormData&&l.delete("content-type"),l}_handleJson(e,t,n={}){return r=>{let i=null,s=null;"number"==typeof r&&(i=r);for(let e in r)"meta"!==e&&r.hasOwnProperty(e)&&(i=r[e],s=e);if("error"===s)return this._handleError(e,n)(new Error(JSON.stringify(i)));if(!i)throw new TypeError("RAPI returned empty JSON");if(Array.isArray(i))for(let e=0,r=i.length;e<r;e++)this._prepareData(i[e],t,n),this._prepareEmbeddedData(i[e],t,n);else this._prepareData(i,t,n),this._prepareEmbeddedData(i,t,n);n.resolve?n.resolve(i):this._notifyWaiters(e,null,i)}}_prepareEmbeddedData(e,t,n={}){n.embed&&Array.isArray(n.embed)&&n.embed.forEach(r=>{const i=e[r.slice(0,-1)+"Objects"];if(Array.isArray(i)){for(let e=0,t=i.length;e<t;e++)this._prepareData(i[e],r,n);this._prepareRelationalData(t,r,e.id,i)}else i&&(this._prepareData(i,r,n),this._prepareRelationalData(t,r,e.id,[i]))})}_getCache(e){return this._getCacheFrom(e,aa)}_getErrorCache(e){return this._getCacheFrom(e,ca)}_getCacheFrom(e,t){let n=t.get(e);return n||(t.set(e,new Map),n=t.get(e)),n}_setCache(e,t,n){n.set(e.toString(),t)}_prepareData(e,t,n=null){let r=this._getCache(t);const i=n&&n.cacheKey?e[n.cacheKey]:e.id;if(i||n&&n.id||"tenants/me"===t)if("tenants/me"!==t){{const t=i||n.id;this._setCache(t,e,r)}e.__rapi_path__=t}else this._setCache("0",e,r);else"shortIds"!==t&&console.error("Can not cache because there is no ID!")}_getRelationsCacheFor(e,t,n){let r=sa.get(t);if(!r){const i=new Map,s=new Map;s.set(n,void 0),i.set(e,s),sa.set(t,i),r=sa.get(t)}let i=r.get(e);if(!i){const t=new Map;t.set(n,void 0),r.set(e,t),i=r.get(e)}return i.get(n)}_prepareGroups(e){const t=e.group,n=e.id;let r=ua(t);r||(ra.set(t,[]),r=ua(t)),-1===r.indexOf(n.toString())&&r.push(n.toString())}_handleError(e,t={}){return n=>{navigator.onLine?(n.rmlErrorCode=1,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(1,[n])):(n.rmlErrorCode=0,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(0,[n])),t.reject?t.reject(n):this._notifyWaiters(e,n,null)}}_getRelationData(e,t,n={}){const r=e.id;if(!r)return Promise.resolve([]);const i=e.__rapi_path__,s=t.rapiPath;let a=this._getCache(s),o=this._getRelationsCacheFor(r.toString(),i,s),l=[];return o?(o.forEach(e=>l.push(a.get(e))),new Promise(e=>e(l))):navigator.onLine?new Promise((e,t)=>{this._get("/"+i+"/"+r+"/"+s,s,n).then(t=>{this._prepareRelationalData(i,s,r,t),e(t)},t)}):Promise.resolve([])}_prepareRelationalData(e,t,n,r){sa.has(e)||sa.set(e,new Map);let i=sa.get(e);const s=n.toString();i.has(s)||i.set(s,new Map);let a=i.get(s),o=this._getCache(t),l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=t.id.toString();l.push(n),o.set(n,t)}a.set(t,l)}_notifyWaiters(e,t,n){const r=da.get(e);if(r&&r.length){for(let e=0,i=r.length;e<i;e++)t?r[e].reject(t):r[e].resolve(n);da.delete(e)}}_tenantMe(){return new Promise((e,t)=>{const n=this._getCache("tenants/me"),r=this._globalInitData.overrideTenant?this._globalInitData.overrideTenant:n.get("0");if(r)return e(r);this._fetchJson("/tenants/me","tenants/me",{resolve:t=>e(t),reject:t})})}async getTenant(e){return e||(e=await this._tenantMe()),this._getById(e.toString(),"tenants")}getCurrentSkin(){return this._tenantMe().then(e=>this._getById(e.toString(),"tenants").then(e=>this._getById(e.skin.toString(),"skins")))}getPrices(e){return this._getByIds(e,"prices",{filterKey:"priceIds",cacheKey:"priceId"})}async getConfiguratorSettings(e){const t=await this._getById(e,"configurators");return t.allowedHosts||(t.allowedHosts=[]),t.allowedHosts&&!Array.isArray(t.allowedHosts)&&(t.allowedHosts=t.allowedHosts.split(" ")),t}sendUserAction(e){return this._save("/userActions",{userAction:e},"userActions",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}_share(e,t,n,r){const i="/"+r+"/"+e+"/shares",s=new FormData;return s.append("email",t),s.append("type",n.toString()),new Promise((e,t)=>{const n={method:"POST",data:s,resolve:e,reject:t,accept:"application/json",contentType:"application/json; charset=UTF-8"};this._fetch(i,n).then(n.resolve,n.reject)})}shareConfiguration(e,t,n){return this._share(e,t,n,"configurations")}sharePlanSnapshot(e,t,n){return this._share(e,t,n,"planSnapshots")}export3D(e,t,n,r={}){const i="/"+(ta(e)?"planSnapshots":"configurations")+"/"+e+"/3d-exports",s={formats:[{file_format:n,pack_external_data:!0,...r}]},a=JSON.stringify(s),o=new FormData;return o.append("email",t),o.append("settings",a),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t};this._fetch(i,n).then(n.resolve,n.reject)})}async trackView(e){if(this._itemLoaded||(t=(()=>{var e;const t=(()=>{if(window.__RML__ENV__&&window.__RML__ENV__.skipIframeCheck)return!1;try{return window.self!==window.top}catch(e){return!0}})();let n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href;if(!n)return null;if(t){if(!document.referrer)return null;n=document.referrer}const{hostname:r}=new URL(n);return r})())&&(Yt.includes(t)||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")||t.endsWith("codesandbox.io")||t.endsWith("stackblitz.com")||/^(admin.*.roomle.com)$/.test(t)))return;var t;const{configuratorId:n}=this._globalInitData,r={module:3,action:1,actionId:e,actionLabel:n};await this.sendUserAction(r),this._itemLoaded=!0}signinUser(e,t){return new Promise((n,r)=>{const i={method:"POST",accept:"application/json",contentType:"application/json; charset=UTF-8",data:JSON.stringify({identification:e,passwordMD5:t}),cacheKey:"token",resolve:n,reject:r};this._fetchJson("/auth/signin","auth",i)})}async signoutUser(e){const t=this._currentToken;t!==e&&this.setCurrentToken(e),await this._fetch("/auth/signout",{}),t&&t!==e?this.setCurrentToken(t):this.removeCurrentToken()}async savePlan(e){const t=e.id?"/plans/"+e.id:"/plans";return this._save(t,{plan:e},"plans",{method:e.id?"PUT":"POST",accept:"application/json",contentType:"application/json; charset=UTF-8"})}async savePlanSnapshot(e){return this._save("/planSnapshots",{planSnapshot:e},"planSnapshots",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}setCurrentToken(e){this._currentToken=e}removeCurrentToken(){this._currentToken=null}createNewPlan(){return{name:"",description:"",changeDate:(new Date).toISOString(),created:(new Date).toISOString(),draftId:null,thumbnail:"data:image/png;base64,missing",planObjects:null,active:!0,open:0,planDirectory:0,changed:0,version:2,floorLevel:0,visibility:9,user:null,tenant:null,assets:[],parent:null,setting:null}}}e("R",ga),tn([rn],ga.prototype,"_formDataUtil",void 0),tn([rn],ga.prototype,"_errorHandler",void 0),tn([rn],ga.prototype,"_dataSyncer",void 0),tn([rn],ga.prototype,"_networkLayer",void 0),tn([rn],ga.prototype,"_localStorage",void 0),tn([rn],ga.prototype,"_globalInitData",void 0),tn([rn],ga.prototype,"_globalCallback",void 0);const fa=e("j",1500),_a=e("P",5);function va(){class e extends A{static _generateOutline(e,t){let n=new z(new Ve(e),new We({color:"#000000",dashSize:.03,gapSize:.01,linewidth:1}));return n.translateOnAxis(t,1),n.userData.ignoreComponentRaycast=!0,n}static cloneDockLine(e,t){let n=new z(e.geometry,e.material);return n.translateOnAxis(t.getCenter(new a),1),n.name="dockline",n.layers.set(5),n.userData.ignoreComponentRaycast=!0,n}_setValues(e,t,n,r){e&&(this.runtimeId=e,this.name=e.toString()),t&&(this.roomlePosition=Object.assign({},t)),n&&(this.roomleRotation=Object.assign({},n)),r&&(this.parentObjectId=r)}constructor(e,t,n,r){super(),this._selected=!1,this.geometryChanged=!0,this.meshes=[],this.castShadow=!1,this.receiveShadow=!0,this._setValues(e,t,n,r)}get loadingMesh(){return this._loadingMesh}get boundingBoxMesh(){return this._boundingBoxMesh}get boundingBox(){return this._boundingBox}set roomlePosition(e){this._roomlePosition=e,e&&this.position.set(e.x/1e3,e.z/1e3,e.y/-1e3)}get roomlePosition(){return this._roomlePosition}set roomleRotation(e){this._roomleRotation=e,e&&this.rotation.set(e.x,e.z,-e.y)}get roomleRotation(){return this._roomleRotation}replaceMeshes(e){this.removeAllMeshes(),e.forEach(e=>{this.addMesh(new H(e.geometry,e.material))})}addMesh(e,t){e.renderOrder=2,e.userData.meshType=0,t&&e.applyMatrix4(wr(t)),this.add(e),this.meshes.push(e)}getMeshById(e){return this.meshes.find(t=>t.userData.meshId===e)}removeMeshById(e){const t=this.getMeshById(e);t?this.removeMesh(t):console.warn("Could not remove mesh with id "+e,this.runtimeId,this.meshes)}removeMesh(e){const t=this.meshes.indexOf(e);this.remove(e),Gi(e),t<0||this.meshes.splice(t,1)}removeAllMeshes(e=!0){this.meshes.forEach(t=>{this.remove(t),e&&Gi(t)}),this.meshes=[],this._removeLoadingMesh(),this.remove(this._boundingBoxMesh),Gi(this._boundingBoxMesh),this._boundingBoxMesh=null}_hideAllMeshes(){this.meshes.forEach(e=>e.visible=!1)}_showAllMeshes(){this.meshes.forEach(e=>e.visible=!0)}select(){this._selected=!0}loading(){if(!this._kernelBoundingBox)return void console.warn("Bounding box (box for measurements) for component "+this.runtimeId+" not set, can not show external mesh loading box!");this._removeLoadingMesh(),this._hideAllMeshes();const{x:e,y:t,z:n}=this._kernelBoundingBox.getSize(new a);let r=new ke(e,t,n);this._loadingMesh=new H(r,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#DDDDDD")})),this._loadingMesh.name="loading mesh",this._loadingMesh.receiveShadow=!1,this._loadingMesh.castShadow=!1,this._loadingMesh.layers.set(5),this._loadingMesh.translateOnAxis(this._kernelBoundingBox.getCenter(new a),1),this._loadingMesh.renderOrder=3,this.add(this._loadingMesh)}_removeLoadingMesh(){this._loadingMesh&&(this.remove(this._loadingMesh),Gi(this._loadingMesh),this._loadingMesh=null)}loadingFinished(){this._removeLoadingMesh(),this._showAllMeshes()}deselect(){this._selected=!1}hoverOn(){ze("pointer")}hoverOff(){ze("default")}removeFromParent(){return this.parent&&(this.parent.remove(this),this.removeAllMeshes()),this}computeBoundingBox(t,n=!1){if(this._boundingBoxMesh&&this.remove(this._boundingBoxMesh),!n&&t&&0===t.size.x&&0===t.size.y&&0===t.size.z)return;let r;if(!t||n){this._boundingBox=new ge;let e=new a;this.meshes.forEach(t=>{if(t.geometry instanceof c){let n=t.geometry.attributes.position;if(void 0!==n)for(let r=0,i=n.count;r<i;r++)e.fromBufferAttribute(n,r).applyMatrix4(t.matrix),this._boundingBox.expandByPoint(e)}}),this._kernelBoundingBox=this._boundingBox.clone();let t=this._boundingBox.max.x-this._boundingBox.min.x,n=this._boundingBox.max.y-this._boundingBox.min.y,i=this._boundingBox.max.z-this._boundingBox.min.z;r=new ke(t,n,i)}else{this._kernelBoundingBox=Pi(t),this._boundingBox=this._kernelBoundingBox.clone();let{x:e,y:n,z:i}=this._boundingBox.getSize(new a);r=new ke(e,n,i)}this._boundingBoxMesh=new H(r,Ti.createMeshStandardMaterial({color:"#FFFFFF",transparent:!0,opacity:0,polygonOffset:!0,polygonOffsetFactor:-1,visible:!1})),this._boundingBoxMesh.name="bounding box mesh";let i=this._boundingBox.getCenter(new a);this._boundingBoxMesh.position.add(i),this._boundingBoxMesh.layers.set(5),this._boundingBoxMesh.renderOrder=3,this._boundingBoxMesh.castShadow=!1,this._boundingBoxMesh.receiveShadow=!1,this.add(this._boundingBoxMesh),this._dockline=e._generateOutline(r,i),this._dockline.name="bounding box outline",this._dockline.layers.set(5),this._selected&&this.add(this._dockline)}recursiveMeshes(){let t=this.meshes.slice();return this.children.forEach(n=>{n instanceof e&&t.push(...n.recursiveMeshes())}),t}isChild(t){let n=!1;return this.children.forEach(r=>{r instanceof e&&!n&&(n=r.runtimeId===t||r.isChild(t))}),n}getKernelPosition(e){let t=this.parent.localToWorld(this.position);return gr(e.worldToLocal(t))}}class t extends e{constructor(e,t){super(e,null,null,null),this.glbUrl=t}}class n extends e{constructor(e,t,n,r,i){super(t,n,r,i),this._stringId=null,this.receivedPointAssociation=!1,this.castShadow=!1,this.receiveShadow=!1,this._creator_=e}get stringId(){return this._stringId?this._stringId:this.runtimeId.toString()}addMesh(e,t){super.addMesh(e,t),e.material instanceof N&&(e.material.opacity=.8,e.material.roughness=1,e.material.metalness=0,e.material.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)),e.renderOrder=1,e.castShadow=!1,e.receiveShadow=!1}startPulsating(){var e,t;if(null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.pulsePreview)for(const e of this.meshes){const t={opacity:.8},n={opacity:.3};new TWEEN.Tween(t).to(n,fa).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.material.opacity=t.opacity}).yoyo(!0).repeat(_a).start()}}hoverOn(){this.remove(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.9,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),ze("pointer")}hoverOff(){this.add(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.8,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),ze("default")}clonePreview(t){const r=new n(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId);return r._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof H&&0===e.userData.meshType&&r.meshes.push(e.clone(!0))}),r.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),r.add(e)}),this._dockline&&(r._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(r._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(r._boundingBox=this._boundingBox.clone()),r}preparePreview(){this.add(this._dockline),this.add(this._boundingBoxMesh)}}tn([rn],n.prototype,"_initData",void 0);class r extends n{constructor(e,t,n,r,i,s){super(e,t,n,r,i),s&&(this._stringId=this.runtimeId+"_has_additional_dock_point_copy")}set roomleLineFrom(e){this._roomleLineFrom=e,this.lineFrom=pr(e)}get roomleLineFrom(){return this._roomleLineFrom}set roomleLineTo(e){this._roomleLineTo=e;let t=pr(e);t.equals(this.lineFrom)&&(console.warn("lineFrom and lineTo are equal!"),t.add(new a(0,.01,0))),this.lineTo=t}get roomleLineTo(){return this._roomleLineTo}set roomlePositionFrom(e){this._roomlePositionFrom=e,this.positionFrom=pr(e)}get roomlePositionFrom(){return this._roomlePositionFrom}set roomlePositionTo(e){this._roomlePositionTo=e;let t=pr(e);t.equals(this.positionFrom)&&(console.warn("positionFrom and positionTo are equal!"),t.add(new a(0,.01,0))),this.positionTo=t}get roomlePositionTo(){return this._roomlePositionTo}addMesh(e,t){super.addMesh(e,t),e.visible=!1,e.renderOrder=3}hoverOn(){this._dockline.visible=!0,ze("pointer")}hoverOff(){this._dockline.visible=!1,ze("default")}preparePreview(){super.preparePreview(),this._dockline.visible=!1;let e=this.lineTo.clone(),t=this.lineFrom.clone();const n=(new a).subVectors(e,t);let r=n.length(),i=n.normalize(),s=new Ke(i,t),o=new qe(.01,.01,r,16,1);this.lineMesh=new H(o,Ti.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:.4})),this.lineMesh.name="line mesh";const l=(new M).setFromEuler(s.rotation);this.lineMesh.quaternion.multiply(l),this.lineMesh.renderOrder=1;let h=(new a).addVectors(e,t).multiplyScalar(.5);this.lineMesh.position.copy((new a).subVectors(h,this.position.clone())),this.add(this.lineMesh);let d=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation),c=null,u=0,p=Math.abs(i.x),m=Math.abs(i.y),g=Math.abs(i.z);p>=m&&p>=g?(c=new a(d.x,0,0),u=Math.sqrt(d.y*d.y+d.z*d.z)):m>=p&&m>=g?(c=new a(0,d.y,0),u=Math.sqrt(d.x*d.x+d.z*d.z)):g>=m&&g>=p&&(c=new a(0,0,d.z),u=Math.sqrt(d.y*d.y+d.x*d.x)),u=u>0?u:.01;let f=(new a).subVectors(this.positionTo.clone(),this.positionFrom.clone()).length()+c.length(),_=new qe(1.1*u,1.1*u,f,32,1);this.boundingLineMesh=new H(_,Ti.createMeshStandardMaterial({color:"#ffffff",transparent:!0,opacity:0})),this.boundingLineMesh.name="bounding line mesh",this.boundingLineMesh.userData.ignoreComponentRaycast=!0,this.boundingLineMesh.layers.set(5);let v=this.positionTo.clone(),w=this.positionFrom.clone(),b=(new a).subVectors(v,w).normalize(),y=new Ke(b,w);const x=(new M).setFromEuler(y.rotation);this.boundingLineMesh.quaternion.multiply(x),this.boundingLineMesh.renderOrder=3;let S=(new a).addVectors(this.positionTo.clone(),this.positionFrom.clone()).multiplyScalar(.5).add(d);this.boundingLineMesh.position.copy((new a).subVectors(S,this.position.clone())),this.add(this.boundingLineMesh)}clonePreviewLine(t){let n=new r(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.receivedPointAssociation);return n._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof H&&0===e.userData.meshType&&n.meshes.push(e.clone(!0))}),n.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),n.add(e)}),this._dockline&&(n._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(n._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(n._boundingBox=this._boundingBox.clone()),n}getPositionForIntersectionPoint(e){let t=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation),n=this.positionTo.clone().add(t),r=this.positionFrom.clone().add(t),i=new Xe(r,n).closestPointToPoint(e,!0,new a);return(isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&i.copy(e),i.sub(t)}updatePreviewPosition(e){let t=this.getPositionForIntersectionPoint(e),n=this.parent.localToWorld(t);this._newPosition=this.worldToLocal(n);let r=this._boundingBox.getCenter(new a).applyEuler(this.docklineRotation);this._dockline.position.copy((new a).addVectors(this._newPosition,r)),this._dockline.rotation.copy(this.docklineRotation)}hideSelectionLine(){this._dockline.visible=!1}getKernelPosition(e){if(this._newPosition){let t=this.localToWorld(this._newPosition);return gr(e.worldToLocal(t))}return super.getKernelPosition(e)}}class i extends Y{constructor(e,t,n,r,i,s,a){super(e,t,n,r,i,s),a||(a={left:0,top:1,right:1,bottom:0}),this.offset=a}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}_calculateProjectionMatrix(){const e=this._calculate2DPlanes();if(this._offset.left>=this._offset.right||this._offset.bottom>this._offset.top)return(new C).makeOrthographic(e.left,e.right,e.top,e.bottom,this.near,this.far);const t=this._scaleRange(e.left,e.right,this._offset.left,this._offset.right);let n=t.from,r=t.to;const i=this._scaleRange(e.bottom,e.top,this._offset.bottom,this._offset.top);let s=i.from,a=i.to;const o=(e.right-e.left)/(e.top-e.bottom),l=(r-n)/(a-s);if(l>o){const e=(s+a)/2,t=(a-s)*l/o;s=e-t/2,a=e+t/2}else{const e=(n+r)/2,t=(r-n)*o/l;n=e-t/2,r=e+t/2}return(new C).makeOrthographic(n,r,a,s,this.near,this.far)}_scaleRange(e,t,n,r){const i=(t-e)/(r-n);return{from:e-i*n,to:t+i*(1-r)}}_calculate2DPlanes(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,s=n+e,a=r+t,o=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,s=i+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}return{left:i,right:s,top:a,bottom:o}}}class o extends X{constructor(e,t,n,r,i){super(e,t,n,r),i||(i={left:0,top:1,right:1,bottom:0}),this.offset=i}copy(e,t){return super.copy(e,t),this._offset=e._offset,this}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}_calculateProjectionMatrix(){let e,t,n,r,i=this.fov*(2*Math.PI/360)/2;n=Math.tan(i),r=-n;let a=Math.atan(this.aspect*Math.tan(i));t=Math.tan(a),e=-t;let o=this._offset.left,l=this._offset.right,h=this._offset.top,d=this._offset.bottom,c=new s(l-o,h-d),u=new s(o+c.x/2,d+c.y/2);if(c.x<c.y){let i=(1-u.x)/(c.x/2),s=u.x/(c.x/2);t*=i,e*=s;let a=(i+s)/2;n*=a,r*=a}else{let i=(1-u.y)/(c.y/2),s=u.y/(c.y/2);n*=i,r*=s;let a=(s+i)/2;e*=a,t*=a}e*=this.near,t*=this.near,n*=this.near,r*=this.near;let p=this.near*Math.tan(Math.PI/180*.5*this.fov)/this.zoom*2,m=this.aspect*p;return this.view&&this.view.enabled&&(e+=this.view.offsetX*m/this.view.fullWidth,n-=this.view.offsetY*p/this.view.fullHeight,t+=this.view.offsetX*m/this.view.fullWidth,r-=this.view.offsetY*p/this.view.fullHeight),(new C).makePerspective(e,t,n,r,this.near,this.far)}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}}return{create:function(t,n,r,i){return new e(t,n,r,i)},createPreview:function(e,t,r){return new n(r,e,{x:0,y:0,z:0},{x:0,y:0,z:0},t)},createStatic:function(e,n){return new t(e,n)},createPreviewLine:function(e,t){let n=new r(t,e.id,e.roomlePosition,e.roomleRotation,e.parentObjectId,e.receivedPointAssociation);return e.meshes.forEach(e=>{let t=e.clone();t.material=e.material.clone(),t.geometry=e.geometry.clone(),n.addMesh(t)}),n.computeBoundingBox(),n},isPreview:function(e){return e instanceof n},isPreviewLine:function(e){return e instanceof r},createPerspectiveCamera:function(e,t,n,r,i){return new o(e,t,n,r,i)},createOrthographicCamera:function(e,t,n,r,s,a,o){return new i(e,t,n,r,s,a,o)}}}const wa=e("u",9);class ba{constructor(e){this._mergeThreshold=3,this._componentsToMerge=new ya,this._mergeInProgress=!1,this._components=new Map,this._previews=new Map,this._componentNumberOfPossibleChildren=new Map,this._creator_=e,this._getKernelAccess().addConfiguratorListener(this),this._componentFactory=va()}get materialQueue(){return this.getMeshGenerator().materialQueue}_getKernelAccess(){return $l.lookup("planner-kernel-access",this._creator_)}_applyMeshTransform(e,t,n,r,i){if(n){const r=e.userData.transform=wr(n);t&&(e.userData.transform=r),e.applyMatrix4(r)}this._applyMeshUVTransform(e,t,r,i)}_applyMeshUVTransform(e,t,n,r){if(6!==(null==n?void 0:n.length)||(e=>1===e[0]&&0===e[1]&&0===e[2]&&1===e[3]&&0===e[4]&&0===e[5])(n))t&&(t.uvTransform=void 0),r&&(e.geometry=r);else{const i=(e=>{const t=new C;return t.set(e[0],e[2],0,e[4],e[1],e[3],0,e[5],0,0,1,0,0,0,0,1),t})(n);t&&(t.uvTransform=i);const s=null!=r?r:e.geometry;if(s&&s.attributes.uv){const t=s.clone();t.attributes.uv.applyMatrix4(i),e.geometry=t}}}_addMeshToSubPart(e,t,n,r,i,s,a,o,l,h){const d=this._generateMesh(e,t,n,s,a,o,l,void 0,void 0,h);this._applyMeshTransform(d,null,r,i),this._subPartObject.add(d)}_addMeshToComponent(e,t,n,r,i,s,a,o,l,h,d,c){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._addMeshToSubPart(e,null,r,null,null,a,o,l,h,c);const u=this.getComponent(e);if(!u)return;const p=this._componentFactory.isPreview(u),m=this._generateMesh(e,n,p?null:r,a,o,l,h,void 0,void 0,c);m.userData.meshId=t,m.userData.geometryId=n,m.userData.materialId=r,this._applyMeshTransform(m,m.userData,i,s),p&&m.layers.set(5),u&&u.addMesh(m),u.meshes.length>this._mergeThreshold&&this._componentsToMerge.set(e,u.meshes.length)}_changeMeshOfComponent(e,t,n,r,i,s,a){const o=this.getComponent(e);if(!o)return;const l=o.getMeshById(t);if(l){l.userData.geometryId!==n&&console.warn("Geometry of mesh has changed!"),l.userData.materialId=r,l.userData.materialAttributes=a;const e=l.material.clone();this._configuratorMeshGenerator.setMaterial(l,r,void 0,a).then(()=>{this._requestRenderSceneUpdateCallback&&this._requestRenderSceneUpdateCallback()}),e.opacity!==l.material.opacity&&this._requestRenderCallback&&this._requestRenderCallback(),i&&(l.position.set(0,0,0),l.scale.set(1,1,1),l.rotation.set(0,0,0));const t=this._configuratorMeshGenerator.getGeometry(n);this._applyMeshTransform(l,l.userData,i,s,t)}}_removeMeshFromComponent(e,t){const n=this.getComponent(e);n&&n.removeMeshById(t)}getComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:(console.warn("component not found!",e),null)}getNumberOfPossibleChildrenForComponent(e){if(this._componentNumberOfPossibleChildren.has(e))return this._componentNumberOfPossibleChildren.get(e);const t=this._getKernelAccess().kernelInstance.getPlanComponentPossibleChildren(e).length;return this._componentNumberOfPossibleChildren.set(e,t),t}tryToMergeComponents(){this._initData.moc||this._mergeInProgress||(this._mergeInProgress=!0,this._componentsToMerge.size,this._requestMergeComponents())}_requestMergeComponents(){window.requestIdleCallback(this._mergeNextComponent.bind(this))}_mergeNextComponent(){if(this._componentsToMerge.size>0){const e=this._componentsToMerge.largestValue();this._componentsToMerge.delete(e),this._mergeComponent(e),this._requestMergeComponents()}else this._mergeInProgress=!1,this._geometriesMerged&&this._geometriesMerged(),this._components.forEach(e=>{e.loadingMesh&&console.warn("component still has loading mesh: ",e.hash)})}_mergeComponent(e){const t=this._components.get(e);if(t&&!(t.meshes.length<=this._mergeThreshold))if(this._cacheHolder.componentCache.has(t.hash)){const e=this._cacheHolder.componentCache.get(t.hash).meshes;t.replaceMeshes(e)}else{const e=new Map,n=[],r=[];t.meshes.forEach(t=>{const i=t.userData.materialId;if(!i)return void console.warn("mesh has no material id set");if(!e.has(i)){const r=new H(new c,t.material);r.userData.materialId=i,r.receiveShadow=!0,r.castShadow=!0,r.layers.set(3),this._setMaterial(r,i),n.push(r),e.set(i,r)}const s=e.get(i),a=s.geometry;t.userData.transform&&t.geometry.applyMatrix4(t.userData.transform),s.geometry=function(e,t=!1){const n=null!==e[0].index,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new c;let h=0;for(let d=0;d<e.length;++d){const c=e[d];let u=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in c.attributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[e]&&(s[e]=[]),s[e].push(c.attributes[e]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in c.morphAttributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[e]&&(a[e]=[]),a[e].push(c.morphAttributes[e])}if(t){let e;if(n)e=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;e=c.attributes.position.count}l.addGroup(h,e,d),h+=e}}if(n){let t=0;const n=[];for(let r=0;r<e.length;++r){const i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}l.setIndex(n)}for(const e in s){const t=pn(s[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in a){const t=a[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let r=0;r<a[e].length;++r)t.push(a[e][r][n]);const r=pn(t);if(!r)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(r)}}return l}([a,t.geometry]),r.push(t)}),n.forEach(e=>t.addMesh(e)),r.forEach(e=>t.removeMesh(e)),this._cacheHolder.componentCache.set(t.hash,t)}}_addRootComponent(e){this._listener&&this._listener.display(e)}removeDockingComponent(){this._getKernelAccess().requestDeleteComponent(this._configuratorContext.dockingRootComponentId),this._configuratorContext.dockingRootComponentId=null}dockComponent(e,t,n,r){let i=this._components.get(t),s=this._components.get(e);s&&(s.roomlePosition=n,s.roomleRotation=r,i&&i.add(s))}dockComponentWithPosition(e,t){let n,r=this._components.get(e.parentId);n=t?t.getKernelPosition(r):e.getKernelPosition(r),Ls.start("dock_component_with_position_"+e.childId),this._getKernelAccess().dockComponentWithPosition(e.parentId,e.parentDockId,e.childId,e.childDockId,n),this._configuratorContext.dockingRootComponentId=null}removePreviews(){this._previews.size>0&&(this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear())}_updatePlanObject(e){const t=this._components.get(e.rootPlanComponentId);let n=!0;t&&(n=t.geometryChanged),this._listener&&this._listener.planObjectUpdated(e,n)}Editor3dAddBakedMesh(e,t,n,r,i,s,a,o){this._addMeshToComponent(e,null,null,t,null,null,n,r,i,s,a,o)}Editor3dAddDockPreview(e,t){const n=this._componentFactory.createPreview(t,e,this._creator_);this._previews.set(t.toString(),n)}Editor3dAddNamedMesh(e,t,n,r,i,s,a,o,l,h,d,c){this._addMeshToComponent(e,t,n,r,i,d,s,a,o,l,h,c)}Editor3ChangedNamedMesh(e,t,n,r,i,s,a){this._changeMeshOfComponent(e,t,n,r,i,s,a)}Editor3dRemoveNamedMesh(e,t){this._removeMeshFromComponent(e,t)}Editor3dBeginConstruction(e,t){if(!t){const t=this._components.get(e);t&&t.removeAllMeshes()}this._subPartGuard&&e===this._subPartGuard.info&&(this._subPartObject=new A)}Editor3dComponentCreated(e,t,n,r,i){i&&(this._configuratorContext.rootComponentId=e);let s=null;this._components.has(e)?(s=this._components.get(e),s.removeAllMeshes()):(s=this._componentFactory.create(e,t,n,r),s.layers.set(3)),this._components.set(e,s),i&&this._addRootComponent(s)}Editor3dComponentDocked(e,t,n,r){this.dockComponent(e,t,n,r)}Editor3dEndConstruction(e){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._subPartGuard.resolve(this._subPartObject);const t=this._getKernelAccess().kernelInstance.getComponent(e),n=this._components.get(e);n&&(n.computeBoundingBox(t.boxForMeasurement),n.boundingBoxMesh&&this._listener&&this._listener.addComponentHandlers(n));let r=this._previews.get(e.toString());r&&r.computeBoundingBox(t.boxForMeasurement,!0)}Editor3dGeometryReady(e){const t=this._components.get(e);t&&t.loadingFinished()}Editor3dGeometryNotReady(e){const t=this._components.get(e);t&&t.loading()}Editor3dPlanObjectConstructionDone(e){const t=this._getKernelAccess().kernelInstance.getPlanObject(e),n=[t,this._getKernelAccess().kernelInstance.getFullPartList(),this._getKernelAccess().kernelInstance.getHashOfConfiguration(e),this._getKernelAccess().kernelInstance.getComponentId(t.rootPlanComponentId)];Ns.finishOperation(2,n),this._updatePlanObject(t),this._listener&&this._listener.planObjectConstructionDone(t)}Editor3dPreviewConstructionDone(e,t){let n=!1;this._previews.forEach(e=>{null!==e.parent&&(this._listener&&(this._componentFactory.isPreviewLine(e)?this._listener.addPreviewLineHandlers(e):this._listener.addPreviewHandlers(e)),n=!0)}),this._listener&&this._listener.previewConstructionDone(this._components.get(e),n)}Editor3dSetPreviewLineAssociations(e,t){let n=this._previews.get(t.toString());if(n.clear(),!n)return;let r=this._componentFactory.createPreviewLine(n,this._creator_),i=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let n;n=0===t?r:r.clonePreviewLine(t),n.name="Preview Line",n.parentDockId=e[t].parentDockId,n.parentId=e[t].parentId,n.childDockId=e[t].childDockId,n.childId=e[t].childId,n.docklineRotation=(s=e[t].rotation,new ve(s.x,s.z,-s.y)),n.roomlePosition=e[t].position,e[t].lineFrom.x>e[t].lineTo.x||e[t].lineFrom.y>e[t].lineTo.y||e[t].lineFrom.z>e[t].lineTo.z?(n.roomleLineFrom=e[t].lineTo,n.roomleLineTo=e[t].lineFrom):(n.roomleLineFrom=e[t].lineFrom,n.roomleLineTo=e[t].lineTo),e[t].positionFrom.x>e[t].positionTo.x||e[t].positionFrom.y>e[t].positionTo.y||e[t].positionFrom.z>e[t].positionTo.z?(n.roomlePositionFrom=e[t].positionTo,n.roomlePositionTo=e[t].positionFrom):(n.roomlePositionFrom=e[t].positionFrom,n.roomlePositionTo=e[t].positionTo),i.add(n),n.preparePreview(),this._previews.set(n.stringId,n)}var s}Editor3dSetPreviewPointAssociations(e,t){let n=this._previews.get(t.toString());if(!n)return;let r=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let i;0===t?i=n:(i=n.clonePreview(t),this._previews.set(i.stringId,i)),i.name="Preview Point",i.parentDockId=e[t].parentDockId,i.parentId=e[t].parentId,i.childDockId=e[t].childDockId,i.childId=e[t].childId,i.preparePreview(),i.receivedPointAssociation=!0,i.userData.ignoreComponentRaycast=!0,r.add(i),i.roomlePosition=e[t].position,i.roomleRotation=e[t].rotation,i.startPulsating()}}componentDeleted(e){const t=this._components.get(e);t&&(this._listener&&this._listener.componentDeleted(t),t.removeFromParent(),t.removeAllMeshes(),this._components.delete(e))}componentMetaUpdated(e){const t=this._getRuntimeComponent(e.id);t&&(t.hash=e.hash,t.roomlePosition=e.position,t.roomleRotation=e.rotation,e.boxForMeasurement&&t.computeBoundingBox(e.boxForMeasurement),this._listener&&this._listener.componentUpdated(t,e))}componentConfigurationUpdated(e,t){const n=this._getRuntimeComponent(e);n&&(n.geometryChanged=t)}_getRuntimeComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:null}configurationLoaded(e,t,n,r,i){10===e&&(this._configuratorContext.dockingRootComponentId=n);let s=0===t;s?this._getKernelAccess().kernelInstance.requestPlanComponentConstructionRecursive(n):this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(t);let a=this._getKernelAccess().kernelInstance.getComponent(n),o=this._components.get(n);o&&(o.computeBoundingBox(a.boxForMeasurement),o.hash=a.hash),this._listener&&this._listener.configurationLoaded(o,s&&void 0!==o.boundingBoxMesh)}finishParameterChange(e,t){this.materialQueue.registerCallback(e)}planObjectConfigurationUpdated(e,t,n){let r=this._getKernelAccess().kernelInstance.getPlanObject(e);this._updatePlanObject(r)}planObjectCreated(e,t){this._configuratorContext.planObjectId=t,this._listener&&this._listener.clearScene()}planObjectUpdated(e){this._updatePlanObject(e)}sceneCleared(){this._components.forEach((function(e){e.removeFromParent(),e.removeAllMeshes()})),this._components.clear(),this._componentNumberOfPossibleChildren.clear(),this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear()}setListener(e){this._listener=e}getBoundingBox(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxForMeasurement)return Pi(e.boxForMeasurement)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxWithPreviews(){const e=this._components.get(this._configuratorContext.rootComponentId);return e?(new ge).setFromObject(e):null}hasPreviews(){return this._previews.size>0}clearRootComponent(){var e;null===(e=this._components.get(this._configuratorContext.rootComponentId))||void 0===e||e.hoverOff()}debugSceneGraph(e){e?this._components.has(e)?this._components.get(e):this._previews.has(e.toString())&&this._previews.get(e.toString()):this._configuratorContext}getComponentsForIds(e){let t=[];return e.forEach(e=>{const n=this._components.get(e);n&&t.push(n)}),t}getComponents(){return Array.from(this._components.values())}getPreviews(){return Array.from(this._previews.values())}hasPreviewLines(){for(const e of this._previews.values())if(this._componentFactory.isPreviewLine(e))return!0;return!1}isPreviewLine(e){return this._componentFactory.isPreviewLine(e)}isPreview(e){return this._componentFactory.isPreview(e)}setGeometriesMergedListener(e){this._geometriesMerged=e}removeGeometriesMergedListener(){this._geometriesMerged=void 0}setMergeThreshold(e){this._mergeThreshold=e}_generateMesh(e=0,t=null,n,r,i,s,a,o,l,h){return this._configuratorMeshGenerator.generateMesh(e,t,n,r,i,s,a,!1,h)}_setMaterial(e,t,n){this._configuratorMeshGenerator.setMaterial(e,t)}constructComponents(e){this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(e)}requestSubPartConstruction(e){return this._subPartGuard=new un(e),this._getKernelAccess().requestPlanComponentConstruction(e,!1),this._subPartGuard.wait()}getMeshGenerator(){return this._configuratorMeshGenerator}setRequestRenderCallback(e){this._requestRenderCallback=e}setRequestRenderSceneUpdateCallback(e){this._requestRenderSceneUpdateCallback=e}}e("C",ba),tn([rn],ba.prototype,"_configuratorMeshGenerator",void 0),tn([rn],ba.prototype,"_configuratorContext",void 0),tn([rn],ba.prototype,"_cacheHolder",void 0),tn([rn],ba.prototype,"_initData",void 0);class ya extends Map{largestValue(){let e=this.entries().next().value[0],t=0;return this.forEach((n,r)=>{n>t&&(e=r,t=n)}),e}}const xa=["material"];class Sa extends Qs{constructor(e){super(e),this.externalMeshQueue=new rs,this.muteKernelCallbacks=!1,this.listOfVariants=(e,t)=>{}}init(e){super.init(e),Ls.addMeta("kernel_is_ready",{isWasm:this._useWASM}),ks.kernelInstance?(this._kernelContainer=ks.kernelContainer,setTimeout(()=>this._loadSuccess(),0)):this._scriptLoader.fetch(this._kernelPath,{id:"kernel"}).then(this._loadSuccess.bind(this),this._loadError.bind(this))}_loadSuccess(){Ls.start("kernel_is_ready"),window.ConfiguratorKernel&&(ks.kernelInstance?setTimeout(()=>this.isReady(),0):(window.ConfiguratorKernel(this._kernelContainer),window.ConfiguratorKernel=null))}_loadError(){this._configuratorKernelAccessCallback.loadError()}selectedComponent(e){this._updateComponentDependencies(e)}uiRequestConfiguration(e){const t=this._kernelInstance.getSerializedConfiguration(e);Ns.finishOperation(1,t)}_updateComponentParameters(e){let t=this._kernelInstance.getComponentParameters(e);const n=this._kernelInstance.getComponent(e);this._configuratorKernelAccessCallback.updateParameters(t,n.parameterGroups,e,1)}selectionChange(e,t){let n=!1,r=[];if(e){let t=this._kernelInstance.getComponent(e);t.componentId=this._kernelInstance.getComponentId(e),t&&t.childIds&&t.childIds.length>0&&(n=!0),r.push(t)}this._configuratorUiCallbacks.onSelectionChange("standard",t,n,r)}multiSelectionChange(e,t){this._updateCommonComponentDependencies(e);let n=!1,r=!1,i=[];e&&e.forEach(e=>{let s=this._kernelInstance.getComponent(e);s.componentId=this._kernelInstance.getComponentId(e),s&&s.childIds&&s.childIds.length>0&&(n=!0),s.id===t&&(r=!0),i.push(s)}),this._configuratorUiCallbacks.onSelectionChange("multiselect",r,n,i)}_updateCommonComponentDependencies(e){const{parameters:t,parameterGroups:n}=this._kernelInstance.getCommonPlanComponentParameters(this._utilityToLongArray(e));this._configuratorKernelAccessCallback.updateParameters(t,n,e,2)}_updateComponentChildren(e){const t=this._kernelInstance.getPlanComponentPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,1)}_updateComponentDependencies(e){this._updateComponentParameters(e),this._updateComponentChildren(e)}_updatePlanObjectParameters(e){let t,n=this._kernelInstance.getPlanObjectParameters(e);if(0===n.length){let r=this._kernelInstance.getRootPlanComponentIdFromObjectId(e);n=this._kernelInstance.getComponentParameters(r),this._enableRootComponentParametersAsGlobal(),t=this._kernelInstance.getComponent(r)}else this._configuratorContext.rootComponentParametersAsGlobal=!1,t=this._kernelInstance.getPlanObject(e);this._configuratorKernelAccessCallback.updateParameters(n,t.parameterGroups,e,0)}_enableRootComponentParametersAsGlobal(){this._configuratorContext.selectedRuntimeComponentId||(this._configuratorContext.rootComponentParametersAsGlobal=!0)}_updatePlanObjectChildren(e){const t=this._kernelInstance.getPlanObjectPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,0)}updatePlanObjectDependencies(e){this._updatePlanObjectParameters(e),this._updatePlanObjectChildren(e)}_updateConfigurationHasChildren(e,t=null){t||(t=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)));const n=t.childIds.size?t.childIds.size():t.childIds.length;this._configuratorUiCallbacks.onConfigurationHasChildren(n>0)}dockComponent(e,t,n,r){const i=this._kernelInstance.getComponentId(n),s=this._kernelInstance.getComponentId(e);this._kernelInstance.dockComponent(n,r,e,t),this._configuratorUiCallbacks.onUserInitiatedDockDone(i,r,s,t,null)}changeUseOfHDGeometry(e,t){this._rapiAccess.changeUseOfHDGeometry();const n=e.planObjectId,r=e.lastLoadedRapiId?e.lastLoadedRapiId:this._kernelInstance.getComponentId(n),i=this._kernelInstance.getSerializedConfiguration(n);this._kernelInstance.clearAll(),this._kernelInstance.useHDGeometry(t),Ns.finishOperation(3,[i,r])}webGlPreviewDockings(e,t){Ns.waitFor(4).then(({componentId:n})=>{t&&this.requestPlanComponentConstruction(n),this._kernelInstance.requestPreviewGeometry(n,e.planObjectId)}),e.lastPossibleChild&&e.lastPossibleChild.isComponent&&(this._kernelIo.setMeta({componentId:e.lastPossibleChild.id}),this._kernelInstance.loadPlainComponent(10,e.lastPossibleChild.id,e.lastPossibleChild.configuration)),e.lastPossibleChild&&e.lastPossibleChild.isItem&&this._kernelInstance.loadFreeFlyingConfiguration(10,e.lastPossibleChild.configuration)}previewDockingsWithDrag(e,t){this._kernelInstance.requestPreviewGeometry(e,t)}loadConfiguration(e){this._initData.id?this._memoryManager.loadingConfiguration(this._initData.id):this._memoryManager.loadingConfigurationString(),this._memoryManager.shouldHardReset()?this._kernelInstance.clearAll():this._kernelInstance.clearScene(),this._kernelInstance.loadConfiguration(wa,e,{x:0,y:0,z:0})}changeCommonComponentParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setPlanComponentParameters(this._utilityToLongArray(e),t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s),this._updateCommonComponentDependencies(e)}changeComponentParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setComponentParameter(e,t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s),this._updateComponentDependencies(e)}changePlanObjectParameter(e,t,n,r,i,s){"string"==typeof r?this._kernelInstance.setPlanObjectParameter(e,t,r):console.warn("tried to set a parameter to a none string value!",r,t,n),this._finishParameterChange(n,i,s)}_finishParameterChange(e,t,n){-1===xa.indexOf(e)?setTimeout(()=>t(),0):this._configuratorKernelCallbackListener.forEach(e=>e.finishParameterChange(t,n))}requestDeleteComponents(e){e&&this._kernelInstance.deletePlanComponents(this._utilityToLongArray(e))}requestDeletePlanComponent(e){var t,n;e&&(null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)&&this._kernelInstance.deletePlanComponent(e)}loadComponentIntoKernel(e,t){this._kernelIo.setMeta({componentId:t}),this._kernelInstance.loadComponentDefinition(10,e)}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const r=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(r,btoa(e))}requestSync(e,t){this.planObjectCreated(e,t),this._kernelInstance.syncPlanObjectToView(e,t)}getGlobalParameters(e,t){return new Promise(n=>{let r=this._kernelInstance.getPlanObjectParameters,i=e;t&&(r=this._kernelInstance.getComponentParameters,i=this._kernelInstance.getRootPlanComponentIdFromObjectId(e)),n(r.apply(this._kernelInstance,[i]))})}getPartList(){return new Promise(e=>{e(this._kernelInstance.getFullPartList())})}getConfigurationHash(e){return new Promise(t=>t(this._kernelInstance.getHashOfConfiguration(e.planObjectId)))}requestPlanObjectConstruction(e){this._kernelInstance.requestPlanObjectConstruction(e)}isReady(){super.isReady(),this._setupKernel(),Ts.isProduction||(window.__RML__DEBUG__.Kernel=this._kernelInstance,window.__RML__DEBUG__.KernelContainer=this._kernelContainer,window.__RML__DEBUG__.Helper={convertCObject:_r}),this._configuratorKernelAccessCallback.isReady(),this._configuratorUiCallbacks.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),ks.planObjectId&&this.planObjectCreated(-1,ks.planObjectId)}_setupKernel(){1===this._kernelType&&(Ls.start("kernel_create_instance"),ks.kernelInstance?this._kernelInstance=ks.kernelInstance:this._kernelInstance=new this._kernelContainer.Kernel),this._initKernel()}onLoadComponentError(e,t){this._configuratorUiCallbacks.onComponentLoadError(e,t)}configurationLoaded(e,t,n,r,i,s){Ns.finishOperation(4,{conversationId:e,objectId:t,componentId:n,hash:r,errors:_r(i)}),this._configuratorKernelCallbackListener.forEach(s=>s.configurationLoaded(e,t,n,r,i))}componentDefinitionLoaded(e,t){Ns.finishOperation(0,t)}componentDefinitionLoadingError(e,t){this._kernelIo.error(t),Ns.failOperation(0,new Error(t))}configurationLoadingError(e,t){let n="Configuration loading error";if(t){const e=_r(t);Array.isArray(e)&&(n=e.join("\n"),e.forEach(e=>this._kernelIo.error(e)))}Ns.failOperation(4,new Error(n)),Ns.failOperation(2,new Error(n))}componentConfigurationUpdated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.componentConfigurationUpdated(e,t)),this._kernelInstance.requestDeltaPlanComponentConstruction(e)}setActiveGroupInView(e){this._kernelInstance.setActiveGroupInView(e)}setActiveGroupInViewForPlanObject(e,t){this._kernelInstance.setActiveGroupInViewForPlanObject(e,t||this._configuratorContext.planObjectId)}componentParameters(){}requestComponentDimensions(){}planObjectCreated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.planObjectCreated(e,t))}planObjectUpdated(e){const t=this._kernelInstance.getPlanObject(e);this._onBoundsUpdate(t),this._configuratorKernelCallbackListener.forEach(e=>e.planObjectUpdated(t))}planObjectConfigurationUpdated(e,t,n,r,i){this.updatePlanObjectDependencies(e);let s=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e));this._configuratorKernelCallbackListener.forEach(r=>r.planObjectConfigurationUpdated(e,t,n));const a=this._kernelInstance.getPlanObject(e);return this._onBoundsUpdate(a),this._configuratorHistory.push(t),this._updateConfigurationHasChildren(e,s),this.requestPartListAndUpdatePricesOfParts(n)}_onBoundsUpdate(e){if(!e.boxForMeasurement)return;const t={width:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.x),height:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.z),depth:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.y),kernelBounds:e.boxForMeasurement};this._configuratorUiCallbacks.onBoundsUpdate(t)}planObjectDeleted(){}requestPlanObjectDimensions(){}async requestExternalMesh(e,t){let n=()=>{};const r=new Promise((e,t)=>{n=e});let i;this.externalMeshQueue.push(r),this._configuratorUiCallbacks.onRequestExternalMesh(e,t);try{i=await this._rapiAccess.getMesh(e,"crt",t)}catch(t){return this._handleInvalidMesh(e),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" can not be loaded. "${t}"`)),void console.error(t)}try{const r=await fetch(new Request(this._dataSyncer.requestAsset(i.url,!0))),s=await r.arrayBuffer();this._handleCortoMesh(s,e,t),n()}catch(t){return this._handleInvalidMesh(e),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" breaks. "${t}"`)),void console.error(t)}}Editor3dComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!1)),r&&r>0&&this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,r,t,n))}Editor3dRootComponentCreated(e,t,n,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,r,!0))}Editor3dPlanObjectConstructionDone(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dPlanObjectConstructionDone(e)),this.updatePlanObjectDependencies(e),this._updateConfigurationHasChildren(e),this._initData.moc||this._calcPrice()}Editor3dBeginGroup(){}Editor3dEndGroup(){}Editor3dSetMaterial(){}Editor3dLoadMaterial(){}Editor3dAddDockPreview(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dAddDockPreview(e,t))}Editor3dSetPreviewPointAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewPointAssociations(e,t))}Editor3dSetPreviewLineAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewLineAssociations(e,t))}Editor3dPreviewConstructionDone(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dPreviewConstructionDone(e,t))}Editor3dTranslateBy(){}Editor3dRotateBy(){}Editor3dRotateAround(){}Editor3dAddCube(){}Editor3dAddCubeUVMod(){}Editor3dAddSphere(){}Editor3dAddSphereUVMod(){}Editor3dAddRectangle(){}Editor3dAddRectangleUVMod(){}Editor3dAddMesh(){}Editor3dAddMeshUVMod(){}Editor3dAddMeshUVCoord(){}Editor3dAddCylinder(){}Editor3dAddCylinderUVMod(){}Editor3dAddPrism(){}Editor3dAddPrismUVMod(){}Editor3dAddFittingPoint(){}Editor3dAddFittingLine(){}Editor3dSelectObject(){}Editor3dCopy(){}Editor3dUpdatePlanObjectPosition(){}Editor3dUpdatePlanObjectRotation(){}Editor3dUpdatePlanObjectTransform(){}Editor3dUpdatePlanComponentPosition(){}Editor3dUpdatePlanComponentRotation(){}Editor3dUpdatePlanComponentTransform(){}getRuntimeComponentIdOfRootComponent(e){return this._kernelInstance?this._kernelInstance.getRootPlanComponentIdFromObjectId(e):(console.warn("this._kernelInstance not ready now"),0)}getRuntimeComponentId(e){return this._kernelInstance.getComponentId(e)}getParameterGroups(){if(!this._configuratorContext.planObjectId)return[];const e=this._kernelInstance.getRootPlanComponentIdFromObjectId(this._configuratorContext.planObjectId);return this._kernelInstance.getComponent(e).parameterGroups}resume(){this.muteKernelCallbacks||super.resume()}getSerializedConfiguration(e){return this._kernelInstance.getSerializedConfiguration(e)}createNewSerializedConfiguration(e){return this._kernelInstance.createNewSerializedConfiguration(e)}getCurrentConfigurationHash(e){return this._kernelInstance.getHashOfConfiguration(e)}listOfVariantsError(e,t){this._kernelIo.setMeta({rapiId:e}),this._kernelIo.error(t)}}tn([rn],Sa.prototype,"_memoryManager",void 0),tn([rn],Sa.prototype,"_configuratorKernelAccessCallback",void 0),tn([rn],Sa.prototype,"_initData",void 0),tn([rn],Sa.prototype,"_configuratorHistory",void 0);class Ca extends ys{constructor(e){super(e);const t=this.getPlanElement().getMaxWallHeight();this._container.position.y=(t<0?2800:t)/1e3+.01,this._container.name="Node Plan Element",this.addMesh(this._nodeUiMesh)}update(){super.update(),this._container.position.y=this.getPlanElement().getMaxWallHeight()/1e3+.01}_initNodeMesh(){if(this._nodeUiMesh)return;const e=new Qe(.05,32),t=new y({color:16777215});this._sphere=new H(e,t);const n=new Ye(.05,.07,32),r=new y({color:0,side:B});this._innerRingMesh=new H(n,r),this._innerRingMesh.rotation.set(Math.PI/2,0,0);const i=new Ye(.07,.08,32),s=new y({color:16777215,side:B});this._outerRingMesh=new H(i,s),this._outerRingMesh.rotation.set(Math.PI/2,0,0),this._nodeUiMesh=new H,this._nodeUiMesh.add(this._sphere),this._nodeUiMesh.add(this._innerRingMesh),this._nodeUiMesh.add(this._outerRingMesh)}setTopView(e){super.setTopView(e),e||(this._nodeUiMesh.visible=!1)}getSize(){return this._initNodeMesh(),(new ge).setFromObject(this._nodeUiMesh).getSize(new a)}show(){this._nodeUiMesh.visible=this._topView}hide(){this._nodeUiMesh.visible=!1}select(){this._innerRingMesh.material=new y({color:10526880,side:B}),super.select()}deselect(){this._innerRingMesh.material=new y({color:0,side:B}),super.deselect()}hoverOn(){this._sphere.geometry=new Qe(.07,32),this._innerRingMesh.geometry=new Ye(.07,.07+.02,32),this._outerRingMesh.geometry=new Ye(.07+.02,.1,32),super.hoverOn()}hoverOff(){this._sphere.geometry=new Qe(.05,32),this._innerRingMesh.geometry=new Ye(.05,.07,32),this._outerRingMesh.geometry=new Ye(.07,.08,32),super.hoverOff()}_generateBoundingBox(){const e=super._generateBoundingBox();return e.layers.set(9),e}addMesh(e){super.addMesh(e)}}e("a3",Ca);class Ma extends Ps{constructor(e){super(e),this._container.name="Construction "+this._container.name}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView(),this._updateBoundingBox()}_enableTopView(){if(!this._topViewContainer){this._topViewContainer=new q;const e=this.getPlanElement(),{x:t,z:n}=mr(e.size),r=new ke(t,.01,n);if(this._topGreyMesh=new H(r,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:11645361})),this._topViewContainer.add(this._topGreyMesh),"window"===e.getObjectType()){const e=new ke(t,.02,.05);this._topBlackMesh=new H(e,Ti.createMeshStandardMaterial({transparent:!0,opacity:1,color:0})),this._topViewContainer.add(this._topBlackMesh)}this._topViewContainer.position.y=5,this._container.add(this._topViewContainer)}this._topViewContainer.visible=!0}_disableTopView(){this._topViewContainer&&(this._topViewContainer.visible=!1)}getPlanElement(){return super.getPlanElement()}_generateBoundingBox(){const e=super._generateBoundingBox(),t=this.getSize();return e.geometry=new ke(t.x,this._topView?5:t.y,t.z),e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new ke(e.x,this._topView?5:e.y,e.z)}getTopViewContainer(){return this._topViewContainer}update(){if(super.update(),!this._topGreyMesh)return;const{x:e,z:t}=mr(this.getPlanElement().size);this._topGreyMesh.geometry=new ke(e,.01,t),this._topBlackMesh&&(this._topBlackMesh.geometry=new ke(e,.02,.05))}}e("a9",Ma);class Ta extends Sa{get kernelContainer(){return this._kernelContainer}constructor(e){super(e),this._plannerKernelCallbackListener=new Set}_loadSuccess(){super._loadSuccess(),window.RoomleCore&&window.RoomleCore(this._kernelContainer)}_loadError(){super._loadError(),console.error("kernel load error")}_createPlanInteractionHandler(){this._planInteractionHandler=new this._kernelContainer.PlanInteractionHandler,this._planInteractionHandler.init(this._planInteractionHandler,1,50,!!this._initData.snappingEnabled,!0,this._kernelContainer.DrawingType.CLICK_PER_CLICK),this._roomlePlannerUiCallback.onPlanInteractionHandlerCreated(this._planInteractionHandler)}addPlannerListener(e){this._plannerKernelCallbackListener.add(e)}removePlannerListener(e){this._plannerKernelCallbackListener.delete(e)}isReady(){super.isReady(),this.registerCallbacks(),this._roomlePlannerUiCallback.onPlannerKernelIsReady(this._kernelContainer),this._roomlePlannerUiCallback.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Ts.isProduction||(window.__RML__DEBUG__.ConfiguratorKernel=this._kernelInstance,window.__RML__DEBUG__.PlannerKernelContainer=this._kernelContainer),this._kernelAccessCallback.isReady()}_setupKernel(){0===this._kernelType&&(this._createPlanInteractionHandler(),ks.kernelInstance?this._kernelInstance=ks.kernelInstance:this._kernelInstance=this._planInteractionHandler.getConfiguratorKernel()),super._setupKernel()}get callbacks(){return this._roomlePlannerUiCallback}get planInteractionHandler(){return this._planInteractionHandler}get planModelViewHelper(){return this._kernelContainer.PlanModelViewHelper}catalogItemLoaded(e){const t=this._rapiItemToKernelItem(e);this._kernelContainer.catalogItemLoaded(t)}async insertItems(e){this.planInteractionHandler.startInteraction();let t=new this._kernelContainer.CatalogItemPtrList;e.forEach(e=>{let n=e.count||1;for(let r=0;r<n;r++)e.count||(e.count=0),t.push_back(this._rapiItemToKernelItem(e))});const n=this.planInteractionHandler.getPlan().extRef.jsObject,r=n.getPlanObjectViewModelsFromRapiId().reduce((e,t)=>(e[t.getId()]=!0,e),{});this.planInteractionHandler.addPlanObjects(t,!0),await Promise.allSettled([Promise.allSettled(n.getStaticPlanObjectViewModels().map(async e=>{if(e.needsRapiItem()){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}})),Promise.allSettled(n.getConfigurablePlanObjectViewModels().map(e=>e.isInitDone()))]);const i=n.getPlanObjectViewModelsFromRapiId().map(e=>e.getId()).filter(e=>!r[e]);return this.planInteractionHandler.endInteraction(),i}duplicateItems(e){const t=new this.kernelContainer.PlanObjectPtrList;return e.forEach(e=>{t.push_back(e)}),this.planInteractionHandler.duplicatePlanObjects(t,1,!0)}_rapiItemToKernelItem(e){let t=new this._kernelContainer.CatalogItem(e.id),n=t.size;return n.x=e.width||0,n.y=e.depth||0,n.z=e.height||0,t.size=n,t.flipable=e.flipable,e.layer&&(t.layer=e.layer),t.orderable=e.orderable,t.scaleable=e.scaleable,t.type=e.type||"other",t.detailType=e.detailType||t.type||"other",t.configuration=e.configuration||"",t}planObjectDeleted(){}requestPlanObjectDimensions(){}cleanUpCallbacks(){var e;super.cleanUpCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.unregisterPlannerCallback)&&this._kernelContainer.unregisterPlannerCallback(this)}registerCallbacks(){var e;super.registerCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.registerPlannerCallback)&&this._kernelContainer.registerPlannerCallback(this)}planElementRemoved(e){this._plannerKernelCallbackListener.forEach(t=>t.planElementRemoved(e)),this._plannerKernelCallbackListener.forEach(t=>t.removePlanObjectFromScene(e.extRef.jsObject)),this._decoupleReferences(e)}handlerSwitchedPlans(e,t){this._decoupleReferences(e),t&&this._plannerKernelCallbackListener.forEach(n=>n.handlerSwitchedPlans(e,t))}planBoundsChanged(){this._plannerKernelCallbackListener.forEach(e=>e.planBoundsChanged())}planCleared(){this._plannerKernelCallbackListener.forEach(e=>e.planCleared())}planCompletelyLoaded(e){this._plannerKernelCallbackListener.forEach(t=>t.planCompletelyLoaded(e))}planElement3dMeshChanged(e,t){if(t.extRef){const e=t.extRef.jsObject;for(let t=e.getObject().children.length-1;t>=0;t--)e.getObject().remove(e.getObject().children[t])}this.planModelViewHelper.requestMesh3d(t)}async _onStaticItemAdded(e,t){let n;n=this.isConstructionPlanElement(t)?new Ma(t):new Ps(t),this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n);const r=t.getCatalogItemId();if(r){const e=await this._rapiAccess.getItem(r);n.setRapiItem(e),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}}_onConfigurableItemAdded(e,t){const n=new Ss(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}async planElementAdded(e,t){if(e&&e.extRef)if(t.getType()===this._kernelContainer.PlanElementType.OBJECT)t.hasConfiguration()?this._onConfigurableItemAdded(e,t):await this._onStaticItemAdded(e,t);else{const n=t;let r;if(t.getType()===this._kernelContainer.PlanElementType.WALL?r=new Rs(n):t.getType()===this._kernelContainer.PlanElementType.FLOOR?r=new Is(n):t.getType()===this._kernelContainer.PlanElementType.CEILING?r=new Ds(n):t.getType()===this._kernelContainer.PlanElementType.NODE&&(r=new Ca(n)),!r)return;this.coupleReferences(r,n),e.extRef.jsObject.addPlanElementViewModel(r),this.planModelViewHelper.requestMesh3d(t),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(null))}}planElementChanged(e,t){if(t.extRef){let n=t.extRef.jsObject;n.update(),this._plannerKernelCallbackListener.forEach(t=>t.planElementChanged(e,n))}}planHistoryStateChanged(){this.planInteractionHandler&&(this._plannerKernelCallbackListener.forEach(e=>e.planHistoryStateChanged()),this._roomlePlannerUiCallback.onHistoryChange(this.planInteractionHandler.isUndoPossible(),this.planInteractionHandler.isRedoPossible()))}planObjectConfigurationCreated(e,t){}planObjectConfigurationLoaded(e,t,n){e&&e.extRef&&t&&t.extRef&&t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId()>0&&this._plannerKernelCallbackListener.forEach(r=>r.planObjectConfigurationLoaded(e,t,n))}requestCatalogItem(e){}startedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.startedDrawing())}stoppedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.stoppedDrawing())}updateMesh2d(){}beginConstruction(){}addMesh(e,t,n,r,i,s){this._plannerKernelCallbackListener.forEach(a=>a.addMesh(e,t,n,r,i,s))}endConstruction(){}beginPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.beginPlanConstruction(e))}addPlanMesh(e,t,n,r,i,s,a){this._plannerKernelCallbackListener.forEach(o=>o.addPlanMesh(e,t,n,r,i,s,a))}endPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.endPlanConstruction(e))}async addPlanObjectFromItem(e,t,n){if(!t&&!n){const t=await this.insertItems([e]);if(1!==t.length)throw new Error("It was expected that 1 element is added but"+t.length+"were added");return t[0]}n=n||0===n?n:0,t=t||{x:0,y:0,z:0};const r=this._planInteractionHandler.addPlanObjectFromItem(this._rapiItemToKernelItem(e),t,n,!1),i=this._planInteractionHandler.getPlan().extRef.jsObject;let s;return r.hasConfiguration()?(s=i.getConfigurablePlanObjectForId(r.getId()),s||console.warn("Could not find configuration")):(s=i.getStaticPlanObjectViewModelForId(r.getId()),s?await s.setRapiItem(e):console.warn("Could not find static item")),await s.isInitDone(),s.getId()}coupleReferences(e,t){let n=new this._kernelContainer.EMSReference;n.jsObject=e,t.extRef=n}_decoupleReferences(e){e&&e.extRef&&(e.extRef.jsObject.clearReference(),e.extRef.jsObject=null,e.extRef.delete(),e.extRef=null)}isConstructionPlanElement(e){return e instanceof this.kernelContainer.ConstructionObject}}e("ac",Ta),tn([rn],Ta.prototype,"_kernelAccessCallback",void 0),tn([rn],Ta.prototype,"_roomlePlannerUiCallback",void 0);class Pa extends is{constructor(e){super(e),this._wallMeshes=[],this._defaultMaterial=Ti.createMeshPhysicalMaterial({color:"#ffffff",side:B})}generateGeometry(e=null,t,n,r,i,s=!1){let a;return a=s?this._generateGeometry(e,t,n,r,i).clone():this._generateGeometry(e,t,n,r,i),a}generateMesh(e=0,t=null,n,r,i,s,a,o,l=!1,h){let d;d=l?this._generateGeometry(t,r,i,s,a).clone():this._generateGeometry(t,r,i,s,a);const c=this._createMesh(e,t,d);return c.userData.materialId=n,c.layers.set(4),n&&this.setMaterial(c,n,o,h).then(()=>{e&&t&&n&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n);const r=o&&3===o.value,i=o&&1===o.value;c.castShadow=!r&&!i}),this._checkWallMaterial(c,o),c}async setMaterial(e,t,n,r){if(e.userData.materialId=Wi(t,n),Ze(t))t?await this._assignMaterial(e,t,r):(console.warn("Used default material because material is empty"),this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)));else{if(!t)return void this.changeMaterialOfMesh(e,this._configuratorPreviewMaterial);2===(t=t).getSourceType().value?await this._assignMaterial(e,t.materialId,r):1===t.getSourceType().value?await this._assignItem(e,t.catalogItemId):3===t.getSourceType().value?await this._assignRGB(e,t.rgbValue):0===t.getSourceType().value?this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)):(this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)),1!==n.value&&7!==n.value&&3!==n.value&&console.warn("Used default material because material is not supported",t))}}_getDefaultMaterial(e){return 3===(null==e?void 0:e.value)?this._defaultMaterialFloor:this._defaultMaterial}set maxAnisotropy(e){this._maxAnisotropy=e}_checkWallMaterial(e,t){t&&1===t.value&&(e.renderOrder=5,this._wallMeshes.push(e))}clear(){super.clear(),this.clearWallMeshes()}clearWallMeshes(){this._wallMeshes.forEach(e=>{Gi(e)}),this._wallMeshes=[]}get wallMeshes(){return this._wallMeshes}}e("ap",Pa);let Aa={InchFeet:null,Feet:null,MM:null,CM:null,Inch:null},Ea={NoUnitString:null,LongUnitString:null,ShortUnitString:null};const Ra=["mm","cm","feet"],Ia=["inch","inchfeet"];class Da{constructor(e){this._formatter=null,this._precision=0,this._creator_=e}init(e){const t=new e.UnitMeasureFormatter;Aa=e.Unit,Ea=e.UnitStringType,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType();const{precisionCm:n,precisionInch:r}=this._initData;this._actualUnit===Aa.InchFeet?this._precision=void 0!==r?parseInt(r,10):2:this._actualUnit===Aa.CM&&(this._precision=void 0!==n?parseInt(n,10):1),t.init("mm","cm","'","ft",'"',"inch","m²","sqft",!0,this._precision,!0),this._formatter=t}_initMeasurementSystemType(){let{measurementSystem:e,unit:t}=this._initData;if(this._actualMeasurementString=e,e||!t){if("metric"===e){t||(t="cm");const e=Ra.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not a metric unit, using CM"),this._actualUnit=Aa.CM,this._actualUnitString="cm")}if("imperial"===e){t||(t="inch");const e=Ia.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not an imperial unit, using Inches"),this._actualUnit=Aa.Inch,this._actualUnitString="inch")}}else{this._actualUnitString=t;const e=Ra.find(e=>e===t);this._actualMeasurementString=e?"metric":"imperial"}}_initActualUnit(){const{unit:e}=this._initData;this._actualUnit=this._getKernelUnitEnum(e)}_getKernelUnitEnum(e){switch(e){case"cm":return Aa.CM;case"mm":return Aa.MM;case"inchfeet":return Aa.InchFeet;case"feet":return Aa.Feet;case"inch":return Aa.Inch;default:return Aa.CM}}_initActualUnitStringType(){const{unitStringType:e}=this._initData;e&&"short"!==e&&console.warn("Only short unit strings is supported at the moment"),this._actualUnitStringType=Ea.ShortUnitString}_isFormatterReady(){return!!this._formatter||(console.warn("Formatter is not ready..."),!1)}formatAngleValueToUnitString(e,t){const n="Integer"===t.type?0:2;return e.toFixed(n)+"°"}parseAngleValueFromUnitString(e){return e.replace("°","").replace(/\s/g,"")}parseValue(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?e:"length"===t.unitType?this.parseMMValueFromUnitString(e,t.unitType):"angle"===t.unitType||"area"===t.unitType?this.parseAngleValueFromUnitString(e):e}formatValueToUnitString(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?"Integer"===t.type?e.toString():parseFloat(e.toString()).toFixed(2):"length"===t.unitType?this.formatMMValueToUnitString(e,t.unitType):"angle"===t.unitType?this.formatAngleValueToUnitString(e,t):"area"===t.unitType?this.formatSquareMMValueToUnitString(e):e}isParseableNumber(e){return this._isFormatterReady()?this._formatter.isParseableNumber(e):null}isParseableUnitString(e,t){return this._isFormatterReady()?"angle"===t.unitType?this._formatter.isParseableUnitString(this.parseAngleValueFromUnitString(e),this._actualUnit):this._formatter.isParseableUnitString(e,this._actualUnit):null}parseMMValueFromUnitString(e,t){return this._isFormatterReady()?"count"===t?parseFloat(e):this._formatter.parseMMValueFromUnitString(e,this._actualUnit):null}parseNumber(e){return this._isFormatterReady()?this._formatter.parseNumber(e):null}formatNumber(e,t=0){return this._isFormatterReady()?this._formatter.formatNumber(e,t):null}formatSquareMMValueToUnitString(e){return this._isFormatterReady()?this._formatter.formatSquareMMValueToUnitString(e,this._actualUnit):null}formatMMValueToUnitString(e,t){return this._isFormatterReady()?"count"===t?e.toString():this._formatter.formatMMValueToUnitString(e,this._actualUnit,this._actualUnitStringType):null}formatMMValueWithReqMaxLength(e,t){return this._isFormatterReady()?this._formatter.formatMMValueWithReqMaxLength(e,this._actualUnit,t):null}_formatParameterValue(e,t){return"length"===t?this.formatMMValueToUnitString(parseFloat(e)):"area"===t?this.formatSquareMMValueToUnitString(parseFloat(e)):e}formatPartListParameter(e){(function(e){return"length"===e.unitType||"area"===e.unitType})(e)&&(e.valueLabel=this._formatParameterValue(e.value,e.unitType))}formatParameter(e){if(e.valueLabel=this._formatParameterValue(e.value,e.unitType),Gs(e))e.uiType="Material";else if(function(e){return"Boolean"===e.type}(e))e.uiType="Boolean";else if(Bs(e)){e.uiType="Range";const t=null!==e.validRange.valueFrom?e.validRange.valueFrom:Number.MIN_SAFE_INTEGER,n=null!==e.validRange.valueTo?e.validRange.valueTo:Number.MAX_SAFE_INTEGER;e.validRangeLabels={valueFrom:this._formatParameterValue(t.toString(),e.unitType),valueTo:this._formatParameterValue(n.toString(),e.unitType),type:e.validRange.type}}else js(e)?(e.uiType="Options",function(e){return!!js(e)&&Array.isArray(e.validValues)&&e.validValues.length>0&&"string"==typeof e.validValues[0].thumbnail}(e)&&(e.uiType="Thumbnails")):(console.error("Could not detect uiType of param"),e.uiType=null)}isInch(){return this._actualUnit===Aa.InchFeet}getActualUnitString(){return this._actualUnitString}getActualMeasurementString(){return this._actualMeasurementString}getUnitStringType(){return this._initData.unitStringType}getPrecision(){return this._precision}getAllowedDelta(){const e=1/Math.pow(10,this._precision);return this.isInch()?25.4*e:e}setUnitInitData(e,t=""){this._initData.unit=e,this._initData.measurementSystem=t,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType(),this._plannerKernelAccess.kernelInstance.setEnvironmentVariable("unit",this._actualUnitString)}}tn([rn],Da.prototype,"_initData",void 0),tn([rn],Da.prototype,"_plannerKernelAccess",void 0);class Oa{constructor(e){this._history=[],this._index=0,this._creator_=e}undo(){if(!this.canUndo())return null;this._index++;const[e]=this._history.slice(this._index);return this._index===this._history.length-1?this._configuratorUiCallbacks.onHistoryChange(!1,!0):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}redo(){if(!this.canRedo())return null;this._index--;const[e]=this._history.slice(this._index);return 0===this._index?this._configuratorUiCallbacks.onHistoryChange(!0,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}push(e){const[t]=this._history.slice(this._index);t!==e&&(this._history=this._history.slice(this._index),this._history.unshift(e),this._index=0,1===this._history.length?this._configuratorUiCallbacks.onHistoryChange(!1,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!1))}canUndo(){return this._index!==this._history.length-1}canRedo(){return 0!==this._index}getHistory(){return this._history}clearHistory(){this._history=[],this._index=0}}tn([rn],Oa.prototype,"_configuratorUiCallbacks",void 0),e("ag",{ADDED:"added",CHANGED:"changed",REMOVED:"removed"});class La{constructor(e){this._kernelCallbacks={isReady:()=>{},throw:e=>console.error("Kernel exception",e),log:e=>{},error:(e,t,n,r)=>{},message:e=>{this._analyzeComponentCallback&&this._analyzeComponentCallback(e)}},this._creator_=e}async init(){if(this._toolsCoreInstance)return Promise.resolve();const e=this,t={locateFile:e=>"RoomleToolsCore.wasm"===e?n()+"static/RoomleToolsCore-0000327e9e7afae4.wasm":e,wasmBinaryFile:n()+"static/RoomleToolsCore-0000327e9e7afae4.wasm",preRun:[],postRun:[],setStatus:null,print(t){e._kernelIo.log(t)},printErr(t){e._kernelIo.error(t)},quit(t){0!==t&&e._kernelIo.throw(t&&t.toString?t.toString():"Unknown error while C/C++ main executes")}};await this._scriptLoader.fetch("static/RoomleToolsCore-09b8f5cc8e93df5f.js",{id:"core-tool"});const r=await window.RoomleToolsCore(t);r.setContext(this._kernelCallbacks),this._toolsCoreInstance=new r.ToolsCore}analyzeComponent(e,t){const n=[];return this._analyzeComponentCallback=e=>{n.push(e)},this._toolsCoreInstance.analyzeComponent(e,t),this._analyzeComponentCallback=null,Promise.resolve(n)}}tn([rn],La.prototype,"_scriptLoader",void 0),tn([rn],La.prototype,"_kernelIo",void 0);
|
|
2
2
|
/*!
|
|
3
3
|
fflate - fast JavaScript compression/decompression
|
|
4
4
|
<https://101arrowz.github.io/fflate>
|
|
5
5
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
6
6
|
version 0.6.9
|
|
7
7
|
*/
|
|
8
|
-
var ka=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(ka(""))}catch(e){ka=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var Ua=Uint8Array,Fa=Uint16Array,Na=Uint32Array,Ba=new Ua([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]),ja=new Ua([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ga=new Ua([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ha=function(e,t){for(var n=new Fa(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Na(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},za=Ha(Ba,2),Va=za[0],Wa=za[1];Va[28]=258,Wa[258]=28;for(var Ka=Ha(ja,0)[0],qa=new Fa(32768),Xa=0;Xa<32768;++Xa){var Qa=(43690&Xa)>>>1|(21845&Xa)<<1;Qa=(61680&(Qa=(52428&Qa)>>>2|(13107&Qa)<<2))>>>4|(3855&Qa)<<4,qa[Xa]=((65280&Qa)>>>8|(255&Qa)<<8)>>>1}var Ya=function(e,t,n){for(var r=e.length,i=0,s=new Fa(t);i<r;++i)++s[e[i]-1];var a,o=new Fa(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new Fa(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var h=i<<4|e[i],d=t-e[i],c=o[e[i]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)a[qa[c]>>>l]=h}else for(a=new Fa(r),i=0;i<r;++i)e[i]&&(a[i]=qa[o[e[i]-1]++]>>>15-e[i]);return a},Za=new Ua(288);for(Xa=0;Xa<144;++Xa)Za[Xa]=8;for(Xa=144;Xa<256;++Xa)Za[Xa]=9;for(Xa=256;Xa<280;++Xa)Za[Xa]=7;for(Xa=280;Xa<288;++Xa)Za[Xa]=8;var Ja=new Ua(32);for(Xa=0;Xa<32;++Xa)Ja[Xa]=5;var $a=Ya(Za,9,1),eo=Ya(Ja,5,1),to=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},no=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},ro=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},io=new Ua(0);function so(e,t){return function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new Ua(0);var i=!t||n,s=!n||n.i;n||(n={}),t||(t=new Ua(3*r));var a,o=function(e){var n=t.length;if(e>n){var r=new Ua(Math.max(2*n,e));r.set(t),t=r}},l=n.f||0,h=n.p||0,d=n.b||0,c=n.l,u=n.d,p=n.m,m=n.n,g=8*r;do{if(!c){n.f=l=no(e,h,1);var f=no(e,h+1,3);if(h+=3,!f){var _=e[(A=((a=h)/8|0)+(7&a&&1)+4)-4]|e[A-3]<<8,v=A+_;if(v>r){if(s)throw"unexpected EOF";break}i&&o(d+_),t.set(e.subarray(A,v),d),n.b=d+=_,n.p=h=8*v;continue}if(1==f)c=$a,u=eo,p=9,m=5;else{if(2!=f)throw"invalid block type";var w=no(e,h,31)+257,b=no(e,h+10,15)+4,y=w+no(e,h+5,31)+1;h+=14;for(var x=new Ua(y),C=new Ua(19),S=0;S<b;++S)C[Ga[S]]=no(e,h+3*S,7);h+=3*b;var M=to(C),T=(1<<M)-1,P=Ya(C,M,1);for(S=0;S<y;){var A,E=P[no(e,h,T)];if(h+=15&E,(A=E>>>4)<16)x[S++]=A;else{var R=0,I=0;for(16==A?(I=3+no(e,h,3),h+=2,R=x[S-1]):17==A?(I=3+no(e,h,7),h+=3):18==A&&(I=11+no(e,h,127),h+=7);I--;)x[S++]=R}}var D=x.subarray(0,w),O=x.subarray(w);p=to(D),m=to(O),c=Ya(D,p,1),u=Ya(O,m,1)}if(h>g){if(s)throw"unexpected EOF";break}}i&&o(d+131072);for(var L=(1<<p)-1,k=(1<<m)-1,U=h;;U=h){var F=(R=c[ro(e,h)&L])>>>4;if((h+=15&R)>g){if(s)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if(F<256)t[d++]=F;else{if(256==F){U=h,c=null;break}var N=F-254;if(F>264){var B=Ba[S=F-257];N=no(e,h,(1<<B)-1)+Va[S],h+=B}var j=u[ro(e,h)&k],G=j>>>4;if(!j)throw"invalid distance";if(h+=15&j,O=Ka[G],G>3&&(B=ja[G],O+=ro(e,h)&(1<<B)-1,h+=B),h>g){if(s)throw"unexpected EOF";break}i&&o(d+131072);for(var H=d+N;d<H;d+=4)t[d]=t[d-O],t[d+1]=t[d+1-O],t[d+2]=t[d+2-O],t[d+3]=t[d+3-O];d=H}}n.l=c,n.p=U,n.b=d,c&&(l=1,n.m=p,n.d=u,n.n=m)}while(!l);return d==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Fa?Fa:e instanceof Na?Na:Ua)(n-t);return r.set(e.subarray(t,n)),r}(t,0,d)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var ao="undefined"!=typeof TextDecoder&&new TextDecoder;try{ao.decode(io,{stream:!0})}catch(e){}class oo extends Je{constructor(e){super(e),this.type=$e}parse(e){const t=Math.pow(2.7182818,2.2),n={l:0,c:0,lc:0};function r(e,t,r,i,s){for(;r<e;)t=t<<8|k(i,s),r+=8;r-=e,n.l=t>>r&(1<<e)-1,n.c=t,n.lc=r}const i=new Array(59);function s(e){return 63&e}function a(e){return e>>6}const o={c:0,lc:0};function l(e,t,n,r){e=e<<8|k(n,r),t+=8,o.c=e,o.lc=t}const h={c:0,lc:0};function d(e,t,n,r,i,s,a,d,c){if(e==t){r<8&&(l(n,r,i,s),n=o.c,r=o.lc);let e=n>>(r-=8);if(e=new Uint8Array([e])[0],d.value+e>c)return!1;const t=a[d.value-1];for(;e-- >0;)a[d.value++]=t}else{if(!(d.value<c))return!1;a[d.value++]=e}h.c=n,h.lc=r}function c(e){return 65535&e}function u(e){const t=c(e);return t>32767?t-65536:t}const p={a:0,b:0};function m(e,t){const n=u(e),r=u(t),i=n+(1&r)+(r>>1),s=i,a=i-r;p.a=s,p.b=a}function g(e,t){const n=c(e),r=c(t),i=n-(r>>1)&65535,s=r+i-32768&65535;p.a=s,p.b=i}function f(e,t,n,r,i,s,a){const o=a<16384,l=n>i?i:n;let h,d,c=1;for(;c<=l;)c<<=1;for(c>>=1,h=c,c>>=1;c>=1;){d=0;const a=d+s*(i-h),l=s*c,u=s*h,f=r*c,_=r*h;let v,w,b,y;for(;d<=a;d+=u){let i=d;const s=d+r*(n-h);for(;i<=s;i+=_){const n=i+f,r=i+l,s=r+f;o?(m(e[i+t],e[r+t]),v=p.a,b=p.b,m(e[n+t],e[s+t]),w=p.a,y=p.b,m(v,w),e[i+t]=p.a,e[n+t]=p.b,m(b,y),e[r+t]=p.a,e[s+t]=p.b):(g(e[i+t],e[r+t]),v=p.a,b=p.b,g(e[n+t],e[s+t]),w=p.a,y=p.b,g(v,w),e[i+t]=p.a,e[n+t]=p.b,g(b,y),e[r+t]=p.a,e[s+t]=p.b)}if(n&c){const n=i+l;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}if(i&c){let i=d;const s=d+r*(n-h);for(;i<=s;i+=_){const n=i+f;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}h=c,c>>=1}return d}function _(e,t,c,u,p,m){const g=c.value,f=L(t,c),_=L(t,c);c.value+=4;const v=L(t,c);if(c.value+=4,f<0||f>=65537||_<0||_>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const w=new Array(65537),b=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(b),function(e,t,s,a,o,l){const h=t;let d=0,c=0;for(;a<=o;a++){if(h.value-t.value>s)return!1;r(6,d,c,e,h);const i=n.l;if(d=n.c,c=n.lc,l[a]=i,63==i){if(h.value-t.value>s)throw new Error("Something wrong with hufUnpackEncTable");r(8,d,c,e,h);let i=n.l+6;if(d=n.c,c=n.lc,a+i>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)l[a++]=0;a--}else if(i>=59){let e=i-59+2;if(a+e>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)l[a++]=0;a--}}!function(e){for(let e=0;e<=58;++e)i[e]=0;for(let t=0;t<65537;++t)i[e[t]]+=1;let t=0;for(let e=58;e>0;--e){const n=t+i[e]>>1;i[e]=t,t=n}for(let t=0;t<65537;++t){const n=e[t];n>0&&(e[t]=n|i[n]++<<6)}}(l)}(e,c,u-(c.value-g),f,_,w),v>8*(u-(c.value-g)))throw new Error("Something wrong with hufUncompress");!function(e,t,n,r){for(;t<=n;t++){const n=a(e[t]),i=s(e[t]);if(n>>i)throw new Error("Invalid table entry");if(i>14){const e=r[n>>i-14];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=new Array(1);e.p[e.lit-1]=t}else if(i){let e=0;for(let s=1<<14-i;s>0;s--){const s=r[(n<<14-i)+e];if(s.len||s.p)throw new Error("Invalid table entry");s.len=i,s.lit=t,e++}}}}(w,f,_,b),function(e,t,n,r,i,c,u,p,m){let g=0,f=0;const _=u,v=Math.trunc(r.value+(i+7)/8);for(;r.value<v;)for(l(g,f,n,r),g=o.c,f=o.lc;f>=14;){const i=t[g>>f-14&16383];if(i.len)f-=i.len,d(i.lit,c,g,f,n,r,p,m,_),g=h.c,f=h.lc;else{if(!i.p)throw new Error("hufDecode issues");let t;for(t=0;t<i.lit;t++){const u=s(e[i.p[t]]);for(;f<u&&r.value<v;)l(g,f,n,r),g=o.c,f=o.lc;if(f>=u&&a(e[i.p[t]])==(g>>f-u&(1<<u)-1)){f-=u,d(i.p[t],c,g,f,n,r,p,m,_),g=h.c,f=h.lc;break}}if(t==i.lit)throw new Error("hufDecode issues")}}const w=8-i&7;for(g>>=w,f-=w;f>0;){const e=t[g<<14-f&16383];if(!e.len)throw new Error("hufDecode issues");f-=e.len,d(e.lit,c,g,f,n,r,p,m,_),g=h.c,f=h.lc}}(w,b,e,c,v,_,m,p,{value:0})}function v(e){for(let t=1;t<e.length;t++){const n=e[t-1]+e[t]-128;e[t]=n}}function b(e,t){let n=0,r=Math.floor((e.length+1)/2),i=0;const s=e.length-1;for(;!(i>s||(t[i++]=e[n++],i>s));)t[i++]=e[r++]}function y(e){let t=e.byteLength;const n=new Array;let r=0;const i=new DataView(e);for(;t>0;){const e=i.getInt8(r++);if(e<0){const s=-e;t-=s+1;for(let e=0;e<s;e++)n.push(i.getUint8(r++))}else{const s=e;t-=2;const a=i.getUint8(r++);for(let e=0;e<s+1;e++)n.push(a)}}return n}function x(e,t,n){let r,i=1;for(;i<64;)r=t[e.value],65280==r?i=64:r>>8==255?i+=255&r:(n[i]=r,i++),e.value++}function C(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),h=new Array(4),d=new Array(4),c=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=r*e[p+2],l[1]=a*e[p+2],l[2]=r*e[p+6],l[3]=a*e[p+6],h[0]=n*e[p+1]+i*e[p+3]+s*e[p+5]+o*e[p+7],h[1]=i*e[p+1]-o*e[p+3]-n*e[p+5]-s*e[p+7],h[2]=s*e[p+1]-n*e[p+3]+o*e[p+5]+i*e[p+7],h[3]=o*e[p+1]-s*e[p+3]+i*e[p+5]-n*e[p+7],d[0]=t*(e[p+0]+e[p+4]),d[3]=t*(e[p+0]-e[p+4]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[p+0]=c[0]+h[0],e[p+1]=c[1]+h[1],e[p+2]=c[2]+h[2],e[p+3]=c[3]+h[3],e[p+4]=c[3]-h[3],e[p+5]=c[2]-h[2],e[p+6]=c[1]-h[1],e[p+7]=c[0]-h[0]}for(let u=0;u<8;++u)l[0]=r*e[16+u],l[1]=a*e[16+u],l[2]=r*e[48+u],l[3]=a*e[48+u],h[0]=n*e[8+u]+i*e[24+u]+s*e[40+u]+o*e[56+u],h[1]=i*e[8+u]-o*e[24+u]-n*e[40+u]-s*e[56+u],h[2]=s*e[8+u]-n*e[24+u]+o*e[40+u]+i*e[56+u],h[3]=o*e[8+u]-s*e[24+u]+i*e[40+u]-n*e[56+u],d[0]=t*(e[u]+e[32+u]),d[3]=t*(e[u]-e[32+u]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[0+u]=c[0]+h[0],e[8+u]=c[1]+h[1],e[16+u]=c[2]+h[2],e[24+u]=c[3]+h[3],e[32+u]=c[3]-h[3],e[40+u]=c[2]-h[2],e[48+u]=c[1]-h[1],e[56+u]=c[0]-h[0]}function S(e){for(let t=0;t<64;++t){const n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function M(e,n,r){for(let s=0;s<64;++s)n[r+s]=rt.toHalfFloat((i=e[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(t,Math.abs(i)-1));var i}function T(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function P(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(y(t)),r=new Uint8Array(n.length);return v(n),b(n,r),new DataView(r.buffer)}function A(e){const t=so(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return v(t),b(t,n),new DataView(n.buffer)}function E(e){const t=e.viewer,n={value:e.offset.value},r=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),i=new Uint8Array(8192);let s=0;const a=new Array(e.channels);for(let t=0;t<e.channels;t++)a[t]={},a[t].start=s,a[t].end=a[t].start,a[t].nx=e.width,a[t].ny=e.lines,a[t].size=e.type,s+=a[t].nx*a[t].ny*a[t].size;const o=G(t,n),l=G(t,n);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let e=0;e<l-o+1;e++)i[e+o]=U(t,n);const h=new Uint16Array(65536),d=function(e,t){let n=0;for(let r=0;r<65536;++r)(0==r||e[r>>3]&1<<(7&r))&&(t[n++]=r);const r=n-1;for(;n<65536;)t[n++]=0;return r}(i,h),c=L(t,n);_(e.array,t,n,c,r,s);for(let t=0;t<e.channels;++t){const e=a[t];for(let n=0;n<a[t].size;++n)f(r,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,d)}!function(e,t,n){for(let r=0;r<n;++r)t[r]=e[t[r]]}(h,r,s);let u=0;const p=new Uint8Array(r.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.channels;t++){const e=a[t],n=e.nx*e.size,i=new Uint8Array(r.buffer,2*e.end,2*n);p.set(i,u),u+=2*n,e.end+=n}return new DataView(p.buffer)}function R(e){const t=so(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.lines*e.channels*e.width,r=1==e.type?new Uint16Array(n):new Uint32Array(n);let i=0,s=0;const a=new Array(4);for(let n=0;n<e.lines;n++)for(let n=0;n<e.channels;n++){let n=0;switch(e.type){case 1:a[0]=i,a[1]=a[0]+e.width,i=a[1]+e.width;for(let i=0;i<e.width;++i)n+=t[a[0]++]<<8|t[a[1]++],r[s]=n,s++;break;case 2:a[0]=i,a[1]=a[0]+e.width,a[2]=a[1]+e.width,i=a[2]+e.width;for(let i=0;i<e.width;++i)n+=t[a[0]++]<<24|t[a[1]++]<<16|t[a[2]++]<<8,r[s]=n,s++}}return new DataView(r.buffer)}function I(e){const t=e.viewer,n={value:e.offset.value},r=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),i={version:F(t,n),unknownUncompressedSize:F(t,n),unknownCompressedSize:F(t,n),acCompressedSize:F(t,n),dcCompressedSize:F(t,n),rleCompressedSize:F(t,n),rleUncompressedSize:F(t,n),rleRawSize:F(t,n),totalAcUncompressedCount:F(t,n),totalDcUncompressedCount:F(t,n),acCompression:F(t,n)};if(i.version<2)throw new Error("EXRLoader.parse: "+q.compression+" version "+i.version+" is unsupported");const s=new Array;let a=G(t,n)-2;for(;a>0;){const e=D(t.buffer,n),r=U(t,n),i=r>>2&3,o=new Int8Array([(r>>4)-1])[0],l=U(t,n);s.push({name:e,index:o,type:l,compression:i}),a-=e.length+3}const o=q.channels,l=new Array(e.channels);for(let t=0;t<e.channels;++t){const n=l[t]={},r=o[t];n.name=r.name,n.compression=0,n.decoded=!1,n.type=r.pixelType,n.pLinear=r.pLinear,n.width=e.width,n.height=e.lines}const h={idx:new Array(3)};for(let t=0;t<e.channels;++t){const e=l[t];for(let n=0;n<s.length;++n){const r=s[n];e.name==r.name&&(e.compression=r.compression,r.index>=0&&(h.idx[r.index]=t),e.offset=t)}}let d,c,u;if(i.acCompressedSize>0)switch(i.acCompression){case 0:d=new Uint16Array(i.totalAcUncompressedCount),_(e.array,t,n,i.acCompressedSize,d,i.totalAcUncompressedCount);break;case 1:const r=so(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));d=new Uint16Array(r.buffer),n.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){const t={array:e.array,offset:n,size:i.dcCompressedSize};c=new Uint16Array(A(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(u=y(so(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0;const m=new Array(l.length);for(let e=0;e<m.length;++e)m[e]=new Array;for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)m[t].push(p),p+=l[t].width*e.type*2;!function(e,t,n,r,i,s){let a=new DataView(s.buffer);const o=n[e.idx[0]].width,l=n[e.idx[0]].height,h=Math.floor(o/8),d=Math.ceil(o/8),c=Math.ceil(l/8),u=o-8*(d-1),p=l-8*(c-1),m={value:0},g=new Array(3),f=new Array(3),_=new Array(3),v=new Array(3),w=new Array(3);for(let n=0;n<3;++n)w[n]=t[e.idx[n]],g[n]=n<1?0:g[n-1]+d*c,f[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(64*d);for(let t=0;t<c;++t){let s=8;t==c-1&&(s=p);let o=8;for(let e=0;e<d;++e){e==d-1&&(o=u);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[g[e]++],x(m,r,_[e]),b=_[e],(y=f[e])[0]=j(b[0]),y[1]=j(b[1]),y[2]=j(b[5]),y[3]=j(b[6]),y[4]=j(b[14]),y[5]=j(b[15]),y[6]=j(b[27]),y[7]=j(b[28]),y[8]=j(b[2]),y[9]=j(b[4]),y[10]=j(b[7]),y[11]=j(b[13]),y[12]=j(b[16]),y[13]=j(b[26]),y[14]=j(b[29]),y[15]=j(b[42]),y[16]=j(b[3]),y[17]=j(b[8]),y[18]=j(b[12]),y[19]=j(b[17]),y[20]=j(b[25]),y[21]=j(b[30]),y[22]=j(b[41]),y[23]=j(b[43]),y[24]=j(b[9]),y[25]=j(b[11]),y[26]=j(b[18]),y[27]=j(b[24]),y[28]=j(b[31]),y[29]=j(b[40]),y[30]=j(b[44]),y[31]=j(b[53]),y[32]=j(b[10]),y[33]=j(b[19]),y[34]=j(b[23]),y[35]=j(b[32]),y[36]=j(b[39]),y[37]=j(b[45]),y[38]=j(b[52]),y[39]=j(b[54]),y[40]=j(b[20]),y[41]=j(b[22]),y[42]=j(b[33]),y[43]=j(b[38]),y[44]=j(b[46]),y[45]=j(b[51]),y[46]=j(b[55]),y[47]=j(b[60]),y[48]=j(b[21]),y[49]=j(b[34]),y[50]=j(b[37]),y[51]=j(b[47]),y[52]=j(b[50]),y[53]=j(b[56]),y[54]=j(b[59]),y[55]=j(b[61]),y[56]=j(b[35]),y[57]=j(b[36]),y[58]=j(b[48]),y[59]=j(b[49]),y[60]=j(b[57]),y[61]=j(b[58]),y[62]=j(b[62]),y[63]=j(b[63]),C(f[e]);S(f);for(let t=0;t<3;++t)M(f[t],v[t],64*e)}let l=0;for(let r=0;r<3;++r){const i=n[e.idx[r]].type;for(let e=8*t;e<8*t+s;++e){l=w[r][e];for(let t=0;t<h;++t){const n=64*t+8*(7&e);a.setUint16(l+0*i,v[r][n+0],!0),a.setUint16(l+2*i,v[r][n+1],!0),a.setUint16(l+4*i,v[r][n+2],!0),a.setUint16(l+6*i,v[r][n+3],!0),a.setUint16(l+8*i,v[r][n+4],!0),a.setUint16(l+10*i,v[r][n+5],!0),a.setUint16(l+12*i,v[r][n+6],!0),a.setUint16(l+14*i,v[r][n+7],!0),l+=16*i}}if(h!=d)for(let e=8*t;e<8*t+s;++e){const t=w[r][e]+8*h*2*i,n=64*h+8*(7&e);for(let e=0;e<o;++e)a.setUint16(t+2*e*i,v[r][n+e],!0)}}}var b,y;const T=new Uint16Array(o);a=new DataView(s.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;const r=n[e.idx[t]].type;if(2==n[t].type)for(let e=0;e<l;++e){const n=w[t][e];for(let e=0;e<o;++e)T[e]=a.getUint16(n+2*e*r,!0);for(let e=0;e<o;++e)a.setFloat32(n+2*e*r,j(T[e]),!0)}}}(h,m,l,d,c,r);for(let t=0;t<l.length;++t){const n=l[t];if(!n.decoded)switch(n.compression){case 2:let i=0,s=0;for(let a=0;a<e.lines;++a){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)r[e++]=u[s+t*n.width*n.height];s++}i++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(r.buffer)}function D(e,t){const n=new Uint8Array(e);let r=0;for(;0!=n[t.value+r];)r+=1;const i=(new TextDecoder).decode(n.slice(t.value,t.value+r));return t.value=t.value+r+1,i}function O(e,t){const n=e.getInt32(t.value,!0);return t.value=t.value+4,n}function L(e,t){const n=e.getUint32(t.value,!0);return t.value=t.value+4,n}function k(e,t){const n=e[t.value];return t.value=t.value+1,n}function U(e,t){const n=e.getUint8(t.value);return t.value=t.value+1,n}const F=function(e,t){let n;return n="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function N(e,t){const n=e.getFloat32(t.value,!0);return t.value+=4,n}function B(e,t){return rt.toHalfFloat(N(e,t))}function j(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function H(e,t){return j(G(e,t))}function z(e,t,n,r,i){return"string"===r||"stringvector"===r||"iccProfile"===r?function(e,t,n){const r=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,r}(t,n,i):"chlist"===r?function(e,t,n,r){const i=n.value,s=[];for(;n.value<i+r-1;){const r=D(t,n),i=O(e,n),a=U(e,n);n.value+=3;const o=O(e,n),l=O(e,n);s.push({name:r,pixelType:i,pLinear:a,xSampling:o,ySampling:l})}return n.value+=1,s}(e,t,n,i):"chromaticities"===r?function(e,t){return{redX:N(e,t),redY:N(e,t),greenX:N(e,t),greenY:N(e,t),blueX:N(e,t),blueY:N(e,t),whiteX:N(e,t),whiteY:N(e,t)}}(e,n):"compression"===r?function(e,t){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][U(e,t)]}(e,n):"box2i"===r?function(e,t){return{xMin:L(e,t),yMin:L(e,t),xMax:L(e,t),yMax:L(e,t)}}(e,n):"lineOrder"===r?function(e,t){return["INCREASING_Y"][U(e,t)]}(e,n):"float"===r?N(e,n):"v2f"===r?function(e,t){return[N(e,t),N(e,t)]}(e,n):"v3f"===r?function(e,t){return[N(e,t),N(e,t),N(e,t)]}(e,n):"int"===r?O(e,n):"rational"===r?function(e,t){return[O(e,t),L(e,t)]}(e,n):"timecode"===r?function(e,t){return[L(e,t),L(e,t)]}(e,n):"preview"===r?(n.value+=i,"skipped"):void(n.value+=i)}const V=new DataView(e),W=new Uint8Array(e),K={value:0},q=function(e,t,n){const r={};if(20000630!=e.getUint32(0,!0))throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");r.version=e.getUint8(4);const i=e.getUint8(5);r.spec={singleTile:!!(2&i),longName:!!(4&i),deepFormat:!!(8&i),multiPart:!!(16&i)},n.value=8;let s=!0;for(;s;){const i=D(t,n);if(0==i)s=!1;else{const s=D(t,n),a=z(e,t,n,s,L(e,n));void 0===a?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${s}'.`):r[i]=a}}if(0!=(-5&i))throw console.error("THREE.EXRHeader:",r),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return r}(V,e,K),X=function(e,t,n,r,i){const s={size:0,viewer:t,array:n,offset:r,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,channels:e.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:e.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:w};switch(e.compression){case"NO_COMPRESSION":s.lines=1,s.uncompress=T;break;case"RLE_COMPRESSION":s.lines=1,s.uncompress=P;break;case"ZIPS_COMPRESSION":s.lines=1,s.uncompress=A;break;case"ZIP_COMPRESSION":s.lines=16,s.uncompress=A;break;case"PIZ_COMPRESSION":s.lines=32,s.uncompress=E;break;case"PXR24_COMPRESSION":s.lines=16,s.uncompress=R;break;case"DWAA_COMPRESSION":s.lines=32,s.uncompress=I;break;case"DWAB_COMPRESSION":s.lines=256,s.uncompress=I;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}if(s.scanlineBlockSize=s.lines,1==s.type)switch(i){case et:s.getter=H,s.inputSize=2;break;case $e:s.getter=G,s.inputSize=2}else{if(2!=s.type)throw new Error("EXRLoader.parse: unsupported pixelType "+s.type+" for "+e.compression+".");switch(i){case et:s.getter=N,s.inputSize=4;break;case $e:s.getter=B,s.inputSize=4}}s.blockCount=(e.dataWindow.yMax+1)/s.scanlineBlockSize;for(let e=0;e<s.blockCount;e++)F(t,r);s.outputChannels=3==s.channels?4:s.channels;const a=s.width*s.height*s.outputChannels;switch(i){case et:s.byteArray=new Float32Array(a),s.channels<s.outputChannels&&s.byteArray.fill(1,0,a);break;case $e:s.byteArray=new Uint16Array(a),s.channels<s.outputChannels&&s.byteArray.fill(15360,0,a);break;default:console.error("THREE.EXRLoader: unsupported type: ",i)}return s.bytesPerLine=s.width*s.inputSize*s.channels,4==s.outputChannels?(s.format=be,s.colorSpace=w):(s.format=tt,s.colorSpace=nt),s}(q,V,W,K,this.type),Q={value:0},Y={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<X.height/X.scanlineBlockSize;e++){const t=L(V,K);X.size=L(V,K),X.lines=t+X.scanlineBlockSize>X.height?X.height-t:X.scanlineBlockSize;const n=X.size<X.lines*X.bytesPerLine?X.uncompress(X):T(X);K.value+=X.size;for(let t=0;t<X.scanlineBlockSize;t++){const r=t+e*X.scanlineBlockSize;if(r>=X.height)break;for(let e=0;e<X.channels;e++){const i=Y[q.channels[e].name];for(let s=0;s<X.width;s++){Q.value=(t*(X.channels*X.width)+e*X.width+s)*X.inputSize;const a=(X.height-1-r)*(X.width*X.outputChannels)+s*X.outputChannels+i;X.byteArray[a]=X.getter(n,Q)}}}}return{header:q,width:X.width,height:X.height,data:X.byteArray,format:X.format,colorSpace:X.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){e.colorSpace=n.colorSpace,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}),n,r)}}class lo extends Je{constructor(e){super(e),this.type=$e}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},n=function(e,t,n){t=t||1024;let r=e.pos,i=-1,s=0,a="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(i=o.indexOf("\n"))&&s<t&&r<e.byteLength;)a+=o,s+=o.length,r+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=s+i+1),a+o.slice(0,i))},r=function(e,t,n,r){const i=e[t+3],s=Math.pow(2,i-128)/255;n[r+0]=e[t+0]*s,n[r+1]=e[t+1]*s,n[r+2]=e[t+2]*s,n[r+3]=1},i=function(e,t,n,r){const i=e[t+3],s=Math.pow(2,i-128)/255;n[r+0]=rt.toHalfFloat(Math.min(e[t+0]*s,65504)),n[r+1]=rt.toHalfFloat(Math.min(e[t+1]*s,65504)),n[r+2]=rt.toHalfFloat(Math.min(e[t+2]*s,65504)),n[r+3]=rt.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const a=function(e){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,h;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(h=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=h[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(r))&&(o.gamma=parseFloat(h[1])),(h=l.match(i))&&(o.exposure=parseFloat(h[1])),(h=l.match(s))&&(o.valid|=2,o.format=h[1]),(h=l.match(a))&&(o.valid|=4,o.height=parseInt(h[1],10),o.width=parseInt(h[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,h=function(e,n,r){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const s=new Uint8Array(4*n*r);s.length||t(4,"unable to allocate buffer space");let a=0,o=0;const l=4*i,h=new Uint8Array(4),d=new Uint8Array(l);let c=r;for(;c>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==i||t(3,"bad rgbe scanline format");let n,r=0;for(;r<l&&o<e.byteLength;){n=e[o++];const i=n>128;if(i&&(n-=128),(0===n||r+n>l)&&t(3,"bad scanline data"),i){const t=e[o++];for(let e=0;e<n;e++)d[r++]=t}else d.set(e.subarray(o,o+n),r),r+=n,o+=n}const u=i;for(let e=0;e<u;e++){let t=0;s[a]=d[e+t],t+=i,s[a+1]=d[e+t],t+=i,s[a+2]=d[e+t],t+=i,s[a+3]=d[e+t],a+=4}c--}return s}(s.subarray(s.pos),o,l);let d,c,u;switch(this.type){case et:u=h.length/4;const e=new Float32Array(4*u);for(let t=0;t<u;t++)r(h,4*t,e,4*t);d=e,c=et;break;case $e:u=h.length/4;const t=new Uint16Array(4*u);for(let e=0;e<u;e++)i(h,4*e,t,4*e);d=t,c=$e;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:o,height:l,data:d,header:a.string,gamma:a.gamma,exposure:a.exposure,type:c}}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){switch(e.type){case et:case $e:e.colorSpace=w,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,r)}}const ho={uniforms:{tDiffuse:{value:null},colorTransform:{value:new S},colorBase:{value:new st(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new at}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = colorTransform * texture2D(tDiffuse, vUv) + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n gl_FragColor = color;\n }"},co=new S,uo=(new S).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),po=(new S).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),mo=(new S).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),go=(new S).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),fo=new st(0,0,0,0),_o=new st(0,0,0,1),vo=new at,wo=(new at).set(1,0,0,0,-1,1,0,0,1),bo=(e,t,n,r)=>(new S).set(e,0,0,1-e,0,t,0,1-t,0,0,n,1-n,0,0,0,r);var yo;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ADDITIVE=1]="ADDITIVE"}(yo||(yo={}));class xo extends ot{constructor(e,t=yo.ADDITIVE){const n=t===yo.ADDITIVE?{blendSrc:lt,blendDst:ht,blendEquation:dt,blendSrcAlpha:ct,blendDstAlpha:ht,blendEquationAlpha:dt}:{};super({uniforms:ut.clone(ho.uniforms),vertexShader:ho.vertexShader,fragmentShader:ho.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,...n}),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const Co={uniforms:{tDiffuse:{value:null},rangeMin:{value:new s(1/512,1/512)},rangeMax:{value:new s(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new s(.1,.9),new s(.1,.9);class So extends ot{constructor(e){super({defines:Object.assign({},So._linearDepthShader.defines),uniforms:ut.clone(So._linearDepthShader.uniforms),vertexShader:So._linearDepthShader.vertexShader,fragmentShader:So._linearDepthShader.fragmentShader,blending:pt}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}So._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new st(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include <packing>\n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class Mo extends ot{constructor(e){var t;super({defines:Object.assign({...Mo._normalAndDepthShader.defines,FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0}),uniforms:ut.clone(Mo._normalAndDepthShader.uniforms),vertexShader:Mo._normalAndDepthShader.vertexShader,fragmentShader:Mo._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:pt}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}Mo._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};const To=new Y(-1,1,1,-1,0,1),Po=new class extends c{constructor(){super(),this.setAttribute("position",new Re([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Re([0,2,0,0,2,0],2))}};class Ao{constructor(e){this._mesh=new H(Po,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,To)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}new E;class Eo{constructor(){this.bounds=new ge(new a(-1,-1,-1),new a(1,1,1)),this.size=new a(2,2,2),this.center=new a(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new a(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Y?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof X&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),r=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const i=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),s=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=i/s,e.fov=Q.radToDeg(2*Math.atan2(s,n)),e.near=n,e.far=r,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}class Ro{changed(e){var t,n;const r=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),r}}class Io{constructor(){this._originalClearColor=new h,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new Ao(void 0),this._emptyScene=new Ce,this._defaultCamera=new X}renderWithOverrideMaterial(e,t,n,r,i,s,a){this._backup(e),this._prepareRenderer(e,i,s,a);const o=t.overrideMaterial;t.overrideMaterial=r,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,r){this._backup(e),this._prepareRenderer(e,t,n,r),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,r,i,s){this._backup(e),this._prepareRenderer(e,r,i,s),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,r,i){this._backup(e),this._prepareRenderer(e,n,r,i),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,r){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(r||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class Do{constructor(e,t){var n;this._renderPass=null!==(n=null==t?void 0:t._renderPass)&&void 0!==n?n:new Io,this._blurMaterial=new ot(null!=e?e:Co),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,r){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=r[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._renderPass.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=r[1],this._renderPass.renderScreenSpace(e,this._blurMaterial,t[2])}}class Oo{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse(e=>{var t,n,r;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(r=this._cache)||void 0===r||r.addObject(e)}),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class Lo{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach(e=>{e.dispose()})}registerCache(e,t){this._cacheMap.set(e,new Oo(t))}clearCache(){this._cacheMap.forEach(e=>{e.clear()})}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const r=this._cacheMap.get(e);r&&(r.update(t),r.onBeforeRender()),n(),r&&r.onAfterRender()}}class ko{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach((e,t)=>{t.visible=!1})}onAfterRender(){this._visibilityCache.forEach((e,t)=>{t.visible=e})}}class Uo{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof N&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!1})}onAfterRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!0})}}class Fo{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach((e,t)=>{this._updateObject(t,e.updateObjectData)})}onAfterRender(){this._objectCache.forEach((e,t)=>{this._updateObject(t,e.originalObjectData)})}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof H?e.receiveShadow:void 0,material:e instanceof H?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof H&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof H&&void 0!==t.material&&(e.material=t.material)}}class No{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatGBufferRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatGBufferRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatGBufferRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get normalRenderMaterial(){var e;return this._normalRenderMaterial=null!==(e=this._normalRenderMaterial)&&void 0!==e?e:this.floatGBufferRgbNormalAlphaDepth?new Mo({blending:pt,floatBufferType:!0,linearDepth:!1}):new mt({blending:pt}),this._normalRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatGBufferRgbNormalAlphaDepth)this._depthNormalRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:et,samples:this._samples});else{const e=new ft(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=_t,e.type=vt,this._depthNormalRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:et,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,r,i,s,a,o,l,h,d,c;this.floatGBufferRgbNormalAlphaDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.floatGBufferRgbNormalAlphaDepth=null!==(r=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==r&&r,this._renderCacheManager=e,this._renderCacheManager&&(this._gBufferMaterialCache=new Bo,this._renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(i=null==t?void 0:t.depthNormalScale)&&void 0!==i?i:1},this._targetMinificationTextureFilter=null!==(s=null==t?void 0:t.textureMinificationFilter)&&void 0!==s?s:ne,this._targetMagnificationTextureFilter=null!==(a=null==t?void 0:t.textureMagnificationFilter)&&void 0!==a?a:ne,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(h=null==t?void 0:t.samples)&&void 0!==h?h:0,this._shared=null!==(d=null==t?void 0:t.shared)&&void 0!==d&&d,this._renderPass=null!==(c=null==t?void 0:t.renderPass)&&void 0!==c?c:new Io}dispose(){var e,t;null===(e=this._normalRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}render(e,t,n){if(this._shared&&!this.needsUpdate)return;this.needsUpdate=!1;const r=this.normalRenderMaterial;r instanceof Mo&&r.update({camera:n}),this._renderCacheManager?this._renderCacheManager.render(this,t,()=>{this._renderGBuffer(e,t,n)}):this._renderGBuffer(e,t,n),this.floatGBufferRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget)}_renderGBuffer(e,t,n){this._renderPass.renderWithOverrideMaterial(e,t,n,this.normalRenderMaterial,this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new xo),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:pt,colorTransform:po,colorBase:_o,multiplyChannels:0,uvTransform:vo}),this.separateDeptRenderTarget)}}class Bo extends Fo{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!1}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof U&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof C&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class jo{constructor(e,t,n){var r;this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=t,this.shadowMapSize=null!==(r=n.shadowMapSize)&&void 0!==r?r:2048,this.parameters=this._getDefaultParameters(n),this._groundShadowFar=this.parameters.cameraFar,this._renderer=e,this._renderCacheManager=null==n?void 0:n._renderCacheManager,this._renderCacheManager&&this._renderCacheManager.registerCache(this,new ko(e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name))),this.renderTarget=new gt(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new gt(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this.shadowGroundPlane=new Go(this.renderTarget.texture,this.parameters),this._groundGroup.add(this.shadowGroundPlane),this._groundContactCamera=new Ho,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new yt,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",Go.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=B,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new Do(Co,n),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return{enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:20,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0,...e}}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFar<e.size.z&&(this._groundShadowFar=1.01*e.size.z);const r=Math.max(e.size.x,e.size.z);this.parameters.planeSize=r+2*Math.max(this._blurScale,null!==(n=this._shadowScale)&&void 0!==n?n:1,1),this.parameters.planeSize>this.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibility(e,t){this.shadowGroundPlane.updateVisibility(e)}render(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,e),this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(e),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this._renderCacheManager?this._renderCacheManager.render(this,e,()=>{this._renderer.render(e,this._groundContactCamera)}):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}jo.addTestMesh=!1;class Go extends H{constructor(e,t){const n=new y({transparent:!0,depthWrite:!1});Go.alphaMap&&n.color.set(0),n.polygonOffset=!0,super(new wt(1,1,10,10),n),this.name="GroundContactShadowPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.visible?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;t.map=e,Go.alphaMap&&(t.alphaMap=e),t.needsUpdate=!0}updateMaterial(e){const t=this.material;t.opacity!==e.opacity&&(t.opacity=e.opacity),t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset)}updateVisibility(e){e?this.layers.enableAll():this.layers.disableAll()}}Go.alphaMap=!1;class Ho extends Y{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,r,i;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new bt(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(r=this.cameraHelper)||void 0===r?void 0:r.parent)&&(null===(i=this.cameraHelper)||void 0===i||i.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}const zo={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},Vo={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new s(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\tprecision highp float;\n\n\tuniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t//----------------------------------------------------------------------------------\n\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t// SDK Version: v3.00\n\t// Email: gameworks@nvidia.com\n\t// Site: http://developer.nvidia.com/\n\t//\n\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t//\n\t// Redistribution and use in source and binary forms, with or without\n\t// modification, are permitted provided that the following conditions\n\t// are met:\n\t// * Redistributions of source code must retain the above copyright\n\t// notice, this list of conditions and the following disclaimer.\n\t// * Redistributions in binary form must reproduce the above copyright\n\t// notice, this list of conditions and the following disclaimer in the\n\t// documentation and/or other materials provided with the distribution.\n\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t// contributors may be used to endorse or promote products derived\n\t// from this software without specific prior written permission.\n\t//\n\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t//\n\t//----------------------------------------------------------------------------------\n\n\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t#endif\n\n\t/*--------------------------------------------------------------------------*/\n\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t/*--------------------------------------------------------------------------*/\n\n\t#define NUM_SAMPLES 5\n\n\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t}\n\n\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t============================================================================*/\n\n\t/*--------------------------------------------------------------------------*/\n\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t\t// locate the edge\n\t\t\t\t\tvec2 dirToEdge;\n\t\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t\t// . 2 . . 1 .\n\t\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t\t// . 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 H\n\n\t\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t\t// V 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 .\n\n\t\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t\t\t// 1 1 .\n\t\t\t\t\t\t\t// 0 0 1\n\t\t\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t\t\t// do a simple blur\n\t\t\t\t\t\t\treturn mix(\n\t\t\t\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t\t\t\t.4\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\t\titerationsUsed = i;\n\n\t\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\t\tif(!doneN) {\n\t\t\t\t\t\t\tnDist += increment;\n\t\t\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(!doneP) {\n\t\t\t\t\t\t\tpDist += increment;\n\t\t\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\t\trgbaM,\n\t\t\t\t\trgbaN,\n\t\t\t\t\tdist * .5\n\t\t\t);\n\t}\n\n\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\t\tvUv,\n\t\t\t\t\ttDiffuse,\n\t\t\t\t\tresolution,\n\t\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t}\n\t"};class Wo extends class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}{constructor(e,t,n,r,i){var a;super(),this.patternTexture=null,this._gBufferRenderTarget=null==i?void 0:i._gBufferRenderTarget,this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new h(1,1,1),this.hiddenEdgeColor=new h(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==i?void 0:i.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==i?void 0:i.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==e?new s(e.x,e.y):new s(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this._gBufferRenderTarget||(this.depthMaterial=new yt,this.depthMaterial.side=B,this.depthMaterial.depthPacking=xt,this.depthMaterial.blending=pt),this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=B,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this._gBufferRenderTarget||(this.renderTargetDepthBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new ot(Vo),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new gt(o,l),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new gt(o,l),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new gt(Math.round(o/2),Math.round(l/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new gt(o,l),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new gt(Math.round(o/2),Math.round(l/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(o,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const d=zo;this.copyUniforms=ut.clone(d.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ot({uniforms:this.copyUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:pt,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new h,this.oldClearAlpha=1,this.fsQuad=new Ao(void 0),this.tempPulseColor1=new h,this.tempPulseColor2=new h,this.textureMatrix=new S}dispose(){var e,t,n,r;this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),null===(t=this.renderTargetDepthBuffer)||void 0===t||t.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),null===(n=this.depthMaterial)||void 0===n||n.dispose(),this.prepareMaskMaterial.dispose(),null===(r=this.fxaaRenderMaterial)||void 0===r||r.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,r,i;this.renderTargetMaskBuffer.setSize(e,t),null===(n=this.renderTargetDepthBuffer)||void 0===n||n.setSize(e,t);let s=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(s,a),this.renderTargetBlurBuffer1.setSize(s,a),this.renderTargetEdgeBuffer1.setSize(s,a),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),s=Math.round(s/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(s,a),this.renderTargetEdgeBuffer2.setSize(s,a),this.separableBlurMaterial2.uniforms.texSize.value.set(s,a),null===(r=this.fxaaRenderMaterial)||void 0===r||r.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(i=this.renderTargetFxaaBuffer)||void 0===i||i.setSize(e,t)}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;function n(n){n.isMesh&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}this.selectedObjects.forEach(e=>e.traverse(n))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];function r(e){e.isMesh&&n.push(e)}this.selectedObjects.forEach(e=>e.traverse(r)),this.renderScene.traverse((function(r){if(r.isMesh||r.isSprite){if(!1===n.some(e=>e.id===r.id)){const n=r.visible;!1!==e&&!0!==t.get(r)||(r.visible=e),t.set(r,n)}}else(r.isPoints||r.isLine)&&(!0===e?r.visible=t.get(r):(t.set(r,r.visible),r.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,r,i){var s,a;if(this.selectedObjects.length>0){null===(s=this._gBufferRenderTarget)||void 0===s||s.render(e,this.renderScene,this.renderCamera),e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;e.autoClear=!1,i&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const r=this.renderScene.background;this.renderScene.background=null,this.renderTargetDepthBuffer&&this.depthMaterial&&(this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera)),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this._gBufferRenderTarget?this.prepareMaskMaterial.uniforms.depthTexture.value=this._gBufferRenderTarget.textureWithDepthValue:this.prepareMaskMaterial.uniforms.depthTexture.value=null===(a=this.renderTargetDepthBuffer)||void 0===a?void 0:a.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=r;let o=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),o=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=o.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Wo.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Wo.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Wo.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Wo.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=o.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}_getPrepareMaskMaterial(e){return new ot({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new s(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new ot({uniforms:{maskTexture:{value:null},texSize:{value:new s(.5,.5)},visibleEdgeColor:{value:new a(1,1,1)},hiddenEdgeColor:{value:new a(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new ot({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new s(.5,.5)},direction:{value:new s(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new ot({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:Ct,depthTest:!1,depthWrite:!1,transparent:!0})}}Wo.BlurDirectionX=new s(1,0),Wo.BlurDirectionY=new s(0,1);class Ko{get isOutlinePassActivated(){return this.outlinePassActivated}constructor(e,t,n,r){this._width=0,this._height=0,this._effectComposer=null,this.outlinePass=null,this.outlinePassActivated=!1,this._effectComposer=e,this._gBufferRenderTarget=null==r?void 0:r._gBufferRenderTarget,this._width=t,this._height=n,this.parameters={enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215,...r}}dispose(){var e;null===(e=this.outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this.outlinePass)||void 0===n||n.setSize(e,t)}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const r=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!r&&this.outlinePassActivated||(!r&&this.outlinePass||(this.outlinePass=new Wo(new s(this._width,this._height),e,t,[],{downSampleRatio:2,edgeDetectionFxaa:!0,_gBufferRenderTarget:this._gBufferRenderTarget})),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class qo extends V{constructor(e,t){const n=new c;n.setAttribute("position",new Re([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new F({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=new c;r.setAttribute("position",new Re([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new H(r,new y({side:St,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}var Xo;!function(e){e[e.DirectionalLightShadow=0]="DirectionalLightShadow",e[e.SpotLightShadow=1]="SpotLightShadow"}(Xo||(Xo={}));const Qo={alwaysUpdate:!1,enableShadowMap:!0,layers:null,shadowLightSourceType:Xo.DirectionalLightShadow,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundContainment:1,fadeOutDistance:.1,fadeOutBlur:20};class Yo{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var r,i;this.needsUpdate=!1,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new tl,this._shadowLightSources=[],this._shadowScale=1,this._renderPass=new Io,this._cameraUpdate=new Ro,this._renderCacheManager=e,this._viewportSize=new s(t.x,t.y),this._samples=null!==(r=null==n?void 0:n.samples)&&void 0!==r?r:0,this._shadowMapSize=null!==(i=null==n?void 0:n.shadowMapSize)&&void 0!==i?i:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new el(this.parameters),this._renderCacheManager.registerCache(this,this._shadowMapPassOverrideMaterialCache);const a=this._samples;this._shadowRenderTarget=new gt(this._viewportSize.x,this._viewportSize.y,{samples:a,format:tt})}_getScreenSpaceShadowMapParameters(e){return{...Qo,...e}}dispose(){this._shadowLightSources.forEach(e=>e.dispose()),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){const n=this._shadowScale;this._shadowScale=t,Math.abs(n-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach(t=>t.updateBounds(e)),this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach(e=>e.forceShadowUpdate()),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map(e=>e.getShadowLight())}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find(t=>t.getOriginalLight()===e))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new rl(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){this._shadowLightSources=this._shadowLightSources.filter(n=>{if(n instanceof rl){const t=n.getRectAreaLight();if(e.includes(t))return n.updatePositionAndTarget(),!0}return n.removeFrom(t),n.dispose(),!1}),e.forEach(e=>{this._shadowLightSources.find(t=>t instanceof rl&&t.getRectAreaLight()===e)||this.addRectAreaLight(e,t)}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){this._shadowLightSources=this._shadowLightSources.filter(t=>{t.removeFrom(e),t.dispose()});const n=1/(t.length>0?Math.max(...t.map(e=>e.maxIntensity)):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach(t=>{t.addTo(e),t.updatePositionAndTarget()}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach(e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new a(e.position.x,e.position.z,e.position.y).multiplyScalar(7),r=new il(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(r)}})}setSize(e,t){this._viewportSize=new s(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach(e=>e.updatePositionAndTarget())}renderShadowMap(e,t,n){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(n)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const r=t.background,i=t.environment,s=n.layers.mask;t.environment=null,t.background=null,this.parameters.layers&&(n.layers.mask=this.parameters.layers.mask),this._renderSimpleShadowMapFromShadowLightSources(e,t,n),n.layers.mask=s,t.environment=i,t.background=r}_renderSimpleShadowMapFromShadowLightSources(e,t,n){this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundContainment,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const r=this._getSortedShadowLightSources();0===r.length?this._renderPass.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(r),this._renderCacheManager.render(this,t,()=>{this._renderPass.render(e,t,n,this._shadowRenderTarget,16777215,1)}),this._shadowLightSources.forEach(e=>e.finishRenderShadow()))}_getSortedShadowLightSources(){let e=[];return this._shadowLightSources.forEach(t=>e.push(...t.prepareRenderShadow())),e.sort((e,t)=>e.light.castShadow&&!t.light.castShadow?-1:!e.light.castShadow&&t.light.castShadow?1:t.intensity-e.intensity),e}_setShadowLightSourcesIntensity(e){var t;let n=0;for(let t=0;t<e.length;t++){const r=e[t];(this.parameters.maximumNumberOfLightSources<0||t<this.parameters.maximumNumberOfLightSources)&&(n+=r.intensity)}for(let r=0;r<e.length;r++){const i=e[r];this.parameters.maximumNumberOfLightSources<0||r<this.parameters.maximumNumberOfLightSources?(i.light.visible=!0,i.light.intensity=i.intensity/n,(t=i.light).castShadow&&(t.castShadow=this.castShadow)):(i.light.visible=!1,i.light.intensity=0,i.light.castShadow=!1)}}_updateShadowType(e){e.shadowMap.type=this.shadowConfiguration.currentConfiguration.type;const t=this.parameters.enableShadowMap&&this.shadowConfiguration.currentConfiguration.castShadow;e.shadowMap.enabled=t,e.shadowMap.needsUpdate=!0,this.castShadow=t&&this.shadowConfiguration.currentConfiguration.castShadow,this._shadowLightSources.forEach(e=>e._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}var Zo,Jo,$o;!function(e){e[e.Default=0]="Default",e[e.Unlit=1]="Unlit",e[e.Emissive=2]="Emissive",e[e.Shadow=3]="Shadow"}(Zo||(Zo={}));class el extends Fo{set shadowOnGround(e){this._shadowOnGround=e}constructor(e){var t,n;super(),this._boundingBoxSet=!1,this._sceneBoxMin=new a(-1,-1,-1),this._sceneBoxMax=new a(1,1,1),this._distributionProperties=new st(1,1,1,0),this._shadowOnGround=!0,this._shadowFadeOut=new s(null!==(t=null==e?void 0:e.fadeOutTo)&&void 0!==t?t:.5,null!==(n=null==e?void 0:e.fadeOutBlur)&&void 0!==n?n:60),this._shadowObjectMaterial=this._createShadowMaterial(Zo.Default),this._unlitMaterial=this._createShadowMaterial(Zo.Unlit),this._emissiveMaterial=this._createShadowMaterial(Zo.Emissive),this._receiveShadowMaterial=this._createShadowMaterial(Zo.Shadow)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,r,i){this._distributionProperties.set(e,t,n,0),this._shadowFadeOut.set(r,i)}setBoundingBox(e){this._boundingBoxSet=!0,this._sceneBoxMin.copy(e.min),this._sceneBoxMax.copy(e.max)}_createShadowMaterial(e){let t;return t=e===Zo.Emissive||e===Zo.Unlit?new y({color:16777215,side:B}):e===Zo.Shadow?new Et({side:B}):el.useModifiedMaterial?this._createCustomerShadowMaterial():new Rt({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:B}),t}_createCustomerShadowMaterial(){const e=new It({side:B});return e.onBeforeCompile=e=>{e.vertexShader="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n #include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\n vWorldPosition = worldPosition.xyz;\n}\n",e.fragmentShader="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n\n#include <common>\n#include <packing>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvec2 getShadowDynamicScale() {\n\n vec2 dynamicScale = vec2(0.0, 1.0);\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (shadowFadeOut.x > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n \n // linear interpolation gives better result than smooth Hermite interpolation\n // float shadowBase = smoothstep(0.0, shadowFadeOut.x, boxDistance);\n float shadowBase = boxDistance / shadowFadeOut.x;\n\n shadowBase = clamp(shadowBase, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n\n float dynamicRadius = shadowRadius;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && shadowFadeOut.x > 0.0) {\n float shadowDepth = unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy));\n float delta = shadowDepth - shadowCoord.z;\n float fadeOutScale = max(shadowScale.x, smoothstep(max(shadowDepth, 0.5), shadowFadeOut.x * 0.5 + 0.5, shadowCoord.z));\n dynamicRadius = shadowRadius + shadowFadeOut.y * max(0.0, fadeOutScale);\n }\n#endif\n\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include <logdepthbuf_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n IncidentLight directLight;\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n float groundContainment = mix(1.0, groundDistance, distributionProperties.z);\n vec2 dynamicScale = getShadowDynamicScale();\n #if ( NUM_DIR_LIGHTS > 0 )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n float dynamicRadius;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float shadowFactor;\n float dotNL;\n float incidentLightFactor;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightFactor = clamp(dotNL, 0.0, 1.0);\n\n dynamicRadius = 0.0;\n shadowFactor = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n incidentLightFactor = mix(\n mix(pow(incidentLightFactor, 4.0), 1.0, step(0.99, shadowFactor)),\n pow(incidentLightFactor, distributionProperties.y),\n groundContainment);\n incidentLightSum += directLight.color * mix(incidentLightFactor, 1.0, groundContainment);\n incidentShadowLight += directLight.color * mix(\n shadowFactor * incidentLightFactor, \n mix(1.0, shadowFactor, incidentLightFactor), \n groundContainment);\n }\n #pragma unroll_loop_end\n\n if (dot(incidentLightSum, vec3(1.0)) > 0.01) {\n directionDependentShadowLight = incidentShadowLight / incidentLightSum;\n }\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(distributionProperties.x, 1.0 - groundDistance));\n outgoingLight = dynamicScale.x + directionDependentShadowLight.y * outgoingLight;\n\n\t#include <opaque_fragment>\n\t#include <premultiplied_alpha_fragment>\n}\n",e.defines=Object.assign({...e.defines,DYNAMIC_SHADOW_RADIUS:""});const t=e.uniforms;t&&(t.distributionProperties={value:this._distributionProperties},t.shadowFadeOut={value:this._shadowFadeOut},t.sceneBoxMin={value:this._sceneBoxMin},t.sceneBoxMax={value:this._sceneBoxMax})},e}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof F||t instanceof y?this.addToCache(e,{material:this._unlitMaterial}):t instanceof N?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}el.useModifiedMaterial=!0;class tl{constructor(){var e;this.types=new Map([["off",tl._noShadow],["BasicShadowMap",tl._basicShadow],["PCFShadowMap",tl._pcfShadow],["PCFSoftShadowMap",tl._pcfSoftShadow],["VSMShadowMap",tl._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:tl._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:tl._defaultType,!0)}}tl._noShadow={castShadow:!1,type:Mt,bias:0,normalBias:0,radius:0},tl._basicShadow={castShadow:!0,type:Tt,bias:-5e-5,normalBias:.005,radius:0},tl._pcfShadow={castShadow:!0,type:Mt,bias:-5e-5,normalBias:.01,radius:4},tl._pcfSoftShadow={castShadow:!0,type:Pt,bias:-5e-5,normalBias:.01,radius:1},tl._vcmShadow={castShadow:!0,type:At,bias:1e-4,normalBias:0,radius:15},tl._defaultType=tl._pcfShadow;class nl{constructor(e,t){var n,r;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(r=null==t?void 0:t._blurSamples)&&void 0!==r?r:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new s(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new a(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof l){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),r=Math.max(.001,Math.min(-n.min.z,-n.max.z)),i=Math.max(-n.min.z,-n.max.z),s=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),a=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(a,s),r);t.aspect=1,t.near=r,t.far=i,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,r,i;if(this._shadowLightSource instanceof l){const n=t.clone().sub(e),r=n.length();n.normalize();const i=t.clone().sub(n.clone().multiplyScalar(4*r));this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(i),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.lookAt(t);null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class rl extends nl{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case Xo.DirectionalLightShadow:n=new i(16777215,1);break;case Xo.SpotLightShadow:n=new l(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new qo(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class il extends nl{constructor(e,t,n){const r=new i(16777215,t);r.position.copy(e),r.lookAt(0,0,0),r.updateMatrix(),r.castShadow=!0,super(r,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}!function(e){e[e.INPUT_RGB_NORMAL=0]="INPUT_RGB_NORMAL",e[e.FLOAT_BUFFER_NORMAL=1]="FLOAT_BUFFER_NORMAL",e[e.CONSTANT_Z=2]="CONSTANT_Z"}(Jo||(Jo={})),function(e){e[e.SEPARATE_BUFFER=0]="SEPARATE_BUFFER",e[e.NORMAL_VECTOR_ALPHA=1]="NORMAL_VECTOR_ALPHA"}($o||($o={}));class sl{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}noise(e,t){let n,r,i;const s=(e+t)*(.5*(Math.sqrt(3)-1)),a=Math.floor(e+s),o=Math.floor(t+s),l=(3-Math.sqrt(3))/6,h=(a+o)*l,d=e-(a-h),c=t-(o-h);let u,p;d>c?(u=1,p=0):(u=0,p=1);const m=d-u+l,g=c-p+l,f=d-1+2*l,_=c-1+2*l,v=255&a,w=255&o,b=this.perm[v+this.perm[w]]%12,y=this.perm[v+u+this.perm[w+p]]%12,x=this.perm[v+1+this.perm[w+1]]%12;let C=.5-d*d-c*c;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[b],d,c));let S=.5-m*m-g*g;S<0?r=0:(S*=S,r=S*S*this.dot(this.grad3[y],m,g));let M=.5-f*f-_*_;return M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[x],f,_)),70*(n+r+i)}noise3d(e,t,n){let r,i,s,a;const o=(e+t+n)*(1/3),l=Math.floor(e+o),h=Math.floor(t+o),d=Math.floor(n+o),c=(l+h+d)*(1/6),u=e-(l-c),p=t-(h-c),m=n-(d-c);let g,f,_,v,w,b;u>=p?p>=m?(g=1,f=0,_=0,v=1,w=1,b=0):u>=m?(g=1,f=0,_=0,v=1,w=0,b=1):(g=0,f=0,_=1,v=1,w=0,b=1):p<m?(g=0,f=0,_=1,v=0,w=1,b=1):u<m?(g=0,f=1,_=0,v=0,w=1,b=1):(g=0,f=1,_=0,v=1,w=1,b=0);const y=u-g+1/6,x=p-f+1/6,C=m-_+1/6,S=u-v+1/6*2,M=p-w+1/6*2,T=m-b+1/6*2,P=u-1+.5,A=p-1+.5,E=m-1+.5,R=255&l,I=255&h,D=255&d,O=this.perm[R+this.perm[I+this.perm[D]]]%12,L=this.perm[R+g+this.perm[I+f+this.perm[D+_]]]%12,k=this.perm[R+v+this.perm[I+w+this.perm[D+b]]]%12,U=this.perm[R+1+this.perm[I+1+this.perm[D+1]]]%12;let F=.6-u*u-p*p-m*m;F<0?r=0:(F*=F,r=F*F*this.dot3(this.grad3[O],u,p,m));let N=.6-y*y-x*x-C*C;N<0?i=0:(N*=N,i=N*N*this.dot3(this.grad3[L],y,x,C));let B=.6-S*S-M*M-T*T;B<0?s=0:(B*=B,s=B*B*this.dot3(this.grad3[k],S,M,T));let j=.6-P*P-A*A-E*E;return j<0?a=0:(j*=j,a=j*j*this.dot3(this.grad3[U],P,A,E)),32*(r+i+s+a)}noise4d(e,t,n,r){const i=this.grad4,s=this.simplex,a=this.perm,o=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20;let h,d,c,u,p;const m=(e+t+n+r)*o,g=Math.floor(e+m),f=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),w=(g+f+_+v)*l,b=e-(g-w),y=t-(f-w),x=n-(_-w),C=r-(v-w),S=(b>y?32:0)+(b>x?16:0)+(y>x?8:0)+(b>C?4:0)+(y>C?2:0)+(x>C?1:0),M=s[S][0]>=3?1:0,T=s[S][1]>=3?1:0,P=s[S][2]>=3?1:0,A=s[S][3]>=3?1:0,E=s[S][0]>=2?1:0,R=s[S][1]>=2?1:0,I=s[S][2]>=2?1:0,D=s[S][3]>=2?1:0,O=s[S][0]>=1?1:0,L=s[S][1]>=1?1:0,k=s[S][2]>=1?1:0,U=s[S][3]>=1?1:0,F=b-M+l,N=y-T+l,B=x-P+l,j=C-A+l,G=b-E+2*l,H=y-R+2*l,z=x-I+2*l,V=C-D+2*l,W=b-O+3*l,K=y-L+3*l,q=x-k+3*l,X=C-U+3*l,Q=b-1+4*l,Y=y-1+4*l,Z=x-1+4*l,J=C-1+4*l,$=255&g,ee=255&f,te=255&_,ne=255&v,re=a[$+a[ee+a[te+a[ne]]]]%32,ie=a[$+M+a[ee+T+a[te+P+a[ne+A]]]]%32,se=a[$+E+a[ee+R+a[te+I+a[ne+D]]]]%32,ae=a[$+O+a[ee+L+a[te+k+a[ne+U]]]]%32,oe=a[$+1+a[ee+1+a[te+1+a[ne+1]]]]%32;let le=.6-b*b-y*y-x*x-C*C;le<0?h=0:(le*=le,h=le*le*this.dot4(i[re],b,y,x,C));let he=.6-F*F-N*N-B*B-j*j;he<0?d=0:(he*=he,d=he*he*this.dot4(i[ie],F,N,B,j));let de=.6-G*G-H*H-z*z-V*V;de<0?c=0:(de*=de,c=de*de*this.dot4(i[se],G,H,z,V));let ce=.6-W*W-K*K-q*q-X*X;ce<0?u=0:(ce*=ce,u=ce*ce*this.dot4(i[ae],W,K,q,X));let ue=.6-Q*Q-Y*Y-Z*Z-J*J;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(i[oe],Q,Y,Z,J)),27*(h+d+c+u+p)}}const al={name:"HBAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,SAMPLE_VECTORS:ol(16),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0,COSINE_SAMPLE_HEMISPHERE:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new s},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new S},cameraProjectionMatrixInverse:{value:new S},radius:{value:2},distanceExponent:{value:1},bias:{value:.01}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float bias;\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\t// source: https://www.shadertoy.com/view/cll3R4\n\t\tvec3 cosineSampleHemisphere(const vec3 n, const vec2 u) {\n\t\t\tfloat r = sqrt(u.x);\n\t\t\tfloat theta = 2.0 * PI * u.y;\n\t\t\tvec3 b = normalize(cross(n, vec3(0.0, 1.0, 1.0)));\n\t\t\tvec3 t = cross(b, n);\n\t\t\treturn normalize(r * sin(theta) * b + sqrt(1.0 - u.x) * n + r * cos(theta) * t);\n\t\t}\n\t\t\n\t\tfloat getOcclusion(const vec2 uv, const vec3 viewPos, const vec3 viewNormal, const float depth, const vec4 sampleViewDir, inout float totalWeight) {\n\t\t\t\n\t\t\tvec3 sampleViewPos = viewPos + sampleViewDir.xyz * radius * pow(sampleViewDir.w, distanceExponent);\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tfloat distSample = abs(getViewZ(sampleDepth));\n\t\t\tfloat distWorld = abs(sampleViewPos.z);\n\t\t\tfloat distanceFalloffToUse = radius;\n\t\t\tfloat rangeCheck = smoothstep(0.0, 1.0, distanceFalloffToUse / (abs(distSample - distWorld)));\n\t\t\tfloat weight = dot(viewNormal, sampleViewDir.xyz);\n\t\t\tvec2 diff = (uv - sampleUv) * resolution;\n\t\t\tvec2 clipRangeCheck = step(0., sampleUv) * step(sampleUv, vec2(1.));\n\t\t\tfloat occlusion = rangeCheck * weight * step(distSample + bias, distWorld) * step(0.707, dot(diff, diff)) * clipRangeCheck.x * clipRangeCheck.y;\n\t\t\ttotalWeight += weight;\n\n\t\t\treturn occlusion;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth == 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n \t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\t\t\n\t\t\t\t#if COSINE_SAMPLE_HEMISPHERE == 1\n\t\t\t\t\tvec4 sampleNoise = noiseTexel;\n\t\t\t\t\tif (i != 0) {\n\t\t\t\t\t\tconst vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);\n\t\t\t\t\t\tsampleNoise = fract(sampleNoise + hn * float(i));\n\t\t\t\t\t\tsampleNoise = mix(sampleNoise, 1.0 - sampleNoise, step(0.5, sampleNoise)) * 2.0;\n\t\t\t\t\t}\n\t\t\t\t\tvec3 hemisphereDir = cosineSampleHemisphere( viewNormal, sampleNoise.rg );\n\t\t\t\t\tvec4 sampleViewDir = vec4(hemisphereDir, sampleNoise.b );\n\t\t\t\t#else\n\t\t\t\t\tvec4 sampleViewDir = sampleKernel[i];\n\t\t\t\t\tsampleViewDir.xyz = normalize(kernelMatrix * sampleViewDir.xyz);\n\t\t\t\t#endif\n\t\t\t\tfloat occlusion = getOcclusion(vUv, viewPos, viewNormal, depth, sampleViewDir, totalWeight);\n\t\t\t\tao += occlusion;\n\t\t\t}\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tao /= totalWeight;\n\t\t\t}\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function ol(e){const t=function(e){const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=.99-n/(e-1)*.9,s=Math.sqrt(1-i*i),a=Math.cos(r)*s,o=Math.sin(r)*s,l=8,h=Math.floor(e/l);let d=1-(Math.floor(n/l)+n%l*h)/e;d=.1+.9*d,t.push(new st(a,o,i,d))}return t}(e);let n="vec4[SAMPLES](";for(let r=0;r<e;r++){const i=t[r];n+=`vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})`,r<e-1&&(n+=",")}return n+=")",n}const ll={resolutionScale:1,samples:16,radius:.5,distanceExponent:1,bias:.01};class hl{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n){this.needsUpdate=!0,this.parameters={...ll},this._width=0,this._height=0,this._loaded=!1,this._normalVectorSourceType=Jo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=$o.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._renderPass=new Io,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Jo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||$o.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=(null==n?void 0:n.modulateRedChannel)||!1,(null==n?void 0:n.hbaoParameters)&&(this.parameters=n.hbaoParameters),n&&this.updateParameters(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new sl,n=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=r,a=i;n[4*(r*e+i)]=127.5*(t.noise(s,a)+1),n[4*(r*e+i)+1]=127.5*(t.noise(s+e,a)+1),n[4*(r*e+i)+2]=127.5*(t.noise(s,a+e)+1),n[4*(r*e+i)+3]=127.5*(t.noise(s+e,a+e)+1)}this._noiseTexture=new ye(n,e,e,be,Dt),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;this._hbaoMaterial||(this._hbaoMaterial=new ot({defines:Object.assign({},al.defines),uniforms:ut.clone(al.uniforms),vertexShader:al.vertexShader,fragmentShader:al.fragmentShader,depthTest:!1,depthWrite:!1}),this._modulateRedChannel&&(this._hbaoMaterial.blending=Ot,this._hbaoMaterial.blendEquation=Lt,this._hbaoMaterial.blendEquationAlpha=null,this._hbaoMaterial.blendSrc=kt,this._hbaoMaterial.blendSrcAlpha=null,this._hbaoMaterial.blendDst=kt,this._hbaoMaterial.blendDstAlpha=null),this._hbaoMaterial.defines.FRAGMENT_OUTPUT=this._modulateRedChannel?"vec4(ao, 1., 1., 1.)":void 0,this._hbaoMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&(this._hbaoMaterial.defines.PERSPECTIVE_CAMERA=e.isPerspectiveCamera?1:0,this._hbaoMaterial.defines.SAMPLES=this.parameters.samples,this._hbaoMaterial.defines.SAMPLE_VECTORS=ol(this.parameters.samples),this._hbaoMaterial.defines.NORMAL_VECTOR_TYPE=this._normalVectorSourceType===Jo.FLOAT_BUFFER_NORMAL?2:1,this._hbaoMaterial.defines.DEPTH_VALUE_SOURCE=this._depthValueSourceType===$o.NORMAL_VECTOR_ALPHA?1:0,this._hbaoMaterial.needsUpdate=!0);const r=this._depthValueSourceType===$o.NORMAL_VECTOR_ALPHA?this.normalTexture:this.depthTexture;this._hbaoMaterial.uniforms.tNormal.value=this.normalTexture,this._hbaoMaterial.uniforms.tDepth.value=r,this._hbaoMaterial.uniforms.resolution.value.set(this._width,this._height),this._hbaoMaterial.uniforms.cameraProjectionMatrix.value.copy(e.projectionMatrix),this._hbaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(e.projectionMatrixInverse);const i=e;return this._hbaoMaterial.uniforms.cameraNear.value=i.near,this._hbaoMaterial.uniforms.cameraFar.value=i.far,this._hbaoMaterial.uniforms.radius.value=this.parameters.radius,this._hbaoMaterial.uniforms.distanceExponent.value=this.parameters.distanceExponent,this._hbaoMaterial.uniforms.bias.value=this.parameters.bias,this._hbaoMaterial}_getRenderTargets(){return this._renderTarget||(this._renderTarget=new gt(this._width,this._height,{magFilter:D,minFilter:D})),this._renderTarget}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._hbaoMaterial)||void 0===t||t.dispose(),null===(n=this._renderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._renderTarget)||void 0===n||n.setSize(e,t),this.needsUpdate=!0}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0);e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t,n,r){const i=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._renderPass.renderScreenSpace(e,i,r||this._getRenderTargets())}}const dl={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:cl(16,4),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new s},cameraProjectionMatrixInverse:{value:new S},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:10},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec2 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\t\t\n\t\tfloat distToPlane(const vec3 viewPos, const vec3 neighborViewPos, const vec3 viewNormal) {\n\t\t\treturn abs(dot(viewPos - neighborViewPos, viewNormal));\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\t//vec2 noiseVec = normalize((index % 2 == 0 ? noiseTexel.xy : noiseTexel.yz) * 2.0 - 1.0);\n\t\t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec2 offset = rotationMatrix * (poissonDisk[i] * radius / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\n\t\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\t\n\t\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\n\t\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\n\t\t\t\tfloat depthDiff = 1. - distToPlane(viewPos, viewPosSample, viewNormal);\n\t\t\t\tfloat depthSimilarity = max(depthDiff / depthPhi, 0.);\n\t\t\n\t\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\t\tdenoised += w * neighborColor;\n\t\t\t\ttotalWeight += w;\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function cl(e,t){const n=function(e,t){const n=2*Math.PI*t/e,r=1/e,i=r,a=[];let o=r,l=0;for(let t=0;t<e;t++){const e=new s(Math.cos(l),Math.sin(l)).multiplyScalar(Math.pow(o,.75));a.push(e),o+=i,l+=n}return a}(e,t);let r="vec2[SAMPLES](";for(let t=0;t<e;t++){const i=n[t];r+=`vec2(${i.x}, ${i.y})`,t<e-1&&(r+=",")}return r+=")",r}const ul={iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:12,normalPhi:3.25,samples:16};class pl{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._renderTargets.length-1].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n){this.needsUpdate=!0,this.parameters={...ul},this._width=0,this._height=0,this._normalVectorSourceType=Jo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=$o.NORMAL_VECTOR_ALPHA,this._rgInputTexture=!0,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._renderPass=new Io,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Jo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||$o.NORMAL_VECTOR_ALPHA,this._rgInputTexture=(null==n?void 0:n.rgInputTexture)||!0,this._inputTexture=(null==n?void 0:n.inputTexture)||null,this.depthTexture=(null==n?void 0:n.depthTexture)||null,this.normalTexture=(null==n?void 0:n.normalTexture)||null,n.poissonDenoisePassParameters?this.parameters=n.poissonDenoisePassParameters:n&&this.updateParameters(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new sl,n=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=r,a=i;n[4*(r*e+i)]=127.5*(t.noise(s,a)+1),n[4*(r*e+i)+1]=127.5*(t.noise(s+e,a)+1),n[4*(r*e+i)+2]=127.5*(t.noise(s,a+e)+1),n[4*(r*e+i)+3]=127.5*(t.noise(s+e,a+e)+1)}this._noiseTexture=new ye(n,e,e,be,Dt),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;this._pdMaterial||(this._pdMaterial=new ot({defines:Object.assign({},dl.defines),uniforms:ut.clone(dl.uniforms),vertexShader:dl.vertexShader,fragmentShader:dl.fragmentShader,depthTest:!1,depthWrite:!1}),this._pdMaterial.defines.SAMPLE_LUMINANCE="(a.r * a.g)",this._pdMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&(this._pdMaterial.defines.SAMPLES=this.parameters.samples,this._pdMaterial.defines.SAMPLE_VECTORS=cl(this.parameters.samples,this.parameters.rings),this._pdMaterial.defines.NORMAL_VECTOR_TYPE=this._normalVectorSourceType===Jo.FLOAT_BUFFER_NORMAL?2:1,this._pdMaterial.defines.DEPTH_VALUE_SOURCE=this._depthValueSourceType===$o.NORMAL_VECTOR_ALPHA?1:0,this._pdMaterial.needsUpdate=!0);const r=this._depthValueSourceType===$o.NORMAL_VECTOR_ALPHA?this.normalTexture:this.depthTexture;return this._pdMaterial.uniforms.tDiffuse.value=this._inputTexture,this._pdMaterial.uniforms.tNormal.value=this.normalTexture,this._pdMaterial.uniforms.tDepth.value=r,this._pdMaterial.uniforms.resolution.value.set(this._width,this._height),this._pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(e.projectionMatrixInverse),this._pdMaterial.uniforms.lumaPhi.value=this.parameters.lumaPhi,this._pdMaterial.uniforms.depthPhi.value=this.parameters.depthPhi,this._pdMaterial.uniforms.normalPhi.value=this.parameters.normalPhi,this._pdMaterial.uniforms.radius.value=this.parameters.radius,this._pdMaterial}_getRenderTargets(){return this._renderTargets.length<2&&(this._renderTargets=[new gt(this._width,this._height,{magFilter:D,minFilter:D}),new gt(this._width,this._height,{magFilter:D,minFilter:D})]),this._renderTargets}dispose(){var e,t;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._pdMaterial)||void 0===t||t.dispose(),this._renderTargets.forEach(e=>e.dispose())}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach(n=>n.setSize(e,t)),this.needsUpdate=!0}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0);e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const r=this._getRenderTargets();for(let t=0;t<2*this.parameters.iterations;t++){const i=r[(t+1)%2],s=r[t%2];n.uniforms.tDiffuse.value=0===t?this._inputTexture:i.texture,n.uniforms.index.value=t,this._renderPass.renderScreenSpace(e,n,s,16777215,1)}}}var ml,gl;!function(e){e[e.OFF=0]="OFF",e[e.HARD=1]="HARD",e[e.POISSON=2]="POISSON",e[e.FULL=3]="FULL"}(ml||(ml={})),function(e){e[e.NONE=0]="NONE",e[e.SSAO=1]="SSAO",e[e.HBAO=2]="HBAO"}(gl||(gl={}));const fl={aoKernelRadius:.25,aoDepthBias:1e-4,aoMaxDistance:.5,aoMaxDepth:.99,aoFadeout:.5,shadowRadius:.05},_l={enabled:!0,aoType:gl.SSAO,aoIntensity:.5,shadowIntensity:.35,aoOnGround:!0,shadowOnGround:!1,alwaysUpdate:!1};class vl{get gBufferRenderTarget(){var e;return this._sharedGBufferRenderTarget?this._sharedGBufferRenderTarget:(this._gBufferRenderTarget=null!==(e=this._gBufferRenderTarget)&&void 0!==e?e:new No(void 0,{_width:this._width,_height:this._height,_samples:this._samples,_renderPass:this._renderPass,textureFilter:ne}),this._gBufferRenderTarget)}get hbaoRenderPass(){return this._hbaoPass||(this._hbaoPass=new hl(this._width,this._height,{normalVectorSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Jo.FLOAT_BUFFER_NORMAL:Jo.INPUT_RGB_NORMAL,depthValueSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?$o.NORMAL_VECTOR_ALPHA:$o.SEPARATE_BUFFER,modulateRedChannel:!0,hbaoParameters:this.parameters.hbao})),this._hbaoPass}get fadeRenderTarget(){var e;return this._fadeRenderTarget=null!==(e=this._fadeRenderTarget)&&void 0!==e?e:new gt(this._width,this._height,{format:Ut,magFilter:D,minFilter:D}),this._fadeRenderTarget}get denoisePass(){return this._poissonDenoisePass||(this._poissonDenoisePass=new pl(this._width,this._height,{inputTexture:this.shadowAndAoRenderTargets.passRenderTarget.texture,depthTexture:this.gBufferRenderTarget.depthBufferTexture,normalTexture:this.gBufferRenderTarget.gBufferTexture,normalVectorSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Jo.FLOAT_BUFFER_NORMAL:Jo.INPUT_RGB_NORMAL,depthValueSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?$o.NORMAL_VECTOR_ALPHA:$o.SEPARATE_BUFFER,rgInputTexture:!0,poissonDenoisePassParameters:this.parameters.poissonDenoise})),this._poissonDenoisePass}get denoiseRenderTargetTexture(){return this.denoisePass?this.denoisePass.texture:null}constructor(e,t,n,r){var i,s,a,o,l,h,d,c;this.needsUpdate=!0,this._renderPass=new Io,this._cameraUpdate=new Ro,(null==r?void 0:r.gBufferRenderTarget)&&(this._sharedGBufferRenderTarget=null==r?void 0:r.gBufferRenderTarget),this._width=e,this._height=t,this._samples=n,this._renderPass=null!==(i=null==r?void 0:r.enderPass)&&void 0!==i?i:new Io,this.shadowAndAoRenderTargets=new wl(this.gBufferRenderTarget,{...r,width:e,height:t,samples:n,renderPass:this._renderPass}),this.parameters={enabled:null!==(s=null==r?void 0:r.enabled)&&void 0!==s?s:_l.enabled,aoType:null!==(a=null==r?void 0:r.aoType)&&void 0!==a?a:_l.aoType,aoIntensity:null!==(o=null==r?void 0:r.aoIntensity)&&void 0!==o?o:_l.aoIntensity,shadowIntensity:null!==(l=null==r?void 0:r.shadowIntensity)&&void 0!==l?l:_l.shadowIntensity,aoOnGround:null!==(h=null==r?void 0:r.aoOnGround)&&void 0!==h?h:_l.aoOnGround,shadowOnGround:null!==(d=null==r?void 0:r.shadowOnGround)&&void 0!==d?d:_l.shadowOnGround,alwaysUpdate:null!==(c=null==r?void 0:r.alwaysUpdate)&&void 0!==c?c:_l.alwaysUpdate,shAndAo:this.shadowAndAoRenderTargets.shadowAndAoParameters,hbao:{...ll},poissonDenoise:{...ul}},this._copyMaterial=new xo,this._blendMaterial=new xo({},yo.DEFAULT)}dispose(){var e,t,n,r,i,s;null===(e=this._gBufferRenderTarget)||void 0===e||e.dispose(),this.shadowAndAoRenderTargets.dispose(),null===(t=this._hbaoPass)||void 0===t||t.dispose(),null===(n=this._fadeRenderTarget)||void 0===n||n.dispose(),null===(r=this._poissonDenoisePass)||void 0===r||r.dispose(),null===(i=this._copyMaterial)||void 0===i||i.dispose(),null===(s=this._blendMaterial)||void 0===s||s.dispose()}setSize(e,t){var n,r,i,s;this._width=e,this._height=t,null===(n=this._gBufferRenderTarget)||void 0===n||n.setSize(e,t),this.shadowAndAoRenderTargets.setSize(e,t),null===(r=this._hbaoPass)||void 0===r||r.setSize(e,t),null===(i=this._fadeRenderTarget)||void 0===i||i.setSize(e,t),null===(s=this._poissonDenoisePass)||void 0===s||s.setSize(this._width,this._height),this.needsUpdate=!0}updateParameters(e){void 0!==e.enabled&&(this.parameters.enabled=e.enabled),void 0!==e.aoType&&(this.parameters.aoType=e.aoType),void 0!==e.aoIntensity&&(this.parameters.aoIntensity=e.aoIntensity),void 0!==e.shadowIntensity&&(this.parameters.shadowIntensity=e.shadowIntensity),void 0!==e.aoOnGround&&(this.parameters.aoOnGround=e.aoOnGround),void 0!==e.shadowOnGround&&(this.parameters.shadowOnGround=e.shadowOnGround),void 0!==e.alwaysUpdate&&(this.parameters.alwaysUpdate=e.alwaysUpdate),this._updatePassParameters(e)}_updatePassParameters(e){var t,n;if(null==e?void 0:e.shAndAo)for(let t in e.shAndAo)this.parameters.shAndAo.hasOwnProperty(t)&&(this.parameters.shAndAo[t]=e.shAndAo[t],this.shadowAndAoRenderTargets.parametersNeedsUpdate=!0);if(null==e?void 0:e.hbao)if(this._hbaoPass)null===(t=this._hbaoPass)||void 0===t||t.updateParameters(null==e?void 0:e.hbao);else for(let t in e.hbao)this.parameters.hbao.hasOwnProperty(t)&&(this.parameters.hbao[t]=e.hbao[t]);if(null==e?void 0:e.poissonDenoise)if(this._poissonDenoisePass)null===(n=this._poissonDenoisePass)||void 0===n||n.updateParameters(null==e?void 0:e.poissonDenoise);else for(let t in e.poissonDenoise)this.parameters.poissonDenoise.hasOwnProperty(t)&&(this.parameters.poissonDenoise[t]=e.poissonDenoise[t])}updateBounds(e,t){this.shadowAndAoRenderTargets.updateBounds(e,t)}render(e,t,n,r,i=ml.FULL,s=ml.FULL,a=0){if(!this._setRenderState())return;let o=!1;const l=s===ml.POISSON&&a>.001,h=s===ml.HARD&&a>.001&&a<.999,d=s===ml.HARD&&!h;!d&&i===ml.FULL&&this._evaluateIfUpdateIsNeeded(n)&&(this._renderShadowAndAo(e,t,n,r),o=!0);let c=d?r:this.denoiseRenderTargetTexture;l&&(c=this._renderDynamicShadow(e,this.shadowAndAoRenderTargets.passRenderTarget.texture,r,a),o=!0),o&&(c=this._renderDenoise(e,n,l)),h&&(c=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,r,a)),this._renderToTarget(e,c,d)}_setRenderState(){return this.shadowAndAoRenderTargets.aoEnabled=this.parameters.aoType===gl.SSAO,this.shadowAndAoRenderTargets.shadowEnabled=this.parameters.shadowIntensity>.01,!(!this.parameters.enabled||this.parameters.aoType===gl.NONE&&!this.shadowAndAoRenderTargets.shadowEnabled||(this.needsUpdate&&(this._hbaoPass&&(this._hbaoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,r){this.gBufferRenderTarget.render(e,t,n),this.shadowAndAoRenderTargets.render(e,n,r),this._renderAoEffect(e,t,n)}_renderAoEffect(e,t,n){if(this.parameters.aoType!==gl.HBAO)return;const r=this.gBufferRenderTarget.depthBufferTexture,i=this.gBufferRenderTarget.gBufferTexture,s=this.shadowAndAoRenderTargets.passRenderTarget,a=e.autoClear;e.autoClear=!1;const o=this.hbaoRenderPass;o.depthTexture=r,o.normalTexture=i,o.render(e,n,t,s),e.autoClear=a}_renderDynamicShadow(e,t,n,r=1){const i=r<.999;return i&&(this._copyMaterial.update({texture:t,blending:pt,colorTransform:co,multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),r>.001&&(this._blendMaterial.update({texture:n,blending:i?Ot:pt,colorTransform:(new S).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,i?r:1),multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n){return this.denoisePass.inputTexture=n?this.fadeRenderTarget.texture:this.shadowAndAoRenderTargets.passRenderTarget.texture,this.denoisePass.render(e,t),this.denoisePass.texture}_renderToTarget(e,t,n){const r=n?this.parameters.shadowIntensity:this.parameters.aoIntensity,i=n?0:this.parameters.shadowIntensity;this._renderPass.renderScreenSpace(e,this._copyMaterial.update({texture:t,blending:Ot,colorTransform:bo(r,i,0,1),multiplyChannels:1}),e.getRenderTarget())}}vl.shadowTransform=(new S).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class wl{get passRenderTarget(){var e;return this._passRenderTarget=null!==(e=this._passRenderTarget)&&void 0!==e?e:new gt(this._width,this._height,{samples:this._aoTargetSamples,format:Ut,magFilter:D,minFilter:D}),this._passRenderTarget}get passRenderMaterial(){var e;return this._passRenderMaterial=null!==(e=this._passRenderMaterial)&&void 0!==e?e:new bl({normalTexture:this._depthAndNormalTextures.gBufferTexture,depthTexture:this._depthAndNormalTextures.depthBufferTexture,noiseTexture:this.noiseTexture,sampleKernel:this.sampleKernel,floatGBufferRgbNormalAlphaDepth:this._depthAndNormalTextures.isFloatGBufferWithRgbNormalAlphaDepth}),this._passRenderMaterial}get noiseTexture(){var e;return this._noiseTexture=null!==(e=this._noiseTexture)&&void 0!==e?e:(e=>{const t=Math.floor(5)%2==0?Math.floor(5)+1:Math.floor(5),n=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,r=Array(n).fill(0);let i=Math.floor(t/2),s=t-1;for(let e=1;e<=n;)-1===i&&s===t?(s=t-2,i=0):(s===t&&(s=0),i<0&&(i=t-1)),0===r[i*t+s]?(r[i*t+s]=e++,s++,i--):(s-=2,i++);return r})(t),r=n.length,i=new Uint8Array(4*r);for(let e=0;e<r;++e){const t=n[e],s=2*Math.PI*t/r,o=new a(Math.cos(s),Math.sin(s),0).normalize();i[4*e]=255*(.5*o.x+.5),i[4*e+1]=255*(.5*o.y+.5),i[4*e+2]=127,i[4*e+3]=0}const s=new ye(i,t,t);return s.wrapS=L,s.wrapT=L,s.needsUpdate=!0,s})(),this._noiseTexture}get sampleKernel(){return this._sampleKernel.length||(this._sampleKernel=(e=>{const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=.99-n/(e-1)*.8,s=Math.sqrt(1-i*i),o=Math.cos(r)*s,l=Math.sin(r)*s,h=8,d=Math.floor(e/h);let c=1-(Math.floor(n/h)+n%h*d)/e;c=Q.lerp(.1,1,c*c),t.push(new a(o*c,l*c,i*c))}return t})(bl.kernelSize)),this._sampleKernel}constructor(e,t){var n,r,i,s;this.parametersNeedsUpdate=!0,this.aoEnabled=!0,this.shadowEnabled=!0,this._sceneBoxMin=new a(-1,-1,-1),this._sceneBoxMax=new a(1,1,1),this._shadowAndAoScale=1,this._aoTargetSamples=0,this._sampleKernel=[],this.shadowAndAoParameters=this._getShadowAndAoParameters(t),this._width=null!==(n=null==t?void 0:t._width)&&void 0!==n?n:1024,this._height=null!==(r=null==t?void 0:t._height)&&void 0!==r?r:1024,this._samples=null!==(i=null==t?void 0:t._samples)&&void 0!==i?i:0,this._depthAndNormalTextures=e,this._renderPass=null!==(s=null==t?void 0:t._renderPass)&&void 0!==s?s:new Io}_getShadowAndAoParameters(e){return{...fl,...e}}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._passRenderMaterial)||void 0===t||t.dispose(),null===(n=this._passRenderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._passRenderMaterial)||void 0===n||n.update({_width:this._width,_height:this._height})}updateBounds(e,t){this._sceneBoxMin.copy(e.bounds.min),this._sceneBoxMax.copy(e.bounds.max),this._shadowAndAoScale=t,this.parametersNeedsUpdate=!0}render(e,t,n){this._renderPass.renderScreenSpace(e,this.updateSSAOMaterial(t,n),this.passRenderTarget),this.parametersNeedsUpdate=!1}updateSSAOMaterial(e,t){const n=this.passRenderMaterial;return n.updateDependencies({_width:this._width,_height:this._height,camera:e,shadowTexture:t,sceneBoxMin:this._sceneBoxMin,sceneBoxMax:this._sceneBoxMax}),this.parametersNeedsUpdate&&n.updateSettings({...this.shadowAndAoParameters,aoKernelRadius:this.shadowAndAoParameters.aoKernelRadius*this._shadowAndAoScale,aoMaxDistance:this.shadowAndAoParameters.aoMaxDistance*this._shadowAndAoScale,shadowRadius:this.shadowAndAoParameters.shadowRadius*this._shadowAndAoScale,aoIntensity:this.aoEnabled?1:0,shadowIntensity:this.shadowEnabled?1:0}),n}}class bl extends ot{constructor(e){var t,n;super({defines:Object.assign({...bl._shader.defines,KERNEL_SIZE:null!==(n=null===(t=null==e?void 0:e.sampleKernel)||void 0===t?void 0:t.length)&&void 0!==n?n:bl.kernelSize,FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH:(null==e?void 0:e.floatGBufferRgbNormalAlphaDepth)?1:0}),uniforms:ut.clone(bl._shader.uniforms),vertexShader:bl._shader.vertexShader,fragmentShader:bl._shader.fragmentShader,blending:pt}),this.update(e)}update(e){return this.updateDependencies(e),this.updateSettings(e),this}updateDependencies(e){var t,n;if(void 0!==(null==e?void 0:e.shadowTexture)&&(this.uniforms.tShadow.value=null==e?void 0:e.shadowTexture),void 0!==(null==e?void 0:e.normalTexture)&&(this.uniforms.tNormal.value=null==e?void 0:e.normalTexture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.noiseTexture)&&(this.uniforms.tNoise.value=null==e?void 0:e.noiseTexture),(null==e?void 0:e._width)||(null==e?void 0:e._height)){const r=null!==(t=null==e?void 0:e._width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e._height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(r,i)}void 0!==(null==e?void 0:e.sampleKernel)&&(this.uniforms.sampleKernel.value=null==e?void 0:e.sampleKernel),void 0!==(null==e?void 0:e.sceneBoxMin)&&(this.uniforms.sceneBoxMin.value=null==e?void 0:e.sceneBoxMin),void 0!==(null==e?void 0:e.sceneBoxMax)&&(this.uniforms.sceneBoxMax.value=null==e?void 0:e.sceneBoxMax),this._updateCameraDependentUniforms(e)}_updateCameraDependentUniforms(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld)}}updateSettings(e){void 0!==(null==e?void 0:e.aoKernelRadius)&&(this.uniforms.aoKernelRadius.value=null==e?void 0:e.aoKernelRadius),void 0!==(null==e?void 0:e.aoDepthBias)&&(this.uniforms.aoDepthBias.value=null==e?void 0:e.aoDepthBias),void 0!==(null==e?void 0:e.aoMaxDistance)&&(this.uniforms.aoMaxDistance.value=null==e?void 0:e.aoMaxDistance),void 0!==(null==e?void 0:e.aoMaxDepth)&&(this.uniforms.aoMaxDepth.value=null==e?void 0:e.aoMaxDepth),void 0!==(null==e?void 0:e.aoIntensity)&&(this.uniforms.aoIntensity.value=null==e?void 0:e.aoIntensity),void 0!==(null==e?void 0:e.aoFadeout)&&(this.uniforms.aoFadeout.value=null==e?void 0:e.aoFadeout),void 0!==(null==e?void 0:e.shadowRadius)&&(this.uniforms.shKernelRadius.value=null==e?void 0:e.shadowRadius),void 0!==(null==e?void 0:e.shadowIntensity)&&(this.uniforms.shIntensity.value=null==e?void 0:e.shadowIntensity)}}bl.kernelSize=32,bl._shader={uniforms:{tShadow:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},sampleKernel:{value:null},cameraNear:{value:.1},cameraFar:{value:1},resolution:{value:new s},cameraProjectionMatrix:{value:new S},cameraInverseProjectionMatrix:{value:new S},cameraWorldMatrix:{value:new S},aoKernelRadius:{value:.1},aoDepthBias:{value:.001},aoMaxDistance:{value:.05},aoMaxDepth:{value:.99},aoIntensity:{value:1},aoFadeout:{value:0},shKernelRadius:{value:.15},shIntensity:{value:1},sceneBoxMin:{value:new a(-1,-1,-1)},sceneBoxMax:{value:new a(1,1,1)}},defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:bl.kernelSize,FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH:0,NORMAL_VECTOR_ANTIALIAS:2,DEPTH_BUFFER_ANTIALIAS:1},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tShadow;\n uniform sampler2D tNormal;\n#if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH != 1 \n uniform sampler2D tDepth;\n#endif \n uniform sampler2D tNoise;\n uniform vec3 sampleKernel[KERNEL_SIZE];\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 cameraWorldMatrix;\n uniform float aoKernelRadius;\n uniform float aoDepthBias; // avoid artifacts caused by neighbour fragments with minimal depth difference\n uniform float aoMaxDistance; // avoid the influence of fragments which are too far away\n uniform float aoMaxDepth;\n uniform float aoIntensity;\n uniform float aoFadeout;\n uniform float shKernelRadius;\n uniform float shIntensity;\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n \n varying vec2 vUv;\n \n #include <packing>\n \n float getDepth(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float d0 = texelFetch(tNormal, p, 0).w;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tNormal, p + ivec2(1, 0), 0).w;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tNormal, p - ivec2(1, 0), 0).w;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tNormal, p + ivec2(0, 1), 0).w;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tNormal, p - ivec2(0, 1), 0).w;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return texture2D(tNormal, screenPosition).w;\n #endif\n #else \n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n \n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n \n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraInverseProjectionMatrix * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n\n vec3 getViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n return texture2D(tNormal, screenPosition).xyz;\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n \n void main() {\n \n float depth = getDepth(vUv);\n float viewZ = getViewZ(depth);\n \n vec3 viewPosition = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n vec3 worldPosition = (cameraWorldMatrix * vec4(viewPosition, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPosition, worldPosition - sceneBoxMax)));\n \n vec2 noiseScale = resolution.xy / vec2(textureSize(tNoise, 0));\n vec3 random = texture2D(tNoise, vUv * noiseScale).xyz * 2.0 - 1.0;\n \n // compute matrix used to reorient a kernel vector\n vec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n \n float aoOcclusion = 0.0;\n float shOcclusion = texture2D(tShadow, vUv).r;\n float shSamples = 0.0;\n if (aoIntensity >= 0.01 && boxDistance < aoMaxDistance && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 aoSampleVector = kernelMatrix * sampleKernel[i]; \n vec3 aoSamplePoint = viewPosition + aoSampleVector * aoKernelRadius; \n vec4 aoSamplePointNDC = cameraProjectionMatrix * vec4(aoSamplePoint, 1.0); \n aoSamplePointNDC /= aoSamplePointNDC.w;\n vec2 aoSamplePointUv = aoSamplePointNDC.xy * 0.5 + 0.5;\n float aoRealSampleDepth = getDepth(aoSamplePointUv);\n float aoSampleDeltaZ = getViewZ(aoRealSampleDepth) - aoSamplePoint.z;\n float aoRealDeltaZ = viewZ - aoSamplePoint.z;\n float w_long = clamp((aoMaxDistance - max(aoRealDeltaZ, aoSampleDeltaZ)) / aoMaxDistance, 0.0, 1.0);\n float w_lat = clamp(1.0 - length(aoSampleVector.xy), 0.0, 1.0);\n aoOcclusion +=\n step(aoRealSampleDepth, aoMaxDepth) * \n step(aoDepthBias, aoSampleDeltaZ / (cameraFar - cameraNear)) * \n step(aoSampleDeltaZ, aoMaxDistance) * mix(1.0, w_long * w_lat, aoFadeout);\n }\n }\n if (shIntensity >= 0.01 && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 shSampleVector = kernelMatrix * sampleKernel[i]; // reorient sample vector in view space\n vec3 shSamplePoint = viewPosition + shSampleVector * shKernelRadius; // calculate sample point\n vec4 shSamplePointNDC = cameraProjectionMatrix * vec4(shSamplePoint, 1.0); // project point and calculate NDC\n shSamplePointNDC /= shSamplePointNDC.w;\n vec2 shSamplePointUv = shSamplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n vec3 shSampleNormal = getViewNormal(shSamplePointUv);\n float shDeltaZ = getViewZ(getDepth(shSamplePointUv)) - shSamplePoint.z;\n float w = step(abs(shDeltaZ), shKernelRadius) * max(0.0, dot(shSampleNormal, viewNormal));\n shSamples += w;\n shOcclusion += texture2D(tShadow, shSamplePointUv).r * w;\n }\n }\n \n aoOcclusion = clamp(aoOcclusion / float(KERNEL_SIZE) * (1.0 + aoFadeout), 0.0, 1.0);\n aoOcclusion = 1.0 - aoOcclusion * clamp(1.0 - boxDistance / aoMaxDistance, 0.0, 1.0);\n shOcclusion = clamp(shOcclusion / (shSamples + 1.0), 0.0, 1.0);\n gl_FragColor = vec4(aoOcclusion, shOcclusion, 0.0, 1.0);\n }"};class yl{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n){var r;this._width=e,this._height=t,this.parameters={enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4,...n},this._copyMaterial=new xo({}),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new xl({_width:this._width/this.parameters.renderTargetDownScale,_height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new Do(Co,n),this._renderPass=null!==(r=null==n?void 0:n._renderPass)&&void 0!==r?r:new Io}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale;let r={};if(e){const e=new ft(t,n);e.format=_t,e.type=vt,r.minFilter=ne,r.magFilter=ne,r.depthTexture=e}else r.samples=1;return new gt(t,n,{format:be,...r})}dispose(){var e,t,n;null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,r,i,s;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._intensityRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._blurRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(s=this._reflectionIntensityMaterial)||void 0===s||s.update({_width:this._width/this.parameters.renderTargetDownScale,_height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const r=this.parameters.intensity*t,i=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new S).set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,r),multiplyChannels:0,uvTransform:wo}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}render(e,t,n,r=1){if(!(this.parameters.enabled&&n instanceof X))return;const i=this._createGroundReflectionCamera(n);this._renderGroundReflection(e,t,i,this.reflectionRenderTarget),this._renderGroundReflectionIntensity(e,i,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,n,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,r),this._renderPass.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,r){const i=e.getRenderTarget();r&&e.setRenderTarget(r),e.render(t,n),r&&e.setRenderTarget(i)}_renderGroundReflectionIntensity(e,t,n){const r=e.getRenderTarget();e.setRenderTarget(n),this._renderPass.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(r)}blurReflection(e,t,n){const r=new a(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),i=this.parameters.blurHorizontal/this._width,s=this.parameters.blurVertical/this._height*Math.abs(r.dot(new a(0,0,1)));this._blurPass.render(e,n,[4*i,4*s],[4*i*(1+this.parameters.blurAscent),4*s*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class xl extends ot{constructor(e){super({defines:Object.assign({},xl.shader.defines),uniforms:ut.clone(xl.shader.uniforms),vertexShader:xl.shader.vertexShader,fragmentShader:xl.shader.fragmentShader,blending:pt}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e._width)||(null==e?void 0:e._height)){const r=null!==(t=null==e?void 0:e._width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e._height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(r,i)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}xl.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new s},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new S},cameraInverseProjectionMatrix:{value:new S},inverseViewMatrix:{value:new S},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec4 fragColor = texture2D(tDiffuse, uv).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha;\n gl_FragColor = fragColor * step(depth, 0.9999);\n }"};const Cl=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new s(t,n)};class Sl{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new gt,this._colorRenderTarget}get environmentMapDecodeTarget(){var e;return this._environmentMapDecodeTarget=null!==(e=this._environmentMapDecodeTarget)&&void 0!==e?e:new gt,this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new Tl(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new Tl(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Y(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,r){var i;this.colorRenderTarget.setSize(n,r),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new H(new wt(2,2),new y({map:t}));const s=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(s);const a=this.environmentMapDecodeTarget.texture,o=new Uint8Array(n*r*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,r,o),{texture:a,pixels:o}}newGrayscaleTexture(e,t,n,r){var i;const s=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name);this.environmentMapDecodeTarget.setSize(n,r),s.setSourceTexture(t),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new H(new wt(2,2),s);const a=e.getRenderTarget();e.setRenderTarget(this.environmentMapDecodeTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const o=this.environmentMapDecodeTarget.texture,l=new Uint8Array(n*r*4);return e.readRenderTargetPixels(this.environmentMapDecodeTarget,0,0,n,r,l),{texture:o,pixels:l}}}const Ml={tDiffuse:{value:null}};class Tl extends ot{constructor(e,t){super({uniforms:ut.clone(Ml),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }",defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}e("W",Tl),e("V",class{constructor(e){var t,n,r,i;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new ce,pixels:new Uint8Array(0)},this.detectorTexture=new ce,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new Al(0),this.lightSources=[],this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=1-n/(e-1)*2,s=Math.sqrt(1-i*i),o=Math.cos(r)*s,l=Math.sin(r)*s;t.push(new a(o,l,i))}return t},this._numberOfSamples=null!==(t=null==e?void 0:e._numberOfSamples)&&void 0!==t?t:1e3,this._width=null!==(n=null==e?void 0:e._width)&&void 0!==n?n:1024,this._height=null!==(r=null==e?void 0:e._height)&&void 0!==r?r:512,this._sampleThreshold=null!==(i=null==e?void 0:e._sampleThreshold)&&void 0!==i?i:.707,this.pointDistance=Math.sqrt(4*Math.PI)/Math.sqrt(this._numberOfSamples),this.pixelDistance=Math.sqrt(2)*Math.PI*2/this._width,this.samplePoints=this._createEquirectangularSamplePoints(this._numberOfSamples),this.sampleUVs=this.samplePoints.map(e=>Cl(e))}detectLightSources(e,t,n){var r;this.textureData=n,this._textureConverter=null!==(r=this._textureConverter)&&void 0!==r?r:new Sl,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort((e,t)=>t.maxIntensity-e.maxIntensity)}_redFromRgbaToNormalizedFloatArray(e,t){const n=new Float32Array(e.length/4);let r=1,i=0;for(let t=0;t<e.length/4;++t){const s=e[4*t]/255;r=Math.min(r,s),i=Math.max(i,s),n[t]=s}if(t)for(let e=0;e<n.length;++e){const s=(n[e]-r)/(i-r);n[e]=Math.pow(s,t)}else for(let e=0;e<n.length;++e)n[e]=(n[e]-r)/(i-r);return n}_grayscaleTextureFromFloatArray(e,t,n){const r=t*n,i=new Uint8Array(4*r);for(let t=0;t<r;t++){const n=255*e[t];i[4*t+0]=n,i[4*t+1]=n,i[4*t+2]=n,i[4*t+3]=255}const s=new ye(i,t,n);return s.needsUpdate=!0,s}_filterLightSamples(e){const t=[];for(let n=0;n<this.sampleUVs.length;n++){const r=this.sampleUVs[n];this._detectorTextureLuminanceValueFromUV(r)>e&&t.push(new Pl(this.samplePoints[n],r))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let r=0;for(let e=Math.max(0,t-2);e<Math.max(0,t+2);++e)for(let t=Math.max(0,n-2);t<Math.max(0,n+2);++t){const n=t*this.textureData._width+e,i=(this.textureData.data[4*n]+this.textureData.data[4*n+1]+this.textureData.data[4*n+2])/3;r=Math.max(r,i)}return r}_findClusterSegments(e,t){const n=2*this.pixelDistance,r=1.5*this.pointDistance,i=new Al(e.length);for(let s=0;s<e.length;s++)for(let a=s+1;a<e.length;a++)if(e[s].position.angleTo(e[a].position)<r){const r=e[a].position.clone().sub(e[s].position),o=Math.floor(r.length()/n);let l=!0,h=0;for(let n=1;n<o;n++){const i=r.clone().multiplyScalar(n/o),a=Cl(e[s].position.clone().add(i).normalize());if(this._detectorTextureLuminanceValueFromUV(a)<t){if(h++,h>1){l=!1;break}}else h=0}l&&(i.adjacent[s].push(a),i.adjacent[a].push(s),i.edges.push([s,a]))}return i}createLightSourcesFromLightGraph(e,t){const n=t.components.filter(e=>e.length>1).map(t=>new El(t.map(t=>e[t])));return n.forEach(e=>e.calculateLightSourceProperties(e=>this._originalLuminanceValueFromUV(e))),n}});class Pl{constructor(e,t){this.position=e,this.uv=t}}class Al{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;t<e;t++)this.adjacent.push([])}findConnectedComponents(){const e=new Array(this.noOfNodes).fill(!1);this.components=[];for(let t=0;t<this.noOfNodes;t++)if(!e[t]){const n=[];this._dfs(t,e,n),this.components.push(n)}this.components.sort((e,t)=>t.length-e.length)}_dfs(e,t,n){t[e]=!0,n.push(e);for(const r of this.adjacent[e])t[r]||this._dfs(r,t,n)}}class El{constructor(e){this.position=new a,this.uv=new s,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new a,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=Cl(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class Rl{constructor(e){this.grayMaterial=Ti.createMeshStandardMaterial({color:12632256,side:B,envMapIntensity:.4}),this._renderPass=new Io,this._sceneRenderer=e,this._environmentMapDecodeMaterial=new Tl(!0,!1),this._environmentMapDecodeMaterial.blending=pt,this._environmentMapDecodeMaterial.depthTest=!1}get _gBufferRenderTarget(){return this._sceneRenderer.gBufferRenderTarget}get _screenSpaceShadow(){return this._sceneRenderer.screenSpaceShadow}get _shadowAndAoPass(){return this._sceneRenderer.shadowAndAoPass}get _groundReflectionPass(){return this._sceneRenderer.groundReflectionPass}get _bakedGroundContactShadow(){return this._sceneRenderer.bakedGroundContactShadow}dispose(){var e,t;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.grayMaterial.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new xo,this._copyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new So({depthTexture:this._gBufferRenderTarget.textureWithDepthValue,depthFilter:this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?new st(0,0,0,1):new st(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}render(e,t,n,r,i,s,a){e(r,i,s),"color"!==a?("grayscale"===a?this._sceneRenderer.renderCacheManager.render("debug",i,()=>{this._renderPass.renderWithOverrideMaterial(r,i,s,this.grayMaterial,null,0,1)}):t(r,i,s),n(r,i,s),this._renderDebugPass(r,i,s,a)):r.render(i,s)}_renderDebugPass(e,t,n,r){var i,s,a,o,l,d;switch(r){default:break;case"lineardepth":this._renderPass.renderScreenSpace(e,this._getDepthRenderMaterial(n),null);break;case"g-normal":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this._gBufferRenderTarget)||void 0===i?void 0:i.gBufferTexture,blending:pt,colorTransform:(new S).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new st(.5,.5,.5,1),multiplyChannels:0,uvTransform:vo}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this._gBufferRenderTarget)||void 0===s?void 0:s.gBufferTexture,blending:pt,colorTransform:uo,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null);break;case"g-depth":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.gBufferTexture,blending:pt,colorTransform:po,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(o=this._gBufferRenderTarget)||void 0===o?void 0:o.depthBufferTexture,blending:pt,colorTransform:mo,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null);break;case"ssao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"ssaodenoise":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowmap":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._screenSpaceShadow.shadowTexture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:pt,colorTransform:vl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowblur":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:vl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowfadein":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.fadeRenderTarget.texture,blending:pt,colorTransform:vl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowandao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:bo(this._shadowAndAoPass.parameters.aoIntensity,this._shadowAndAoPass.parameters.shadowIntensity,0,1),colorBase:fo,multiplyChannels:1,uvTransform:vo}),null);break;case"groundreflection":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._groundReflectionPass.reflectionRenderTarget.texture,blending:pt,colorTransform:co,colorBase:fo,multiplyChannels:0,uvTransform:wo}),null);break;case"bakedgroundshadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._bakedGroundContactShadow.renderTarget.texture,blending:pt,colorTransform:co,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(t.environment),this._renderPass.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(l=t.userData)||void 0===l?void 0:l.environmentDefinition){const n=this._sceneRenderer.width/this._sceneRenderer.height,r=new Y(-1,1,1/n,-1/n,-1,1),i=null===(d=t.userData)||void 0===d?void 0:d.environmentDefinition.createDebugScene(e,t);i.background=new h(16777215),e.render(i,r)}}}}var Il;!function(e){e[e.HIGHEST=0]="HIGHEST",e[e.HIGH=1]="HIGH",e[e.MEDIUM=2]="MEDIUM",e[e.LOW=3]="LOW"}(Il||(Il={}));class Dl{constructor(e,t,n){this.debugOutput="off",this._prevDebugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.movingCamera=!1,this.groundLevel=0,this.uiInteractionMode=!1,this._noUpdateNeededCount=0,this._cameraUpdate=new Ro,this.width=0,this.height=0,this._maxSamples=1,this._cameraChanged=!0,this.boundingVolume=new Eo,this._boundingVolumeSet=!1,this.renderCacheManager=new Lo,this._renderPass=new Io,this.selectedObjects=[],this.groundGroup=new q,this._qualityLevel=Il.HIGHEST,this._qualityMap=new Map,this.width=t,this.height=n,this._maxSamples=e.capabilities.maxSamples,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new ko(e=>e===this.groundGroup)),this.renderCacheManager.registerCache("debug",new ko),this.renderCacheManager.registerCache("floorDepthWrite",new Uo(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor})),this.gBufferRenderTarget=new No(this.renderCacheManager,{shared:!0,capabilities:e.capabilities,width:this.width,height:this.height,samples:1,_renderPass:this._renderPass,textureFilter:ne}),this.shadowAndAoPass=new vl(this.width,this.height,1,{gBufferRenderTarget:this.gBufferRenderTarget}),this.screenSpaceShadow=new Yo(this.renderCacheManager,new s(this.width,this.height),{samples:this._maxSamples,alwaysUpdate:!1}),this.groundReflectionPass=new yl(this.width,this.height,{_renderPass:this._renderPass}),this.bakedGroundContactShadow=new jo(this.renderer,this.groundGroup,{_renderPass:this._renderPass,renderCacheManager:this.renderCacheManager}),this.groundGroup.rotateX(-Math.PI/2),this.outlineRenderer=new Ko(null,this.width,this.height,{gBufferRenderTarget:this.gBufferRenderTarget}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderTarget.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadow.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadow.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:ml.OFF},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",()=>{}),e.domElement.addEventListener("webglcontextrestored",()=>{this._forceEnvironmentMapUpdate(this.renderer)})}dispose(){var e,t;null===(e=this._debugPass)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.gBufferRenderTarget.dispose(),this.screenSpaceShadow.dispose(),this.shadowAndAoPass.dispose(),this.outlineRenderer.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this.gBufferRenderTarget.setSize(e,t),this.screenSpaceShadow.setSize(e,t),this.shadowAndAoPass.setSize(e,t),this.outlineRenderer.setSize(e,t),this.groundReflectionPass.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}applyCurrentParameters(){this._qualityMap.has(this._qualityLevel)&&(this.updateParameters(this._qualityMap.get(this._qualityLevel)),this.bakedGroundContactShadow.applyParameters()),this.uiInteractionMode&&this.updateParameters({groundReflectionParameters:{enabled:!1}})}clearCache(){this.gBufferRenderTarget.groundDepthWrite=this._boundingVolumeSet&&this.shadowAndAoPass.parameters.aoOnGround,this.screenSpaceShadow.shadowOnGround=this.shadowAndAoPass.parameters.shadowOnGround,this.renderCacheManager.clearCache()}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderTarget.needsUpdate=!0,this.screenSpaceShadow.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadow.needsUpdate=!0)}updateParameters(e){void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.effectParameters&&this.shadowAndAoPass.updateParameters({effectParameters:e.effectParameters}),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadow.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadow.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadow.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadow.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadow.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache(),this._boundingVolumeSet=!0,this.gBufferRenderTarget.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(e);const n=this.boundingVolume.size,r=(n.x+n.y+n.z)/3,i=Math.min(n.x,n.y,n.z),s=Math.max(n.x,n.y,n.z),a=i<.5?i/.5:n.z>5?n.z/5:1;this.bakedGroundContactShadow.setScale(t?r:a,r),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,s)),this.screenSpaceShadow.updateBounds(this.boundingVolume,r),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?r:Math.min(1,2*s))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_setRenderState(e,t){var n;const r=this.debugOutput!==this._prevDebugOutput;this._prevDebugOutput=this.debugOutput,this.screenSpaceShadow.parameters.alwaysUpdate=this.shadowAndAoPass.parameters.alwaysUpdate,this._cameraChanged=this._cameraUpdate.changed(t),(n=this.gBufferRenderTarget).needsUpdate||(n.needsUpdate=this._cameraChanged||r)}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,r;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const i=e.userData;if(i&&((null===(r=t.userData)||void 0===r?void 0:r.environmentDefinition.needsUpdate)||!i.environmentTexture||i.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(i.environmentDefinition=n,i.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadow.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==i?void 0:i.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._setRenderState(e,t),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.movingCamera?[]:this.selectedObjects),this.renderer.setRenderTarget(null),this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput?this._renderDebug(this.renderer,e,t):(this.renderPreRenderPasses(this.renderer,e,t),this._renderScene(this.renderer,e,t),this.renderPostProcessingEffects(this.renderer,e,t)),e.remove(this.groundGroup)}_renderDebug(e,t,n){var r;this._debugPass=null!==(r=this._debugPass)&&void 0!==r?r:new Rl(this),this._debugPass.render((e,t,n)=>this.renderPreRenderPasses(e,t,n),(e,t,n)=>this._renderScene(e,t,n),(e,t,n)=>this.renderPostProcessingEffects(e,t,n),e,t,n,this.debugOutput)}renderPreRenderPasses(e,t,n){this._renderGroundContactShadow(t)}_renderScene(e,t,n){this.renderCacheManager.onBeforeRender("floorDepthWrite",t),this.bakedGroundContactShadow.setGroundVisibility(!0,n),e.render(t,n),this.bakedGroundContactShadow.setGroundVisibility(!1,n),this.renderCacheManager.onAfterRender("floorDepthWrite")}renderPostProcessingEffects(e,t,n){this.renderShadowAndAo(e,t,n),this._renderOutline()}_renderGroundContactShadow(e){this.bakedGroundContactShadow.needsUpdate&&this.bakedGroundContactShadow.updateBounds(this.boundingVolume,this.groundLevel),this.bakedGroundContactShadow.render(e)}renderShadowAndAo(e,t,n){const r=this._evaluateIfShadowAndAoUpdateIsNeeded(n);if(r.needsUpdate||r.shadowOnCameraChange!==ml.OFF){if(!this.parameters.suspendGroundReflection||r.needsUpdate){const i=this.parameters.suspendGroundReflection?r.intensityScale:1;this._renderGroundReflection(e,t,n,i)}this.gBufferRenderTarget.needsUpdate=r.needsUpdate||r.shadowOnCameraChange===ml.POISSON,this.gBufferRenderTarget.render(e,t,n),this.shadowAndAoPass.parameters.shadowIntensity>0&&this.screenSpaceShadow.renderShadowMap(e,t,n),this.shadowAndAoPass.render(e,t,n,this.screenSpaceShadow.shadowTexture,r.needsUpdate?ml.FULL:r.shadowOnCameraChange,r.shadowOnCameraChange,1-r.intensityScale)}}_evaluateIfShadowAndAoUpdateIsNeeded(e){const t=this.shadowAndAoPass.parameters.alwaysUpdate||this.screenSpaceShadow.needsUpdate||this.screenSpaceShadow.shadowTypeNeedsUpdate;let n=(this.shadowAndAoPass.parameters.enabled||this.groundReflectionPass.parameters.enabled)&&(0===this.parameters.effectSuspendFrames||this._cameraChanged);n&&(this._noUpdateNeededCount=0);let r=1;return!t&&this.parameters.effectSuspendFrames>0&&(this._noUpdateNeededCount++,n=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,r=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),n=t||n,{needsUpdate:n,shadowOnCameraChange:!n||r<.99?this.parameters.shadowOnCameraChange:ml.OFF,intensityScale:r}}_renderGroundReflection(e,t,n,r=1){this.groundReflectionPass.parameters.enabled&&this.renderCacheManager.render("inivisibleGround",t,()=>{this.groundReflectionPass.render(e,t,n,r)})}_renderOutline(){if(this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass){const e=this.renderer.getClearColor(new h),t=this.renderer.getClearAlpha();"outline"===this.debugOutput&&(this.renderer.setClearColor(0,255),this.renderer.clear(!0,!1,!1)),this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.render(this.renderer,null,null,0,!1),"outline"===this.debugOutput&&this.renderer.setClearColor(e,t)}}}class Ol{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const r=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(r,t);const i=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(i,t);const s=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(s,t);const a=e.addFolder("Outline");this._addOutlineGUI(a,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",w],["SRGBColorSpace",x]]),r=[];n.forEach((e,t)=>{r.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)}),e.add(this._sceneRenderer,"outputColorSpace",r).onChange(e=>{var r;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(r=n.get(e))&&void 0!==r?r:x,t())});const i=new Map([["NoToneMapping",Ft],["LinearToneMapping",Nt],["ReinhardToneMapping",Bt],["CineonToneMapping",jt],["ACESFilmicToneMapping",Gt]]),s=[];i.forEach((e,t)=>{s.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)}),e.add(this._sceneRenderer,"toneMapping",s).onChange(e=>{var n;i.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=i.get(e))&&void 0!==n?n:Ft,t())})}_addDebugGUI(e,t){const n=new Map([["HIGHEST",Il.HIGHEST],["HIGH",Il.HIGH],["MEDIUM",Il.MEDIUM],["LOW",Il.LOW]]),r=[];n.forEach((e,t)=>r.push(t)),e.add(this,"_qualityLevel",r).onChange(e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:Il.HIGHEST)}),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow Monte Carlo":"shadow","shadow blur":"shadowblur","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","ground reflection":"groundreflection","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange(()=>t())}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadow.shadowConfiguration,r=[];n.types.forEach((e,t)=>{r.push(t)});const i=()=>{this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",r).onChange(e=>{this._sceneRenderer.screenSpaceShadow.switchType(e)&&(s.object=n.currentConfiguration,a.object=n.currentConfiguration,o.object=n.currentConfiguration,s.updateDisplay(),a.updateDisplay(),o.updateDisplay(),i())});const s=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange(()=>i()),a=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange(()=>i()),o=e.add(n.currentConfiguration,"radius",0,100).onChange(()=>i())}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.gBufferRenderTarget.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.shadowAndAoRenderTargets.parametersNeedsUpdate=!0,t()},r=this._sceneRenderer.shadowAndAoPass.parameters,i=r.shAndAo,s=this._sceneRenderer.screenSpaceShadow.parameters,a=r.hbao,o=r.poissonDenoise;e.add(r,"enabled").onChange(()=>n());const l=new Map([["none",gl.NONE],["SSAO",gl.SSAO],["HBAO",gl.HBAO]]),h=Array.from(l.keys());l.forEach((e,t)=>{e===r.aoType&&(this._ambientOcclusionType=t)}),e.add(this,"_ambientOcclusionType",h).onChange(e=>{var t;l.has(e)&&(r.aoType=null!==(t=l.get(e))&&void 0!==t?t:gl.SSAO,n())}),e.add(r,"aoIntensity",0,1).onChange(()=>{n()}),e.add(r,"aoOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(r,"shadowOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(r,"shadowIntensity",0,1).onChange(()=>n()),e.add(r,"alwaysUpdate").onChange(()=>n());const d=e.addFolder("Shadow and Monte Carlo integration");d.add(s,"maximumNumberOfLightSources").onChange(()=>n()),d.add(s,"directionalDependency",0,1,.01).onChange(()=>n()),d.add(s,"directionalExponent",0,2,.01).onChange(()=>n()),d.add(s,"groundContainment",0,1,.01).onChange(()=>n()),d.add(s,"fadeOutDistance",0,5,.01).onChange(()=>n()),d.add(s,"fadeOutBlur",0,100).onChange(()=>n()),d.add(i,"shadowRadius",.001,.5).onChange(()=>n());const c=e.addFolder("SSAO");c.add(i,"aoFadeout",0,1).onChange(()=>n()),c.add(i,"aoKernelRadius",.001,1).onChange(()=>n()),c.add(i,"aoDepthBias",1e-4,.01).onChange(()=>n()),c.add(i,"aoMaxDistance",.01,1).onChange(()=>n()),c.add(i,"aoMaxDepth",.9,1).onChange(()=>n());const u=e.addFolder("HBAO");u.add(a,"samples",1,64,1).onChange(()=>n()),u.add(a,"radius",.1,10,.01).onChange(()=>n()),u.add(a,"distanceExponent",.1,5,.1).onChange(()=>n()),u.add(a,"bias",.001,.1,.001).onChange(()=>n());const p=e.addFolder("Possion Denoise");p.add(o,"iterations",0,3,1).onChange(()=>n()),p.add(o,"radius",0,32,1).onChange(()=>n()),p.add(o,"rings",0,16,.125).onChange(()=>n()),p.add(o,"samples",0,32,1).onChange(()=>n()),p.add(o,"lumaPhi",0,20,.001).onChange(()=>n()),p.add(o,"depthPhi",0,20,.001).onChange(()=>n()),p.add(o,"normalPhi",0,20,.001).onChange(()=>n())}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange(()=>t()),e.add(n,"fadeOutDistance",0,4).onChange(()=>t()),e.add(n,"fadeOutExponent",.1,10).onChange(()=>t()),e.add(n,"brightness",0,2).onChange(()=>t()),e.add(n,"blurHorizontal",0,10).onChange(()=>t()),e.add(n,"blurVertical",0,10).onChange(()=>t())}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadow.applyParameters(),t()},r=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(r,"enabled"),e.add(r,"cameraHelper").onChange(()=>n()),e.add(r,"alwaysUpdate"),e.add(r,"fadeIn"),e.add(r,"blurMin",0,.2,.001).onChange(()=>n()),e.add(r,"blurMax",0,.5,.01).onChange(()=>n()),e.add(r,"fadeoutFalloff",0,1,.01).onChange(()=>n()),e.add(r,"fadeoutBias",0,.5).onChange(()=>n()),e.add(r,"opacity",0,1,.01).onChange(()=>n()),e.add(r,"maximumPlaneSize",0,50,1).onChange(()=>n()),e.add(r,"cameraFar",.1,10,.1).onChange(()=>n())}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},r=this._sceneRenderer.outlineRenderer.parameters;e.add(r,"enabled"),e.add(r,"edgeStrength",.5,20).onChange(()=>n()),e.add(r,"edgeGlow",0,20).onChange(()=>n()),e.add(r,"edgeThickness",.5,20).onChange(()=>n()),e.add(r,"pulsePeriod",0,5).onChange(()=>n()),e.addColor(r,"visibleEdgeColor").onChange(()=>n()),e.addColor(r,"hiddenEdgeColor").onChange(()=>n())}}const Ll={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:ml.FULL},kl={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:ml.POISSON},Ul={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:ml.HARD},Fl={iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:12,normalPhi:3.25,samples:16},Nl=e("Z",new Map([[Il.HIGHEST,{...Ll,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:Fl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],[Il.HIGH,{...kl,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:Fl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],[Il.MEDIUM,{...Ul,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}}],[Il.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]])),Bl=new Ht;Bl.enable(3);const jl=new Ht;jl.disableAll(),jl.enable(9);const Gl={enabled:!0,aoType:gl.SSAO,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,poissonDenoise:Fl},Hl={enabled:!0,aoType:gl.HBAO,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,hbao:{samples:16,radius:.5,distanceExponent:2,bias:.01},poissonDenoise:{iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:2,normalPhi:3.25,samples:16}},zl=Hl,Vl={enabled:!0,fadeoutFalloff:.9,blurMax:.1,opacity:.5,hardLayers:null,softLayers:null,polygonOffset:2},Wl={enabled:!0,fadeoutFalloff:.8,blurMax:.15,opacity:.5,hardLayers:jl,softLayers:null,polygonOffset:-1},Kl={enabled:!1},ql=new Map([[Il.HIGHEST,{...Ll,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Vl}],[Il.HIGH,{...kl,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Vl}],[Il.MEDIUM,{...Ul,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Vl}],[Il.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Vl}]]),Xl=new Map([[Il.HIGHEST,{...Ll,shAndAoPassParameters:Hl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Wl}],[Il.HIGH,{...kl,shAndAoPassParameters:Hl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Wl}],[Il.MEDIUM,{...Ul,shAndAoPassParameters:Hl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Wl}],[Il.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Wl}]]),Ql=new Map([[Il.HIGHEST,{...Ll,shAndAoPassParameters:zl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Kl}],[Il.HIGH,{...kl,shAndAoPassParameters:zl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Kl}],[Il.MEDIUM,{...Ul,shAndAoPassParameters:zl,screenSpaceShadowMapParameters:{layers:Bl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Kl}],[Il.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Kl}]]);class Yl{constructor(){this._index=0,this._prevTime=0,this._frames=0,this._fps=-1,this._fpsList=Array(2).fill(0),this._prevTime=(performance||Date).now(),this.reset()}update(){this._frames++;const e=(performance||Date).now();e>=this._prevTime+1e3&&(this._fpsList[this._index%2]=1e3*this._frames/(e-this._prevTime),this._index>=2&&(this._fps=this._fpsList.reduce((e,t)=>e+t)/this._fpsList.length),this._prevTime=e,this._frames=0,this._index++)}start(){this._prevTime=(performance||Date).now(),this._frames=0}reset(){this._fps=-1,this._fpsList=Array(2).fill(0),this._index=0}getFps(){return this._fps}}var Zl;e("af",Zl),function(e){e[e.Mode3D=0]="Mode3D",e[e.Mode2D=1]="Mode2D"}(Zl||e("af",Zl={}));class Jl{get renderer(){return this._renderer}get screenSpaceShadowParameters(){return this.sceneRenderer.screenSpaceShadow.parameters}get shadowAndAoPassParameters(){return this.sceneRenderer.shadowAndAoPass.parameters}get bakedGroundContactShadowParameters(){return this.sceneRenderer.bakedGroundContactShadow.parameters}get groundReflectionParameters(){return this.sceneRenderer.groundReflectionPass.parameters}get outlineParameters(){return this.sceneRenderer.outlineRenderer.parameters}constructor(e,t,n){this.configuratorMode=!0,this.uiInteractionMode=!0,this._renderer=e,this.sceneRenderer=new Dl(this._renderer,t,n),this.outlineParameters.enabled=!0,this.outlineParameters.edgeStrength=2,this.outlineParameters.edgeGlow=1,this.outlineParameters.edgeThickness=2,this.outlineParameters.pulsePeriod=0,this.outlineParameters.usePatternTexture=!1,this.outlineParameters.visibleEdgeColor=16777215,this.outlineParameters.hiddenEdgeColor=16777215,Jl.enableRectAreaLightShadow&&(Qt.rectAreaLightReplacement=!1,Qt.rectAreaLightLoadingListener=this.loadRectAreLight),this.sceneRenderer.setQualityLevel(Il.HIGHEST),this.SceneRendererGUI=new Ol(this.sceneRenderer)}dispose(){this.sceneRenderer.dispose()}setSize(e,t){this.sceneRenderer.setSize(e,t)}setAutoQuality(e){!this._fpsCounter&&e?this._fpsCounter=new Yl:this._fpsCounter&&!e&&(this._fpsCounter=null)}setQualityLevel(e){this.sceneRenderer.setQualityLevel(e)}setQualityMap(e){this.sceneRenderer.setQualityMap(e)}enableUiInteractionMode(){this.sceneRenderer.uiInteractionMode=!0,this.sceneRenderer.applyCurrentParameters()}disableUiInteractionMode(){this.sceneRenderer.uiInteractionMode=!1,this.sceneRenderer.applyCurrentParameters()}loadRectAreLight(e){Jl.rectAreaLightsNeedsUpdate=!0}updateRectAreaLight(e){let t=[];e.traverse(e=>{e instanceof o&&t.push(e)}),this.sceneRenderer.updateRectAreaLights(t,e),Jl.rectAreaLightsNeedsUpdate=!1}clearCache(){this.sceneRenderer.clearCache()}forceShadowUpdates(e){this.sceneRenderer.forceShadowUpdates(e)}switchToConfigurator(){this.configuratorMode=!0,this.sceneRenderer.setQualityMap(ql)}switchToPlanner(e){Zl.Mode3D,this.configuratorMode=!1,e===Zl.Mode3D?this.sceneRenderer.setQualityMap(Xl):this.sceneRenderer.setQualityMap(Ql)}updateBounds(e){this.sceneRenderer.updateBounds(e,!1)}updateEnvironment(e,t=!1){e&&this.updateBounds(e)}movingCameraStarts(){var e;this.sceneRenderer.movingCamera=!0,null===(e=this._fpsCounter)||void 0===e||e.start()}movingCameraStops(){this.sceneRenderer.movingCamera=!1}highlightObjects(e){this.sceneRenderer.selectObjects(e)}render(e,t){var n;Jl.rectAreaLightsNeedsUpdate&&this.updateRectAreaLight(e),t.updateMatrixWorld(),(t instanceof X||t instanceof Y)&&t.updateProjectionMatrix();const r=Jl.updateNearAndFarPlaneOfPerspectiveCamera?this.createRenderCamera(t):t;if(this.sceneRenderer.render(e,r),this.sceneRenderer.movingCamera&&this._fpsCounter){null===(n=this._fpsCounter)||void 0===n||n.update();const e=this.sceneRenderer.getQualityLevel(),t=this._fpsCounter.getFps();t>0&&t<30&&e<3&&(this.sceneRenderer.setQualityLevel(e+1),this._fpsCounter.reset())}}createRenderCamera(e){const t=e.clone();return this.configuratorMode&&t instanceof X&&(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(t,120),t.updateProjectionMatrix()),t}showGUI(e){const t=Fi();this.SceneRendererGUI.addGUI(t,e)}clear(){this.renderer.clear()}}e("Y",Jl),Jl.enableRectAreaLightShadow=!0,Jl.rectAreaLightsNeedsUpdate=!1,Jl.updateNearAndFarPlaneOfPerspectiveCamera=!1;class $l{_getRoomleRenderer(e=!1){if(!this._roomleRenderer){const t=new zt({antialias:!e,alpha:!0});t.outputColorSpace=x,t.autoClear=!0,t.setSize(1024,1024),t.outputColorSpace=x,t.autoClear=!1,t.shadowMap.enabled=!0,t.shadowMap.type=Pt,this._roomleRenderer=new Jl(t,1024,1024),this._roomleRenderer.setQualityMap(Nl),this._roomleRenderer.setSize(1024,1024)}return this._roomleRenderer}switchToPlannerSettings(){this._getRoomleRenderer().switchToPlanner(Zl.Mode3D)}switchToConfiguratorSettings(){this._getRoomleRenderer().switchToConfigurator()}static getCameraTargetForBBox(e,t=0){if(!e){const e=new a;return{center:e,bounds:e,diagonal:0}}const n=e.getSize(new a);return n.addScalar(t),{center:e.getCenter(new a),bounds:n,diagonal:Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2))}}preparePerspectiveImage(e,t,n,r,i={},s=0,a=!1){return new Promise(o=>{const{size:l=1024,showDimensions:h}=i,d=this._getRoomleRenderer(a);d.setSize(l,l);const c=e.fog?e.fog.clone():null,u=e.background?e.background.clone():null;e.background=null,e.fog=null,n.layers.disable(2),n.layers.disable(6),n.layers.disable(5),h?n.layers.enable(8):n.layers.disable(8);const p=-30+cr(s);$l.placeCameraForPerspectiveImage(n,r,-20,p);const m=this._render(d,e,t,n,a);n.layers.enable(2),n.layers.enable(6),n.layers.enable(5),e.background=u,e.fog=c,o({image:m,width:l,height:l,blob:null})})}renderPerspectiveImage(e,t,n,r){return new Promise(i=>{r||(r=1024);const s=this._getRoomleRenderer();s.setSize(r,r);const a=e.fog?e.fog.clone():null,o=e.background?e.background.clone():null;e.background=null,e.fog=null,t.layers.disable(2),t.layers.disable(6),t.layers.disable(5),n?$l.placeCameraForPerspectiveImage(t,n,-20,-30):(t.aspect=1,t.updateProjectionMatrix());const l=this._render(s,e,null,t);t.layers.enable(2),t.layers.enable(6),t.layers.enable(5),e.background=o,e.fog=a,i({image:l,width:r,height:r,blob:null})})}static placeCameraForPerspectiveImage(e,t,n,r){e.far=1e3,e.fov=15,e.aspect=1,e.position.copy(t.center),e.rotation.set(0,0,0),e.rotateY(dr(r)),e.rotateX(dr(n)),e.translateZ(3.8*t.diagonal),e.updateProjectionMatrix()}prepareTopImage(e,t,n,r={}){const{showDimensions:i=!1}=r;return new Promise(r=>{const s=this._getRoomleRenderer();let a=new Y(-n.bounds.x/2,n.bounds.x/2,n.bounds.z/2,-n.bounds.z/2,.5);a.position.copy(n.center),a.rotateX(dr(-90)),a.translateZ(n.bounds.y+1),a.far=a.position.y+.5,a.layers.mask=65535;let o=200*n.bounds.x,l=200*n.bounds.z;if(o>4096||l>4096){let e=0;o>4096?e=o/4096:l>4096&&(e=l/4096),o/=e,l/=e}s.setSize(o,l);let h=e.fog?e.fog.clone():null,d=e.background?e.background.clone():null;e.background=null,e.fog=null,a.layers.disable(2),a.layers.disable(6),a.layers.disable(5),i?a.layers.enable(8):a.layers.disable(8);const c=this._render(s,e,t,a);a.layers.enable(2),a.layers.enable(6),a.layers.enable(5),e.background=d,e.fog=h,r({image:c,width:o,height:l,blob:null})})}_render(e,t,n,r,i=!1){i?e.renderer.render(t,r):(e.forceShadowUpdates(!0),e.render(t,r),e.render(t,r)),n&&(e.renderer.autoClear=!1,e.renderer.clearDepth(),e.renderer.render(n,r),e.renderer.autoClear=!0);const s=e.renderer.domElement.toDataURL();return e.clear(),s}}e("m",$l);const eh=e("I",[new Wt("error-handler",class{constructor(){this._listeners={}}_subscribe(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}subscribe(e,t){this._subscribe(e,t)}dispatch(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++){const r=n[e];r.apply(r,t)}}unsubscribe(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++)if(n[e]===t)return n.splice(e,1),r--,void e--}softReject(e,t,n){return this.dispatch(n,[t]),e()}}),new Wt("form-data-util",qt),new Wt("hdr-environment-loader",class{constructor(e){this._creator_=e;const t=new h("#DDDDDD");this._environmentMap=((e,t,n,r)=>{const i=new we;i.format=be,i.generateMipmaps=!1;for(let r=0;r<6;++r){const s=Ri(e,t,n,1);s.format=i.format,s.type=i.type,s.minFilter=i.minFilter,s.magFilter=i.magFilter,s.generateMipmaps=i.generateMipmaps,s.needsUpdate=!0,i.images[r]=s}return i.needsUpdate=!0,i})(t.r,t.g,t.b)}async loadUrl(e,t){const n=t.toLowerCase();this._environmentMap=n.endsWith(".exr")?await this._loadExr(t):await this._loadRgbe(t),this._environmentMap.mapping=it;const r={url:t,environmentMap:this._environmentMap};return this._envChangedCallback(r),r}_loadExr(e){var t;return this._exrLoader=null!==(t=this._exrLoader)&&void 0!==t?t:new oo,this._exrLoader.setPath(e.startsWith("http")?"":n()),this._exrLoader.loadAsync(e)}_loadRgbe(e){var t;return this._rgbeLoader=null!==(t=this._rgbeLoader)&&void 0!==t?t:new lo,this._rgbeLoader.setPath(e.startsWith("http")?"":n()),this._rgbeLoader.loadAsync(e)}registerEnvironmentChangedCallback(e){this._envChangedCallback=e}}),new Wt("static-item-loader",class{constructor(e){this._gltfLoaderGuard=new un,this._creator_=e,this._initLoaders()}_initLoaders(){this._gltfLoader=new gn;const e=new ar,t=e._loadLibrary.bind(e._loadLibrary);e._loadLibrary=(e,r)=>{const i=lr[e];if(!i)throw new Error('Can not load draco dependency "'+e+'" did three.js update DracoLoader lib? Available files'+JSON.stringify(lr));return t(n()+i,r)},e.setDecoderConfig({type:"wasm"}),this._gltfLoader.setDRACOLoader(e),this._gltfLoaderGuard.resolve(this._gltfLoader)}async loadGLB(e,t,n,r,i,s,a,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.load(e,e=>{l(this._handleGLTFScene("GLB",e,t,n,r,i,s,a))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}async loadGLTF(e,t,n,r,i,s,a,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.parse(e,null,e=>{l(this._handleGLTFScene("GLTF",e,t,n,r,i,s,a))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}_handleGLTFScene(e,t,n,r,i,s,o,l){if(!t||!t.scene||!t.scene.children||0===t.scene.children.length)return null;n&&t.scene.position.copy(n),r&&(t.scene.rotation.y=r);const d=new ge;if(d.setFromObject(t.scene),i){const{x:e,y:n,z:r}=d.getSize(new a);let s=new a(i.x/e,i.y/n,i.z/r);t.scene.scale.copy(s)}return s&&t.scene.scale.multiply(s),t.scene.type=e,t.scene.traverse(e=>{if(e instanceof H){if(e.layers.set(3),e.material instanceof N){const t=e.material;if(l&&o&&o>0){let e=new h(o);t.color=e.copySRGBToLinear(e),t.roughness=.5,t.metalness=.1}t.needsUpdate=!0}e.castShadow=!0,e.receiveShadow=!0}}),{boundingBox:d,scene:t.scene}}},0),new Wt("form-data-util",qt),new Wt("single-promise-factory",class{constructor(e){this._promises=new Map,this._creator_=e}create(e,t,n){return new Promise((r,i)=>{let s=this._promises.get(e),a=!0;if(!s){const t=new Map;this._promises.set(e,t),s=this._promises.get(e),a=!1}s.get(t)||(s.set(t,[]),a=!1);const o=s.get(t);o.push({resolve:r,reject:i}),s.set(t,o);const l=()=>{s.delete(t),0===s.size&&this._promises.delete(e)};a||new Promise(n).then(e=>{s.get(t).forEach(({resolve:t})=>t(e)),l()},e=>{s.get(t).forEach(({reject:t})=>t(e)),l()})})}},1),new Wt("dynamic-light-setting-loader",Qt),new Wt("network-layer",en),new Wt("local-storage",class{constructor(e){this._context_=e}get _localStorage(){let e=null;try{e=window.localStorage}catch(e){console.error(e)}return e}getItem(e){if(!this._localStorage)return null;const t=this._localStorage.getItem(e);try{return JSON.parse(t)}catch(e){return t}}setItem(e,t){if(this._localStorage)try{const n=JSON.stringify(t);this._localStorage.setItem(e,n)}catch(e){console.error(e)}}}),new Wt("network-layer",en),new Wt("kernel-io",an,0),new Wt("data-syncer",cn),new Wt("memory-manager",class{constructor(){this._configurationStringSet=new Set,this._singleLoadCounter=0}loadingConfigurationString(){this._singleLoadCounter+=1}loadingConfiguration(e){this._configurationStringSet.add(e),this._singleLoadCounter+=1}shouldHardReset(){return this._configurationStringSet.size>=15||this._singleLoadCounter>=30}executedHardReset(){this._configurationStringSet.clear(),this._singleLoadCounter=0}}),new Wt("life-cycle-manager",class{constructor(){this._listeners=[]}addEventListener(e){this._listeners.push(e)}removeEventListener(e){const t=this._listeners;let n=t.length;if(n)for(let r=0;r<n;r++)t[r]===e&&(t.splice(r,1),r--,n--)}pause(){this._listeners.forEach(e=>e.pause())}resume(){this._listeners.forEach(e=>e.resume())}destroy(){this._listeners.forEach(e=>e.destroy())}},1),new Wt("local-storage-helper",hr),new Wt("cache-holder",class{constructor(){this._componentCache=new Map,this._geometryCache=new Map,this._materialCache=new Map}get componentCache(){return this._componentCache}get geometryCache(){return this._geometryCache}get materialCache(){return this._materialCache}clear(){for(const e of this._componentCache.values())ji(e);for(const e of this._materialCache.values())zi(e);for(const e of this._geometryCache.values())Hi(e);this._componentCache.clear(),this._geometryCache.clear(),this._materialCache.clear()}},0),new Wt("kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Wt("configurator-kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}updatePossibleChildren(e,t,n){this._callbackListener.forEach(r=>r.updatePossibleChildren(e,t,n))}updateParameters(e,t,n,r){this._callbackListener.forEach(i=>i.updateParameters(e,t,n,r))}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Wt("configurator-context",class{constructor(){this.planObjectId=0,this.planElementId=0,this.rootComponentId=0,this.dockingRootComponentId=0,this.baseContext=null,this.rootComponentParametersAsGlobal=!1,this.lastLoadedRapiId=null,this.selectedRuntimeComponentIds=[],this.selectionMode="standard"}get selectedRuntimeComponentId(){return this.selectedRuntimeComponentIds.length>0?this.selectedRuntimeComponentIds[0]:null}},1),new Wt("init-data",Yi,1),new Wt("global-init-data",Ji,0),new Wt("global-callback",es,0),new Wt("dom-helper",ts,1),new Wt("unit-formatter",Da,0),new Wt("plugin-system",ns,1),new Wt("configurator-mesh-generator",ss),new Wt("configurator-input-manager",class extends cs{},1),new Wt("selection-handler",class extends as{constructor(){super(...arguments),this._selectionMode="standard",this._selectedComponents=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedComponents.size&&this._selectedComponents.forEach((e,t)=>{e.deselect(),this._selectedComponents.delete(t),this.dispatchEvent(1,new us({component:e}))})}_checkStandard(e){this._selectedComponents.has(e.runtimeId)?this.dispatchEvent(0,new us({component:e,consecutive:!0})):(this._selectedComponents.size>0&&this._selectedComponents.forEach((e,t)=>{this._selectedComponents.delete(t),this.dispatchEvent(1,new us({component:e,resetCamera:!1}))}),this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new us({component:e,consecutive:!1})))}_checkMulti(e){if(this._selectedComponents.has(e.runtimeId))return this._selectedComponents.delete(e.runtimeId),void this.dispatchEvent(1,new us({component:e,resetCamera:0===this._selectedComponents.size}));this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new us({component:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedComponents.size>0}getSelectedRuntimeComponentIds(){let e=[];return this._selectedComponents.forEach(t=>e.push(t.runtimeId)),e}isSelected(e){return this._selectedComponents.has(e.runtimeId)}},1),new Wt("component-dimensioning-helper",ws,1),new Wt("component-dimensioning-helper",ws,1),new Wt("planner-kernel-access",Ta),new Wt("planner-mesh-generator",Pa,1),new Wt("unit-formatter",Da),new Wt("configurator-history",Oa,1),new Wt("roomle-planner-ui-callback",class extends $i{constructor(e){super(e),this.onItemsLoaded=()=>{},this.onCameraChanged=e=>{},this.onCameraIdle=()=>{},this.onTotalFloorAreaChanged=e=>{},this.onPlanInteractionHandlerCreated=e=>{},this.onPlannerKernelIsReady=e=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onSelectionChange=(e,t,n,r,i)=>{},this.onSelectionCancel=e=>{},this.onPlanChanged=()=>{},this.onPlanElementChanged=(e,t)=>{},this.onCompletelyLoaded=()=>{},this.onRotationCancel=()=>{},this.onHistoryChange=(e,t)=>{},this.onUpdateWallDimensions=e=>{},this.disableWallDimensions=()=>{},this.onUpdatePlanObjectPositions=e=>{},this.onDrawCancel=()=>{},this.onHandlerSwitchedPlans=()=>{},this.onDragElementStart=()=>{},this.onDragElementEnd=()=>{},this.onClickElement=e=>{},this.onMultiSelectionChange=e=>{}}}),new Wt("configurator-ui-callbacks",class extends $i{constructor(e){super(e),this.onKernelIsReady=null,this.onComponentPositionsUpdated=null,this.onUpdateParameters=e=>{},this.onUpdatePossibleChildren=(e,t)=>{},this.onUpdatePrice=(e,t)=>{},this.onSelectionChange=(e,t,n,r)=>{},this.onSelectionCancel=()=>{},this.onPartListUpdate=(e,t)=>{},this.onBoundsUpdate=e=>{},this.onLoadConfiguration=()=>{},this.onConfigurationReady=(e,t,n)=>{},this.onOpenTag=e=>{},this.onOpenAddOns=()=>{},this.onClickOutside=()=>{},this.onNoDockingsAvailable=()=>{},this.onUiIntersectionChange=e=>{},this.onZoomChange=(e,t)=>{},this.onZoomToComponent=()=>{},this.onDimensionsVisibilityChange=e=>{},this.onErrorDueToOffline=e=>{},this.onError=e=>{},this.onDockingsPreviewRemoved=()=>{},this.onConfigurationHasChildren=e=>{},this.onTrackTiming=(e,t,n,r)=>{},this.onUserInitiatedDockDone=(e,t,n,r,i)=>{},this.onAddonPlusHover=()=>{},this.onAddonPlusHoverOff=()=>{},this.onAddonPlusShown=()=>{},this.onAddonPlusHidden=()=>{},this.onContentProblem=e=>{},this.onSyncStarted=()=>{},this.onSyncDone=()=>{},this.onOpenFloorMaterials=()=>{},this.onOpenPartList=()=>{},this.onComponentLoadError=(e,t)=>{},this.onConfigurationLoadError=()=>{},this.onChangeTypeChangeTag=e=>{},this.onRemoveTypeChangeTag=e=>{},this.onConfigurationLabelChange=(e,t,n)=>{},this.onMemoryCorruption=()=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onConfigurationSaved=e=>{},this.onCameraPositionChanges=()=>{},this.onHistoryChange=(e,t)=>{},this.onClickComponent=e=>{},this.onRequestExternalMesh=(e,t)=>{},this.onGeometryReady=e=>{},this.onGeometryNotReady=e=>{}}},1),new Wt("roomle-tools-core",La,0),new Wt("image-renderer",$l,0)]);class th{static _ensureContainer(){window.__RML__DI__||(window.__RML__DI__=new Vt,window.__RML__DI__.addDependencyInjectionAssignments(eh))}static setup(e){th.addToContainer(e)}static lookup(e,t){return window.__RML__DI__?window.__RML__DI__.lookup(e,t):null}static getContext(e){return th._ensureContainer(),window.__RML__DI__.getContext(e)}static cleanUp(e){return window.__RML__DI__?window.__RML__DI__.cleanUp(e):null}static addToContainer(e){th._ensureContainer(),window.__RML__DI__.addDependencyInjectionAssignments(e)}}e("b",th)}}}));
|
|
9
|
-
//# sourceMappingURL=roomle-dependency-injection-
|
|
8
|
+
var ka=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(ka(""))}catch(e){ka=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var Ua=Uint8Array,Fa=Uint16Array,Na=Uint32Array,Ba=new Ua([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]),ja=new Ua([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ga=new Ua([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ha=function(e,t){for(var n=new Fa(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Na(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},za=Ha(Ba,2),Va=za[0],Wa=za[1];Va[28]=258,Wa[258]=28;for(var Ka=Ha(ja,0)[0],qa=new Fa(32768),Xa=0;Xa<32768;++Xa){var Qa=(43690&Xa)>>>1|(21845&Xa)<<1;Qa=(61680&(Qa=(52428&Qa)>>>2|(13107&Qa)<<2))>>>4|(3855&Qa)<<4,qa[Xa]=((65280&Qa)>>>8|(255&Qa)<<8)>>>1}var Ya=function(e,t,n){for(var r=e.length,i=0,s=new Fa(t);i<r;++i)++s[e[i]-1];var a,o=new Fa(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new Fa(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var h=i<<4|e[i],d=t-e[i],c=o[e[i]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)a[qa[c]>>>l]=h}else for(a=new Fa(r),i=0;i<r;++i)e[i]&&(a[i]=qa[o[e[i]-1]++]>>>15-e[i]);return a},Za=new Ua(288);for(Xa=0;Xa<144;++Xa)Za[Xa]=8;for(Xa=144;Xa<256;++Xa)Za[Xa]=9;for(Xa=256;Xa<280;++Xa)Za[Xa]=7;for(Xa=280;Xa<288;++Xa)Za[Xa]=8;var Ja=new Ua(32);for(Xa=0;Xa<32;++Xa)Ja[Xa]=5;var $a=Ya(Za,9,1),eo=Ya(Ja,5,1),to=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},no=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},ro=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},io=new Ua(0);function so(e,t){return function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new Ua(0);var i=!t||n,s=!n||n.i;n||(n={}),t||(t=new Ua(3*r));var a,o=function(e){var n=t.length;if(e>n){var r=new Ua(Math.max(2*n,e));r.set(t),t=r}},l=n.f||0,h=n.p||0,d=n.b||0,c=n.l,u=n.d,p=n.m,m=n.n,g=8*r;do{if(!c){n.f=l=no(e,h,1);var f=no(e,h+1,3);if(h+=3,!f){var _=e[(A=((a=h)/8|0)+(7&a&&1)+4)-4]|e[A-3]<<8,v=A+_;if(v>r){if(s)throw"unexpected EOF";break}i&&o(d+_),t.set(e.subarray(A,v),d),n.b=d+=_,n.p=h=8*v;continue}if(1==f)c=$a,u=eo,p=9,m=5;else{if(2!=f)throw"invalid block type";var w=no(e,h,31)+257,b=no(e,h+10,15)+4,y=w+no(e,h+5,31)+1;h+=14;for(var x=new Ua(y),S=new Ua(19),C=0;C<b;++C)S[Ga[C]]=no(e,h+3*C,7);h+=3*b;var M=to(S),T=(1<<M)-1,P=Ya(S,M,1);for(C=0;C<y;){var A,E=P[no(e,h,T)];if(h+=15&E,(A=E>>>4)<16)x[C++]=A;else{var R=0,I=0;for(16==A?(I=3+no(e,h,3),h+=2,R=x[C-1]):17==A?(I=3+no(e,h,7),h+=3):18==A&&(I=11+no(e,h,127),h+=7);I--;)x[C++]=R}}var D=x.subarray(0,w),O=x.subarray(w);p=to(D),m=to(O),c=Ya(D,p,1),u=Ya(O,m,1)}if(h>g){if(s)throw"unexpected EOF";break}}i&&o(d+131072);for(var L=(1<<p)-1,k=(1<<m)-1,U=h;;U=h){var F=(R=c[ro(e,h)&L])>>>4;if((h+=15&R)>g){if(s)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if(F<256)t[d++]=F;else{if(256==F){U=h,c=null;break}var N=F-254;if(F>264){var B=Ba[C=F-257];N=no(e,h,(1<<B)-1)+Va[C],h+=B}var j=u[ro(e,h)&k],G=j>>>4;if(!j)throw"invalid distance";if(h+=15&j,O=Ka[G],G>3&&(B=ja[G],O+=ro(e,h)&(1<<B)-1,h+=B),h>g){if(s)throw"unexpected EOF";break}i&&o(d+131072);for(var H=d+N;d<H;d+=4)t[d]=t[d-O],t[d+1]=t[d+1-O],t[d+2]=t[d+2-O],t[d+3]=t[d+3-O];d=H}}n.l=c,n.p=U,n.b=d,c&&(l=1,n.m=p,n.d=u,n.n=m)}while(!l);return d==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Fa?Fa:e instanceof Na?Na:Ua)(n-t);return r.set(e.subarray(t,n)),r}(t,0,d)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var ao="undefined"!=typeof TextDecoder&&new TextDecoder;try{ao.decode(io,{stream:!0})}catch(e){}class oo extends Je{constructor(e){super(e),this.type=$e}parse(e){const t=Math.pow(2.7182818,2.2),n={l:0,c:0,lc:0};function r(e,t,r,i,s){for(;r<e;)t=t<<8|k(i,s),r+=8;r-=e,n.l=t>>r&(1<<e)-1,n.c=t,n.lc=r}const i=new Array(59);function s(e){return 63&e}function a(e){return e>>6}const o={c:0,lc:0};function l(e,t,n,r){e=e<<8|k(n,r),t+=8,o.c=e,o.lc=t}const h={c:0,lc:0};function d(e,t,n,r,i,s,a,d,c){if(e==t){r<8&&(l(n,r,i,s),n=o.c,r=o.lc);let e=n>>(r-=8);if(e=new Uint8Array([e])[0],d.value+e>c)return!1;const t=a[d.value-1];for(;e-- >0;)a[d.value++]=t}else{if(!(d.value<c))return!1;a[d.value++]=e}h.c=n,h.lc=r}function c(e){return 65535&e}function u(e){const t=c(e);return t>32767?t-65536:t}const p={a:0,b:0};function m(e,t){const n=u(e),r=u(t),i=n+(1&r)+(r>>1),s=i,a=i-r;p.a=s,p.b=a}function g(e,t){const n=c(e),r=c(t),i=n-(r>>1)&65535,s=r+i-32768&65535;p.a=s,p.b=i}function f(e,t,n,r,i,s,a){const o=a<16384,l=n>i?i:n;let h,d,c=1;for(;c<=l;)c<<=1;for(c>>=1,h=c,c>>=1;c>=1;){d=0;const a=d+s*(i-h),l=s*c,u=s*h,f=r*c,_=r*h;let v,w,b,y;for(;d<=a;d+=u){let i=d;const s=d+r*(n-h);for(;i<=s;i+=_){const n=i+f,r=i+l,s=r+f;o?(m(e[i+t],e[r+t]),v=p.a,b=p.b,m(e[n+t],e[s+t]),w=p.a,y=p.b,m(v,w),e[i+t]=p.a,e[n+t]=p.b,m(b,y),e[r+t]=p.a,e[s+t]=p.b):(g(e[i+t],e[r+t]),v=p.a,b=p.b,g(e[n+t],e[s+t]),w=p.a,y=p.b,g(v,w),e[i+t]=p.a,e[n+t]=p.b,g(b,y),e[r+t]=p.a,e[s+t]=p.b)}if(n&c){const n=i+l;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}if(i&c){let i=d;const s=d+r*(n-h);for(;i<=s;i+=_){const n=i+f;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}h=c,c>>=1}return d}function _(e,t,c,u,p,m){const g=c.value,f=L(t,c),_=L(t,c);c.value+=4;const v=L(t,c);if(c.value+=4,f<0||f>=65537||_<0||_>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const w=new Array(65537),b=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(b),function(e,t,s,a,o,l){const h=t;let d=0,c=0;for(;a<=o;a++){if(h.value-t.value>s)return!1;r(6,d,c,e,h);const i=n.l;if(d=n.c,c=n.lc,l[a]=i,63==i){if(h.value-t.value>s)throw new Error("Something wrong with hufUnpackEncTable");r(8,d,c,e,h);let i=n.l+6;if(d=n.c,c=n.lc,a+i>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)l[a++]=0;a--}else if(i>=59){let e=i-59+2;if(a+e>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)l[a++]=0;a--}}!function(e){for(let e=0;e<=58;++e)i[e]=0;for(let t=0;t<65537;++t)i[e[t]]+=1;let t=0;for(let e=58;e>0;--e){const n=t+i[e]>>1;i[e]=t,t=n}for(let t=0;t<65537;++t){const n=e[t];n>0&&(e[t]=n|i[n]++<<6)}}(l)}(e,c,u-(c.value-g),f,_,w),v>8*(u-(c.value-g)))throw new Error("Something wrong with hufUncompress");!function(e,t,n,r){for(;t<=n;t++){const n=a(e[t]),i=s(e[t]);if(n>>i)throw new Error("Invalid table entry");if(i>14){const e=r[n>>i-14];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=new Array(1);e.p[e.lit-1]=t}else if(i){let e=0;for(let s=1<<14-i;s>0;s--){const s=r[(n<<14-i)+e];if(s.len||s.p)throw new Error("Invalid table entry");s.len=i,s.lit=t,e++}}}}(w,f,_,b),function(e,t,n,r,i,c,u,p,m){let g=0,f=0;const _=u,v=Math.trunc(r.value+(i+7)/8);for(;r.value<v;)for(l(g,f,n,r),g=o.c,f=o.lc;f>=14;){const i=t[g>>f-14&16383];if(i.len)f-=i.len,d(i.lit,c,g,f,n,r,p,m,_),g=h.c,f=h.lc;else{if(!i.p)throw new Error("hufDecode issues");let t;for(t=0;t<i.lit;t++){const u=s(e[i.p[t]]);for(;f<u&&r.value<v;)l(g,f,n,r),g=o.c,f=o.lc;if(f>=u&&a(e[i.p[t]])==(g>>f-u&(1<<u)-1)){f-=u,d(i.p[t],c,g,f,n,r,p,m,_),g=h.c,f=h.lc;break}}if(t==i.lit)throw new Error("hufDecode issues")}}const w=8-i&7;for(g>>=w,f-=w;f>0;){const e=t[g<<14-f&16383];if(!e.len)throw new Error("hufDecode issues");f-=e.len,d(e.lit,c,g,f,n,r,p,m,_),g=h.c,f=h.lc}}(w,b,e,c,v,_,m,p,{value:0})}function v(e){for(let t=1;t<e.length;t++){const n=e[t-1]+e[t]-128;e[t]=n}}function b(e,t){let n=0,r=Math.floor((e.length+1)/2),i=0;const s=e.length-1;for(;!(i>s||(t[i++]=e[n++],i>s));)t[i++]=e[r++]}function y(e){let t=e.byteLength;const n=new Array;let r=0;const i=new DataView(e);for(;t>0;){const e=i.getInt8(r++);if(e<0){const s=-e;t-=s+1;for(let e=0;e<s;e++)n.push(i.getUint8(r++))}else{const s=e;t-=2;const a=i.getUint8(r++);for(let e=0;e<s+1;e++)n.push(a)}}return n}function x(e,t,n){let r,i=1;for(;i<64;)r=t[e.value],65280==r?i=64:r>>8==255?i+=255&r:(n[i]=r,i++),e.value++}function S(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),h=new Array(4),d=new Array(4),c=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=r*e[p+2],l[1]=a*e[p+2],l[2]=r*e[p+6],l[3]=a*e[p+6],h[0]=n*e[p+1]+i*e[p+3]+s*e[p+5]+o*e[p+7],h[1]=i*e[p+1]-o*e[p+3]-n*e[p+5]-s*e[p+7],h[2]=s*e[p+1]-n*e[p+3]+o*e[p+5]+i*e[p+7],h[3]=o*e[p+1]-s*e[p+3]+i*e[p+5]-n*e[p+7],d[0]=t*(e[p+0]+e[p+4]),d[3]=t*(e[p+0]-e[p+4]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[p+0]=c[0]+h[0],e[p+1]=c[1]+h[1],e[p+2]=c[2]+h[2],e[p+3]=c[3]+h[3],e[p+4]=c[3]-h[3],e[p+5]=c[2]-h[2],e[p+6]=c[1]-h[1],e[p+7]=c[0]-h[0]}for(let u=0;u<8;++u)l[0]=r*e[16+u],l[1]=a*e[16+u],l[2]=r*e[48+u],l[3]=a*e[48+u],h[0]=n*e[8+u]+i*e[24+u]+s*e[40+u]+o*e[56+u],h[1]=i*e[8+u]-o*e[24+u]-n*e[40+u]-s*e[56+u],h[2]=s*e[8+u]-n*e[24+u]+o*e[40+u]+i*e[56+u],h[3]=o*e[8+u]-s*e[24+u]+i*e[40+u]-n*e[56+u],d[0]=t*(e[u]+e[32+u]),d[3]=t*(e[u]-e[32+u]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[0+u]=c[0]+h[0],e[8+u]=c[1]+h[1],e[16+u]=c[2]+h[2],e[24+u]=c[3]+h[3],e[32+u]=c[3]-h[3],e[40+u]=c[2]-h[2],e[48+u]=c[1]-h[1],e[56+u]=c[0]-h[0]}function C(e){for(let t=0;t<64;++t){const n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function M(e,n,r){for(let s=0;s<64;++s)n[r+s]=rt.toHalfFloat((i=e[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(t,Math.abs(i)-1));var i}function T(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function P(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(y(t)),r=new Uint8Array(n.length);return v(n),b(n,r),new DataView(r.buffer)}function A(e){const t=so(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return v(t),b(t,n),new DataView(n.buffer)}function E(e){const t=e.viewer,n={value:e.offset.value},r=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),i=new Uint8Array(8192);let s=0;const a=new Array(e.channels);for(let t=0;t<e.channels;t++)a[t]={},a[t].start=s,a[t].end=a[t].start,a[t].nx=e.width,a[t].ny=e.lines,a[t].size=e.type,s+=a[t].nx*a[t].ny*a[t].size;const o=G(t,n),l=G(t,n);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let e=0;e<l-o+1;e++)i[e+o]=U(t,n);const h=new Uint16Array(65536),d=function(e,t){let n=0;for(let r=0;r<65536;++r)(0==r||e[r>>3]&1<<(7&r))&&(t[n++]=r);const r=n-1;for(;n<65536;)t[n++]=0;return r}(i,h),c=L(t,n);_(e.array,t,n,c,r,s);for(let t=0;t<e.channels;++t){const e=a[t];for(let n=0;n<a[t].size;++n)f(r,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,d)}!function(e,t,n){for(let r=0;r<n;++r)t[r]=e[t[r]]}(h,r,s);let u=0;const p=new Uint8Array(r.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.channels;t++){const e=a[t],n=e.nx*e.size,i=new Uint8Array(r.buffer,2*e.end,2*n);p.set(i,u),u+=2*n,e.end+=n}return new DataView(p.buffer)}function R(e){const t=so(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.lines*e.channels*e.width,r=1==e.type?new Uint16Array(n):new Uint32Array(n);let i=0,s=0;const a=new Array(4);for(let n=0;n<e.lines;n++)for(let n=0;n<e.channels;n++){let n=0;switch(e.type){case 1:a[0]=i,a[1]=a[0]+e.width,i=a[1]+e.width;for(let i=0;i<e.width;++i)n+=t[a[0]++]<<8|t[a[1]++],r[s]=n,s++;break;case 2:a[0]=i,a[1]=a[0]+e.width,a[2]=a[1]+e.width,i=a[2]+e.width;for(let i=0;i<e.width;++i)n+=t[a[0]++]<<24|t[a[1]++]<<16|t[a[2]++]<<8,r[s]=n,s++}}return new DataView(r.buffer)}function I(e){const t=e.viewer,n={value:e.offset.value},r=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),i={version:F(t,n),unknownUncompressedSize:F(t,n),unknownCompressedSize:F(t,n),acCompressedSize:F(t,n),dcCompressedSize:F(t,n),rleCompressedSize:F(t,n),rleUncompressedSize:F(t,n),rleRawSize:F(t,n),totalAcUncompressedCount:F(t,n),totalDcUncompressedCount:F(t,n),acCompression:F(t,n)};if(i.version<2)throw new Error("EXRLoader.parse: "+q.compression+" version "+i.version+" is unsupported");const s=new Array;let a=G(t,n)-2;for(;a>0;){const e=D(t.buffer,n),r=U(t,n),i=r>>2&3,o=new Int8Array([(r>>4)-1])[0],l=U(t,n);s.push({name:e,index:o,type:l,compression:i}),a-=e.length+3}const o=q.channels,l=new Array(e.channels);for(let t=0;t<e.channels;++t){const n=l[t]={},r=o[t];n.name=r.name,n.compression=0,n.decoded=!1,n.type=r.pixelType,n.pLinear=r.pLinear,n.width=e.width,n.height=e.lines}const h={idx:new Array(3)};for(let t=0;t<e.channels;++t){const e=l[t];for(let n=0;n<s.length;++n){const r=s[n];e.name==r.name&&(e.compression=r.compression,r.index>=0&&(h.idx[r.index]=t),e.offset=t)}}let d,c,u;if(i.acCompressedSize>0)switch(i.acCompression){case 0:d=new Uint16Array(i.totalAcUncompressedCount),_(e.array,t,n,i.acCompressedSize,d,i.totalAcUncompressedCount);break;case 1:const r=so(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));d=new Uint16Array(r.buffer),n.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){const t={array:e.array,offset:n,size:i.dcCompressedSize};c=new Uint16Array(A(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(u=y(so(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0;const m=new Array(l.length);for(let e=0;e<m.length;++e)m[e]=new Array;for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)m[t].push(p),p+=l[t].width*e.type*2;!function(e,t,n,r,i,s){let a=new DataView(s.buffer);const o=n[e.idx[0]].width,l=n[e.idx[0]].height,h=Math.floor(o/8),d=Math.ceil(o/8),c=Math.ceil(l/8),u=o-8*(d-1),p=l-8*(c-1),m={value:0},g=new Array(3),f=new Array(3),_=new Array(3),v=new Array(3),w=new Array(3);for(let n=0;n<3;++n)w[n]=t[e.idx[n]],g[n]=n<1?0:g[n-1]+d*c,f[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(64*d);for(let t=0;t<c;++t){let s=8;t==c-1&&(s=p);let o=8;for(let e=0;e<d;++e){e==d-1&&(o=u);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[g[e]++],x(m,r,_[e]),b=_[e],(y=f[e])[0]=j(b[0]),y[1]=j(b[1]),y[2]=j(b[5]),y[3]=j(b[6]),y[4]=j(b[14]),y[5]=j(b[15]),y[6]=j(b[27]),y[7]=j(b[28]),y[8]=j(b[2]),y[9]=j(b[4]),y[10]=j(b[7]),y[11]=j(b[13]),y[12]=j(b[16]),y[13]=j(b[26]),y[14]=j(b[29]),y[15]=j(b[42]),y[16]=j(b[3]),y[17]=j(b[8]),y[18]=j(b[12]),y[19]=j(b[17]),y[20]=j(b[25]),y[21]=j(b[30]),y[22]=j(b[41]),y[23]=j(b[43]),y[24]=j(b[9]),y[25]=j(b[11]),y[26]=j(b[18]),y[27]=j(b[24]),y[28]=j(b[31]),y[29]=j(b[40]),y[30]=j(b[44]),y[31]=j(b[53]),y[32]=j(b[10]),y[33]=j(b[19]),y[34]=j(b[23]),y[35]=j(b[32]),y[36]=j(b[39]),y[37]=j(b[45]),y[38]=j(b[52]),y[39]=j(b[54]),y[40]=j(b[20]),y[41]=j(b[22]),y[42]=j(b[33]),y[43]=j(b[38]),y[44]=j(b[46]),y[45]=j(b[51]),y[46]=j(b[55]),y[47]=j(b[60]),y[48]=j(b[21]),y[49]=j(b[34]),y[50]=j(b[37]),y[51]=j(b[47]),y[52]=j(b[50]),y[53]=j(b[56]),y[54]=j(b[59]),y[55]=j(b[61]),y[56]=j(b[35]),y[57]=j(b[36]),y[58]=j(b[48]),y[59]=j(b[49]),y[60]=j(b[57]),y[61]=j(b[58]),y[62]=j(b[62]),y[63]=j(b[63]),S(f[e]);C(f);for(let t=0;t<3;++t)M(f[t],v[t],64*e)}let l=0;for(let r=0;r<3;++r){const i=n[e.idx[r]].type;for(let e=8*t;e<8*t+s;++e){l=w[r][e];for(let t=0;t<h;++t){const n=64*t+8*(7&e);a.setUint16(l+0*i,v[r][n+0],!0),a.setUint16(l+2*i,v[r][n+1],!0),a.setUint16(l+4*i,v[r][n+2],!0),a.setUint16(l+6*i,v[r][n+3],!0),a.setUint16(l+8*i,v[r][n+4],!0),a.setUint16(l+10*i,v[r][n+5],!0),a.setUint16(l+12*i,v[r][n+6],!0),a.setUint16(l+14*i,v[r][n+7],!0),l+=16*i}}if(h!=d)for(let e=8*t;e<8*t+s;++e){const t=w[r][e]+8*h*2*i,n=64*h+8*(7&e);for(let e=0;e<o;++e)a.setUint16(t+2*e*i,v[r][n+e],!0)}}}var b,y;const T=new Uint16Array(o);a=new DataView(s.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;const r=n[e.idx[t]].type;if(2==n[t].type)for(let e=0;e<l;++e){const n=w[t][e];for(let e=0;e<o;++e)T[e]=a.getUint16(n+2*e*r,!0);for(let e=0;e<o;++e)a.setFloat32(n+2*e*r,j(T[e]),!0)}}}(h,m,l,d,c,r);for(let t=0;t<l.length;++t){const n=l[t];if(!n.decoded)switch(n.compression){case 2:let i=0,s=0;for(let a=0;a<e.lines;++a){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)r[e++]=u[s+t*n.width*n.height];s++}i++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(r.buffer)}function D(e,t){const n=new Uint8Array(e);let r=0;for(;0!=n[t.value+r];)r+=1;const i=(new TextDecoder).decode(n.slice(t.value,t.value+r));return t.value=t.value+r+1,i}function O(e,t){const n=e.getInt32(t.value,!0);return t.value=t.value+4,n}function L(e,t){const n=e.getUint32(t.value,!0);return t.value=t.value+4,n}function k(e,t){const n=e[t.value];return t.value=t.value+1,n}function U(e,t){const n=e.getUint8(t.value);return t.value=t.value+1,n}const F=function(e,t){let n;return n="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function N(e,t){const n=e.getFloat32(t.value,!0);return t.value+=4,n}function B(e,t){return rt.toHalfFloat(N(e,t))}function j(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function H(e,t){return j(G(e,t))}function z(e,t,n,r,i){return"string"===r||"stringvector"===r||"iccProfile"===r?function(e,t,n){const r=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,r}(t,n,i):"chlist"===r?function(e,t,n,r){const i=n.value,s=[];for(;n.value<i+r-1;){const r=D(t,n),i=O(e,n),a=U(e,n);n.value+=3;const o=O(e,n),l=O(e,n);s.push({name:r,pixelType:i,pLinear:a,xSampling:o,ySampling:l})}return n.value+=1,s}(e,t,n,i):"chromaticities"===r?function(e,t){return{redX:N(e,t),redY:N(e,t),greenX:N(e,t),greenY:N(e,t),blueX:N(e,t),blueY:N(e,t),whiteX:N(e,t),whiteY:N(e,t)}}(e,n):"compression"===r?function(e,t){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][U(e,t)]}(e,n):"box2i"===r?function(e,t){return{xMin:L(e,t),yMin:L(e,t),xMax:L(e,t),yMax:L(e,t)}}(e,n):"lineOrder"===r?function(e,t){return["INCREASING_Y"][U(e,t)]}(e,n):"float"===r?N(e,n):"v2f"===r?function(e,t){return[N(e,t),N(e,t)]}(e,n):"v3f"===r?function(e,t){return[N(e,t),N(e,t),N(e,t)]}(e,n):"int"===r?O(e,n):"rational"===r?function(e,t){return[O(e,t),L(e,t)]}(e,n):"timecode"===r?function(e,t){return[L(e,t),L(e,t)]}(e,n):"preview"===r?(n.value+=i,"skipped"):void(n.value+=i)}const V=new DataView(e),W=new Uint8Array(e),K={value:0},q=function(e,t,n){const r={};if(20000630!=e.getUint32(0,!0))throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");r.version=e.getUint8(4);const i=e.getUint8(5);r.spec={singleTile:!!(2&i),longName:!!(4&i),deepFormat:!!(8&i),multiPart:!!(16&i)},n.value=8;let s=!0;for(;s;){const i=D(t,n);if(0==i)s=!1;else{const s=D(t,n),a=z(e,t,n,s,L(e,n));void 0===a?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${s}'.`):r[i]=a}}if(0!=(-5&i))throw console.error("THREE.EXRHeader:",r),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return r}(V,e,K),X=function(e,t,n,r,i){const s={size:0,viewer:t,array:n,offset:r,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,channels:e.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:e.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:w};switch(e.compression){case"NO_COMPRESSION":s.lines=1,s.uncompress=T;break;case"RLE_COMPRESSION":s.lines=1,s.uncompress=P;break;case"ZIPS_COMPRESSION":s.lines=1,s.uncompress=A;break;case"ZIP_COMPRESSION":s.lines=16,s.uncompress=A;break;case"PIZ_COMPRESSION":s.lines=32,s.uncompress=E;break;case"PXR24_COMPRESSION":s.lines=16,s.uncompress=R;break;case"DWAA_COMPRESSION":s.lines=32,s.uncompress=I;break;case"DWAB_COMPRESSION":s.lines=256,s.uncompress=I;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}if(s.scanlineBlockSize=s.lines,1==s.type)switch(i){case et:s.getter=H,s.inputSize=2;break;case $e:s.getter=G,s.inputSize=2}else{if(2!=s.type)throw new Error("EXRLoader.parse: unsupported pixelType "+s.type+" for "+e.compression+".");switch(i){case et:s.getter=N,s.inputSize=4;break;case $e:s.getter=B,s.inputSize=4}}s.blockCount=(e.dataWindow.yMax+1)/s.scanlineBlockSize;for(let e=0;e<s.blockCount;e++)F(t,r);s.outputChannels=3==s.channels?4:s.channels;const a=s.width*s.height*s.outputChannels;switch(i){case et:s.byteArray=new Float32Array(a),s.channels<s.outputChannels&&s.byteArray.fill(1,0,a);break;case $e:s.byteArray=new Uint16Array(a),s.channels<s.outputChannels&&s.byteArray.fill(15360,0,a);break;default:console.error("THREE.EXRLoader: unsupported type: ",i)}return s.bytesPerLine=s.width*s.inputSize*s.channels,4==s.outputChannels?(s.format=be,s.colorSpace=w):(s.format=tt,s.colorSpace=nt),s}(q,V,W,K,this.type),Q={value:0},Y={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<X.height/X.scanlineBlockSize;e++){const t=L(V,K);X.size=L(V,K),X.lines=t+X.scanlineBlockSize>X.height?X.height-t:X.scanlineBlockSize;const n=X.size<X.lines*X.bytesPerLine?X.uncompress(X):T(X);K.value+=X.size;for(let t=0;t<X.scanlineBlockSize;t++){const r=t+e*X.scanlineBlockSize;if(r>=X.height)break;for(let e=0;e<X.channels;e++){const i=Y[q.channels[e].name];for(let s=0;s<X.width;s++){Q.value=(t*(X.channels*X.width)+e*X.width+s)*X.inputSize;const a=(X.height-1-r)*(X.width*X.outputChannels)+s*X.outputChannels+i;X.byteArray[a]=X.getter(n,Q)}}}}return{header:q,width:X.width,height:X.height,data:X.byteArray,format:X.format,colorSpace:X.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){e.colorSpace=n.colorSpace,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}),n,r)}}class lo extends Je{constructor(e){super(e),this.type=$e}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},n=function(e,t,n){t=t||1024;let r=e.pos,i=-1,s=0,a="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(i=o.indexOf("\n"))&&s<t&&r<e.byteLength;)a+=o,s+=o.length,r+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=s+i+1),a+o.slice(0,i))},r=function(e,t,n,r){const i=e[t+3],s=Math.pow(2,i-128)/255;n[r+0]=e[t+0]*s,n[r+1]=e[t+1]*s,n[r+2]=e[t+2]*s,n[r+3]=1},i=function(e,t,n,r){const i=e[t+3],s=Math.pow(2,i-128)/255;n[r+0]=rt.toHalfFloat(Math.min(e[t+0]*s,65504)),n[r+1]=rt.toHalfFloat(Math.min(e[t+1]*s,65504)),n[r+2]=rt.toHalfFloat(Math.min(e[t+2]*s,65504)),n[r+3]=rt.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const a=function(e){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,h;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(h=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=h[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(r))&&(o.gamma=parseFloat(h[1])),(h=l.match(i))&&(o.exposure=parseFloat(h[1])),(h=l.match(s))&&(o.valid|=2,o.format=h[1]),(h=l.match(a))&&(o.valid|=4,o.height=parseInt(h[1],10),o.width=parseInt(h[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,h=function(e,n,r){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const s=new Uint8Array(4*n*r);s.length||t(4,"unable to allocate buffer space");let a=0,o=0;const l=4*i,h=new Uint8Array(4),d=new Uint8Array(l);let c=r;for(;c>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==i||t(3,"bad rgbe scanline format");let n,r=0;for(;r<l&&o<e.byteLength;){n=e[o++];const i=n>128;if(i&&(n-=128),(0===n||r+n>l)&&t(3,"bad scanline data"),i){const t=e[o++];for(let e=0;e<n;e++)d[r++]=t}else d.set(e.subarray(o,o+n),r),r+=n,o+=n}const u=i;for(let e=0;e<u;e++){let t=0;s[a]=d[e+t],t+=i,s[a+1]=d[e+t],t+=i,s[a+2]=d[e+t],t+=i,s[a+3]=d[e+t],a+=4}c--}return s}(s.subarray(s.pos),o,l);let d,c,u;switch(this.type){case et:u=h.length/4;const e=new Float32Array(4*u);for(let t=0;t<u;t++)r(h,4*t,e,4*t);d=e,c=et;break;case $e:u=h.length/4;const t=new Uint16Array(4*u);for(let e=0;e<u;e++)i(h,4*e,t,4*e);d=t,c=$e;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:o,height:l,data:d,header:a.string,gamma:a.gamma,exposure:a.exposure,type:c}}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){switch(e.type){case et:case $e:e.colorSpace=w,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,r)}}const ho={uniforms:{tDiffuse:{value:null},colorTransform:{value:new C},colorBase:{value:new st(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new at}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = colorTransform * texture2D(tDiffuse, vUv) + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n gl_FragColor = color;\n }"},co=new C,uo=(new C).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),po=(new C).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),mo=(new C).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),go=(new C).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),fo=new st(0,0,0,0),_o=new st(0,0,0,1),vo=new at,wo=(new at).set(1,0,0,0,-1,1,0,0,1),bo=(e,t,n,r)=>(new C).set(e,0,0,1-e,0,t,0,1-t,0,0,n,1-n,0,0,0,r);var yo;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ADDITIVE=1]="ADDITIVE"}(yo||(yo={}));class xo extends ot{constructor(e,t=yo.ADDITIVE){const n=t===yo.ADDITIVE?{blendSrc:lt,blendDst:ht,blendEquation:dt,blendSrcAlpha:ct,blendDstAlpha:ht,blendEquationAlpha:dt}:{};super({uniforms:ut.clone(ho.uniforms),vertexShader:ho.vertexShader,fragmentShader:ho.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,...n}),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const So={uniforms:{tDiffuse:{value:null},rangeMin:{value:new s(1/512,1/512)},rangeMax:{value:new s(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new s(.1,.9),new s(.1,.9);class Co extends ot{constructor(e){super({defines:Object.assign({},Co._linearDepthShader.defines),uniforms:ut.clone(Co._linearDepthShader.uniforms),vertexShader:Co._linearDepthShader.vertexShader,fragmentShader:Co._linearDepthShader.fragmentShader,blending:pt}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}Co._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new st(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include <packing>\n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class Mo extends ot{constructor(e){var t;super({defines:Object.assign({...Mo._normalAndDepthShader.defines,FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0}),uniforms:ut.clone(Mo._normalAndDepthShader.uniforms),vertexShader:Mo._normalAndDepthShader.vertexShader,fragmentShader:Mo._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:pt}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}Mo._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};const To=new Y(-1,1,1,-1,0,1),Po=new class extends c{constructor(){super(),this.setAttribute("position",new Re([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Re([0,2,0,0,2,0],2))}};class Ao{constructor(e){this._mesh=new H(Po,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,To)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}new E;class Eo{constructor(){this.bounds=new ge(new a(-1,-1,-1),new a(1,1,1)),this.size=new a(2,2,2),this.center=new a(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new a(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Y?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof X&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),r=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const i=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),s=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=i/s,e.fov=Q.radToDeg(2*Math.atan2(s,n)),e.near=n,e.far=r,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}class Ro{changed(e){var t,n;const r=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),r}}class Io{constructor(){this._originalClearColor=new h,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new Ao(void 0),this._emptyScene=new Se,this._defaultCamera=new X}renderWithOverrideMaterial(e,t,n,r,i,s,a){this._backup(e),this._prepareRenderer(e,i,s,a);const o=t.overrideMaterial;t.overrideMaterial=r,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,r){this._backup(e),this._prepareRenderer(e,t,n,r),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,r,i,s){this._backup(e),this._prepareRenderer(e,r,i,s),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,r,i){this._backup(e),this._prepareRenderer(e,n,r,i),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,r){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(r||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class Do{constructor(e,t){var n;this._renderPass=null!==(n=null==t?void 0:t._renderPass)&&void 0!==n?n:new Io,this._blurMaterial=new ot(null!=e?e:So),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,r){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=r[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._renderPass.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=r[1],this._renderPass.renderScreenSpace(e,this._blurMaterial,t[2])}}class Oo{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse(e=>{var t,n,r;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(r=this._cache)||void 0===r||r.addObject(e)}),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class Lo{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach(e=>{e.dispose()})}registerCache(e,t){this._cacheMap.set(e,new Oo(t))}clearCache(){this._cacheMap.forEach(e=>{e.clear()})}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const r=this._cacheMap.get(e);r&&(r.update(t),r.onBeforeRender()),n(),r&&r.onAfterRender()}}class ko{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach((e,t)=>{t.visible=!1})}onAfterRender(){this._visibilityCache.forEach((e,t)=>{t.visible=e})}}class Uo{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof N&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!1})}onAfterRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!0})}}class Fo{get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatGBufferRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatGBufferRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatGBufferRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get normalRenderMaterial(){var e;return this._normalRenderMaterial=null!==(e=this._normalRenderMaterial)&&void 0!==e?e:this.floatGBufferRgbNormalAlphaDepth?new Mo({blending:pt,floatBufferType:!0,linearDepth:!1}):new mt({blending:pt}),this._normalRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatGBufferRgbNormalAlphaDepth)this._depthNormalRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:et,samples:this._samples});else{const e=new ft(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=_t,e.type=vt,this._depthNormalRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:et,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,r,i,s,a,o,l,h,d,c;this.floatGBufferRgbNormalAlphaDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.floatGBufferRgbNormalAlphaDepth=null!==(r=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==r&&r,this._renderCacheManager=e,this._renderCacheManager&&this._renderCacheManager.registerCache(this,new ko(e=>{if(e.isMesh&&e.material){if(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)return!0;if(e.material instanceof S)return e.material.transmission>0}return!1})),this.parameters={depthNormalScale:null!==(i=null==t?void 0:t.depthNormalScale)&&void 0!==i?i:1},this._targetMinificationTextureFilter=null!==(s=null==t?void 0:t.textureMinificationFilter)&&void 0!==s?s:ne,this._targetMagnificationTextureFilter=null!==(a=null==t?void 0:t.textureMagnificationFilter)&&void 0!==a?a:ne,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(h=null==t?void 0:t.samples)&&void 0!==h?h:0,this._shared=null!==(d=null==t?void 0:t.shared)&&void 0!==d&&d,this._renderPass=null!==(c=null==t?void 0:t.renderPass)&&void 0!==c?c:new Io}dispose(){var e,t;null===(e=this._normalRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}render(e,t,n){if(this._shared&&!this.needsUpdate)return;this.needsUpdate=!1;const r=this.normalRenderMaterial;r instanceof Mo&&r.update({camera:n}),this._renderCacheManager?this._renderCacheManager.render(this,t,()=>{this._renderGBuffer(e,t,n)}):this._renderGBuffer(e,t,n),this.floatGBufferRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget)}_renderGBuffer(e,t,n){this._renderPass.renderWithOverrideMaterial(e,t,n,this.normalRenderMaterial,this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new xo),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:pt,colorTransform:po,colorBase:_o,multiplyChannels:0,uvTransform:vo}),this.separateDeptRenderTarget)}}class No{constructor(e,t,n){var r;this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=t,this.shadowMapSize=null!==(r=n.shadowMapSize)&&void 0!==r?r:2048,this.parameters=this._getDefaultParameters(n),this._groundShadowFar=this.parameters.cameraFar,this._renderer=e,this._renderCacheManager=null==n?void 0:n._renderCacheManager,this._renderCacheManager&&this._renderCacheManager.registerCache(this,new ko(e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name))),this.renderTarget=new gt(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new gt(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this.shadowGroundPlane=new Bo(this.renderTarget.texture,this.parameters),this._groundGroup.add(this.shadowGroundPlane),this._groundContactCamera=new jo,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new yt,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",Bo.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=B,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new Do(So,n),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return{enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:20,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0,...e}}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFar<e.size.z&&(this._groundShadowFar=1.01*e.size.z);const r=Math.max(e.size.x,e.size.z);this.parameters.planeSize=r+2*Math.max(this._blurScale,null!==(n=this._shadowScale)&&void 0!==n?n:1,1),this.parameters.planeSize>this.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibility(e,t){this.shadowGroundPlane.updateVisibility(e)}render(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,e),this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(e),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this._renderCacheManager?this._renderCacheManager.render(this,e,()=>{this._renderer.render(e,this._groundContactCamera)}):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}No.addTestMesh=!1;class Bo extends H{constructor(e,t){const n=new y({transparent:!0,depthWrite:!1});Bo.alphaMap&&n.color.set(0),n.polygonOffset=!0,super(new wt(1,1,10,10),n),this.name="GroundContactShadowPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.visible?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;t.map=e,Bo.alphaMap&&(t.alphaMap=e),t.needsUpdate=!0}updateMaterial(e){const t=this.material;t.opacity!==e.opacity&&(t.opacity=e.opacity),t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset)}updateVisibility(e){e?this.layers.enableAll():this.layers.disableAll()}}Bo.alphaMap=!1;class jo extends Y{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,r,i;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new bt(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(r=this.cameraHelper)||void 0===r?void 0:r.parent)&&(null===(i=this.cameraHelper)||void 0===i||i.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}const Go={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},Ho={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new s(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\tprecision highp float;\n\n\tuniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t//----------------------------------------------------------------------------------\n\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t// SDK Version: v3.00\n\t// Email: gameworks@nvidia.com\n\t// Site: http://developer.nvidia.com/\n\t//\n\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t//\n\t// Redistribution and use in source and binary forms, with or without\n\t// modification, are permitted provided that the following conditions\n\t// are met:\n\t// * Redistributions of source code must retain the above copyright\n\t// notice, this list of conditions and the following disclaimer.\n\t// * Redistributions in binary form must reproduce the above copyright\n\t// notice, this list of conditions and the following disclaimer in the\n\t// documentation and/or other materials provided with the distribution.\n\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t// contributors may be used to endorse or promote products derived\n\t// from this software without specific prior written permission.\n\t//\n\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t//\n\t//----------------------------------------------------------------------------------\n\n\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t#endif\n\n\t/*--------------------------------------------------------------------------*/\n\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t/*--------------------------------------------------------------------------*/\n\n\t#define NUM_SAMPLES 5\n\n\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t}\n\n\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t============================================================================*/\n\n\t/*--------------------------------------------------------------------------*/\n\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t\t// locate the edge\n\t\t\t\t\tvec2 dirToEdge;\n\t\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t\t// . 2 . . 1 .\n\t\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t\t// . 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 H\n\n\t\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t\t// V 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 .\n\n\t\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t\t\t// 1 1 .\n\t\t\t\t\t\t\t// 0 0 1\n\t\t\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t\t\t// do a simple blur\n\t\t\t\t\t\t\treturn mix(\n\t\t\t\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t\t\t\t.4\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\t\titerationsUsed = i;\n\n\t\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\t\tif(!doneN) {\n\t\t\t\t\t\t\tnDist += increment;\n\t\t\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(!doneP) {\n\t\t\t\t\t\t\tpDist += increment;\n\t\t\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\t\trgbaM,\n\t\t\t\t\trgbaN,\n\t\t\t\t\tdist * .5\n\t\t\t);\n\t}\n\n\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\t\tvUv,\n\t\t\t\t\ttDiffuse,\n\t\t\t\t\tresolution,\n\t\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t}\n\t"};class zo extends class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}{constructor(e,t,n,r,i){var a;super(),this.patternTexture=null,this._gBufferRenderTarget=null==i?void 0:i._gBufferRenderTarget,this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new h(1,1,1),this.hiddenEdgeColor=new h(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==i?void 0:i.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==i?void 0:i.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==e?new s(e.x,e.y):new s(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this._gBufferRenderTarget||(this.depthMaterial=new yt,this.depthMaterial.side=B,this.depthMaterial.depthPacking=xt,this.depthMaterial.blending=pt),this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=B,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this._gBufferRenderTarget||(this.renderTargetDepthBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new ot(Ho),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new gt(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new gt(o,l),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new gt(o,l),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new gt(Math.round(o/2),Math.round(l/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new gt(o,l),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new gt(Math.round(o/2),Math.round(l/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(o,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const d=Go;this.copyUniforms=ut.clone(d.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ot({uniforms:this.copyUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:pt,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new h,this.oldClearAlpha=1,this.fsQuad=new Ao(void 0),this.tempPulseColor1=new h,this.tempPulseColor2=new h,this.textureMatrix=new C}dispose(){var e,t,n,r;this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),null===(t=this.renderTargetDepthBuffer)||void 0===t||t.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),null===(n=this.depthMaterial)||void 0===n||n.dispose(),this.prepareMaskMaterial.dispose(),null===(r=this.fxaaRenderMaterial)||void 0===r||r.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,r,i;this.renderTargetMaskBuffer.setSize(e,t),null===(n=this.renderTargetDepthBuffer)||void 0===n||n.setSize(e,t);let s=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(s,a),this.renderTargetBlurBuffer1.setSize(s,a),this.renderTargetEdgeBuffer1.setSize(s,a),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),s=Math.round(s/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(s,a),this.renderTargetEdgeBuffer2.setSize(s,a),this.separableBlurMaterial2.uniforms.texSize.value.set(s,a),null===(r=this.fxaaRenderMaterial)||void 0===r||r.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(i=this.renderTargetFxaaBuffer)||void 0===i||i.setSize(e,t)}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;function n(n){n.isMesh&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}this.selectedObjects.forEach(e=>e.traverse(n))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];function r(e){e.isMesh&&n.push(e)}this.selectedObjects.forEach(e=>e.traverse(r)),this.renderScene.traverse((function(r){if(r.isMesh||r.isSprite){if(!1===n.some(e=>e.id===r.id)){const n=r.visible;!1!==e&&!0!==t.get(r)||(r.visible=e),t.set(r,n)}}else(r.isPoints||r.isLine)&&(!0===e?r.visible=t.get(r):(t.set(r,r.visible),r.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,r,i){var s,a;if(this.selectedObjects.length>0){null===(s=this._gBufferRenderTarget)||void 0===s||s.render(e,this.renderScene,this.renderCamera),e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;e.autoClear=!1,i&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const r=this.renderScene.background;this.renderScene.background=null,this.renderTargetDepthBuffer&&this.depthMaterial&&(this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera)),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this._gBufferRenderTarget?this.prepareMaskMaterial.uniforms.depthTexture.value=this._gBufferRenderTarget.textureWithDepthValue:this.prepareMaskMaterial.uniforms.depthTexture.value=null===(a=this.renderTargetDepthBuffer)||void 0===a?void 0:a.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=r;let o=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),o=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=o.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=zo.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=zo.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=zo.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=zo.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=o.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}_getPrepareMaskMaterial(e){return new ot({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new s(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new ot({uniforms:{maskTexture:{value:null},texSize:{value:new s(.5,.5)},visibleEdgeColor:{value:new a(1,1,1)},hiddenEdgeColor:{value:new a(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new ot({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new s(.5,.5)},direction:{value:new s(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new ot({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:St,depthTest:!1,depthWrite:!1,transparent:!0})}}zo.BlurDirectionX=new s(1,0),zo.BlurDirectionY=new s(0,1);class Vo{get isOutlinePassActivated(){return this.outlinePassActivated}constructor(e,t,n,r){this._width=0,this._height=0,this._effectComposer=null,this.outlinePass=null,this.outlinePassActivated=!1,this._effectComposer=e,this._gBufferRenderTarget=null==r?void 0:r._gBufferRenderTarget,this._width=t,this._height=n,this.parameters={enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215,...r}}dispose(){var e;null===(e=this.outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this.outlinePass)||void 0===n||n.setSize(e,t)}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const r=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!r&&this.outlinePassActivated||(!r&&this.outlinePass||(this.outlinePass=new zo(new s(this._width,this._height),e,t,[],{downSampleRatio:2,edgeDetectionFxaa:!0,_gBufferRenderTarget:this._gBufferRenderTarget})),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class Wo extends V{constructor(e,t){const n=new c;n.setAttribute("position",new Re([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new F({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=new c;r.setAttribute("position",new Re([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new H(r,new y({side:Ct,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}var Ko;!function(e){e[e.DirectionalLightShadow=0]="DirectionalLightShadow",e[e.SpotLightShadow=1]="SpotLightShadow"}(Ko||(Ko={}));const qo={alwaysUpdate:!1,enableShadowMap:!0,layers:null,shadowLightSourceType:Ko.DirectionalLightShadow,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundContainment:1,fadeOutDistance:.1,fadeOutBlur:20};class Xo{get shadowTexture(){return this._shadowRenderTarget.texture}constructor(e,t,n){var r,i;this.needsUpdate=!1,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new $o,this._shadowLightSources=[],this._shadowScale=1,this._renderPass=new Io,this._cameraUpdate=new Ro,this._renderCacheManager=e,this._viewportSize=new s(t.x,t.y),this._samples=null!==(r=null==n?void 0:n.samples)&&void 0!==r?r:0,this._shadowMapSize=null!==(i=null==n?void 0:n.shadowMapSize)&&void 0!==i?i:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Jo(this.parameters),this._renderCacheManager.registerCache(this,this._shadowMapPassOverrideMaterialCache);const a=this._samples;this._shadowRenderTarget=new gt(this._viewportSize.x,this._viewportSize.y,{samples:a,format:tt})}_getScreenSpaceShadowMapParameters(e){return{...qo,...e}}dispose(){this._shadowLightSources.forEach(e=>e.dispose()),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){const n=this._shadowScale;this._shadowScale=t,Math.abs(n-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach(t=>t.updateBounds(e)),this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach(e=>e.forceShadowUpdate()),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map(e=>e.getShadowLight())}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find(t=>t.getOriginalLight()===e))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new tl(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){this._shadowLightSources=this._shadowLightSources.filter(n=>{if(n instanceof tl){const t=n.getRectAreaLight();if(e.includes(t))return n.updatePositionAndTarget(),!0}return n.removeFrom(t),n.dispose(),!1}),e.forEach(e=>{this._shadowLightSources.find(t=>t instanceof tl&&t.getRectAreaLight()===e)||this.addRectAreaLight(e,t)}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){this._shadowLightSources=this._shadowLightSources.filter(t=>{t.removeFrom(e),t.dispose()});const n=1/(t.length>0?Math.max(...t.map(e=>e.maxIntensity)):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach(t=>{t.addTo(e),t.updatePositionAndTarget()}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach(e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new a(e.position.x,e.position.z,e.position.y).multiplyScalar(7),r=new nl(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(r)}})}setSize(e,t){this._viewportSize=new s(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach(e=>e.updatePositionAndTarget())}renderShadowMap(e,t,n){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(n)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const r=t.background,i=t.environment,s=n.layers.mask;t.environment=null,t.background=null,this.parameters.layers&&(n.layers.mask=this.parameters.layers.mask),this._renderSimpleShadowMapFromShadowLightSources(e,t,n),n.layers.mask=s,t.environment=i,t.background=r}_renderSimpleShadowMapFromShadowLightSources(e,t,n){this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundContainment,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const r=this._getSortedShadowLightSources();0===r.length?this._renderPass.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(r),this._renderCacheManager.render(this,t,()=>{this._renderPass.render(e,t,n,this._shadowRenderTarget,16777215,1)}),this._shadowLightSources.forEach(e=>e.finishRenderShadow()))}_getSortedShadowLightSources(){let e=[];return this._shadowLightSources.forEach(t=>e.push(...t.prepareRenderShadow())),e.sort((e,t)=>e.light.castShadow&&!t.light.castShadow?-1:!e.light.castShadow&&t.light.castShadow?1:t.intensity-e.intensity),e}_setShadowLightSourcesIntensity(e){var t;let n=0;for(let t=0;t<e.length;t++){const r=e[t];(this.parameters.maximumNumberOfLightSources<0||t<this.parameters.maximumNumberOfLightSources)&&(n+=r.intensity)}for(let r=0;r<e.length;r++){const i=e[r];this.parameters.maximumNumberOfLightSources<0||r<this.parameters.maximumNumberOfLightSources?(i.light.visible=!0,i.light.intensity=i.intensity/n,(t=i.light).castShadow&&(t.castShadow=this.castShadow)):(i.light.visible=!1,i.light.intensity=0,i.light.castShadow=!1)}}_updateShadowType(e){e.shadowMap.type=this.shadowConfiguration.currentConfiguration.type;const t=this.parameters.enableShadowMap&&this.shadowConfiguration.currentConfiguration.castShadow;e.shadowMap.enabled=t,e.shadowMap.needsUpdate=!0,this.castShadow=t&&this.shadowConfiguration.currentConfiguration.castShadow,this._shadowLightSources.forEach(e=>e._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}var Qo,Yo,Zo;!function(e){e[e.Default=0]="Default",e[e.Unlit=1]="Unlit",e[e.Emissive=2]="Emissive",e[e.Shadow=3]="Shadow"}(Qo||(Qo={}));class Jo{constructor(e){var t,n;this._sceneBoxMin=new a(-1,-1,-1),this._sceneBoxMax=new a(1,1,1),this._distributionProperties=new st(1,1,1,0),this._objectCache=new Map,this._shadowFadeOut=new s(null!==(t=null==e?void 0:e.fadeOutTo)&&void 0!==t?t:.5,null!==(n=null==e?void 0:e.fadeOutBlur)&&void 0!==n?n:60),this._shadowObjectMaterial=this._createShadowMaterial(Qo.Default),this._unlitMaterial=this._createShadowMaterial(Qo.Unlit),this._emissiveMaterial=this._createShadowMaterial(Qo.Emissive),this._receiveShadowMaterial=this._createShadowMaterial(Qo.Shadow)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,r,i){this._distributionProperties.set(e,t,n,0),this._shadowFadeOut.set(r,i)}setBoundingBox(e){this._sceneBoxMin.copy(e.min),this._sceneBoxMax.copy(e.max)}_createShadowMaterial(e){let t;return t=e===Qo.Emissive||e===Qo.Unlit?new y({color:16777215,side:B}):e===Qo.Shadow?new Et({side:B}):Jo.useModifiedMaterial?this._createCustomerShadowMaterial():new Rt({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:B}),t}_createCustomerShadowMaterial(){const e=new It({side:B});return e.onBeforeCompile=e=>{e.vertexShader="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n #include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\n vWorldPosition = worldPosition.xyz;\n}\n",e.fragmentShader="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n\n#include <common>\n#include <packing>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvec2 getShadowDynamicScale() {\n\n vec2 dynamicScale = vec2(0.0, 1.0);\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (shadowFadeOut.x > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n \n // linear interpolation gives better result than smooth Hermite interpolation\n // float shadowBase = smoothstep(0.0, shadowFadeOut.x, boxDistance);\n float shadowBase = boxDistance / shadowFadeOut.x;\n\n shadowBase = clamp(shadowBase, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n\n float dynamicRadius = shadowRadius;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && shadowFadeOut.x > 0.0) {\n float shadowDepth = unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy));\n float delta = shadowDepth - shadowCoord.z;\n float fadeOutScale = max(shadowScale.x, smoothstep(max(shadowDepth, 0.5), shadowFadeOut.x * 0.5 + 0.5, shadowCoord.z));\n dynamicRadius = shadowRadius + shadowFadeOut.y * max(0.0, fadeOutScale);\n }\n#endif\n\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include <logdepthbuf_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n IncidentLight directLight;\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n float groundContainment = mix(1.0, groundDistance, distributionProperties.z);\n vec2 dynamicScale = getShadowDynamicScale();\n #if ( NUM_DIR_LIGHTS > 0 )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n float dynamicRadius;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float shadowFactor;\n float dotNL;\n float incidentLightFactor;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightFactor = clamp(dotNL, 0.0, 1.0);\n\n dynamicRadius = 0.0;\n shadowFactor = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n incidentLightFactor = mix(\n mix(pow(incidentLightFactor, 4.0), 1.0, step(0.99, shadowFactor)),\n pow(incidentLightFactor, distributionProperties.y),\n groundContainment);\n incidentLightSum += directLight.color * mix(incidentLightFactor, 1.0, groundContainment);\n incidentShadowLight += directLight.color * mix(\n shadowFactor * incidentLightFactor, \n mix(1.0, shadowFactor, incidentLightFactor), \n groundContainment);\n }\n #pragma unroll_loop_end\n\n if (dot(incidentLightSum, vec3(1.0)) > 0.01) {\n directionDependentShadowLight = incidentShadowLight / incidentLightSum;\n }\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(distributionProperties.x, 1.0 - groundDistance));\n outgoingLight = dynamicScale.x + directionDependentShadowLight.y * outgoingLight;\n\n\t#include <opaque_fragment>\n\t#include <premultiplied_alpha_fragment>\n}\n",e.defines=Object.assign({...e.defines,DYNAMIC_SHADOW_RADIUS:""});const t=e.uniforms;t&&(t.distributionProperties={value:this._distributionProperties},t.shadowFadeOut={value:this._shadowFadeOut},t.sceneBoxMin={value:this._sceneBoxMin},t.sceneBoxMax={value:this._sceneBoxMax})},e}clear(){this._objectCache.clear()}addLineOrPoint(e){this._addCacheEntry(e,!1,!1)}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this._addCacheEntry(e,!1,!1)}_addCacheEntry(e,t,n,r){this._objectCache.set(e,{originalObject:{visible:e.visible,castShadow:e.castShadow,material:e.material},shadowObject:{visible:t,castShadow:n,material:r}})}onBeforeRender(){this._objectCache.forEach((e,t)=>{t.visible=e.shadowObject.visible,t.castShadow=e.shadowObject.castShadow,t instanceof H&&e.shadowObject.material&&(t.material=e.shadowObject.material)})}onAfterRender(){this._objectCache.forEach((e,t)=>{t.visible=e.originalObject.visible,t.castShadow=e.originalObject.castShadow,e.originalObject.material&&(t.material=e.originalObject.material)})}_setMeshMaterialAndVisibility(e){!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.userData.isFloor?this._addCacheEntry(e,e.visible,e.castShadow,this._shadowObjectMaterial):e.material&&e.material.transparent&&e.material.opacity<.9?this._addCacheEntry(e,!1,e.castShadow,this._shadowObjectMaterial):e.receiveShadow?this._addCacheEntry(e,e.visible,!1,this._receiveShadowMaterial):this._addCacheEntry(e,!1,e.castShadow,e.material):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof F||t instanceof y?this._addCacheEntry(e,e.visible,e.castShadow,this._unlitMaterial):t instanceof N?this._setMeshShadowStandardMaterial(e,t):this._addCacheEntry(e,e.visible,e.castShadow,e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial)}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this._addCacheEntry(e,e.visible,!n&&e.castShadow,n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial)}}Jo.useModifiedMaterial=!0;class $o{constructor(){var e;this.types=new Map([["off",$o._noShadow],["BasicShadowMap",$o._basicShadow],["PCFShadowMap",$o._pcfShadow],["PCFSoftShadowMap",$o._pcfSoftShadow],["VSMShadowMap",$o._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:$o._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:$o._defaultType,!0)}}$o._noShadow={castShadow:!1,type:Mt,bias:0,normalBias:0,radius:0},$o._basicShadow={castShadow:!0,type:Tt,bias:-5e-5,normalBias:.005,radius:0},$o._pcfShadow={castShadow:!0,type:Mt,bias:-5e-5,normalBias:.01,radius:4},$o._pcfSoftShadow={castShadow:!0,type:Pt,bias:-5e-5,normalBias:.01,radius:1},$o._vcmShadow={castShadow:!0,type:At,bias:1e-4,normalBias:0,radius:15},$o._defaultType=$o._pcfShadow;class el{constructor(e,t){var n,r;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(r=null==t?void 0:t._blurSamples)&&void 0!==r?r:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new s(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new a(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof l){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),r=Math.max(.001,Math.min(-n.min.z,-n.max.z)),i=Math.max(-n.min.z,-n.max.z),s=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),a=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(a,s),r);t.aspect=1,t.near=r,t.far=i,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,r,i;if(this._shadowLightSource instanceof l){const n=t.clone().sub(e),r=n.length();n.normalize();const i=t.clone().sub(n.clone().multiplyScalar(4*r));this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(i),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.lookAt(t);null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class tl extends el{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case Ko.DirectionalLightShadow:n=new i(16777215,1);break;case Ko.SpotLightShadow:n=new l(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new Wo(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class nl extends el{constructor(e,t,n){const r=new i(16777215,t);r.position.copy(e),r.lookAt(0,0,0),r.updateMatrix(),r.castShadow=!0,super(r,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}!function(e){e[e.INPUT_RGB_NORMAL=0]="INPUT_RGB_NORMAL",e[e.FLOAT_BUFFER_NORMAL=1]="FLOAT_BUFFER_NORMAL",e[e.CONSTANT_Z=2]="CONSTANT_Z"}(Yo||(Yo={})),function(e){e[e.SEPARATE_BUFFER=0]="SEPARATE_BUFFER",e[e.NORMAL_VECTOR_ALPHA=1]="NORMAL_VECTOR_ALPHA"}(Zo||(Zo={}));class rl{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}noise(e,t){let n,r,i;const s=(e+t)*(.5*(Math.sqrt(3)-1)),a=Math.floor(e+s),o=Math.floor(t+s),l=(3-Math.sqrt(3))/6,h=(a+o)*l,d=e-(a-h),c=t-(o-h);let u,p;d>c?(u=1,p=0):(u=0,p=1);const m=d-u+l,g=c-p+l,f=d-1+2*l,_=c-1+2*l,v=255&a,w=255&o,b=this.perm[v+this.perm[w]]%12,y=this.perm[v+u+this.perm[w+p]]%12,x=this.perm[v+1+this.perm[w+1]]%12;let S=.5-d*d-c*c;S<0?n=0:(S*=S,n=S*S*this.dot(this.grad3[b],d,c));let C=.5-m*m-g*g;C<0?r=0:(C*=C,r=C*C*this.dot(this.grad3[y],m,g));let M=.5-f*f-_*_;return M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[x],f,_)),70*(n+r+i)}noise3d(e,t,n){let r,i,s,a;const o=(e+t+n)*(1/3),l=Math.floor(e+o),h=Math.floor(t+o),d=Math.floor(n+o),c=(l+h+d)*(1/6),u=e-(l-c),p=t-(h-c),m=n-(d-c);let g,f,_,v,w,b;u>=p?p>=m?(g=1,f=0,_=0,v=1,w=1,b=0):u>=m?(g=1,f=0,_=0,v=1,w=0,b=1):(g=0,f=0,_=1,v=1,w=0,b=1):p<m?(g=0,f=0,_=1,v=0,w=1,b=1):u<m?(g=0,f=1,_=0,v=0,w=1,b=1):(g=0,f=1,_=0,v=1,w=1,b=0);const y=u-g+1/6,x=p-f+1/6,S=m-_+1/6,C=u-v+1/6*2,M=p-w+1/6*2,T=m-b+1/6*2,P=u-1+.5,A=p-1+.5,E=m-1+.5,R=255&l,I=255&h,D=255&d,O=this.perm[R+this.perm[I+this.perm[D]]]%12,L=this.perm[R+g+this.perm[I+f+this.perm[D+_]]]%12,k=this.perm[R+v+this.perm[I+w+this.perm[D+b]]]%12,U=this.perm[R+1+this.perm[I+1+this.perm[D+1]]]%12;let F=.6-u*u-p*p-m*m;F<0?r=0:(F*=F,r=F*F*this.dot3(this.grad3[O],u,p,m));let N=.6-y*y-x*x-S*S;N<0?i=0:(N*=N,i=N*N*this.dot3(this.grad3[L],y,x,S));let B=.6-C*C-M*M-T*T;B<0?s=0:(B*=B,s=B*B*this.dot3(this.grad3[k],C,M,T));let j=.6-P*P-A*A-E*E;return j<0?a=0:(j*=j,a=j*j*this.dot3(this.grad3[U],P,A,E)),32*(r+i+s+a)}noise4d(e,t,n,r){const i=this.grad4,s=this.simplex,a=this.perm,o=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20;let h,d,c,u,p;const m=(e+t+n+r)*o,g=Math.floor(e+m),f=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),w=(g+f+_+v)*l,b=e-(g-w),y=t-(f-w),x=n-(_-w),S=r-(v-w),C=(b>y?32:0)+(b>x?16:0)+(y>x?8:0)+(b>S?4:0)+(y>S?2:0)+(x>S?1:0),M=s[C][0]>=3?1:0,T=s[C][1]>=3?1:0,P=s[C][2]>=3?1:0,A=s[C][3]>=3?1:0,E=s[C][0]>=2?1:0,R=s[C][1]>=2?1:0,I=s[C][2]>=2?1:0,D=s[C][3]>=2?1:0,O=s[C][0]>=1?1:0,L=s[C][1]>=1?1:0,k=s[C][2]>=1?1:0,U=s[C][3]>=1?1:0,F=b-M+l,N=y-T+l,B=x-P+l,j=S-A+l,G=b-E+2*l,H=y-R+2*l,z=x-I+2*l,V=S-D+2*l,W=b-O+3*l,K=y-L+3*l,q=x-k+3*l,X=S-U+3*l,Q=b-1+4*l,Y=y-1+4*l,Z=x-1+4*l,J=S-1+4*l,$=255&g,ee=255&f,te=255&_,ne=255&v,re=a[$+a[ee+a[te+a[ne]]]]%32,ie=a[$+M+a[ee+T+a[te+P+a[ne+A]]]]%32,se=a[$+E+a[ee+R+a[te+I+a[ne+D]]]]%32,ae=a[$+O+a[ee+L+a[te+k+a[ne+U]]]]%32,oe=a[$+1+a[ee+1+a[te+1+a[ne+1]]]]%32;let le=.6-b*b-y*y-x*x-S*S;le<0?h=0:(le*=le,h=le*le*this.dot4(i[re],b,y,x,S));let he=.6-F*F-N*N-B*B-j*j;he<0?d=0:(he*=he,d=he*he*this.dot4(i[ie],F,N,B,j));let de=.6-G*G-H*H-z*z-V*V;de<0?c=0:(de*=de,c=de*de*this.dot4(i[se],G,H,z,V));let ce=.6-W*W-K*K-q*q-X*X;ce<0?u=0:(ce*=ce,u=ce*ce*this.dot4(i[ae],W,K,q,X));let ue=.6-Q*Q-Y*Y-Z*Z-J*J;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(i[oe],Q,Y,Z,J)),27*(h+d+c+u+p)}}const il={name:"HBAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,SAMPLE_VECTORS:sl(16),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0,COSINE_SAMPLE_HEMISPHERE:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new s},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new C},cameraProjectionMatrixInverse:{value:new C},radius:{value:2},distanceExponent:{value:1},bias:{value:.01}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float bias;\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\t// source: https://www.shadertoy.com/view/cll3R4\n\t\tvec3 cosineSampleHemisphere(const vec3 n, const vec2 u) {\n\t\t\tfloat r = sqrt(u.x);\n\t\t\tfloat theta = 2.0 * PI * u.y;\n\t\t\tvec3 b = normalize(cross(n, vec3(0.0, 1.0, 1.0)));\n\t\t\tvec3 t = cross(b, n);\n\t\t\treturn normalize(r * sin(theta) * b + sqrt(1.0 - u.x) * n + r * cos(theta) * t);\n\t\t}\n\t\t\n\t\tfloat getOcclusion(const vec2 uv, const vec3 viewPos, const vec3 viewNormal, const float depth, const vec4 sampleViewDir, inout float totalWeight) {\n\t\t\t\n\t\t\tvec3 sampleViewPos = viewPos + sampleViewDir.xyz * radius * pow(sampleViewDir.w, distanceExponent);\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tfloat distSample = abs(getViewZ(sampleDepth));\n\t\t\tfloat distWorld = abs(sampleViewPos.z);\n\t\t\tfloat distanceFalloffToUse = radius;\n\t\t\tfloat rangeCheck = smoothstep(0.0, 1.0, distanceFalloffToUse / (abs(distSample - distWorld)));\n\t\t\tfloat weight = dot(viewNormal, sampleViewDir.xyz);\n\t\t\tvec2 diff = (uv - sampleUv) * resolution;\n\t\t\tvec2 clipRangeCheck = step(0., sampleUv) * step(sampleUv, vec2(1.));\n\t\t\tfloat occlusion = rangeCheck * weight * step(distSample + bias, distWorld) * step(0.707, dot(diff, diff)) * clipRangeCheck.x * clipRangeCheck.y;\n\t\t\ttotalWeight += weight;\n\n\t\t\treturn occlusion;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth == 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n \t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\t\t\n\t\t\t\t#if COSINE_SAMPLE_HEMISPHERE == 1\n\t\t\t\t\tvec4 sampleNoise = noiseTexel;\n\t\t\t\t\tif (i != 0) {\n\t\t\t\t\t\tconst vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);\n\t\t\t\t\t\tsampleNoise = fract(sampleNoise + hn * float(i));\n\t\t\t\t\t\tsampleNoise = mix(sampleNoise, 1.0 - sampleNoise, step(0.5, sampleNoise)) * 2.0;\n\t\t\t\t\t}\n\t\t\t\t\tvec3 hemisphereDir = cosineSampleHemisphere( viewNormal, sampleNoise.rg );\n\t\t\t\t\tvec4 sampleViewDir = vec4(hemisphereDir, sampleNoise.b );\n\t\t\t\t#else\n\t\t\t\t\tvec4 sampleViewDir = sampleKernel[i];\n\t\t\t\t\tsampleViewDir.xyz = normalize(kernelMatrix * sampleViewDir.xyz);\n\t\t\t\t#endif\n\t\t\t\tfloat occlusion = getOcclusion(vUv, viewPos, viewNormal, depth, sampleViewDir, totalWeight);\n\t\t\t\tao += occlusion;\n\t\t\t}\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tao /= totalWeight;\n\t\t\t}\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function sl(e){const t=function(e){const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=.99-n/(e-1)*.9,s=Math.sqrt(1-i*i),a=Math.cos(r)*s,o=Math.sin(r)*s,l=8,h=Math.floor(e/l);let d=1-(Math.floor(n/l)+n%l*h)/e;d=.1+.9*d,t.push(new st(a,o,i,d))}return t}(e);let n="vec4[SAMPLES](";for(let r=0;r<e;r++){const i=t[r];n+=`vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})`,r<e-1&&(n+=",")}return n+=")",n}const al={resolutionScale:1,samples:16,radius:.5,distanceExponent:1,bias:.01};class ol{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n){this.needsUpdate=!0,this.parameters={...al},this._width=0,this._height=0,this._loaded=!1,this._normalVectorSourceType=Yo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Zo.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._renderPass=new Io,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Yo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Zo.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=(null==n?void 0:n.modulateRedChannel)||!1,(null==n?void 0:n.hbaoParameters)&&(this.parameters=n.hbaoParameters),n&&this.updateParameters(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new rl,n=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=r,a=i;n[4*(r*e+i)]=127.5*(t.noise(s,a)+1),n[4*(r*e+i)+1]=127.5*(t.noise(s+e,a)+1),n[4*(r*e+i)+2]=127.5*(t.noise(s,a+e)+1),n[4*(r*e+i)+3]=127.5*(t.noise(s+e,a+e)+1)}this._noiseTexture=new ye(n,e,e,be,Dt),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;this._hbaoMaterial||(this._hbaoMaterial=new ot({defines:Object.assign({},il.defines),uniforms:ut.clone(il.uniforms),vertexShader:il.vertexShader,fragmentShader:il.fragmentShader,depthTest:!1,depthWrite:!1}),this._modulateRedChannel&&(this._hbaoMaterial.blending=Ot,this._hbaoMaterial.blendEquation=Lt,this._hbaoMaterial.blendEquationAlpha=null,this._hbaoMaterial.blendSrc=kt,this._hbaoMaterial.blendSrcAlpha=null,this._hbaoMaterial.blendDst=kt,this._hbaoMaterial.blendDstAlpha=null),this._hbaoMaterial.defines.FRAGMENT_OUTPUT=this._modulateRedChannel?"vec4(ao, 1., 1., 1.)":void 0,this._hbaoMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&(this._hbaoMaterial.defines.PERSPECTIVE_CAMERA=e.isPerspectiveCamera?1:0,this._hbaoMaterial.defines.SAMPLES=this.parameters.samples,this._hbaoMaterial.defines.SAMPLE_VECTORS=sl(this.parameters.samples),this._hbaoMaterial.defines.NORMAL_VECTOR_TYPE=this._normalVectorSourceType===Yo.FLOAT_BUFFER_NORMAL?2:1,this._hbaoMaterial.defines.DEPTH_VALUE_SOURCE=this._depthValueSourceType===Zo.NORMAL_VECTOR_ALPHA?1:0,this._hbaoMaterial.needsUpdate=!0);const r=this._depthValueSourceType===Zo.NORMAL_VECTOR_ALPHA?this.normalTexture:this.depthTexture;this._hbaoMaterial.uniforms.tNormal.value=this.normalTexture,this._hbaoMaterial.uniforms.tDepth.value=r,this._hbaoMaterial.uniforms.resolution.value.set(this._width,this._height),this._hbaoMaterial.uniforms.cameraProjectionMatrix.value.copy(e.projectionMatrix),this._hbaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(e.projectionMatrixInverse);const i=e;return this._hbaoMaterial.uniforms.cameraNear.value=i.near,this._hbaoMaterial.uniforms.cameraFar.value=i.far,this._hbaoMaterial.uniforms.radius.value=this.parameters.radius,this._hbaoMaterial.uniforms.distanceExponent.value=this.parameters.distanceExponent,this._hbaoMaterial.uniforms.bias.value=this.parameters.bias,this._hbaoMaterial}_getRenderTargets(){return this._renderTarget||(this._renderTarget=new gt(this._width,this._height,{magFilter:D,minFilter:D})),this._renderTarget}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._hbaoMaterial)||void 0===t||t.dispose(),null===(n=this._renderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._renderTarget)||void 0===n||n.setSize(e,t),this.needsUpdate=!0}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0);e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t,n,r){const i=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._renderPass.renderScreenSpace(e,i,r||this._getRenderTargets())}}const ll={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:hl(16,4),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new s},cameraProjectionMatrixInverse:{value:new C},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:10},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec2 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\t\t\n\t\tfloat distToPlane(const vec3 viewPos, const vec3 neighborViewPos, const vec3 viewNormal) {\n\t\t\treturn abs(dot(viewPos - neighborViewPos, viewNormal));\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\t//vec2 noiseVec = normalize((index % 2 == 0 ? noiseTexel.xy : noiseTexel.yz) * 2.0 - 1.0);\n\t\t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec2 offset = rotationMatrix * (poissonDisk[i] * radius / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\n\t\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\t\n\t\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\n\t\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\n\t\t\t\tfloat depthDiff = 1. - distToPlane(viewPos, viewPosSample, viewNormal);\n\t\t\t\tfloat depthSimilarity = max(depthDiff / depthPhi, 0.);\n\t\t\n\t\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\t\tdenoised += w * neighborColor;\n\t\t\t\ttotalWeight += w;\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function hl(e,t){const n=function(e,t){const n=2*Math.PI*t/e,r=1/e,i=r,a=[];let o=r,l=0;for(let t=0;t<e;t++){const e=new s(Math.cos(l),Math.sin(l)).multiplyScalar(Math.pow(o,.75));a.push(e),o+=i,l+=n}return a}(e,t);let r="vec2[SAMPLES](";for(let t=0;t<e;t++){const i=n[t];r+=`vec2(${i.x}, ${i.y})`,t<e-1&&(r+=",")}return r+=")",r}const dl={iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:12,normalPhi:3.25,samples:16};class cl{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._renderTargets.length-1].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n){this.needsUpdate=!0,this.parameters={...dl},this._width=0,this._height=0,this._normalVectorSourceType=Yo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Zo.NORMAL_VECTOR_ALPHA,this._rgInputTexture=!0,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._renderPass=new Io,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Yo.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Zo.NORMAL_VECTOR_ALPHA,this._rgInputTexture=(null==n?void 0:n.rgInputTexture)||!0,this._inputTexture=(null==n?void 0:n.inputTexture)||null,this.depthTexture=(null==n?void 0:n.depthTexture)||null,this.normalTexture=(null==n?void 0:n.normalTexture)||null,n.poissonDenoisePassParameters?this.parameters=n.poissonDenoisePassParameters:n&&this.updateParameters(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new rl,n=new Uint8Array(e*e*4);for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=r,a=i;n[4*(r*e+i)]=127.5*(t.noise(s,a)+1),n[4*(r*e+i)+1]=127.5*(t.noise(s+e,a)+1),n[4*(r*e+i)+2]=127.5*(t.noise(s,a+e)+1),n[4*(r*e+i)+3]=127.5*(t.noise(s+e,a+e)+1)}this._noiseTexture=new ye(n,e,e,be,Dt),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;this._pdMaterial||(this._pdMaterial=new ot({defines:Object.assign({},ll.defines),uniforms:ut.clone(ll.uniforms),vertexShader:ll.vertexShader,fragmentShader:ll.fragmentShader,depthTest:!1,depthWrite:!1}),this._pdMaterial.defines.SAMPLE_LUMINANCE="(a.r * a.g)",this._pdMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&(this._pdMaterial.defines.SAMPLES=this.parameters.samples,this._pdMaterial.defines.SAMPLE_VECTORS=hl(this.parameters.samples,this.parameters.rings),this._pdMaterial.defines.NORMAL_VECTOR_TYPE=this._normalVectorSourceType===Yo.FLOAT_BUFFER_NORMAL?2:1,this._pdMaterial.defines.DEPTH_VALUE_SOURCE=this._depthValueSourceType===Zo.NORMAL_VECTOR_ALPHA?1:0,this._pdMaterial.needsUpdate=!0);const r=this._depthValueSourceType===Zo.NORMAL_VECTOR_ALPHA?this.normalTexture:this.depthTexture;return this._pdMaterial.uniforms.tDiffuse.value=this._inputTexture,this._pdMaterial.uniforms.tNormal.value=this.normalTexture,this._pdMaterial.uniforms.tDepth.value=r,this._pdMaterial.uniforms.resolution.value.set(this._width,this._height),this._pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(e.projectionMatrixInverse),this._pdMaterial.uniforms.lumaPhi.value=this.parameters.lumaPhi,this._pdMaterial.uniforms.depthPhi.value=this.parameters.depthPhi,this._pdMaterial.uniforms.normalPhi.value=this.parameters.normalPhi,this._pdMaterial.uniforms.radius.value=this.parameters.radius,this._pdMaterial}_getRenderTargets(){return this._renderTargets.length<2&&(this._renderTargets=[new gt(this._width,this._height,{magFilter:D,minFilter:D}),new gt(this._width,this._height,{magFilter:D,minFilter:D})]),this._renderTargets}dispose(){var e,t;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._pdMaterial)||void 0===t||t.dispose(),this._renderTargets.forEach(e=>e.dispose())}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach(n=>n.setSize(e,t)),this.needsUpdate=!0}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0);e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const r=this._getRenderTargets();for(let t=0;t<2*this.parameters.iterations;t++){const i=r[(t+1)%2],s=r[t%2];n.uniforms.tDiffuse.value=0===t?this._inputTexture:i.texture,n.uniforms.index.value=t,this._renderPass.renderScreenSpace(e,n,s,16777215,1)}}}var ul,pl;!function(e){e[e.OFF=0]="OFF",e[e.HARD=1]="HARD",e[e.POISSON=2]="POISSON",e[e.FULL=3]="FULL"}(ul||(ul={})),function(e){e[e.NONE=0]="NONE",e[e.SSAO=1]="SSAO",e[e.HBAO=2]="HBAO"}(pl||(pl={}));const ml={aoKernelRadius:.25,aoDepthBias:1e-4,aoMaxDistance:.5,aoMaxDepth:.99,aoFadeout:.5,shadowRadius:.05},gl={enabled:!0,aoType:pl.SSAO,aoIntensity:.5,shadowIntensity:.35,aoOnGround:!0,shadowOnGround:!1,alwaysUpdate:!1};class fl{get gBufferRenderTarget(){var e;return this._sharedGBufferRenderTarget?this._sharedGBufferRenderTarget:(this._gBufferRenderTarget=null!==(e=this._gBufferRenderTarget)&&void 0!==e?e:new Fo(void 0,{_width:this._width,_height:this._height,_samples:this._samples,_renderPass:this._renderPass,textureFilter:ne}),this._gBufferRenderTarget)}get hbaoRenderPass(){return this._hbaoPass||(this._hbaoPass=new ol(this._width,this._height,{normalVectorSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Yo.FLOAT_BUFFER_NORMAL:Yo.INPUT_RGB_NORMAL,depthValueSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Zo.NORMAL_VECTOR_ALPHA:Zo.SEPARATE_BUFFER,modulateRedChannel:!0,hbaoParameters:this.parameters.hbao})),this._hbaoPass}get fadeRenderTarget(){var e;return this._fadeRenderTarget=null!==(e=this._fadeRenderTarget)&&void 0!==e?e:new gt(this._width,this._height,{format:Ut,magFilter:D,minFilter:D}),this._fadeRenderTarget}get denoisePass(){return this._poissonDenoisePass||(this._poissonDenoisePass=new cl(this._width,this._height,{inputTexture:this.shadowAndAoRenderTargets.passRenderTarget.texture,depthTexture:this.gBufferRenderTarget.depthBufferTexture,normalTexture:this.gBufferRenderTarget.gBufferTexture,normalVectorSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Yo.FLOAT_BUFFER_NORMAL:Yo.INPUT_RGB_NORMAL,depthValueSourceType:this.gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?Zo.NORMAL_VECTOR_ALPHA:Zo.SEPARATE_BUFFER,rgInputTexture:!0,poissonDenoisePassParameters:this.parameters.poissonDenoise})),this._poissonDenoisePass}get denoiseRenderTargetTexture(){return this.denoisePass?this.denoisePass.texture:null}constructor(e,t,n,r){var i,s,a,o,l,h,d,c;this.needsUpdate=!0,this._renderPass=new Io,this._cameraUpdate=new Ro,(null==r?void 0:r.gBufferRenderTarget)&&(this._sharedGBufferRenderTarget=null==r?void 0:r.gBufferRenderTarget),this._width=e,this._height=t,this._samples=n,this._renderPass=null!==(i=null==r?void 0:r.enderPass)&&void 0!==i?i:new Io,this.shadowAndAoRenderTargets=new _l(this.gBufferRenderTarget,{...r,width:e,height:t,samples:n,renderPass:this._renderPass}),this.parameters={enabled:null!==(s=null==r?void 0:r.enabled)&&void 0!==s?s:gl.enabled,aoType:null!==(a=null==r?void 0:r.aoType)&&void 0!==a?a:gl.aoType,aoIntensity:null!==(o=null==r?void 0:r.aoIntensity)&&void 0!==o?o:gl.aoIntensity,shadowIntensity:null!==(l=null==r?void 0:r.shadowIntensity)&&void 0!==l?l:gl.shadowIntensity,aoOnGround:null!==(h=null==r?void 0:r.aoOnGround)&&void 0!==h?h:gl.aoOnGround,shadowOnGround:null!==(d=null==r?void 0:r.shadowOnGround)&&void 0!==d?d:gl.shadowOnGround,alwaysUpdate:null!==(c=null==r?void 0:r.alwaysUpdate)&&void 0!==c?c:gl.alwaysUpdate,shAndAo:this.shadowAndAoRenderTargets.shadowAndAoParameters,hbao:{...al},poissonDenoise:{...dl}},this._copyMaterial=new xo,this._blendMaterial=new xo({},yo.DEFAULT)}dispose(){var e,t,n,r,i,s;null===(e=this._gBufferRenderTarget)||void 0===e||e.dispose(),this.shadowAndAoRenderTargets.dispose(),null===(t=this._hbaoPass)||void 0===t||t.dispose(),null===(n=this._fadeRenderTarget)||void 0===n||n.dispose(),null===(r=this._poissonDenoisePass)||void 0===r||r.dispose(),null===(i=this._copyMaterial)||void 0===i||i.dispose(),null===(s=this._blendMaterial)||void 0===s||s.dispose()}setSize(e,t){var n,r,i,s;this._width=e,this._height=t,null===(n=this._gBufferRenderTarget)||void 0===n||n.setSize(e,t),this.shadowAndAoRenderTargets.setSize(e,t),null===(r=this._hbaoPass)||void 0===r||r.setSize(e,t),null===(i=this._fadeRenderTarget)||void 0===i||i.setSize(e,t),null===(s=this._poissonDenoisePass)||void 0===s||s.setSize(this._width,this._height),this.needsUpdate=!0}updateParameters(e){void 0!==e.enabled&&(this.parameters.enabled=e.enabled),void 0!==e.aoType&&(this.parameters.aoType=e.aoType),void 0!==e.aoIntensity&&(this.parameters.aoIntensity=e.aoIntensity),void 0!==e.shadowIntensity&&(this.parameters.shadowIntensity=e.shadowIntensity),void 0!==e.aoOnGround&&(this.parameters.aoOnGround=e.aoOnGround),void 0!==e.shadowOnGround&&(this.parameters.shadowOnGround=e.shadowOnGround),void 0!==e.alwaysUpdate&&(this.parameters.alwaysUpdate=e.alwaysUpdate),this._updatePassParameters(e)}_updatePassParameters(e){var t,n;if(null==e?void 0:e.shAndAo)for(let t in e.shAndAo)this.parameters.shAndAo.hasOwnProperty(t)&&(this.parameters.shAndAo[t]=e.shAndAo[t],this.shadowAndAoRenderTargets.parametersNeedsUpdate=!0);if(null==e?void 0:e.hbao)if(this._hbaoPass)null===(t=this._hbaoPass)||void 0===t||t.updateParameters(null==e?void 0:e.hbao);else for(let t in e.hbao)this.parameters.hbao.hasOwnProperty(t)&&(this.parameters.hbao[t]=e.hbao[t]);if(null==e?void 0:e.poissonDenoise)if(this._poissonDenoisePass)null===(n=this._poissonDenoisePass)||void 0===n||n.updateParameters(null==e?void 0:e.poissonDenoise);else for(let t in e.poissonDenoise)this.parameters.poissonDenoise.hasOwnProperty(t)&&(this.parameters.poissonDenoise[t]=e.poissonDenoise[t])}updateBounds(e,t){this.shadowAndAoRenderTargets.updateBounds(e,t)}render(e,t,n,r,i=ul.FULL,s=ul.FULL,a=0){if(!this._setRenderState())return;let o=!1;const l=s===ul.POISSON&&a>.001,h=s===ul.HARD&&a>.001&&a<.999,d=s===ul.HARD&&!h;!d&&i===ul.FULL&&this._evaluateIfUpdateIsNeeded(n)&&(this._renderShadowAndAo(e,t,n,r),o=!0);let c=d?r:this.denoiseRenderTargetTexture;l&&(c=this._renderDynamicShadow(e,this.shadowAndAoRenderTargets.passRenderTarget.texture,r,a),o=!0),o&&(c=this._renderDenoise(e,n,l)),h&&(c=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,r,a)),this._renderToTarget(e,c,d)}_setRenderState(){return this.shadowAndAoRenderTargets.aoEnabled=this.parameters.aoType===pl.SSAO,this.shadowAndAoRenderTargets.shadowEnabled=this.parameters.shadowIntensity>.01,!(!this.parameters.enabled||this.parameters.aoType===pl.NONE&&!this.shadowAndAoRenderTargets.shadowEnabled||(this.needsUpdate&&(this._hbaoPass&&(this._hbaoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,r){this.gBufferRenderTarget.render(e,t,n),this.shadowAndAoRenderTargets.render(e,n,r),this._renderAoEffect(e,t,n)}_renderAoEffect(e,t,n){if(this.parameters.aoType!==pl.HBAO)return;const r=this.gBufferRenderTarget.depthBufferTexture,i=this.gBufferRenderTarget.gBufferTexture,s=this.shadowAndAoRenderTargets.passRenderTarget,a=e.autoClear;e.autoClear=!1;const o=this.hbaoRenderPass;o.depthTexture=r,o.normalTexture=i,o.render(e,n,t,s),e.autoClear=a}_renderDynamicShadow(e,t,n,r=1){const i=r<.999;return i&&(this._copyMaterial.update({texture:t,blending:pt,colorTransform:co,multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),r>.001&&(this._blendMaterial.update({texture:n,blending:i?Ot:pt,colorTransform:(new C).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,i?r:1),multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n){return this.denoisePass.inputTexture=n?this.fadeRenderTarget.texture:this.shadowAndAoRenderTargets.passRenderTarget.texture,this.denoisePass.render(e,t),this.denoisePass.texture}_renderToTarget(e,t,n){const r=n?this.parameters.shadowIntensity:this.parameters.aoIntensity,i=n?0:this.parameters.shadowIntensity;this._renderPass.renderScreenSpace(e,this._copyMaterial.update({texture:t,blending:Ot,colorTransform:bo(r,i,0,1),multiplyChannels:1}),e.getRenderTarget())}}fl.shadowTransform=(new C).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class _l{get passRenderTarget(){var e;return this._passRenderTarget=null!==(e=this._passRenderTarget)&&void 0!==e?e:new gt(this._width,this._height,{samples:this._aoTargetSamples,format:Ut,magFilter:D,minFilter:D}),this._passRenderTarget}get passRenderMaterial(){var e;return this._passRenderMaterial=null!==(e=this._passRenderMaterial)&&void 0!==e?e:new vl({normalTexture:this._depthAndNormalTextures.gBufferTexture,depthTexture:this._depthAndNormalTextures.depthBufferTexture,noiseTexture:this.noiseTexture,sampleKernel:this.sampleKernel,floatGBufferRgbNormalAlphaDepth:this._depthAndNormalTextures.isFloatGBufferWithRgbNormalAlphaDepth}),this._passRenderMaterial}get noiseTexture(){var e;return this._noiseTexture=null!==(e=this._noiseTexture)&&void 0!==e?e:(e=>{const t=Math.floor(5)%2==0?Math.floor(5)+1:Math.floor(5),n=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,r=Array(n).fill(0);let i=Math.floor(t/2),s=t-1;for(let e=1;e<=n;)-1===i&&s===t?(s=t-2,i=0):(s===t&&(s=0),i<0&&(i=t-1)),0===r[i*t+s]?(r[i*t+s]=e++,s++,i--):(s-=2,i++);return r})(t),r=n.length,i=new Uint8Array(4*r);for(let e=0;e<r;++e){const t=n[e],s=2*Math.PI*t/r,o=new a(Math.cos(s),Math.sin(s),0).normalize();i[4*e]=255*(.5*o.x+.5),i[4*e+1]=255*(.5*o.y+.5),i[4*e+2]=127,i[4*e+3]=0}const s=new ye(i,t,t);return s.wrapS=L,s.wrapT=L,s.needsUpdate=!0,s})(),this._noiseTexture}get sampleKernel(){return this._sampleKernel.length||(this._sampleKernel=(e=>{const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=.99-n/(e-1)*.8,s=Math.sqrt(1-i*i),o=Math.cos(r)*s,l=Math.sin(r)*s,h=8,d=Math.floor(e/h);let c=1-(Math.floor(n/h)+n%h*d)/e;c=Q.lerp(.1,1,c*c),t.push(new a(o*c,l*c,i*c))}return t})(vl.kernelSize)),this._sampleKernel}constructor(e,t){var n,r,i,s;this.parametersNeedsUpdate=!0,this.aoEnabled=!0,this.shadowEnabled=!0,this._sceneBoxMin=new a(-1,-1,-1),this._sceneBoxMax=new a(1,1,1),this._shadowAndAoScale=1,this._aoTargetSamples=0,this._sampleKernel=[],this.shadowAndAoParameters=this._getShadowAndAoParameters(t),this._width=null!==(n=null==t?void 0:t._width)&&void 0!==n?n:1024,this._height=null!==(r=null==t?void 0:t._height)&&void 0!==r?r:1024,this._samples=null!==(i=null==t?void 0:t._samples)&&void 0!==i?i:0,this._depthAndNormalTextures=e,this._renderPass=null!==(s=null==t?void 0:t._renderPass)&&void 0!==s?s:new Io}_getShadowAndAoParameters(e){return{...ml,...e}}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._passRenderMaterial)||void 0===t||t.dispose(),null===(n=this._passRenderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._passRenderMaterial)||void 0===n||n.update({_width:this._width,_height:this._height})}updateBounds(e,t){this._sceneBoxMin.copy(e.bounds.min),this._sceneBoxMax.copy(e.bounds.max),this._shadowAndAoScale=t,this.parametersNeedsUpdate=!0}render(e,t,n){this._renderPass.renderScreenSpace(e,this.updateSSAOMaterial(t,n),this.passRenderTarget),this.parametersNeedsUpdate=!1}updateSSAOMaterial(e,t){const n=this.passRenderMaterial;return n.updateDependencies({_width:this._width,_height:this._height,camera:e,shadowTexture:t,sceneBoxMin:this._sceneBoxMin,sceneBoxMax:this._sceneBoxMax}),this.parametersNeedsUpdate&&n.updateSettings({...this.shadowAndAoParameters,aoKernelRadius:this.shadowAndAoParameters.aoKernelRadius*this._shadowAndAoScale,aoMaxDistance:this.shadowAndAoParameters.aoMaxDistance*this._shadowAndAoScale,shadowRadius:this.shadowAndAoParameters.shadowRadius*this._shadowAndAoScale,aoIntensity:this.aoEnabled?1:0,shadowIntensity:this.shadowEnabled?1:0}),n}}class vl extends ot{constructor(e){var t,n;super({defines:Object.assign({...vl._shader.defines,KERNEL_SIZE:null!==(n=null===(t=null==e?void 0:e.sampleKernel)||void 0===t?void 0:t.length)&&void 0!==n?n:vl.kernelSize,FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH:(null==e?void 0:e.floatGBufferRgbNormalAlphaDepth)?1:0}),uniforms:ut.clone(vl._shader.uniforms),vertexShader:vl._shader.vertexShader,fragmentShader:vl._shader.fragmentShader,blending:pt}),this.update(e)}update(e){return this.updateDependencies(e),this.updateSettings(e),this}updateDependencies(e){var t,n;if(void 0!==(null==e?void 0:e.shadowTexture)&&(this.uniforms.tShadow.value=null==e?void 0:e.shadowTexture),void 0!==(null==e?void 0:e.normalTexture)&&(this.uniforms.tNormal.value=null==e?void 0:e.normalTexture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.noiseTexture)&&(this.uniforms.tNoise.value=null==e?void 0:e.noiseTexture),(null==e?void 0:e._width)||(null==e?void 0:e._height)){const r=null!==(t=null==e?void 0:e._width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e._height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(r,i)}void 0!==(null==e?void 0:e.sampleKernel)&&(this.uniforms.sampleKernel.value=null==e?void 0:e.sampleKernel),void 0!==(null==e?void 0:e.sceneBoxMin)&&(this.uniforms.sceneBoxMin.value=null==e?void 0:e.sceneBoxMin),void 0!==(null==e?void 0:e.sceneBoxMax)&&(this.uniforms.sceneBoxMax.value=null==e?void 0:e.sceneBoxMax),this._updateCameraDependentUniforms(e)}_updateCameraDependentUniforms(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld)}}updateSettings(e){void 0!==(null==e?void 0:e.aoKernelRadius)&&(this.uniforms.aoKernelRadius.value=null==e?void 0:e.aoKernelRadius),void 0!==(null==e?void 0:e.aoDepthBias)&&(this.uniforms.aoDepthBias.value=null==e?void 0:e.aoDepthBias),void 0!==(null==e?void 0:e.aoMaxDistance)&&(this.uniforms.aoMaxDistance.value=null==e?void 0:e.aoMaxDistance),void 0!==(null==e?void 0:e.aoMaxDepth)&&(this.uniforms.aoMaxDepth.value=null==e?void 0:e.aoMaxDepth),void 0!==(null==e?void 0:e.aoIntensity)&&(this.uniforms.aoIntensity.value=null==e?void 0:e.aoIntensity),void 0!==(null==e?void 0:e.aoFadeout)&&(this.uniforms.aoFadeout.value=null==e?void 0:e.aoFadeout),void 0!==(null==e?void 0:e.shadowRadius)&&(this.uniforms.shKernelRadius.value=null==e?void 0:e.shadowRadius),void 0!==(null==e?void 0:e.shadowIntensity)&&(this.uniforms.shIntensity.value=null==e?void 0:e.shadowIntensity)}}vl.kernelSize=32,vl._shader={uniforms:{tShadow:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},sampleKernel:{value:null},cameraNear:{value:.1},cameraFar:{value:1},resolution:{value:new s},cameraProjectionMatrix:{value:new C},cameraInverseProjectionMatrix:{value:new C},cameraWorldMatrix:{value:new C},aoKernelRadius:{value:.1},aoDepthBias:{value:.001},aoMaxDistance:{value:.05},aoMaxDepth:{value:.99},aoIntensity:{value:1},aoFadeout:{value:0},shKernelRadius:{value:.15},shIntensity:{value:1},sceneBoxMin:{value:new a(-1,-1,-1)},sceneBoxMax:{value:new a(1,1,1)}},defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:vl.kernelSize,FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH:0,NORMAL_VECTOR_ANTIALIAS:2,DEPTH_BUFFER_ANTIALIAS:1},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tShadow;\n uniform sampler2D tNormal;\n#if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH != 1 \n uniform sampler2D tDepth;\n#endif \n uniform sampler2D tNoise;\n uniform vec3 sampleKernel[KERNEL_SIZE];\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 cameraWorldMatrix;\n uniform float aoKernelRadius;\n uniform float aoDepthBias; // avoid artifacts caused by neighbour fragments with minimal depth difference\n uniform float aoMaxDistance; // avoid the influence of fragments which are too far away\n uniform float aoMaxDepth;\n uniform float aoIntensity;\n uniform float aoFadeout;\n uniform float shKernelRadius;\n uniform float shIntensity;\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n \n varying vec2 vUv;\n \n #include <packing>\n \n float getDepth(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float d0 = texelFetch(tNormal, p, 0).w;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tNormal, p + ivec2(1, 0), 0).w;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tNormal, p - ivec2(1, 0), 0).w;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tNormal, p + ivec2(0, 1), 0).w;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tNormal, p - ivec2(0, 1), 0).w;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return texture2D(tNormal, screenPosition).w;\n #endif\n #else \n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n \n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n \n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraInverseProjectionMatrix * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n\n vec3 getViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n return texture2D(tNormal, screenPosition).xyz;\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n \n void main() {\n \n float depth = getDepth(vUv);\n float viewZ = getViewZ(depth);\n \n vec3 viewPosition = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n vec3 worldPosition = (cameraWorldMatrix * vec4(viewPosition, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPosition, worldPosition - sceneBoxMax)));\n \n vec2 noiseScale = resolution.xy / vec2(textureSize(tNoise, 0));\n vec3 random = texture2D(tNoise, vUv * noiseScale).xyz * 2.0 - 1.0;\n \n // compute matrix used to reorient a kernel vector\n vec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n \n float aoOcclusion = 0.0;\n float shOcclusion = texture2D(tShadow, vUv).r;\n float shSamples = 0.0;\n if (aoIntensity >= 0.01 && boxDistance < aoMaxDistance && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 aoSampleVector = kernelMatrix * sampleKernel[i]; \n vec3 aoSamplePoint = viewPosition + aoSampleVector * aoKernelRadius; \n vec4 aoSamplePointNDC = cameraProjectionMatrix * vec4(aoSamplePoint, 1.0); \n aoSamplePointNDC /= aoSamplePointNDC.w;\n vec2 aoSamplePointUv = aoSamplePointNDC.xy * 0.5 + 0.5;\n float aoRealSampleDepth = getDepth(aoSamplePointUv);\n float aoSampleDeltaZ = getViewZ(aoRealSampleDepth) - aoSamplePoint.z;\n float aoRealDeltaZ = viewZ - aoSamplePoint.z;\n float w_long = clamp((aoMaxDistance - max(aoRealDeltaZ, aoSampleDeltaZ)) / aoMaxDistance, 0.0, 1.0);\n float w_lat = clamp(1.0 - length(aoSampleVector.xy), 0.0, 1.0);\n aoOcclusion +=\n step(aoRealSampleDepth, aoMaxDepth) * \n step(aoDepthBias, aoSampleDeltaZ / (cameraFar - cameraNear)) * \n step(aoSampleDeltaZ, aoMaxDistance) * mix(1.0, w_long * w_lat, aoFadeout);\n }\n }\n if (shIntensity >= 0.01 && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 shSampleVector = kernelMatrix * sampleKernel[i]; // reorient sample vector in view space\n vec3 shSamplePoint = viewPosition + shSampleVector * shKernelRadius; // calculate sample point\n vec4 shSamplePointNDC = cameraProjectionMatrix * vec4(shSamplePoint, 1.0); // project point and calculate NDC\n shSamplePointNDC /= shSamplePointNDC.w;\n vec2 shSamplePointUv = shSamplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n vec3 shSampleNormal = getViewNormal(shSamplePointUv);\n float shDeltaZ = getViewZ(getDepth(shSamplePointUv)) - shSamplePoint.z;\n float w = step(abs(shDeltaZ), shKernelRadius) * max(0.0, dot(shSampleNormal, viewNormal));\n shSamples += w;\n shOcclusion += texture2D(tShadow, shSamplePointUv).r * w;\n }\n }\n \n aoOcclusion = clamp(aoOcclusion / float(KERNEL_SIZE) * (1.0 + aoFadeout), 0.0, 1.0);\n aoOcclusion = 1.0 - aoOcclusion * clamp(1.0 - boxDistance / aoMaxDistance, 0.0, 1.0);\n shOcclusion = clamp(shOcclusion / (shSamples + 1.0), 0.0, 1.0);\n gl_FragColor = vec4(aoOcclusion, shOcclusion, 0.0, 1.0);\n }"};class wl{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n){var r;this._width=e,this._height=t,this.parameters={enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4,...n},this._copyMaterial=new xo({}),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new bl({_width:this._width/this.parameters.renderTargetDownScale,_height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new Do(So,n),this._renderPass=null!==(r=null==n?void 0:n._renderPass)&&void 0!==r?r:new Io}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale;let r={};if(e){const e=new ft(t,n);e.format=_t,e.type=vt,r.minFilter=ne,r.magFilter=ne,r.depthTexture=e}else r.samples=1;return new gt(t,n,{format:be,...r})}dispose(){var e,t,n;null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,r,i,s;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._intensityRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._blurRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(s=this._reflectionIntensityMaterial)||void 0===s||s.update({_width:this._width/this.parameters.renderTargetDownScale,_height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const r=this.parameters.intensity*t,i=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new C).set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,r),multiplyChannels:0,uvTransform:wo}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}render(e,t,n,r=1){if(!(this.parameters.enabled&&n instanceof X))return;const i=this._createGroundReflectionCamera(n);this._renderGroundReflection(e,t,i,this.reflectionRenderTarget),this._renderGroundReflectionIntensity(e,i,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,n,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,r),this._renderPass.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,r){const i=e.getRenderTarget();r&&e.setRenderTarget(r),e.render(t,n),r&&e.setRenderTarget(i)}_renderGroundReflectionIntensity(e,t,n){const r=e.getRenderTarget();e.setRenderTarget(n),this._renderPass.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(r)}blurReflection(e,t,n){const r=new a(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),i=this.parameters.blurHorizontal/this._width,s=this.parameters.blurVertical/this._height*Math.abs(r.dot(new a(0,0,1)));this._blurPass.render(e,n,[4*i,4*s],[4*i*(1+this.parameters.blurAscent),4*s*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class bl extends ot{constructor(e){super({defines:Object.assign({},bl.shader.defines),uniforms:ut.clone(bl.shader.uniforms),vertexShader:bl.shader.vertexShader,fragmentShader:bl.shader.fragmentShader,blending:pt}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e._width)||(null==e?void 0:e._height)){const r=null!==(t=null==e?void 0:e._width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e._height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(r,i)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}bl.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new s},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new C},cameraInverseProjectionMatrix:{value:new C},inverseViewMatrix:{value:new C},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec4 fragColor = texture2D(tDiffuse, uv).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha;\n gl_FragColor = fragColor * step(depth, 0.9999);\n }"};const yl=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new s(t,n)};class xl{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new gt,this._colorRenderTarget}get environmentMapDecodeTarget(){var e;return this._environmentMapDecodeTarget=null!==(e=this._environmentMapDecodeTarget)&&void 0!==e?e:new gt,this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new Cl(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new Cl(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Y(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,r){var i;this.colorRenderTarget.setSize(n,r),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new H(new wt(2,2),new y({map:t}));const s=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(s);const a=this.environmentMapDecodeTarget.texture,o=new Uint8Array(n*r*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,r,o),{texture:a,pixels:o}}newGrayscaleTexture(e,t,n,r){var i;const s=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name);this.environmentMapDecodeTarget.setSize(n,r),s.setSourceTexture(t),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new H(new wt(2,2),s);const a=e.getRenderTarget();e.setRenderTarget(this.environmentMapDecodeTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const o=this.environmentMapDecodeTarget.texture,l=new Uint8Array(n*r*4);return e.readRenderTargetPixels(this.environmentMapDecodeTarget,0,0,n,r,l),{texture:o,pixels:l}}}const Sl={tDiffuse:{value:null}};class Cl extends ot{constructor(e,t){super({uniforms:ut.clone(Sl),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }",defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}e("W",Cl),e("V",class{constructor(e){var t,n,r,i;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new ce,pixels:new Uint8Array(0)},this.detectorTexture=new ce,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new Tl(0),this.lightSources=[],this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;n<e;n++){const r=n*Math.PI*(3-Math.sqrt(5)),i=1-n/(e-1)*2,s=Math.sqrt(1-i*i),o=Math.cos(r)*s,l=Math.sin(r)*s;t.push(new a(o,l,i))}return t},this._numberOfSamples=null!==(t=null==e?void 0:e._numberOfSamples)&&void 0!==t?t:1e3,this._width=null!==(n=null==e?void 0:e._width)&&void 0!==n?n:1024,this._height=null!==(r=null==e?void 0:e._height)&&void 0!==r?r:512,this._sampleThreshold=null!==(i=null==e?void 0:e._sampleThreshold)&&void 0!==i?i:.707,this.pointDistance=Math.sqrt(4*Math.PI)/Math.sqrt(this._numberOfSamples),this.pixelDistance=Math.sqrt(2)*Math.PI*2/this._width,this.samplePoints=this._createEquirectangularSamplePoints(this._numberOfSamples),this.sampleUVs=this.samplePoints.map(e=>yl(e))}detectLightSources(e,t,n){var r;this.textureData=n,this._textureConverter=null!==(r=this._textureConverter)&&void 0!==r?r:new xl,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort((e,t)=>t.maxIntensity-e.maxIntensity)}_redFromRgbaToNormalizedFloatArray(e,t){const n=new Float32Array(e.length/4);let r=1,i=0;for(let t=0;t<e.length/4;++t){const s=e[4*t]/255;r=Math.min(r,s),i=Math.max(i,s),n[t]=s}if(t)for(let e=0;e<n.length;++e){const s=(n[e]-r)/(i-r);n[e]=Math.pow(s,t)}else for(let e=0;e<n.length;++e)n[e]=(n[e]-r)/(i-r);return n}_grayscaleTextureFromFloatArray(e,t,n){const r=t*n,i=new Uint8Array(4*r);for(let t=0;t<r;t++){const n=255*e[t];i[4*t+0]=n,i[4*t+1]=n,i[4*t+2]=n,i[4*t+3]=255}const s=new ye(i,t,n);return s.needsUpdate=!0,s}_filterLightSamples(e){const t=[];for(let n=0;n<this.sampleUVs.length;n++){const r=this.sampleUVs[n];this._detectorTextureLuminanceValueFromUV(r)>e&&t.push(new Ml(this.samplePoints[n],r))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let r=0;for(let e=Math.max(0,t-2);e<Math.max(0,t+2);++e)for(let t=Math.max(0,n-2);t<Math.max(0,n+2);++t){const n=t*this.textureData._width+e,i=(this.textureData.data[4*n]+this.textureData.data[4*n+1]+this.textureData.data[4*n+2])/3;r=Math.max(r,i)}return r}_findClusterSegments(e,t){const n=2*this.pixelDistance,r=1.5*this.pointDistance,i=new Tl(e.length);for(let s=0;s<e.length;s++)for(let a=s+1;a<e.length;a++)if(e[s].position.angleTo(e[a].position)<r){const r=e[a].position.clone().sub(e[s].position),o=Math.floor(r.length()/n);let l=!0,h=0;for(let n=1;n<o;n++){const i=r.clone().multiplyScalar(n/o),a=yl(e[s].position.clone().add(i).normalize());if(this._detectorTextureLuminanceValueFromUV(a)<t){if(h++,h>1){l=!1;break}}else h=0}l&&(i.adjacent[s].push(a),i.adjacent[a].push(s),i.edges.push([s,a]))}return i}createLightSourcesFromLightGraph(e,t){const n=t.components.filter(e=>e.length>1).map(t=>new Pl(t.map(t=>e[t])));return n.forEach(e=>e.calculateLightSourceProperties(e=>this._originalLuminanceValueFromUV(e))),n}});class Ml{constructor(e,t){this.position=e,this.uv=t}}class Tl{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;t<e;t++)this.adjacent.push([])}findConnectedComponents(){const e=new Array(this.noOfNodes).fill(!1);this.components=[];for(let t=0;t<this.noOfNodes;t++)if(!e[t]){const n=[];this._dfs(t,e,n),this.components.push(n)}this.components.sort((e,t)=>t.length-e.length)}_dfs(e,t,n){t[e]=!0,n.push(e);for(const r of this.adjacent[e])t[r]||this._dfs(r,t,n)}}class Pl{constructor(e){this.position=new a,this.uv=new s,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new a,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=yl(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class Al{constructor(e){this.grayMaterial=Ti.createMeshStandardMaterial({color:12632256,side:B,envMapIntensity:.4}),this._renderPass=new Io,this._sceneRenderer=e,this._environmentMapDecodeMaterial=new Cl(!0,!1),this._environmentMapDecodeMaterial.blending=pt,this._environmentMapDecodeMaterial.depthTest=!1}get _gBufferRenderTarget(){return this._sceneRenderer.gBufferRenderTarget}get _screenSpaceShadow(){return this._sceneRenderer.screenSpaceShadow}get _shadowAndAoPass(){return this._sceneRenderer.shadowAndAoPass}get _groundReflectionPass(){return this._sceneRenderer.groundReflectionPass}get _bakedGroundContactShadow(){return this._sceneRenderer.bakedGroundContactShadow}dispose(){var e,t;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.grayMaterial.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new xo,this._copyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new Co({depthTexture:this._gBufferRenderTarget.textureWithDepthValue,depthFilter:this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?new st(0,0,0,1):new st(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}render(e,t,n,r,i,s,a){e(r,i,s),"color"!==a?("grayscale"===a?this._sceneRenderer.renderCacheManager.render("debug",i,()=>{this._renderPass.renderWithOverrideMaterial(r,i,s,this.grayMaterial,null,0,1)}):t(r,i,s),n(r,i,s),this._renderDebugPass(r,i,s,a)):r.render(i,s)}_renderDebugPass(e,t,n,r){var i,s,a,o,l,d;switch(r){default:break;case"lineardepth":this._renderPass.renderScreenSpace(e,this._getDepthRenderMaterial(n),null);break;case"g-normal":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this._gBufferRenderTarget)||void 0===i?void 0:i.gBufferTexture,blending:pt,colorTransform:(new C).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new st(.5,.5,.5,1),multiplyChannels:0,uvTransform:vo}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this._gBufferRenderTarget)||void 0===s?void 0:s.gBufferTexture,blending:pt,colorTransform:uo,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null);break;case"g-depth":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.gBufferTexture,blending:pt,colorTransform:po,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(o=this._gBufferRenderTarget)||void 0===o?void 0:o.depthBufferTexture,blending:pt,colorTransform:mo,colorBase:_o,multiplyChannels:0,uvTransform:vo}),null);break;case"ssao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"ssaodenoise":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowmap":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._screenSpaceShadow.shadowTexture,blending:pt,colorTransform:go,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:pt,colorTransform:fl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowblur":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:fl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowfadein":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.fadeRenderTarget.texture,blending:pt,colorTransform:fl.shadowTransform,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"shadowandao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:pt,colorTransform:bo(this._shadowAndAoPass.parameters.aoIntensity,this._shadowAndAoPass.parameters.shadowIntensity,0,1),colorBase:fo,multiplyChannels:1,uvTransform:vo}),null);break;case"groundreflection":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._groundReflectionPass.reflectionRenderTarget.texture,blending:pt,colorTransform:co,colorBase:fo,multiplyChannels:0,uvTransform:wo}),null);break;case"bakedgroundshadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._bakedGroundContactShadow.renderTarget.texture,blending:pt,colorTransform:co,colorBase:fo,multiplyChannels:0,uvTransform:vo}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(t.environment),this._renderPass.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(l=t.userData)||void 0===l?void 0:l.environmentDefinition){const n=this._sceneRenderer.width/this._sceneRenderer.height,r=new Y(-1,1,1/n,-1/n,-1,1),i=null===(d=t.userData)||void 0===d?void 0:d.environmentDefinition.createDebugScene(e,t);i.background=new h(16777215),e.render(i,r)}}}}var El;!function(e){e[e.HIGHEST=0]="HIGHEST",e[e.HIGH=1]="HIGH",e[e.MEDIUM=2]="MEDIUM",e[e.LOW=3]="LOW"}(El||(El={}));class Rl{constructor(e,t,n){this.debugOutput="off",this._prevDebugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.movingCamera=!1,this.groundLevel=0,this.uiInteractionMode=!1,this._noUpdateNeededCount=0,this._cameraUpdate=new Ro,this.width=0,this.height=0,this._maxSamples=1,this._cameraChanged=!0,this.boundingVolume=new Eo,this._boundingVolumeSet=!1,this.renderCacheManager=new Lo,this._renderPass=new Io,this.selectedObjects=[],this.groundGroup=new q,this._qualityLevel=El.HIGHEST,this._qualityMap=new Map,this.width=t,this.height=n,this._maxSamples=e.capabilities.maxSamples,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new ko(e=>e===this.groundGroup)),this.renderCacheManager.registerCache("debug",new ko),this.renderCacheManager.registerCache("floorDepthWrite",new Uo(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor})),this.gBufferRenderTarget=new Fo(this.renderCacheManager,{shared:!0,capabilities:e.capabilities,width:this.width,height:this.height,samples:1,_renderPass:this._renderPass,textureFilter:ne}),this.shadowAndAoPass=new fl(this.width,this.height,1,{gBufferRenderTarget:this.gBufferRenderTarget}),this.screenSpaceShadow=new Xo(this.renderCacheManager,new s(this.width,this.height),{samples:this._maxSamples,alwaysUpdate:!1}),this.groundReflectionPass=new wl(this.width,this.height,{_renderPass:this._renderPass}),this.bakedGroundContactShadow=new No(this.renderer,this.groundGroup,{_renderPass:this._renderPass,renderCacheManager:this.renderCacheManager}),this.groundGroup.rotateX(-Math.PI/2),this.outlineRenderer=new Vo(null,this.width,this.height,{gBufferRenderTarget:this.gBufferRenderTarget}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderTarget.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadow.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadow.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:ul.OFF},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",()=>{}),e.domElement.addEventListener("webglcontextrestored",()=>{this._forceEnvironmentMapUpdate(this.renderer)})}dispose(){var e,t;null===(e=this._debugPass)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.gBufferRenderTarget.dispose(),this.screenSpaceShadow.dispose(),this.shadowAndAoPass.dispose(),this.outlineRenderer.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this.gBufferRenderTarget.setSize(e,t),this.screenSpaceShadow.setSize(e,t),this.shadowAndAoPass.setSize(e,t),this.outlineRenderer.setSize(e,t),this.groundReflectionPass.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}applyCurrentParameters(){this._qualityMap.has(this._qualityLevel)&&(this.updateParameters(this._qualityMap.get(this._qualityLevel)),this.bakedGroundContactShadow.applyParameters()),this.uiInteractionMode&&this.updateParameters({groundReflectionParameters:{enabled:!1}})}clearCache(){this.renderCacheManager.clearCache()}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderTarget.needsUpdate=!0,this.screenSpaceShadow.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadow.needsUpdate=!0)}updateParameters(e){void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.effectParameters&&this.shadowAndAoPass.updateParameters({effectParameters:e.effectParameters}),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadow.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadow.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadow.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadow.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadow.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.renderCacheManager.clearCache(),this._boundingVolumeSet=!0,this.boundingVolume.updateFromBox(e);const n=this.boundingVolume.size,r=(n.x+n.y+n.z)/3,i=Math.min(n.x,n.y,n.z),s=Math.max(n.x,n.y,n.z),a=i<.5?i/.5:n.z>5?n.z/5:1;this.bakedGroundContactShadow.setScale(t?r:a,r),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,s)),this.screenSpaceShadow.updateBounds(this.boundingVolume,r),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?r:Math.min(1,2*s))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_setRenderState(e,t){var n;const r=this.debugOutput!==this._prevDebugOutput;this._prevDebugOutput=this.debugOutput,this.screenSpaceShadow.parameters.alwaysUpdate=this.shadowAndAoPass.parameters.alwaysUpdate,this._cameraChanged=this._cameraUpdate.changed(t),(n=this.gBufferRenderTarget).needsUpdate||(n.needsUpdate=this._cameraChanged||r)}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,r;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const i=e.userData;if(i&&((null===(r=t.userData)||void 0===r?void 0:r.environmentDefinition.needsUpdate)||!i.environmentTexture||i.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(i.environmentDefinition=n,i.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadow.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==i?void 0:i.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._setRenderState(e,t),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.movingCamera?[]:this.selectedObjects),this.renderer.setRenderTarget(null),this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput?this._renderDebug(this.renderer,e,t):(this.renderPreRenderPasses(this.renderer,e,t),this._renderScene(this.renderer,e,t),this.renderPostProcessingEffects(this.renderer,e,t)),e.remove(this.groundGroup)}_renderDebug(e,t,n){var r;this._debugPass=null!==(r=this._debugPass)&&void 0!==r?r:new Al(this),this._debugPass.render((e,t,n)=>this.renderPreRenderPasses(e,t,n),(e,t,n)=>this._renderScene(e,t,n),(e,t,n)=>this.renderPostProcessingEffects(e,t,n),e,t,n,this.debugOutput)}renderPreRenderPasses(e,t,n){this._renderGroundContactShadow(t)}_renderScene(e,t,n){this.renderCacheManager.onBeforeRender("floorDepthWrite",t),this.bakedGroundContactShadow.setGroundVisibility(!0,n),e.render(t,n),this.bakedGroundContactShadow.setGroundVisibility(!1,n),this.renderCacheManager.onAfterRender("floorDepthWrite")}renderPostProcessingEffects(e,t,n){this.renderShadowAndAo(e,t,n),this._renderOutline()}_renderGroundContactShadow(e){this.bakedGroundContactShadow.needsUpdate&&this.bakedGroundContactShadow.updateBounds(this.boundingVolume,this.groundLevel),this.bakedGroundContactShadow.render(e)}renderShadowAndAo(e,t,n){const r=this._evaluateIfShadowAndAoUpdateIsNeeded(n);if(r.needsUpdate||r.shadowOnCameraChange!==ul.OFF){if(!this.parameters.suspendGroundReflection||r.needsUpdate){const i=this.parameters.suspendGroundReflection?r.intensityScale:1;this._renderGroundReflection(e,t,n,i)}this.gBufferRenderTarget.needsUpdate=r.needsUpdate||r.shadowOnCameraChange===ul.POISSON,this._renderEffectsWithGround(e,t,n),this._renderEffectsWithoutGround(e,t,n),this.shadowAndAoPass.render(e,t,n,this.screenSpaceShadow.shadowTexture,r.needsUpdate?ul.FULL:r.shadowOnCameraChange,r.shadowOnCameraChange,1-r.intensityScale)}}_evaluateIfShadowAndAoUpdateIsNeeded(e){const t=this.shadowAndAoPass.parameters.alwaysUpdate||this.screenSpaceShadow.needsUpdate||this.screenSpaceShadow.shadowTypeNeedsUpdate;let n=(this.shadowAndAoPass.parameters.enabled||this.groundReflectionPass.parameters.enabled)&&(0===this.parameters.effectSuspendFrames||this._cameraChanged);n&&(this._noUpdateNeededCount=0);let r=1;return!t&&this.parameters.effectSuspendFrames>0&&(this._noUpdateNeededCount++,n=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,r=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),n=t||n,{needsUpdate:n,shadowOnCameraChange:!n||r<.99?this.parameters.shadowOnCameraChange:ul.OFF,intensityScale:r}}_renderGroundReflection(e,t,n,r=1){this.groundReflectionPass.parameters.enabled&&this.renderCacheManager.render("inivisibleGround",t,()=>{this.groundReflectionPass.render(e,t,n,r)})}_renderEffectsWithGround(e,t,n){const r=this._boundingVolumeSet&&this.shadowAndAoPass.parameters.aoOnGround,i=this.shadowAndAoPass.parameters.shadowIntensity>0&&this._boundingVolumeSet&&this.shadowAndAoPass.parameters.shadowOnGround,s=this.bakedGroundContactShadow.shadowGroundPlane;if(r){const r=null===this.bakedGroundContactShadow.parameters.hardLayers;r&&s.setDepthWrite(!0),this.gBufferRenderTarget.render(e,t,n),r&&s.setDepthWrite(!1)}i&&(s.setReceiveShadow(!0),this.screenSpaceShadow.renderShadowMap(e,t,n),s.setReceiveShadow(!1))}_renderEffectsWithoutGround(e,t,n){const r=!this._boundingVolumeSet||!this.shadowAndAoPass.parameters.aoOnGround,i=this.shadowAndAoPass.parameters.shadowIntensity>0&&(!this._boundingVolumeSet||!this.shadowAndAoPass.parameters.shadowOnGround);(r||i)&&this.renderCacheManager.render("inivisibleGround",t,()=>{r&&this.gBufferRenderTarget.render(e,t,n),i&&this.screenSpaceShadow.renderShadowMap(e,t,n)})}_renderOutline(){if(this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass){const e=this.renderer.getClearColor(new h),t=this.renderer.getClearAlpha();"outline"===this.debugOutput&&(this.renderer.setClearColor(0,255),this.renderer.clear(!0,!1,!1)),this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.render(this.renderer,null,null,0,!1),"outline"===this.debugOutput&&this.renderer.setClearColor(e,t)}}}class Il{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const r=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(r,t);const i=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(i,t);const s=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(s,t);const a=e.addFolder("Outline");this._addOutlineGUI(a,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",w],["SRGBColorSpace",x]]),r=[];n.forEach((e,t)=>{r.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)}),e.add(this._sceneRenderer,"outputColorSpace",r).onChange(e=>{var r;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(r=n.get(e))&&void 0!==r?r:x,t())});const i=new Map([["NoToneMapping",Ft],["LinearToneMapping",Nt],["ReinhardToneMapping",Bt],["CineonToneMapping",jt],["ACESFilmicToneMapping",Gt]]),s=[];i.forEach((e,t)=>{s.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)}),e.add(this._sceneRenderer,"toneMapping",s).onChange(e=>{var n;i.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=i.get(e))&&void 0!==n?n:Ft,t())})}_addDebugGUI(e,t){const n=new Map([["HIGHEST",El.HIGHEST],["HIGH",El.HIGH],["MEDIUM",El.MEDIUM],["LOW",El.LOW]]),r=[];n.forEach((e,t)=>r.push(t)),e.add(this,"_qualityLevel",r).onChange(e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:El.HIGHEST)}),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow Monte Carlo":"shadow","shadow blur":"shadowblur","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","ground reflection":"groundreflection","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange(()=>t())}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadow.shadowConfiguration,r=[];n.types.forEach((e,t)=>{r.push(t)});const i=()=>{this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",r).onChange(e=>{this._sceneRenderer.screenSpaceShadow.switchType(e)&&(s.object=n.currentConfiguration,a.object=n.currentConfiguration,o.object=n.currentConfiguration,s.updateDisplay(),a.updateDisplay(),o.updateDisplay(),i())});const s=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange(()=>i()),a=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange(()=>i()),o=e.add(n.currentConfiguration,"radius",0,100).onChange(()=>i())}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.gBufferRenderTarget.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.shadowAndAoRenderTargets.parametersNeedsUpdate=!0,t()},r=this._sceneRenderer.shadowAndAoPass.parameters,i=r.shAndAo,s=this._sceneRenderer.screenSpaceShadow.parameters,a=r.hbao,o=r.poissonDenoise;e.add(r,"enabled").onChange(()=>n());const l=new Map([["none",pl.NONE],["SSAO",pl.SSAO],["HBAO",pl.HBAO]]),h=Array.from(l.keys());l.forEach((e,t)=>{e===r.aoType&&(this._ambientOcclusionType=t)}),e.add(this,"_ambientOcclusionType",h).onChange(e=>{var t;l.has(e)&&(r.aoType=null!==(t=l.get(e))&&void 0!==t?t:pl.SSAO,n())}),e.add(r,"aoIntensity",0,1).onChange(()=>{n()}),e.add(r,"aoOnGround").onChange(()=>{n()}),e.add(r,"shadowOnGround").onChange(()=>{n()}),e.add(r,"shadowIntensity",0,1).onChange(()=>n()),e.add(r,"alwaysUpdate").onChange(()=>n());const d=e.addFolder("Shadow and Monte Carlo integration");d.add(s,"maximumNumberOfLightSources").onChange(()=>n()),d.add(s,"directionalDependency",0,1,.01).onChange(()=>n()),d.add(s,"directionalExponent",0,2,.01).onChange(()=>n()),d.add(s,"groundContainment",0,1,.01).onChange(()=>n()),d.add(s,"fadeOutDistance",0,5,.01).onChange(()=>n()),d.add(s,"fadeOutBlur",0,100).onChange(()=>n()),d.add(i,"shadowRadius",.001,.5).onChange(()=>n());const c=e.addFolder("SSAO");c.add(i,"aoFadeout",0,1).onChange(()=>n()),c.add(i,"aoKernelRadius",.001,1).onChange(()=>n()),c.add(i,"aoDepthBias",1e-4,.01).onChange(()=>n()),c.add(i,"aoMaxDistance",.01,1).onChange(()=>n()),c.add(i,"aoMaxDepth",.9,1).onChange(()=>n());const u=e.addFolder("HBAO");u.add(a,"samples",1,64,1).onChange(()=>n()),u.add(a,"radius",.1,10,.01).onChange(()=>n()),u.add(a,"distanceExponent",.1,5,.1).onChange(()=>n()),u.add(a,"bias",.001,.1,.001).onChange(()=>n());const p=e.addFolder("Possion Denoise");p.add(o,"iterations",0,3,1).onChange(()=>n()),p.add(o,"radius",0,32,1).onChange(()=>n()),p.add(o,"rings",0,16,.125).onChange(()=>n()),p.add(o,"samples",0,32,1).onChange(()=>n()),p.add(o,"lumaPhi",0,20,.001).onChange(()=>n()),p.add(o,"depthPhi",0,20,.001).onChange(()=>n()),p.add(o,"normalPhi",0,20,.001).onChange(()=>n())}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange(()=>t()),e.add(n,"fadeOutDistance",0,4).onChange(()=>t()),e.add(n,"fadeOutExponent",.1,10).onChange(()=>t()),e.add(n,"brightness",0,2).onChange(()=>t()),e.add(n,"blurHorizontal",0,10).onChange(()=>t()),e.add(n,"blurVertical",0,10).onChange(()=>t())}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadow.applyParameters(),t()},r=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(r,"enabled"),e.add(r,"cameraHelper").onChange(()=>n()),e.add(r,"alwaysUpdate"),e.add(r,"fadeIn"),e.add(r,"blurMin",0,.2,.001).onChange(()=>n()),e.add(r,"blurMax",0,.5,.01).onChange(()=>n()),e.add(r,"fadeoutFalloff",0,1,.01).onChange(()=>n()),e.add(r,"fadeoutBias",0,.5).onChange(()=>n()),e.add(r,"opacity",0,1,.01).onChange(()=>n()),e.add(r,"maximumPlaneSize",0,50,1).onChange(()=>n()),e.add(r,"cameraFar",.1,10,.1).onChange(()=>n())}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},r=this._sceneRenderer.outlineRenderer.parameters;e.add(r,"enabled"),e.add(r,"edgeStrength",.5,20).onChange(()=>n()),e.add(r,"edgeGlow",0,20).onChange(()=>n()),e.add(r,"edgeThickness",.5,20).onChange(()=>n()),e.add(r,"pulsePeriod",0,5).onChange(()=>n()),e.addColor(r,"visibleEdgeColor").onChange(()=>n()),e.addColor(r,"hiddenEdgeColor").onChange(()=>n())}}const Dl={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:ul.FULL},Ol={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:ul.POISSON},Ll={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:ul.HARD},kl={iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:12,normalPhi:3.25,samples:16},Ul=e("Z",new Map([[El.HIGHEST,{...Dl,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:kl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],[El.HIGH,{...Ol,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:kl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],[El.MEDIUM,{...Ll,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,poissonDenoise:kl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}}],[El.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]])),Fl=new Ht;Fl.enable(3);const Nl=new Ht;Nl.disableAll(),Nl.enable(9);const Bl={enabled:!0,aoType:pl.SSAO,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,poissonDenoise:kl},jl={enabled:!0,aoType:pl.HBAO,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,hbao:{samples:16,radius:.5,distanceExponent:2,bias:.01},poissonDenoise:{iterations:1,radius:10,rings:4,lumaPhi:10,depthPhi:2,normalPhi:3.25,samples:16}},Gl=jl,Hl={enabled:!0,fadeoutFalloff:.9,blurMax:.1,opacity:.5,hardLayers:null,softLayers:null,polygonOffset:2},zl={enabled:!0,fadeoutFalloff:.8,blurMax:.15,opacity:.5,hardLayers:Nl,softLayers:null,polygonOffset:-1},Vl={enabled:!1},Wl=new Map([[El.HIGHEST,{...Dl,shAndAoPassParameters:Bl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Hl}],[El.HIGH,{...Ol,shAndAoPassParameters:Bl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Hl}],[El.MEDIUM,{...Ll,shAndAoPassParameters:Bl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Hl}],[El.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Hl}]]),Kl=new Map([[El.HIGHEST,{...Dl,shAndAoPassParameters:jl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:zl}],[El.HIGH,{...Ol,shAndAoPassParameters:jl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:zl}],[El.MEDIUM,{...Ll,shAndAoPassParameters:jl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:zl}],[El.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:zl}]]),ql=new Map([[El.HIGHEST,{...Dl,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Vl}],[El.HIGH,{...Ol,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Vl}],[El.MEDIUM,{...Ll,shAndAoPassParameters:Gl,screenSpaceShadowMapParameters:{layers:Fl},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Vl}],[El.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Vl}]]);class Xl{constructor(){this._index=0,this._prevTime=0,this._frames=0,this._fps=-1,this._fpsList=Array(2).fill(0),this._prevTime=(performance||Date).now(),this.reset()}update(){this._frames++;const e=(performance||Date).now();e>=this._prevTime+1e3&&(this._fpsList[this._index%2]=1e3*this._frames/(e-this._prevTime),this._index>=2&&(this._fps=this._fpsList.reduce((e,t)=>e+t)/this._fpsList.length),this._prevTime=e,this._frames=0,this._index++)}start(){this._prevTime=(performance||Date).now(),this._frames=0}reset(){this._fps=-1,this._fpsList=Array(2).fill(0),this._index=0}getFps(){return this._fps}}var Ql;e("af",Ql),function(e){e[e.Mode3D=0]="Mode3D",e[e.Mode2D=1]="Mode2D"}(Ql||e("af",Ql={}));class Yl{get renderer(){return this._renderer}get screenSpaceShadowParameters(){return this.sceneRenderer.screenSpaceShadow.parameters}get shadowAndAoPassParameters(){return this.sceneRenderer.shadowAndAoPass.parameters}get bakedGroundContactShadowParameters(){return this.sceneRenderer.bakedGroundContactShadow.parameters}get groundReflectionParameters(){return this.sceneRenderer.groundReflectionPass.parameters}get outlineParameters(){return this.sceneRenderer.outlineRenderer.parameters}constructor(e,t,n){this.configuratorMode=!0,this.uiInteractionMode=!0,this._renderer=e,this.sceneRenderer=new Rl(this._renderer,t,n),this.outlineParameters.enabled=!0,this.outlineParameters.edgeStrength=2,this.outlineParameters.edgeGlow=1,this.outlineParameters.edgeThickness=2,this.outlineParameters.pulsePeriod=0,this.outlineParameters.usePatternTexture=!1,this.outlineParameters.visibleEdgeColor=16777215,this.outlineParameters.hiddenEdgeColor=16777215,Yl.enableRectAreaLightShadow&&(Qt.rectAreaLightReplacement=!1,Qt.rectAreaLightLoadingListener=this.loadRectAreLight),this.sceneRenderer.setQualityLevel(El.HIGHEST),this.SceneRendererGUI=new Il(this.sceneRenderer)}dispose(){this.sceneRenderer.dispose()}setSize(e,t){this.sceneRenderer.setSize(e,t)}setAutoQuality(e){!this._fpsCounter&&e?this._fpsCounter=new Xl:this._fpsCounter&&!e&&(this._fpsCounter=null)}setQualityLevel(e){this.sceneRenderer.setQualityLevel(e)}setQualityMap(e){this.sceneRenderer.setQualityMap(e)}enableUiInteractionMode(){this.sceneRenderer.uiInteractionMode=!0,this.sceneRenderer.applyCurrentParameters()}disableUiInteractionMode(){this.sceneRenderer.uiInteractionMode=!1,this.sceneRenderer.applyCurrentParameters()}loadRectAreLight(e){Yl.rectAreaLightsNeedsUpdate=!0}updateRectAreaLight(e){let t=[];e.traverse(e=>{e instanceof o&&t.push(e)}),this.sceneRenderer.updateRectAreaLights(t,e),Yl.rectAreaLightsNeedsUpdate=!1}clearCache(){this.sceneRenderer.clearCache()}forceShadowUpdates(e){this.sceneRenderer.forceShadowUpdates(e)}switchToConfigurator(){this.configuratorMode=!0,this.sceneRenderer.setQualityMap(Wl)}switchToPlanner(e){Ql.Mode3D,this.configuratorMode=!1,e===Ql.Mode3D?this.sceneRenderer.setQualityMap(Kl):this.sceneRenderer.setQualityMap(ql)}updateBounds(e){this.sceneRenderer.updateBounds(e,!1)}updateEnvironment(e,t=!1){e&&this.updateBounds(e)}movingCameraStarts(){var e;this.sceneRenderer.movingCamera=!0,null===(e=this._fpsCounter)||void 0===e||e.start()}movingCameraStops(){this.sceneRenderer.movingCamera=!1}highlightObjects(e){this.sceneRenderer.selectObjects(e)}render(e,t){var n;Yl.rectAreaLightsNeedsUpdate&&this.updateRectAreaLight(e),t.updateMatrixWorld(),(t instanceof X||t instanceof Y)&&t.updateProjectionMatrix();const r=Yl.updateNearAndFarPlaneOfPerspectiveCamera?this.createRenderCamera(t):t;if(this.sceneRenderer.render(e,r),this.sceneRenderer.movingCamera&&this._fpsCounter){null===(n=this._fpsCounter)||void 0===n||n.update();const e=this.sceneRenderer.getQualityLevel(),t=this._fpsCounter.getFps();t>0&&t<30&&e<3&&(this.sceneRenderer.setQualityLevel(e+1),this._fpsCounter.reset())}}createRenderCamera(e){const t=e.clone();return this.configuratorMode&&t instanceof X&&(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(t,120),t.updateProjectionMatrix()),t}showGUI(e){const t=Fi();this.SceneRendererGUI.addGUI(t,e)}clear(){this.renderer.clear()}}e("Y",Yl),Yl.enableRectAreaLightShadow=!0,Yl.rectAreaLightsNeedsUpdate=!1,Yl.updateNearAndFarPlaneOfPerspectiveCamera=!1;class Zl{_getRoomleRenderer(e=!1){if(!this._roomleRenderer){const t=new zt({antialias:!e,alpha:!0});t.outputColorSpace=x,t.autoClear=!0,t.setSize(1024,1024),t.outputColorSpace=x,t.autoClear=!1,t.shadowMap.enabled=!0,t.shadowMap.type=Pt,this._roomleRenderer=new Yl(t,1024,1024),this._roomleRenderer.setQualityMap(Ul),this._roomleRenderer.setSize(1024,1024)}return this._roomleRenderer}switchToPlannerSettings(){this._getRoomleRenderer().switchToPlanner(Ql.Mode3D)}switchToConfiguratorSettings(){this._getRoomleRenderer().switchToConfigurator()}static getCameraTargetForBBox(e,t=0){if(!e){const e=new a;return{center:e,bounds:e,diagonal:0}}const n=e.getSize(new a);return n.addScalar(t),{center:e.getCenter(new a),bounds:n,diagonal:Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2))}}preparePerspectiveImage(e,t,n,r,i={},s=0,a=!1){return new Promise(o=>{const{size:l=1024,showDimensions:h}=i,d=this._getRoomleRenderer(a);d.setSize(l,l);const c=e.fog?e.fog.clone():null,u=e.background?e.background.clone():null;e.background=null,e.fog=null,n.layers.disable(2),n.layers.disable(6),n.layers.disable(5),h?n.layers.enable(8):n.layers.disable(8);const p=-30+cr(s);Zl.placeCameraForPerspectiveImage(n,r,-20,p);const m=this._render(d,e,t,n,a);n.layers.enable(2),n.layers.enable(6),n.layers.enable(5),e.background=u,e.fog=c,o({image:m,width:l,height:l,blob:null})})}renderPerspectiveImage(e,t,n,r){return new Promise(i=>{r||(r=1024);const s=this._getRoomleRenderer();s.setSize(r,r);const a=e.fog?e.fog.clone():null,o=e.background?e.background.clone():null;e.background=null,e.fog=null,t.layers.disable(2),t.layers.disable(6),t.layers.disable(5),n?Zl.placeCameraForPerspectiveImage(t,n,-20,-30):(t.aspect=1,t.updateProjectionMatrix());const l=this._render(s,e,null,t);t.layers.enable(2),t.layers.enable(6),t.layers.enable(5),e.background=o,e.fog=a,i({image:l,width:r,height:r,blob:null})})}static placeCameraForPerspectiveImage(e,t,n,r){e.far=1e3,e.fov=15,e.aspect=1,e.position.copy(t.center),e.rotation.set(0,0,0),e.rotateY(dr(r)),e.rotateX(dr(n)),e.translateZ(3.8*t.diagonal),e.updateProjectionMatrix()}prepareTopImage(e,t,n,r={}){const{showDimensions:i=!1}=r;return new Promise(r=>{const s=this._getRoomleRenderer();let a=new Y(-n.bounds.x/2,n.bounds.x/2,n.bounds.z/2,-n.bounds.z/2,.5);a.position.copy(n.center),a.rotateX(dr(-90)),a.translateZ(n.bounds.y+1),a.far=a.position.y+.5,a.layers.mask=65535;let o=200*n.bounds.x,l=200*n.bounds.z;if(o>4096||l>4096){let e=0;o>4096?e=o/4096:l>4096&&(e=l/4096),o/=e,l/=e}s.setSize(o,l);let h=e.fog?e.fog.clone():null,d=e.background?e.background.clone():null;e.background=null,e.fog=null,a.layers.disable(2),a.layers.disable(6),a.layers.disable(5),i?a.layers.enable(8):a.layers.disable(8);const c=this._render(s,e,t,a);a.layers.enable(2),a.layers.enable(6),a.layers.enable(5),e.background=d,e.fog=h,r({image:c,width:o,height:l,blob:null})})}_render(e,t,n,r,i=!1){i?e.renderer.render(t,r):(e.forceShadowUpdates(!0),e.render(t,r),e.render(t,r)),n&&(e.renderer.autoClear=!1,e.renderer.clearDepth(),e.renderer.render(n,r),e.renderer.autoClear=!0);const s=e.renderer.domElement.toDataURL();return e.clear(),s}}e("m",Zl);const Jl=e("I",[new Wt("error-handler",class{constructor(){this._listeners={}}_subscribe(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}subscribe(e,t){this._subscribe(e,t)}dispatch(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++){const r=n[e];r.apply(r,t)}}unsubscribe(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let r=n.length;for(let e=0;e<r;e++)if(n[e]===t)return n.splice(e,1),r--,void e--}softReject(e,t,n){return this.dispatch(n,[t]),e()}}),new Wt("form-data-util",qt),new Wt("hdr-environment-loader",class{constructor(e){this._creator_=e;const t=new h("#DDDDDD");this._environmentMap=((e,t,n,r)=>{const i=new we;i.format=be,i.generateMipmaps=!1;for(let r=0;r<6;++r){const s=Ri(e,t,n,1);s.format=i.format,s.type=i.type,s.minFilter=i.minFilter,s.magFilter=i.magFilter,s.generateMipmaps=i.generateMipmaps,s.needsUpdate=!0,i.images[r]=s}return i.needsUpdate=!0,i})(t.r,t.g,t.b)}async loadUrl(e,t){const n=t.toLowerCase();this._environmentMap=n.endsWith(".exr")?await this._loadExr(t):await this._loadRgbe(t),this._environmentMap.mapping=it;const r={url:t,environmentMap:this._environmentMap};return this._envChangedCallback(r),r}_loadExr(e){var t;return this._exrLoader=null!==(t=this._exrLoader)&&void 0!==t?t:new oo,this._exrLoader.setPath(e.startsWith("http")?"":n()),this._exrLoader.loadAsync(e)}_loadRgbe(e){var t;return this._rgbeLoader=null!==(t=this._rgbeLoader)&&void 0!==t?t:new lo,this._rgbeLoader.setPath(e.startsWith("http")?"":n()),this._rgbeLoader.loadAsync(e)}registerEnvironmentChangedCallback(e){this._envChangedCallback=e}}),new Wt("static-item-loader",class{constructor(e){this._gltfLoaderGuard=new un,this._creator_=e,this._initLoaders()}_initLoaders(){this._gltfLoader=new gn;const e=new ar,t=e._loadLibrary.bind(e._loadLibrary);e._loadLibrary=(e,r)=>{const i=lr[e];if(!i)throw new Error('Can not load draco dependency "'+e+'" did three.js update DracoLoader lib? Available files'+JSON.stringify(lr));return t(n()+i,r)},e.setDecoderConfig({type:"wasm"}),this._gltfLoader.setDRACOLoader(e),this._gltfLoaderGuard.resolve(this._gltfLoader)}async loadGLB(e,t,n,r,i,s,a,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.load(e,e=>{l(this._handleGLTFScene("GLB",e,t,n,r,i,s,a))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}async loadGLTF(e,t,n,r,i,s,a,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.parse(e,null,e=>{l(this._handleGLTFScene("GLTF",e,t,n,r,i,s,a))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}_handleGLTFScene(e,t,n,r,i,s,o,l){if(!t||!t.scene||!t.scene.children||0===t.scene.children.length)return null;n&&t.scene.position.copy(n),r&&(t.scene.rotation.y=r);const d=new ge;if(d.setFromObject(t.scene),i){const{x:e,y:n,z:r}=d.getSize(new a);let s=new a(i.x/e,i.y/n,i.z/r);t.scene.scale.copy(s)}return s&&t.scene.scale.multiply(s),t.scene.type=e,t.scene.traverse(e=>{if(e instanceof H){if(e.layers.set(3),e.material instanceof N){const t=e.material;if(l&&o&&o>0){let e=new h(o);t.color=e.copySRGBToLinear(e),t.roughness=.5,t.metalness=.1}t.needsUpdate=!0}e.castShadow=!0,e.receiveShadow=!0}}),{boundingBox:d,scene:t.scene}}},0),new Wt("form-data-util",qt),new Wt("single-promise-factory",class{constructor(e){this._promises=new Map,this._creator_=e}create(e,t,n){return new Promise((r,i)=>{let s=this._promises.get(e),a=!0;if(!s){const t=new Map;this._promises.set(e,t),s=this._promises.get(e),a=!1}s.get(t)||(s.set(t,[]),a=!1);const o=s.get(t);o.push({resolve:r,reject:i}),s.set(t,o);const l=()=>{s.delete(t),0===s.size&&this._promises.delete(e)};a||new Promise(n).then(e=>{s.get(t).forEach(({resolve:t})=>t(e)),l()},e=>{s.get(t).forEach(({reject:t})=>t(e)),l()})})}},1),new Wt("dynamic-light-setting-loader",Qt),new Wt("network-layer",en),new Wt("local-storage",class{constructor(e){this._context_=e}get _localStorage(){let e=null;try{e=window.localStorage}catch(e){console.error(e)}return e}getItem(e){if(!this._localStorage)return null;const t=this._localStorage.getItem(e);try{return JSON.parse(t)}catch(e){return t}}setItem(e,t){if(this._localStorage)try{const n=JSON.stringify(t);this._localStorage.setItem(e,n)}catch(e){console.error(e)}}}),new Wt("network-layer",en),new Wt("kernel-io",an,0),new Wt("data-syncer",cn),new Wt("memory-manager",class{constructor(){this._configurationStringSet=new Set,this._singleLoadCounter=0}loadingConfigurationString(){this._singleLoadCounter+=1}loadingConfiguration(e){this._configurationStringSet.add(e),this._singleLoadCounter+=1}shouldHardReset(){return this._configurationStringSet.size>=15||this._singleLoadCounter>=30}executedHardReset(){this._configurationStringSet.clear(),this._singleLoadCounter=0}}),new Wt("life-cycle-manager",class{constructor(){this._listeners=[]}addEventListener(e){this._listeners.push(e)}removeEventListener(e){const t=this._listeners;let n=t.length;if(n)for(let r=0;r<n;r++)t[r]===e&&(t.splice(r,1),r--,n--)}pause(){this._listeners.forEach(e=>e.pause())}resume(){this._listeners.forEach(e=>e.resume())}destroy(){this._listeners.forEach(e=>e.destroy())}},1),new Wt("local-storage-helper",hr),new Wt("cache-holder",class{constructor(){this._componentCache=new Map,this._geometryCache=new Map,this._materialCache=new Map}get componentCache(){return this._componentCache}get geometryCache(){return this._geometryCache}get materialCache(){return this._materialCache}clear(){for(const e of this._componentCache.values())ji(e);for(const e of this._materialCache.values())zi(e);for(const e of this._geometryCache.values())Hi(e);this._componentCache.clear(),this._geometryCache.clear(),this._materialCache.clear()}},0),new Wt("kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Wt("configurator-kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}updatePossibleChildren(e,t,n){this._callbackListener.forEach(r=>r.updatePossibleChildren(e,t,n))}updateParameters(e,t,n,r){this._callbackListener.forEach(i=>i.updateParameters(e,t,n,r))}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Wt("configurator-context",class{constructor(){this.planObjectId=0,this.planElementId=0,this.rootComponentId=0,this.dockingRootComponentId=0,this.baseContext=null,this.rootComponentParametersAsGlobal=!1,this.lastLoadedRapiId=null,this.selectedRuntimeComponentIds=[],this.selectionMode="standard"}get selectedRuntimeComponentId(){return this.selectedRuntimeComponentIds.length>0?this.selectedRuntimeComponentIds[0]:null}},1),new Wt("init-data",Yi,1),new Wt("global-init-data",Ji,0),new Wt("global-callback",es,0),new Wt("dom-helper",ts,1),new Wt("unit-formatter",Da,0),new Wt("plugin-system",ns,1),new Wt("configurator-mesh-generator",ss),new Wt("configurator-input-manager",class extends cs{},1),new Wt("selection-handler",class extends as{constructor(){super(...arguments),this._selectionMode="standard",this._selectedComponents=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedComponents.size&&this._selectedComponents.forEach((e,t)=>{e.deselect(),this._selectedComponents.delete(t),this.dispatchEvent(1,new us({component:e}))})}_checkStandard(e){this._selectedComponents.has(e.runtimeId)?this.dispatchEvent(0,new us({component:e,consecutive:!0})):(this._selectedComponents.size>0&&this._selectedComponents.forEach((e,t)=>{this._selectedComponents.delete(t),this.dispatchEvent(1,new us({component:e,resetCamera:!1}))}),this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new us({component:e,consecutive:!1})))}_checkMulti(e){if(this._selectedComponents.has(e.runtimeId))return this._selectedComponents.delete(e.runtimeId),void this.dispatchEvent(1,new us({component:e,resetCamera:0===this._selectedComponents.size}));this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new us({component:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedComponents.size>0}getSelectedRuntimeComponentIds(){let e=[];return this._selectedComponents.forEach(t=>e.push(t.runtimeId)),e}isSelected(e){return this._selectedComponents.has(e.runtimeId)}},1),new Wt("component-dimensioning-helper",ws,1),new Wt("component-dimensioning-helper",ws,1),new Wt("planner-kernel-access",Ta),new Wt("planner-mesh-generator",Pa,1),new Wt("unit-formatter",Da),new Wt("configurator-history",Oa,1),new Wt("roomle-planner-ui-callback",class extends $i{constructor(e){super(e),this.onItemsLoaded=()=>{},this.onCameraChanged=e=>{},this.onCameraIdle=()=>{},this.onTotalFloorAreaChanged=e=>{},this.onPlanInteractionHandlerCreated=e=>{},this.onPlannerKernelIsReady=e=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onSelectionChange=(e,t,n,r,i)=>{},this.onSelectionCancel=e=>{},this.onPlanChanged=()=>{},this.onPlanElementChanged=(e,t)=>{},this.onCompletelyLoaded=()=>{},this.onRotationCancel=()=>{},this.onHistoryChange=(e,t)=>{},this.onUpdateWallDimensions=e=>{},this.disableWallDimensions=()=>{},this.onUpdatePlanObjectPositions=e=>{},this.onDrawCancel=()=>{},this.onHandlerSwitchedPlans=()=>{},this.onDragElementStart=()=>{},this.onDragElementEnd=()=>{},this.onClickElement=e=>{},this.onMultiSelectionChange=e=>{}}}),new Wt("configurator-ui-callbacks",class extends $i{constructor(e){super(e),this.onKernelIsReady=null,this.onComponentPositionsUpdated=null,this.onUpdateParameters=e=>{},this.onUpdatePossibleChildren=(e,t)=>{},this.onUpdatePrice=(e,t)=>{},this.onSelectionChange=(e,t,n,r)=>{},this.onSelectionCancel=()=>{},this.onPartListUpdate=(e,t)=>{},this.onBoundsUpdate=e=>{},this.onLoadConfiguration=()=>{},this.onConfigurationReady=(e,t,n)=>{},this.onOpenTag=e=>{},this.onOpenAddOns=()=>{},this.onClickOutside=()=>{},this.onNoDockingsAvailable=()=>{},this.onUiIntersectionChange=e=>{},this.onZoomChange=(e,t)=>{},this.onZoomToComponent=()=>{},this.onDimensionsVisibilityChange=e=>{},this.onErrorDueToOffline=e=>{},this.onError=e=>{},this.onDockingsPreviewRemoved=()=>{},this.onConfigurationHasChildren=e=>{},this.onTrackTiming=(e,t,n,r)=>{},this.onUserInitiatedDockDone=(e,t,n,r,i)=>{},this.onAddonPlusHover=()=>{},this.onAddonPlusHoverOff=()=>{},this.onAddonPlusShown=()=>{},this.onAddonPlusHidden=()=>{},this.onContentProblem=e=>{},this.onSyncStarted=()=>{},this.onSyncDone=()=>{},this.onOpenFloorMaterials=()=>{},this.onOpenPartList=()=>{},this.onComponentLoadError=(e,t)=>{},this.onConfigurationLoadError=()=>{},this.onChangeTypeChangeTag=e=>{},this.onRemoveTypeChangeTag=e=>{},this.onConfigurationLabelChange=(e,t,n)=>{},this.onMemoryCorruption=()=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onConfigurationSaved=e=>{},this.onCameraPositionChanges=()=>{},this.onHistoryChange=(e,t)=>{},this.onClickComponent=e=>{},this.onRequestExternalMesh=(e,t)=>{},this.onGeometryReady=e=>{},this.onGeometryNotReady=e=>{}}},1),new Wt("roomle-tools-core",La,0),new Wt("image-renderer",Zl,0)]);class $l{static _ensureContainer(){window.__RML__DI__||(window.__RML__DI__=new Vt,window.__RML__DI__.addDependencyInjectionAssignments(Jl))}static setup(e){$l.addToContainer(e)}static lookup(e,t){return window.__RML__DI__?window.__RML__DI__.lookup(e,t):null}static getContext(e){return $l._ensureContainer(),window.__RML__DI__.getContext(e)}static cleanUp(e){return window.__RML__DI__?window.__RML__DI__.cleanUp(e):null}static addToContainer(e){$l._ensureContainer(),window.__RML__DI__.addDependencyInjectionAssignments(e)}}e("b",$l)}}}));
|
|
9
|
+
//# sourceMappingURL=roomle-dependency-injection-060afa00.nomodule.js.map
|