illutions 0.31.0 → 0.32.0

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/dist/main.min.cjs CHANGED
@@ -5,4 +5,4 @@
5
5
  * Commercial use is permitted only under the illutions License Agreement. Unauthorized copying, modification, distribution, resale, sublicensing, reverse engineering, deobfuscation, or bypassing of license mechanisms is prohibited.
6
6
  * The illutions menu bar, branding, attribution, and license validation must not be removed, hidden, disabled, altered, or obscured without prior written permission.
7
7
  */
8
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let three=require("three"),gsap=require("gsap"),xstate=require("xstate");var THREE={ACESFilmicToneMapping:three.ACESFilmicToneMapping,AgXToneMapping:three.AgXToneMapping,AmbientLight:three.AmbientLight,AdditiveAnimationBlendMode:three.AdditiveAnimationBlendMode,AnimationAction:three.AnimationAction,AnimationClip:three.AnimationClip,AnimationMixer:three.AnimationMixer,Audio:three.Audio,AudioContext:three.AudioContext,AudioListener:three.AudioListener,AudioLoader:three.AudioLoader,BasicShadowMap:three.BasicShadowMap,Box3:three.Box3,BoxGeometry:three.BoxGeometry,Camera:three.Camera,CatmullRomCurve3:three.CatmullRomCurve3,CineonToneMapping:three.CineonToneMapping,Color:three.Color,CustomToneMapping:three.CustomToneMapping,DataTexture:three.DataTexture,DirectionalLight:three.DirectionalLight,EquirectangularReflectionMapping:three.EquirectangularReflectionMapping,Euler:three.Euler,FloatType:three.FloatType,Fog:three.Fog,Group:three.Group,HalfFloatType:three.HalfFloatType,HemisphereLight:three.HemisphereLight,KeyframeTrack:three.KeyframeTrack,Light:three.Light,LinearSRGBColorSpace:three.LinearSRGBColorSpace,LinearToneMapping:three.LinearToneMapping,NormalAnimationBlendMode:three.NormalAnimationBlendMode,LoopOnce:three.LoopOnce,LoopRepeat:three.LoopRepeat,MathUtils:three.MathUtils,Matrix4:three.Matrix4,Mesh:three.Mesh,MeshBasicMaterial:three.MeshBasicMaterial,MeshPhysicalMaterial:three.MeshPhysicalMaterial,MeshStandardMaterial:three.MeshStandardMaterial,MOUSE:three.MOUSE,NeutralToneMapping:three.NeutralToneMapping,NoColorSpace:three.NoColorSpace,NoToneMapping:three.NoToneMapping,Object3D:three.Object3D,OrthographicCamera:three.OrthographicCamera,PCFShadowMap:three.PCFShadowMap,PMREMGenerator:three.PMREMGenerator,PerspectiveCamera:three.PerspectiveCamera,PointLight:three.PointLight,PositionalAudio:three.PositionalAudio,Quaternion:three.Quaternion,Raycaster:three.Raycaster,ReinhardToneMapping:three.ReinhardToneMapping,RenderTarget:three.RenderTarget,Scene:three.Scene,SpotLight:three.SpotLight,Sphere:three.Sphere,SRGBColorSpace:three.SRGBColorSpace,Texture:three.Texture,TextureLoader:three.TextureLoader,TOUCH:three.TOUCH,UnsignedByteType:three.UnsignedByteType,Vector2:three.Vector2,Vector3:three.Vector3,VSMShadowMap:three.VSMShadowMap,WebGLRenderer:three.WebGLRenderer,WebGLRenderTarget:three.WebGLRenderTarget},EventDispatcher=class{listeners=new Map;addEventListener(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const s=this.listeners.get(e);s&&(s.delete(t),0===s.size&&this.listeners.delete(e))}emit(e){const t=this.listeners.get(e.type);if(t)for(const s of[...t])s(e)}listenerCount(e){return this.listeners.get(e)?.size??0}},Obj3D=class{canvas;cfg;events;name;obj=null;objs3D=null;raycast;hidden=!1;renderer;scene;eventDispatcher=new EventDispatcher;posNdc=new THREE.Vector3;posScreen=new THREE.Vector2;posScreenLast=null;posWorld=new THREE.Vector3;posWorldLast=null;posCamWorld=new THREE.Vector3;posWorldOccl=null;posCamWorldOccl=null;quatWorld=new THREE.Quaternion;quatWorldLast=null;rotWorld=new THREE.Euler;visible=!1;inFrustum=!1;inFrustumLast=null;visibleLast=null;occluded=!1;objHidden=null;visibleBeforeHidden=!0;constructor(e,t,s,i={}){this.canvas=e,this.cfg=t,this.name=s,void 0!==i.hidden&&(this.hidden=i.hidden)}addEventListener(e,t){const s=this.eventDispatcher.addEventListener(e,t);return()=>{s(),0===this.eventDispatcher.listenerCount(e)&&this.resetEventState(e)}}calcFrustumVisibility(){this.inFrustum=this.posNdc.x>=-1&&this.posNdc.x<=1&&this.posNdc.y>=-1&&this.posNdc.y<=1&&this.posNdc.z>=-1&&this.posNdc.z<=1;const e=this.inFrustum!==this.inFrustumLast;return e&&(this.inFrustumLast=this.inFrustum),e}calcPosScreen(e){this.posNdc.copy(this.posWorld).project(e.obj);const t=this.canvas.getBoundingClientRect();this.posScreen.set((.5*this.posNdc.x+.5)*t.width,(.5*-this.posNdc.y+.5)*t.height);const s=null===this.posScreenLast||!this.posScreen.equals(this.posScreenLast);return s&&(null===this.posScreenLast?this.posScreenLast=this.posScreen.clone():this.posScreenLast.copy(this.posScreen)),s}calcPosWorld(e){e.getWorldPosition(this.posWorld);const t=null===this.posWorldLast||!this.posWorld.equals(this.posWorldLast);return t&&(null===this.posWorldLast?this.posWorldLast=this.posWorld.clone():this.posWorldLast.copy(this.posWorld)),t}calcPosOccl(e){e.obj.getWorldPosition(this.posCamWorld);const t=this.posCamWorld.distanceTo(this.posWorld)*Math.max(0,this.cfg.raycast.occlusionMoveFactor),s=t*t,i=null===this.posWorldOccl||this.posWorldOccl.distanceToSquared(this.posWorld)>s,n=null===this.posCamWorldOccl||this.posCamWorldOccl.distanceToSquared(this.posCamWorld)>s;return i&&(null===this.posWorldOccl?this.posWorldOccl=this.posWorld.clone():this.posWorldOccl.copy(this.posWorld)),n&&(null===this.posCamWorldOccl?this.posCamWorldOccl=this.posCamWorld.clone():this.posCamWorldOccl.copy(this.posCamWorld)),{posWorldOcclChanged:i,posCamWorldOcclChanged:n}}calcRotWorld(e){return e.getWorldQuaternion(this.quatWorld),(null===this.quatWorldLast||!this.quatWorld.equals(this.quatWorldLast))&&(null===this.quatWorldLast?this.quatWorldLast=this.quatWorld.clone():this.quatWorldLast.copy(this.quatWorld),this.rotWorld.setFromQuaternion(this.quatWorld),!0)}calcVisibility(e,t){if(this.inFrustum)t&&this.raycast.trackOccludee(e),this.occluded=!this.raycast.getOccludeeVisible(e);else{this.occluded=!1;const t=this.raycast.getOccludeeState(e);t.needsCheck=!1,t.visible=!1}this.visible=!this.hidden&&e.visible&&this.inFrustum&&!this.occluded,this.visible!==this.visibleLast&&(this.visibleLast=this.visible,this.emitEvent({type:"Obj3D_Visible_Changed",visible:this.visible}))}emitEvent(e){this.events.send(e,this.name),this.eventDispatcher.emit(e)}getScreenPos(e){if(!this.obj)return null;this.obj.getWorldPosition(this.posWorld),this.posNdc.copy(this.posWorld).project(e.obj);const t=this.canvas.getBoundingClientRect();return{x:(.5*this.posNdc.x+.5)*t.width,y:(.5*-this.posNdc.y+.5)*t.height}}hasEventListener(e){return this.eventDispatcher.listenerCount(e)>0}onReady(){}onStart(){}onTraverse(e){this.obj=e}applyHidden(){this.obj&&(null!==this.objHidden&&this.objHidden!==this.obj&&(this.objHidden.visible=this.visibleBeforeHidden,this.objHidden=null),this.hidden?(null===this.objHidden&&(this.objHidden=this.obj,this.visibleBeforeHidden=this.obj.visible),this.obj.visible=!1):this.objHidden===this.obj&&(this.obj.visible=this.visibleBeforeHidden,this.objHidden=null),this.visible=!this.hidden&&this.obj.visible)}onUpdate(e){}ready(e){this.objs3D=e,this.onReady()}removeEventListener(e,t){this.eventDispatcher.removeEventListener(e,t),0===this.eventDispatcher.listenerCount(e)&&this.resetEventState(e)}resetEventState(e){"Obj3D_Pos_World_Changed"===e&&(this.posWorldLast=null,this.posWorldOccl=null),"Obj3D_Pos_Screen_Changed"===e&&(this.posScreenLast=null),"Obj3D_Rot_World_Changed"===e&&(this.quatWorldLast=null),"Obj3D_Frustum_Changed"===e&&(this.inFrustumLast=null),"Obj3D_Visible_Changed"===e&&(this.visibleLast=null,this.posWorldOccl=null,this.posCamWorldOccl=null,this.obj&&this.raycast.untrackOccludee(this.obj))}start(e,t){this.renderer=e,this.scene=t,this.onStart(),this.applyHidden()}traverse(e){this.onTraverse(e),this.applyHidden()}update(e,t){if(!this.obj)return;this.onUpdate(e);const s=this.hasEventListener("Obj3D_Pos_World_Changed"),i=this.hasEventListener("Obj3D_Pos_Screen_Changed"),n=this.hasEventListener("Obj3D_Rot_World_Changed"),o=this.hasEventListener("Obj3D_Frustum_Changed"),a=this.hasEventListener("Obj3D_Visible_Changed");if(n&&this.calcRotWorld(this.obj)&&this.eventDispatcher.emit({type:"Obj3D_Rot_World_Changed",rotWorld:this.rotWorld.clone()}),!(s||i||o||a))return;const r=this.calcPosWorld(this.obj);if(s&&r&&this.eventDispatcher.emit({type:"Obj3D_Pos_World_Changed",posWorld:this.posWorld.clone()}),!(i||o||a))return;const l=this.calcPosScreen(t);if(i&&l&&this.eventDispatcher.emit({type:"Obj3D_Pos_Screen_Changed",posScreen:this.posScreen.clone()}),!o&&!a)return;const d=this.calcFrustumVisibility();if(o&&d&&this.emitEvent({type:"Obj3D_Frustum_Changed",visibleFrustum:this.inFrustum}),!a)return;const{posWorldOcclChanged:c,posCamWorldOcclChanged:h}=this.calcPosOccl(t);this.calcVisibility(this.obj,c||d||h)}},Web=class extends HTMLElement{canvas;cfg;events;objs3D;webs=null;obj3DFollow=null;visible=null;visibleFollow=!1;visibleOverlap=!0;webCtrls=null;unSubFollow=void 0;unSubVisible=void 0;clearFollow(){this.obj3DFollow=null,this.visibleFollow=!1,this.unSubFollow&&(this.unSubFollow(),this.unSubFollow=void 0),this.unSubVisible&&(this.unSubVisible(),this.unSubVisible=void 0)}emitEvent(e){this.events.send(e,this.constructor.name)}follow({obj:e}){const t=this.follow.name;if(!e)return void console.warn(`${t}: Missing parameter object`);const s=e instanceof Obj3D?e:this.objs3D.get(e);s?s.obj?s!==this.obj3DFollow&&(this.clearFollow(),this.obj3DFollow=s,this.unSubFollow=s.addEventListener("Obj3D_Pos_Screen_Changed",e=>{const{x:t,y:s}=e.posScreen;this.style.left=`${t}px`,this.style.top=`${s}px`}),this.unSubVisible=s.addEventListener("Obj3D_Visible_Changed",e=>{this.visibleFollow=e.visible,this.updateVisibility()}),this.webCtrls?.refreshOverlap(this)):console.warn(`${t}: Obj3D "${e}" has no THREE.Object3D assigned.`):console.warn(`${t}: Obj3D "${e}" is not registered.`)}getObj3DFollow(){return this.obj3DFollow}isVisibleFollow(){return this.visibleFollow}onVisibilityChanged(e){this.style.display=e?"block":"none"}onReady(){}onStart(){}ready(e){this.objs3D=e,this.onReady()}setVisibleOverlap(e){e!==this.visibleOverlap&&(this.visibleOverlap=e,this.emitEvent({type:"Web_Overlap_Changed",web:this,overlapped:!e}),this.updateVisibility())}start(e,t){this.webs=e,this.webCtrls=t,this.onStart()}trackOverlap(){this.webCtrls?.trackOverlap(this)}unfollow(){this.clearFollow(),this.updateVisibility(),this.webCtrls?.refreshOverlap(this)}untrackOverlap(){this.webCtrls?.untrackOverlap(this)}updateVisibility(){const e=this.visibleFollow&&this.visibleOverlap;e!==this.visible&&(this.visible=e,this.onVisibilityChanged(e),this.emitEvent({type:"Web_Visible_Changed",web:this,visible:e}))}},Cam3D=class extends Obj3D{lookMode="target";obj;objGltf=null;objTarget;targetGltf=null;tmpVec=new THREE.Vector3;constructor(e,t,s,i={}){super(e,t,s,i),this.canvas=e;const n=e.getBoundingClientRect();"perspective"===t.cam.type?this.obj=new THREE.PerspectiveCamera(t.cam.perspective.fov,n.width/n.height,t.cam.near,t.cam.far):this.obj=new THREE.OrthographicCamera(t.cam.orthographic.left,t.cam.orthographic.right,t.cam.orthographic.top,t.cam.orthographic.bottom,t.cam.near,t.cam.far),this.objTarget=new THREE.Object3D,this.objTarget.position.copy(t.cam.lookAt),this.obj.position.copy(t.cam.position),this.obj.lookAt(this.objTarget.position)}onTraverse(e){const t=new THREE.Vector3,s=new THREE.Quaternion,i=new THREE.Vector3;e.updateMatrixWorld(!0),e.matrixWorld.decompose(t,s,i),this.obj.copy(e),this.obj.position.copy(t),this.obj.quaternion.copy(s),this.obj.scale.copy(i),this.obj instanceof THREE.PerspectiveCamera&&e instanceof THREE.PerspectiveCamera&&this.obj.updateProjectionMatrix(),this.obj.updateMatrixWorld(!0),this.objGltf=e}traverse(e){if(this.obj instanceof THREE.PerspectiveCamera&&e instanceof THREE.PerspectiveCamera||this.obj instanceof THREE.OrthographicCamera&&e instanceof THREE.OrthographicCamera){this.onTraverse(e),this.applyHidden();let t=this.canvas.getBoundingClientRect();this.updateCanvasResize(t)}else console.warn("Camera type mismatch between cfg and .gltf model.")}update(e,t){if(this.onUpdate(e),"target"===this.lookMode)this.obj.lookAt(this.objTarget.position);else{let e=this.obj.position.distanceTo(this.objTarget.position);this.objTarget.position.copy(this.obj.position).add(this.tmpVec.set(0,0,-e).applyQuaternion(this.obj.quaternion))}this.obj.updateMatrixWorld(!0),this.hasEventListener("Obj3D_Pos_World_Changed")&&this.calcPosWorld(this.obj)&&this.eventDispatcher.emit({type:"Obj3D_Pos_World_Changed",posWorld:this.obj.getWorldPosition(this.tmpVec).clone()})}updateCanvasResize(e){const t=e.width/e.height;if(this.obj instanceof THREE.PerspectiveCamera)this.obj.aspect=t,this.obj.updateProjectionMatrix();else if(this.obj instanceof THREE.OrthographicCamera){const e=this.obj.top-this.obj.bottom,s=e*t/2,i=e/2;this.obj.left=-s,this.obj.right=s,this.obj.top=i,this.obj.bottom=-i,this.obj.updateProjectionMatrix()}}},Light3D=class extends Obj3D{obj;constructor(e,t,s,i={}){super(e,t,s,i),this.obj=new THREE.PointLight}onTraverse(e){this.obj=e}traverse(e){this.onTraverse(e),this.applyHidden()}},Mesh3D=class extends Obj3D{obj;groundReflector=null;reflectivesSSR=[];model=null;constructor(e,t,s,i={}){super(e,t,s,i),this.obj=new THREE.Mesh(new THREE.BoxGeometry,new THREE.MeshPhysicalMaterial)}animMaterialColor(e){this.scene.animMaterialColor({...e,mesh:this})}animMaterialNumeric({needsUpdate:e=!1,...t}){this.scene.animMaterialNumeric({...t,mesh:this,needsUpdate:e})}getImageTexture(e){if(!this.model)throw new Error(`Image texture "${e}" could not be accessed because no model is available.`);return this.model.getTextureFromImageUnused(e)}onTraverse(e){this.obj=e}requestImageTexture(e){if(!this.model)throw new Error(`Image texture "${e}" could not be requested because no model is available.`);this.model.addImageUnusedName(e)}setMaterialProps({recursive:e=!1,needsUpdate:t=!1,...s}){this.scene.setMaterialProps({...s,obj:this,recursive:e,needsUpdate:t})}setModel(e){this.model=e}setReflectivesSSR(e){this.reflectivesSSR=e}traverse(e){this.onTraverse(e),this.applyHidden()}},Coll3D=class extends Mesh3D{target=null;pickable=!1;occluder=!1;targetName;constructor(e,t,s,i={}){super(e,t,s,i),this.targetName=i.target??null,void 0!==i.pickable&&(this.pickable=i.pickable),void 0!==i.occluder&&(this.occluder=i.occluder)}resolveTarget(e){if(null===this.targetName)return;const t=e.get(this.targetName);t instanceof Mesh3D?this.target=t:console.warn(`Coll3D "${this.name}": Target "${this.targetName}" is not a registered Mesh3D.`)}},Audio=class{ctx=THREE.AudioContext.getContext();loader=new THREE.AudioLoader;scene;events;loadedSounds=[];params;listener=null;constructor(e,t,s){this.events=s,this.params={...e},this.scene=t}attachSoundTo(e,t){if(!e)return void console.warn("No name assigned.");if(!t)return void console.warn("No object to attach provided.");const s=this.scene.obj.getObjectByName(t);if(!s)return void console.warn(`Object "${t}" not found in scene.`);const i=this.loadedSounds.find(t=>t.name===e);i?s.add(i.audio):console.warn(`Sound "${e}" not found.`)}get(){return{delayPlaySound:this.params.delayPlaySound,refDistance:this.params.refDistance,rolloffFactor:this.params.rolloffFactor,maxDistance:this.params.maxDistance,distanceModel:this.params.distanceModel,coneInnerAngle:this.params.coneInnerAngle,coneOuterAngle:this.params.coneOuterAngle,coneOuterGain:this.params.coneOuterGain}}isLoaded({name:e}){return!!this.loadedSounds.find(t=>t.name===e)}isPlaying({name:e}){let t=this.isPlaying.name;if("running"!==this.ctx.state)return console.warn(`${t}: ctx.state is not running.`),!1;const s=this.loadedSounds.find(t=>t.name===e);return s?s.audio.isPlaying:(console.warn(`${t}: Sound not found.`),!1)}loadSound({name:e,url:t,object:s,volume:i,fade:n,loop:o},a=!1){if(!this.listener)return void console.warn(`${this.load.name}: No audio listener set.`);if(this.loadedSounds.some(t=>t.name===e))return void console.warn(`${this.load.name}: Sound with name '${e}' is already loaded.`);const r=s?new THREE.PositionalAudio(this.listener):new THREE.Audio(this.listener);this.loader.load(t,t=>{r.setBuffer(t),r.setLoop(o),r.setVolume(0),r instanceof THREE.PositionalAudio&&this.setPositionalSoundCfg(r),this.loadedSounds.push({name:e,audio:r,volume:i,fade:n,loop:o}),s&&this.attachSoundTo(e,s),this.events.audioLoaded({type:"Audio_Loaded",soundName:e}),a&&this.play({name:e})},void 0,e=>{throw new Error(`Audio loading error for ${t}: ${e}`)})}load({name:e,url:t,object:s,volume:i=0,fade:n=2,loop:o=!0}){this.loadSound({name:e,url:t,object:s,volume:i,fade:n,loop:o})}loadAndPlay({name:e,url:t,object:s,volume:i=0,fade:n=2,loop:o=!0}){let a=this.loadAndPlay.name;if(!this.listener)return void console.warn(`${a}: No audio listener set.`);const r=()=>{this.loadSound({name:e,url:t,object:s,volume:i,fade:n,loop:o},!0)};"suspended"===this.ctx.state||"running"===this.ctx.state?this.ctx.resume().then(()=>{setTimeout(()=>{r()},this.params.delayPlaySound)}).catch(e=>{throw new Error(`Audio API resume error: ${e}`)}):r()}play({name:e}){let t=this.play.name;if("suspended"===this.ctx.state)return void this.ctx.resume().then(()=>this.play({name:e})).catch(e=>{throw new Error(`Audio API resume error: ${e}`)});if("running"!==this.ctx.state)return void console.warn(`${t}: AudioContext is not running.`);const s=this.loadedSounds.find(t=>t.name===e);if(!s)return void console.warn(`${t}: Sound with name '${e}' is not loaded.`);if(s.audio.isPlaying)return;s.audio.play();const i={value:0};gsap.gsap.to(i,{duration:s.fade,value:s.volume,ease:"power1.in",onUpdate:()=>{s.audio.setVolume(i.value)}})}resume(){"suspended"===this.ctx.state&&this.ctx.resume().catch(e=>{throw new Error(`Audio API resume error: ${e}`)})}setAttribute({name:e,attribute:t,duration:s,value:i}){if("running"!==this.ctx.state)return void console.warn("AudioContext is not running.");const n=this.loadedSounds.find(t=>t.name===e);n?gsap.gsap.to(n.audio,{duration:s,[t]:i,ease:"power1.inOut"}):console.warn(`Sound '${e}' not found.`)}setAudioContext({state:e}){if(!this.ctx)return void console.warn("AudioContext does not exist.");const t=this.ctx.state;if(this.ctx.state!==e)switch(e){case"running":"suspended"===t&&this.ctx.resume().catch(e=>{throw new Error(`Error resuming context: ${e}`)});break;case"suspended":"running"===t&&this.ctx.suspend().catch(e=>{throw new Error(`Error suspending context: ${e}`)});break;case"closed":"closed"!==t&&this.ctx.close().catch(e=>{throw new Error(`Error closing context: ${e}`)});break;default:throw new Error(`Unknown AudioContext state: ${e}`)}}setListener({object:e}){const t="string"==typeof e?this.scene.obj.getObjectByName(e):e.obj;if(!t)return void console.warn(`${this.setListener.name}: Listener object not found.`);const s=new THREE.AudioListener;t.add(s),this.listener=s}setAllPositionalSoundsCfg(){for(const e of this.loadedSounds)e.audio instanceof THREE.PositionalAudio&&this.setPositionalSoundCfg(e.audio)}setPositionalSoundCfg(e){e.setRefDistance(this.params.refDistance),e.setRolloffFactor(this.params.rolloffFactor),e.setMaxDistance(this.params.maxDistance),e.setDistanceModel(this.params.distanceModel),e.setDirectionalCone(this.params.coneInnerAngle,this.params.coneOuterAngle,this.params.coneOuterGain)}set(e){let t=!1;void 0!==e.delayPlaySound&&(this.params.delayPlaySound=e.delayPlaySound),void 0!==e.refDistance&&(this.params.refDistance=e.refDistance,t=!0),void 0!==e.rolloffFactor&&(this.params.rolloffFactor=e.rolloffFactor,t=!0),void 0!==e.maxDistance&&(this.params.maxDistance=e.maxDistance,t=!0),void 0!==e.distanceModel&&(this.params.distanceModel=e.distanceModel,t=!0),void 0!==e.coneInnerAngle&&(this.params.coneInnerAngle=e.coneInnerAngle,t=!0),void 0!==e.coneOuterAngle&&(this.params.coneOuterAngle=e.coneOuterAngle,t=!0),void 0!==e.coneOuterGain&&(this.params.coneOuterGain=e.coneOuterGain,t=!0),t&&this.setAllPositionalSoundsCfg()}stop({name:e}){let t=this.stop.name;if("running"!==this.ctx.state)return void console.warn(`${t}: AudioContext is not running.`);const s=this.loadedSounds.find(t=>t.name===e);if(!s)return void console.warn(`${t}: Sound '${e}' not found.`);const i={value:s.audio.getVolume()};gsap.gsap.to(i,{duration:s.fade,value:0,ease:"power1.inOut",onUpdate:()=>{s.audio.setVolume(i.value)},onComplete:()=>{s.audio.stop()}})}use(e){e(this)}},infobox_default=":host {\r\n z-index: 999;\r\n position: absolute;\r\n left: 8px; top: 8px;\r\n font-family: monospace;\r\n font-size: 12px;\r\n color: #ffffff;\r\n pointer-events: none;\r\n}\r\n\r\n#infobox {\r\n padding: 8px;\r\n border-radius: 8px;\r\n background: hsla(230, 25%, 16%, 1.00);\r\n box-sizing: border-box;\r\n}\r\n\r\n.row {\r\n display: flex;\r\n justify-content: space-between;\r\n gap: 1em;\r\n line-height: 1.45;\r\n white-space: nowrap;\r\n}\r\n\r\n.label {\r\n opacity: 0.75;\r\n}\r\n\r\n.value {\r\n text-align: right;\r\n}\r\n\r\n.separator {\r\n height: 1px;\r\n margin: 5px 0;\r\n background: rgba(255, 255, 255, 0.18);\r\n}",InfoBox=class extends HTMLElement{cfg;rendererApi="WebGL";values=new Map;timeBegin=0;timeLastFrame=0;timeFrameMs=0;timeCpuMs=0;fps=0;timeLastUpdate=0;updateInterval=100;constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=infobox_default;const s=document.createElement("div");s.id="infobox",this.addRow(s,"Api","api"),this.addSeparator(s),this.addRow(s,"Fps","fps"),this.addRow(s,"Cpu","cpu"),this.addRow(s,"Frame","frame"),this.addSeparator(s),this.addRow(s,"Calls","calls"),this.addRow(s,"Triangles","triangles"),this.addRow(s,"Lines","lines"),this.addRow(s,"Points","points"),this.addSeparator(s),this.addRow(s,"Geometries","geometries"),this.addRow(s,"Textures","textures"),this.addRow(s,"Programs","programs"),e.append(t,s)}applyCfg(){this.setValue("api",this.rendererApi);const e=this.cfg?.gui.infoBox;e&&(this.setVisible("fps",e.fps),this.setVisible("cpu",e.cpu),this.setVisible("frame",e.frame),this.setVisible("calls",e.calls),this.setVisible("triangles",e.triangles),this.setVisible("lines",e.lines),this.setVisible("points",e.points),this.setVisible("geometries",e.geometries),this.setVisible("textures",e.textures),this.setVisible("programs",e.programs),this.updateInterval=1e3/Math.max(1,e.logsPerSecond))}begin(e){this.timeLastFrame>0&&(this.timeFrameMs=e-this.timeLastFrame,this.timeFrameMs>0&&(this.fps=1e3/this.timeFrameMs)),this.timeLastFrame=e,this.timeBegin=e}end(e,t){if(this.timeCpuMs=e-this.timeBegin,e-this.timeLastUpdate<this.updateInterval)return;this.timeLastUpdate=e;const s=t.info,i=Array.isArray(s.programs)?s.programs.length:s.memory.programs??0;this.setValue("fps",this.fps.toFixed(0)),this.setValue("cpu",`${this.timeCpuMs.toFixed(2)} ms`),this.setValue("frame",`${this.timeFrameMs.toFixed(2)} ms`),this.setValue("calls",String(s.render.drawCalls??s.render.calls??0)),this.setValue("triangles",this.formatNumber(s.render.triangles??0)),this.setValue("lines",this.formatNumber(s.render.lines??0)),this.setValue("points",this.formatNumber(s.render.points??0)),this.setValue("geometries",String(s.memory.geometries??0)),this.setValue("textures",String(s.memory.textures??0)),this.setValue("programs",String(i))}setUpdateInterval(e){this.updateInterval=Math.max(0,e)}addRow(e,t,s){const i=document.createElement("div");i.className="row";const n=document.createElement("span");n.className="label",n.textContent=t;const o=document.createElement("span");o.className="value",o.textContent="-",i.append(n,o),e.appendChild(i),this.values.set(s,o)}addSeparator(e){const t=document.createElement("div");t.className="separator",e.appendChild(t)}setValue(e,t){const s=this.values.get(e);s&&(s.textContent=t)}setVisible(e,t){const s=this.values.get(e);s?.parentElement&&(s.parentElement.style.display=t?"":"none")}formatNumber(e){return Math.round(e).toLocaleString("de-DE")}};function loadInfoBox(e,t){const s="ilu-infobox";customElements.get(s)||customElements.define(s,InfoBox);const i=document.createElement(s);return i.cfg=e,i.rendererApi=t,i.applyCfg(),document.body.appendChild(i),i}var Engine=class{cam3D;cfg;events;modules;objs3D;scene;infoBox=null;callbacks=[];resolveWaitForRender=null;rendererReady=null;canvas;composer=null;renderer;renderPipeline=null;postProfile={aa:"none",ssl:"none",ssr:!1};postProfileLast=null;fxaaPass=null;outputPass=null;renderPass=null;smaaPass=null;tslPass=null;aaNode=null;rttNode=null;traaWarmupContext=null;ssaoPass=null;gtaoNode=null;ssgiNode=null;ssrPass=null;ssrNode=null;ecoButtonActive=!1;gfxEvents=new EventDispatcher;gfxChanging=!1;gfxIndex=0;gfxLevels=[];gfxMode="off";gfxPostProfiles=[{aa:"none",ssl:"none",ssr:!1}];gfxState="idle";gfxDownOnly=!1;dTs=[];dT=0;timeGsap=0;timeLast=performance.now();timeLastFrame=0;resizeTimeout=null;resizeDelay=100;constructor(e,t,s,i,n,o,a){this.canvas=s,this.cam3D=t,this.cfg=i,this.events=n,this.modules=o,this.objs3D=a,this.scene=e;const r=this.modules.webGpuRendererClass;if(r){const e=this.cfg.render.profile.webgpu;this.postProfile={aa:e.aa,ssl:e.ssl,ssr:e.ssr};const t={...this.cfg.render.params,...this.cfg.render.webgpu.params,antialias:"none"!==e.msaa};if("ssgi"===this.postProfile.ssl&&this.postProfile.ssr){const e=t.requiredLimits||{};t.requiredLimits={...e,maxColorAttachmentBytesPerSample:Math.max(e.maxColorAttachmentBytesPerSample||0,40)}}if(this.renderer=new r(t),this.cfg.light.rectArea){const e=this.modules.rectAreaLightNodeClass,t=this.modules.rectAreaLightTexturesLib;e&&t?e.setLTC(t.init()):console.warn("RectAreaLight WebGPU modules could not be initialized.")}"none"!==this.cfg.debug.log&&console.log("Info: WebGPU Renderer")}else{const e=this.cfg.render.profile.webgl;this.postProfile={aa:e.aa,ssl:e.ssl,ssr:e.ssr};const t={...this.cfg.render.params,...this.cfg.render.webgl.params,antialias:"none"!==e.msaa};this.renderer=new THREE.WebGLRenderer(t),this.cfg.light.rectArea&&(this.modules.rectAreaLightUniformsLib?this.modules.rectAreaLightUniformsLib.init():console.warn("RectAreaLight WebGL module could not be initialized.")),this.rendererReady=Promise.resolve(),"none"!==this.cfg.debug.log&&console.log("Info: "+this.renderer.getContext().getParameter(this.renderer.getContext().VERSION))}let l=this.gfxPostProfiles[0];if("none"!==this.postProfile.aa&&(l={...l,aa:this.postProfile.aa},this.gfxPostProfiles.push(l)),"none"!==this.postProfile.ssl){const e=this.modules.webGpuRendererClass?"gtao":"ssao";l={...l,ssl:e},this.gfxPostProfiles.push(l)}this.postProfile.ssr&&(l={...l,ssr:!0},this.gfxPostProfiles.push(l)),"ssgi"===this.postProfile.ssl&&this.gfxPostProfiles.push({...l,ssl:"ssgi"}),this.gfxLevels=this.getGfxLevels();const d=this.canvas.getBoundingClientRect();this.renderer.setPixelRatio(this.cfg.render.pixelRatio),this.renderer.setSize(d.width,d.height,!1),this.renderer.shadowMap.enabled=this.cfg.render.shadowMapEnabled,this.renderer.shadowMap.type=this.cfg.render.shadowMapType,this.renderer.toneMapping=this.cfg.render.toneMapping,this.renderer.toneMappingExposure=this.cfg.render.toneMappingExposure,this.renderer.outputColorSpace=this.cfg.render.outputColorSpace;const c=this.renderer.domElement;c.style.display="block",c.style.width="100%",c.style.height="100%",c.style.boxSizing="border-box",this.canvas.tabIndex=0;const h={pointerId:null,downX:0,downY:0,moved:!1};this.canvas.addEventListener("pointerdown",e=>{e.isPrimary&&0===e.button&&(h.pointerId=e.pointerId,h.downX=e.clientX,h.downY=e.clientY,h.moved=!1)}),this.canvas.addEventListener("pointermove",e=>{if(e.pointerId!==h.pointerId||h.moved)return;const t=e.clientX-h.downX,s=e.clientY-h.downY;h.moved=Math.hypot(t,s)>5}),this.canvas.addEventListener("pointercancel",e=>{e.pointerId===h.pointerId&&(h.pointerId=null,h.moved=!1)}),this.canvas.addEventListener("click",e=>{this.canvas.focus(),null===h.pointerId||h.moved||this.events.send({type:"Canvas_Click",event:e}),h.pointerId=null,h.moved=!1}),this.canvas.addEventListener("pointerleave",e=>{this.events.send({type:"Canvas_Pointer_Leave",event:e})}),this.canvas.addEventListener("pointerenter",e=>{this.events.send({type:"Canvas_Pointer_Enter",event:e})}),this.canvas.addEventListener("keydown",e=>{this.events.send({type:"Canvas_Key_Down",event:e})}),this.canvas.addEventListener("keyup",e=>{this.events.send({type:"Canvas_Key_Up",event:e})}),this.canvas.prepend(this.renderer.domElement),this.cfg.gui.infoBox.enable&&(loadInfoBox(this.cfg,r?"WebGPU":"WebGL"),this.infoBox=document.querySelector("ilu-infobox"),this.renderer.info.autoReset=!1),this.timeLastFrame=performance.now()/1e3,this.updateCanvasResize(),window.addEventListener("resize",()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{!1===this.cfg.render.autoResize?this.events.windowResize({type:"Window_Resize"}):this.updateCanvasResize()},this.resizeDelay)}),gsap.gsap.ticker.remove(gsap.gsap.updateRoot),gsap.gsap.ticker.lagSmoothing(0)}async init(){this.renderer instanceof THREE.WebGLRenderer&&!this.renderer.extensions.has("KHR_parallel_shader_compile")?this.renderer.compile(this.scene.obj,this.cam3D.obj):await this.renderer.compileAsync(this.scene.obj,this.cam3D.obj);const e=this.isPostCfg();this.cfg.render.adaptiveGfx&&(this.gfxIndex=0,this.postProfile={...this.gfxPostProfiles[0]},this.scene.groundReflector&&(this.scene.groundReflector.visible=!1)),e&&(this.modules.webGpuRendererClass?(this.setPostWebGpu(this.postProfile),this.cfg.render.adaptiveGfx||this.renderPipeline?.render()):(this.setPostWebGl(this.postProfile),this.composer?.render())),!this.cfg.render.adaptiveGfx&&e||this.renderer.render(this.scene.obj,this.cam3D.obj),!this.cfg.render.adaptiveGfx&&this.cfg.render.ecoMode&&(this.gfxMode="eco"),this.resolveWaitForRender&&(this.resolveWaitForRender(),this.resolveWaitForRender=null)}async initRenderer(){if(null===this.rendererReady){const e=this.modules.webGpuRendererClass;e&&this.renderer instanceof e&&(this.rendererReady=this.renderer.init())}await this.rendererReady}addOnFrameUpdate(e){this.callbacks.push(e)}async enableAaMode(e){if(this.modules.webGpuRendererClass)"fxaa"===e?await this.modules.importFXAANode(e):"smaa"===e?await this.modules.importSMAANode(e):"traa"===e&&(await this.modules.importTRAANode(e),await this.modules.importSsgiNode(this.postProfile.ssl,e)),this.postProfile.aa=e,this.setPostWebGpu(this.postProfile);else{if("traa"===e)return;await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.fxaaPass||"fxaa"!==e?this.smaaPass||"smaa"!==e||await this.modules.importSMAAPass(e):await this.modules.importFXAAShader(e),this.postProfile.aa=e,this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.aa=e)}}async enableSslMode(e){if(this.modules.webGpuRendererClass){if("ssao"===e)return;"gtao"===e?await this.modules.importGtaoNode(!0):"ssgi"===e&&"traa"===this.postProfile.aa&&await this.modules.importSsgiNode(e,this.postProfile.aa),this.postProfile.ssl=e,this.setPostWebGpu(this.postProfile)}else{if("gtao"===e||"ssgi"===e)return;await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.postProfile.ssl=e,await this.modules.importSSAOPass("ssao"===e),this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.ssl=e)}}async enableSsr(e){this.modules.webGpuRendererClass?(await this.modules.importSsrNode(e),this.postProfile.ssr=e,this.setPostWebGpu(this.postProfile)):(await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.postProfile.ssr=e,e&&!this.ssrPass?await this.modules.importSsrPass(e):!e&&this.scene.groundReflector&&(this.scene.groundReflector.visible=!1),this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.ssr=e))}getGfxLevels(){return this.gfxPostProfiles.map((e,t)=>t)}isPostCfg(){return"none"!==this.postProfile.ssl||this.postProfile.ssr||"none"!==this.postProfile.aa}removeOnFrameUpdate(e){this.callbacks=this.callbacks.filter(t=>t!==e)}setAnimationLoop(){this.renderer.setAnimationLoop(e=>this.update(e))}setEcoButtonActive(e){this.ecoButtonActive=e,this.cfg.render.adaptiveGfx&&(e?"complete"===this.gfxState?this.gfxMode="eco":this.updateGfx("complete"):(this.dTs.length=0,this.gfxMode="complete"===this.gfxState&&this.gfxIndex>0?"graphics":"off"))}async setGfxLevel(e){this.gfxChanging=!0,this.gfxMode="off";try{const t=this.gfxPostProfiles[e];if(!t)return;this.postProfile={...t},this.modules.webGpuRendererClass?(await this.modules.importGtaoNode("gtao"===t.ssl),await this.modules.importSsgiNode(t.ssl,t.aa),await this.modules.importSsrNode(t.ssr),this.setPostWebGpu(this.postProfile)):(await this.modules.importSSAOPass("ssao"===t.ssl),await this.modules.importSsrPass(t.ssr),this.setPostWebGl(this.postProfile),e>0&&this.composer?.render()),this.gfxIndex=e,this.gfxEvents.emit({type:"Gfx_Changed",gfxLevel:this.gfxLevels[this.gfxIndex]})}catch(e){console.error("Graphics level could not be applied.",e),this.updateGfx("complete")}finally{this.gfxChanging=!1}}setPostAaParams(){if(this.modules.webGpuRendererClass||!this.fxaaPass)return;const e=this.renderer.getSize(new THREE.Vector2),t=this.renderer.getPixelRatio(),s=this.cfg.post.webgl.aa.fxaa.sharpness,i=this.fxaaPass.material.uniforms;i.resolution.value.x=s/(e.x*t),i.resolution.value.y=s/(e.y*t)}setPostSslParams(){if(this.modules.webGpuRendererClass){if(this.gtaoNode){const e=this.cfg.post.webgpu.gtao;this.gtaoNode.radius.value=e.radius,this.gtaoNode.thickness.value=e.thickness,this.gtaoNode.scale.value=e.scale,this.gtaoNode.samples.value=Math.round(e.samples),this.gtaoNode.resolutionScale=e.resolutionScale,this.gtaoNode.useTemporalFiltering="traa"===this.postProfile.aa}if(this.ssgiNode){const e=this.cfg.post.webgpu.ssgi;this.ssgiNode.sliceCount.value=Math.round(e.sliceCount),this.ssgiNode.stepCount.value=Math.round(e.stepCount),this.ssgiNode.aoIntensity.value=e.aoIntensity,this.ssgiNode.giIntensity.value=e.giIntensity,this.ssgiNode.radius.value=e.radius,this.ssgiNode.useScreenSpaceSampling.value=e.useScreenSpaceSampling,this.ssgiNode.expFactor.value=e.expFactor,this.ssgiNode.thickness.value=e.thickness,this.ssgiNode.useLinearThickness.value=e.useLinearThickness,this.ssgiNode.backfaceLighting.value=e.backfaceLighting,this.ssgiNode.useTemporalFiltering=!0}}else if(this.ssaoPass){const e=this.cfg.post.webgl.ssao;this.ssaoPass.kernelRadius=e.kernelRadius,this.ssaoPass.minDistance=e.minDistance,this.ssaoPass.maxDistance=e.maxDistance}}setPostSsrParams(){const e=this.cfg.post.ssr;if(this.modules.webGpuRendererClass){if(!this.ssrNode)return;const t=this.cfg.post.webgpu.ssr;this.ssrNode.quality.value=t.quality,this.ssrNode.blurQuality=Math.round(t.blurQuality),this.ssrNode.maxDistance.value=e.maxDistance,this.ssrNode.intensity.value=t.intensity,this.ssrNode.thickness.value=e.thickness,this.ssrNode.resolutionScale=e.resolutionScale}else{const t=this.cfg.post.webgl.ssr;this.ssrPass&&(this.ssrPass.clear=t.clear,this.ssrPass.selective=t.selective,this.ssrPass.fresnel=t.fresnel,this.ssrPass.distanceAttenuation=t.distanceAttenuation,this.ssrPass.infiniteThick=t.infiniteThick,this.ssrPass.maxDistance=e.maxDistance,this.ssrPass.opacity=t.opacity,this.ssrPass.thickness=e.thickness,this.ssrPass.resolutionScale=e.resolutionScale,this.ssrPass.blur=t.blur,this.ssrPass.output=t.output,this.ssrPass.bouncing=t.bouncing),this.scene.groundReflector&&(this.scene.groundReflector.fresnel=t.fresnel,this.scene.groundReflector.distanceAttenuation=t.distanceAttenuation,this.scene.groundReflector.maxDistance=e.maxDistance,this.scene.groundReflector.opacity=t.opacity)}}setPostWebGl(e){if(!(this.renderer instanceof THREE.WebGLRenderer))return;const t=this.canvas.getBoundingClientRect();if(!this.composer){const e=this.modules.effectComposerClass;if(e)if("post"===this.cfg.render.profile.webgl.msaa){const s=this.renderer.getContext(),i=s.getParameter(s.SAMPLES),n="number"==typeof i?i:0,o=new THREE.WebGLRenderTarget(1,1,{type:THREE.HalfFloatType,samples:n});this.composer=new e(this.renderer,o),this.composer.setSize(t.width,t.height)}else this.composer=new e(this.renderer);else console.warn("EffectComposer could not be started.")}if(this.composer){if(this.composer.passes.length=0,!this.renderPass){const e=this.modules.renderPassClass;e?this.renderPass=new e(this.scene.obj,this.cam3D.obj):console.warn("Module Three.js RenderPass could not be imported.")}if(this.renderPass&&this.composer.addPass(this.renderPass),e.ssr){if(!this.ssrPass)if(this.modules.ssrPassClass){this.scene.groundReflector&&!this.scene.groundReflector.parent&&this.scene.obj.add(this.scene.groundReflector);const e=this.cfg.post.webgl.ssr;this.ssrPass=new this.modules.ssrPassClass({renderer:this.renderer,scene:this.scene.obj,camera:this.cam3D.obj,width:t.width,height:t.height,bouncing:e.bouncing,groundReflector:this.scene.groundReflector,selects:e.selective?this.scene.reflectivesSSR:null}),this.ssrPass.enabled=!0}else console.warn("Module Three.js SSRPass could not be imported.");this.setPostSsrParams(),this.ssrPass&&this.composer.addPass(this.ssrPass)}if("ssao"===e.ssl&&(this.ssaoPass||(this.modules.ssaoPassClass?(this.ssaoPass=new this.modules.ssaoPassClass(this.scene.obj,this.cam3D.obj,t.width,t.height),this.ssaoPass.enabled=!0):console.warn("Module Three.js SSAOPass could not be imported.")),this.setPostSslParams(),this.ssaoPass&&this.composer.addPass(this.ssaoPass)),"smaa"===e.aa&&(this.smaaPass||(this.modules.smaaPassClass?(this.smaaPass=new this.modules.smaaPassClass,this.smaaPass.enabled=!0):console.warn("Module Three.js SMAAPass could not be imported.")),this.smaaPass&&this.composer.addPass(this.smaaPass)),!this.outputPass){const e=this.modules.outputPassClass;e?this.outputPass=new e:console.warn("Module Three.js OutputPass could not be imported.")}if(this.outputPass&&this.composer.addPass(this.outputPass),"fxaa"===e.aa){if(!this.fxaaPass){const e=this.modules.shaderPassClass;e&&this.modules.fxaaShader?(this.fxaaPass=new e(this.modules.fxaaShader),this.fxaaPass.enabled=!0,this.setPostAaParams()):console.warn("Module Three.js FXAAShader could not be imported.")}this.fxaaPass&&this.composer.addPass(this.fxaaPass)}}}setPostWebGpu(e){const t=this.modules.webGpuRendererClass;if(!(t&&this.renderer instanceof t))return;const{aa:s,ssl:i,ssr:n}=e,o="post"===this.cfg.render.profile.webgpu.msaa&&"traa"!==s,a="gtao"===i&&!o,r="ssgi"===i&&"traa"===s&&this.renderer.hasFeature("rg11b10ufloat-renderable"),l=a||r||n,d=!this.postProfileLast||this.postProfileLast.aa!==s||this.postProfileLast.ssl!==i||this.postProfileLast.ssr!==n;if(!this.renderPipeline){const e=this.modules.renderPipelineClass;e?this.renderPipeline=new e(this.renderer):console.warn("EffectComposer could not be started.")}if(!this.renderPipeline)return;const{tslPass:c,tslRtt:h,tslMrt:m,tslContext:p,tslOutput:u,tslDiffuseColor:g,tslVelocity:b,tslRenderOutput:f,tslNormalView:v,tslMetalness:C,tslRoughness:w,tslSample:y,tslVec2:x,tslVec3:P,tslVec4:M,packNormalToRGB:S,unpackRGBToNormal:L}=this.modules;if(!(c&&h&&m&&u&&f&&v&&C&&w&&y&&x&&P&&M&&S&&L))return;if("traa"===s&&!b)return;if(d&&(this.aaNode?.dispose(),this.rttNode?.dispose(),this.gtaoNode?.dispose(),this.ssgiNode?.dispose(),this.ssrNode?.dispose(),this.tslPass?.dispose(),this.aaNode=null,this.rttNode=null,this.gtaoNode=null,this.ssgiNode=null,this.ssrNode=null,this.tslPass=null,this.postProfileLast={...e}),!this.tslPass){const e=o?c(this.scene.obj,this.cam3D.obj):c(this.scene.obj,this.cam3D.obj,{samples:0});this.tslPass=e;const t={output:u};l&&(t.normal=S(v)),n&&(t.metalrough=x(C,w)),r&&g&&(t.diffuse=g),"traa"===s&&b&&(t.velocity=b),e.setMRT(m(t)),l&&(e.getTexture("normal").type=THREE.UnsignedByteType),n&&(e.getTexture("metalrough").type=THREE.UnsignedByteType),r&&g&&(e.getTexture("diffuse").type=THREE.UnsignedByteType)}const T=this.tslPass,E=T.getTextureNode("output"),j=T.getTextureNode("depth"),G=l?T.getTextureNode("normal"):null,D=n?T.getTextureNode("metalrough"):null,A=r&&g?T.getTextureNode("diffuse"):null;if(!this.gtaoNode&&a&&G)if(this.modules.gtaoNodeClass){const e=y(e=>L(G.sample(e)));this.gtaoNode=this.modules.gtaoNodeClass(j,e,this.cam3D.obj)}else console.warn("Module Three.js GTAONode could not be imported.");if(!this.ssgiNode&&r&&G&&this.cam3D.obj instanceof THREE.PerspectiveCamera)if(this.modules.ssgiNodeClass){const e=y(e=>L(G.sample(e)));this.ssgiNode=this.modules.ssgiNodeClass(E,j,e,this.cam3D.obj)}else console.warn("Module Three.js SSGINode could not be imported.");if(!this.ssrNode&&n&&G&&D)if(this.modules.ssrNode){const e=y(e=>L(G.sample(e)));this.ssrNode=this.modules.ssrNode(E,j,e,{metalnessNode:D.r,roughnessNode:D.g,camera:this.cam3D.obj})}else console.warn("Module Three.js SSRNode could not be imported.");this.rttNode||"none"===s||(this.rttNode=h(E)),!this.aaNode&&this.rttNode&&("smaa"===s&&this.modules.smaaNode?this.aaNode=this.modules.smaaNode(this.rttNode):"traa"===s&&this.modules.traaNode?this.aaNode=this.modules.traaNode(this.rttNode,j,T.getTextureNode("velocity"),this.cam3D.obj):"fxaa"===s&&this.modules.fxaaNode&&(this.aaNode=this.modules.fxaaNode(this.rttNode)));let R=E;if(this.setPostSslParams(),this.gtaoNode&&a){const e=this.gtaoNode.getTextureNode();R=R.mul(M(P(e.r),1))}if(this.ssgiNode&&r&&A){const e=this.ssgiNode.getAONode(),t=this.ssgiNode.getGINode();R=R.mul(M(P(e.r),1)).add(M(A.rgb.mul(t.rgb),0))}this.setPostSsrParams(),this.ssrNode&&n&&(R=R.add(M(this.ssrNode.rgb,0))),this.rttNode&&(this.rttNode.node="fxaa"===s?f(R):R,this.rttNode.needsUpdate=!0),this.aaNode&&(this.aaNode.needsUpdate=!0,R=this.aaNode),this.renderPipeline.outputColorTransform="fxaa"!==s||!this.aaNode,this.renderPipeline.outputNode=R,this.renderPipeline.needsUpdate=!0;const k=this.renderPipeline,O=k.renderer,B=O.getDrawingBufferSize(new THREE.Vector2),U="traa"===s&&null!==this.rttNode;this.rttNode&&U&&B.x>0&&B.y>0&&this.rttNode.setSize(B.x,B.y);const N=new THREE.RenderTarget(B.x,B.y,{depthBuffer:!1,type:THREE.HalfFloatType}),I=O.getRenderTarget(),W=O.getActiveCubeFace(),z=O.getActiveMipmapLevel(),J=T.getMRT(),F=T.contextNode;try{O.setRenderTarget(N);const e=U?2:1;for(let t=0;t<e;t++){if(0===t&&U&&this.rttNode){if(!J||!p)throw new Error("TRAA warmup requires the scene MRT and TSL context module.");const e=m({...J.outputNodes,velocity:x(0)});for(const t of Object.keys(J.outputNodes))e.setBlendMode(t,J.getBlendMode(t));null===this.traaWarmupContext&&(this.traaWarmupContext=p({})),T.setMRT(e),T.contextNode=this.traaWarmupContext,k.outputNode=this.rttNode,k.needsUpdate=!0}else U&&(T.setMRT(J),T.contextNode=F,k.outputNode=R,k.needsUpdate=!0);k.render()}}finally{T.setMRT(J),T.contextNode=F,k.outputNode!==R&&(k.outputNode=R,k.needsUpdate=!0),O.setRenderTarget(I,W,z),N.dispose()}}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.canvas.requestFullscreen()}update(e){this.dT=(e-this.timeLast)/1e3,this.timeLast=e;let t=!0,s=this.dT;if(("graphics"===this.gfxMode||"eco"===this.gfxMode&&this.ecoButtonActive)&&(this.dTs.push(this.dT),this.dTs.length>this.cfg.render.deltaTimesMax&&this.dTs.shift(),this.dTs.length===this.cfg.render.deltaTimesMax)){const i=[...this.dTs].sort((e,t)=>e-t),n=i[Math.floor(.25*(i.length-1))];if("graphics"===this.gfxMode){const e=i[Math.floor(.5*(i.length-1))],t=i[Math.floor(.8*(i.length-1))],s=e<=1.2*n&&t<=1.2*e?"up":e>=1.4*n||t>=1.4*e?"down":"neutral";"complete"===this.gfxState?"down"===s?this.updateGfx("complete",s):this.dTs.length=0:(this.gfxMode="off",this.updateGfx(this.gfxState,s))}else if("eco"===this.gfxMode){const i=2*n;if(i<=1/this.cfg.render.fpsMin&&this.ecoButtonActive){t=!1,s=(e-this.timeLastFrame)/1e3;const o=s+n;(s>=i||o>=i&&o-i>i-s)&&(t=!0)}}}if(t&&!this.gfxChanging){this.infoBox&&this.infoBox.begin(e),this.timeGsap+=s,gsap.gsap.updateRoot(this.timeGsap),this.scene.mixer&&this.scene.actionCtrls&&(this.scene.actionCtrls.update(),this.scene.mixer.update(s));for(const e of this.callbacks)e(s);for(const e of this.objs3D.values())e.update(s,this.cam3D);let t=!1;!this.isPostCfg()||this.cfg.render.adaptiveGfx&&0===this.gfxIndex?(this.renderer.render(this.scene.obj,this.cam3D.obj),t=!0):this.modules.webGpuRendererClass?this.renderPipeline&&(this.renderPipeline.render(),t=!0):this.composer&&(this.composer.render(),t=!0),t&&("next"!==this.gfxState&&"back"!==this.gfxState||this.updateGfx(this.gfxState),this.resolveWaitForRender&&(this.resolveWaitForRender(),this.resolveWaitForRender=null)),this.timeLastFrame=e,this.infoBox&&(this.infoBox.end(performance.now(),this.renderer),this.renderer.info.reset())}}updateCanvasResize(){const e=this.canvas.getBoundingClientRect(),t=e.width,s=e.height;this.renderer.setSize(t,s,!1),this.modules.webGpuRendererClass?(this.tslPass?.setSize(t,s),this.gtaoNode?.setSize(t,s),this.ssrNode?.setSize(t,s),this.renderPipeline&&(this.renderPipeline.needsUpdate=!0)):(this.composer?.setSize(t,s),this.smaaPass?.setSize(t,s),this.fxaaPass&&this.setPostAaParams()),this.dTs.length=0,this.cam3D.updateCanvasResize(e),this.scene.groundReflector&&(this.scene.groundReflector.getRenderTarget().setSize(t,s),this.scene.groundReflector.resolution.set(t,s))}updateGfx(e,t){switch(e){case"idle":if(this.gfxState="idle",this.gfxDownOnly=!1,1===this.gfxLevels.length)return void this.updateGfx("complete");this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0;break;case"current":if(void 0===t)return;if(this.gfxDownOnly&&"down"!==t)return void this.updateGfx("complete");if("up"===t){if(this.gfxIndex===this.gfxLevels.length-1)return void this.updateGfx("complete");this.gfxState="next",this.setGfxLevel(this.gfxIndex+1)}else if("down"===t){if(0===this.gfxIndex)return void this.updateGfx("complete");this.gfxState="back",this.setGfxLevel(this.gfxIndex-1)}else this.updateGfx("complete");break;case"next":this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0;break;case"back":this.gfxDownOnly?(this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0):this.updateGfx("complete");break;case"complete":if("down"===t&&this.gfxIndex>0){this.gfxDownOnly=!0,this.gfxState="back",this.setGfxLevel(this.gfxIndex-1);break}this.gfxState="complete",this.gfxDownOnly=!1,this.dTs.length=0,this.gfxMode=this.cfg.render.ecoMode&&this.ecoButtonActive?"eco":this.gfxIndex>0?"graphics":"off",this.gfxEvents.emit({type:"Gfx_Ready",gfxLevel:this.gfxLevels[this.gfxIndex]})}}use(e){e(this)}waitForRender(){return new Promise(e=>{this.resolveWaitForRender=e})}},EnvCtrls=class{cfg;engine;events;modules;scene;envReady=Promise.resolve();textReady=Promise.resolve(null);bgdReady=Promise.resolve();envEnabled=!1;envInit=!1;envLoadId=0;envIntensity;bgdIntensity;bgdBlurriness;rotation;rotationSpeed;envType;envMaps;envText=null;bgdText=null;callback=null;frameWaiters=[];timeBgdRot=0;constructor(e,t,s,i,n){this.cfg=e,this.engine=t,this.scene=s,this.events=i,this.modules=n,this.envIntensity=this.cfg.envCtrls.environmentIntensity,this.bgdIntensity=this.cfg.envCtrls.backgroundIntensity,this.bgdBlurriness=this.cfg.envCtrls.backgroundBlurriness,this.rotationSpeed=this.cfg.envCtrls.rotationSpeed,this.envType=this.cfg.envCtrls.type,this.envMaps=[...this.cfg.envCtrls.map],this.rotation=new THREE.Euler(THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.x),THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.y),THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.z))}init(){if(!this.cfg.envCtrls.enable||this.envEnabled||this.envInit)return this.envReady;this.envInit=!0;const e=this.envMaps.length>0?this.envMaps[0]:"";return this.textReady=this.loadText(this.envType,e),this.startEnv(),this.envReady}async applyBgds(e,t,s,i){let n=i;for(const i of s){const s=await this.loadText(t,i);if(s){if(this.envLoadId!==e)return void this.disposeText(s);if(await this.waitFrames(2),this.envLoadId!==e)return void this.disposeText(s);if(this.setBgd(s),await this.waitFrames(1),this.envLoadId!==e)return this.disposeText(s),void this.disposePrevBgd(n);this.disposePrevBgd(n),n=s}}this.envLoadId===e&&this.events.send({type:"Env_Loaded"},"Environment and background maps loaded")}async applyEnv(e,t,s){const i=await this.textReady;if(!i||this.envLoadId!==e)return;const n=this.modules.webGpuRendererClass;if(n&&this.engine.renderer instanceof n)this.setEnv(i);else{const e=new THREE.PMREMGenerator(this.engine.renderer);try{e.compileEquirectangularShader();const t=e.fromEquirectangular(i).texture;this.setEnv(t,i)}finally{e.dispose()}}this.callback||(this.callback=e=>this.update(e),this.engine.addOnFrameUpdate(this.callback)),this.bgdReady=this.applyBgds(e,t,s.slice(1),i).catch(e=>{console.warn("Failed to apply background map:",e)})}disposePrevBgd(e){e&&this.envText!==e&&this.scene.obj.environment!==e&&(this.bgdText===e&&(this.bgdText=null),this.disposeText(e))}disposeText(e){e&&(this.envText===e&&(this.envText=null),this.bgdText===e&&(this.bgdText=null),e.dispose())}enable(e){if(this.envEnabled)return;const t=e?.type??this.cfg.envCtrls.type,s=[...e?.map??this.cfg.envCtrls.map];this.cfg.envCtrls.enable=!0,this.envEnabled=!0,this.envType=t,this.envMaps=s,this.textReady=this.loadText(t,s[0]??""),this.startEnv(t,s)}disable(){if(!this.envEnabled&&!this.envInit&&!this.isEnabled())return;this.cfg.envCtrls.enable=!1,this.envEnabled=!1,this.envInit=!1,this.envLoadId++,this.resolveFrameWaiters(!0),this.engine&&this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null);const e=this.envText,t=this.bgdText;this.disposeText(e),t!==e&&this.disposeText(t),this.scene.obj.environment=null,this.scene.obj.environmentRotation.set(0,0,0),this.scene.obj.environmentIntensity=this.envIntensity,this.scene.obj.background=null,this.scene.obj.backgroundRotation.set(0,0,0),this.scene.obj.backgroundIntensity=this.bgdIntensity,this.scene.obj.backgroundBlurriness=this.bgdBlurriness,this.rotationSpeed=this.cfg.envCtrls.rotationSpeed,this.timeBgdRot=0}get(){return{rotationSpeed:this.rotationSpeed,environmentIntensity:this.envIntensity,backgroundIntensity:this.bgdIntensity,backgroundBlurriness:this.bgdBlurriness,rotation:{x:THREE.MathUtils.radToDeg(this.rotation.x),y:THREE.MathUtils.radToDeg(this.rotation.y),z:THREE.MathUtils.radToDeg(this.rotation.z)}}}isEnabled(){return null!==this.scene.obj.environment||null!==this.scene.obj.background}async loadText(e,t){if(!t)return console.warn("Environment map is empty."),null;try{let s;if("hdr"===e||"exr"===e){if(!this.modules.envLoader)return console.warn("Modules EXRLoader or ENVLoader could not be imported."),null;const e=this.modules.webGpuRendererClass,i="float"===this.cfg.envCtrls.dataType&&(e&&this.engine.renderer instanceof e||this.engine.renderer.extensions.has("OES_texture_float_linear"));this.modules.envLoader.setDataType(i?THREE.FloatType:THREE.HalfFloatType),s=await this.modules.envLoader.loadAsync(t)}else s=await(new THREE.TextureLoader).loadAsync(t);return s.mapping=THREE.EquirectangularReflectionMapping,s}catch(e){return console.warn("Failed to load environment map:",t,e),null}}set(e){void 0!==e.rotationSpeed&&(this.rotationSpeed=e.rotationSpeed),void 0!==e.environmentIntensity&&(this.envIntensity=e.environmentIntensity,this.scene.obj.environmentIntensity=this.envIntensity),void 0!==e.backgroundIntensity&&(this.bgdIntensity=e.backgroundIntensity,this.scene.obj.backgroundIntensity=this.bgdIntensity),void 0!==e.backgroundBlurriness&&(this.bgdBlurriness=e.backgroundBlurriness,this.scene.obj.backgroundBlurriness=this.bgdBlurriness),void 0!==e.rotation&&(this.rotation.set(THREE.MathUtils.degToRad(e.rotation.x),THREE.MathUtils.degToRad(e.rotation.y),THREE.MathUtils.degToRad(e.rotation.z)),this.scene.obj.environmentRotation.copy(this.rotation),this.scene.obj.backgroundRotation.copy(this.rotation))}setEnv(e,t=e){this.envText=e,this.scene.obj.environment=e,this.scene.obj.environmentRotation.copy(this.rotation),this.scene.obj.environmentIntensity=this.envIntensity,this.setBgd(t)}setBgd(e){this.bgdText=e,this.scene.obj.background=e,this.scene.obj.backgroundRotation.copy(this.rotation),this.scene.obj.backgroundIntensity=this.bgdIntensity,this.scene.obj.backgroundBlurriness=this.bgdBlurriness}startEnv(e=this.envType,t=this.envMaps){const s=++this.envLoadId;this.envReady=this.applyEnv(s,e,t).catch(e=>{console.warn("Failed to apply environment:",e),this.envLoadId===s&&this.setEnv(null)})}waitFrames(e){return e<=0?Promise.resolve():new Promise(t=>{this.frameWaiters.push({remaining:e,resolve:t})})}resolveFrameWaiters(e=!1){const t=[];for(const s of this.frameWaiters)e||s.remaining--,e||s.remaining<=0?s.resolve():t.push(s);this.frameWaiters=t}update(e){if(0===this.rotationSpeed)this.scene.obj.environmentRotation.copy(this.rotation);else{this.timeBgdRot+=e*this.rotationSpeed;const t=THREE.MathUtils.degToRad(this.timeBgdRot);this.scene.obj.environmentRotation.set(this.rotation.x,this.rotation.y+t,this.rotation.z)}this.scene.obj.backgroundRotation.copy(this.scene.obj.environmentRotation),this.resolveFrameWaiters()}},Events=class{cfg;stateMachine;eventQueue=[];isProcessingEvents=!1;constructor(e,t){this.cfg=e,this.stateMachine=t}enqueue(e){if(this.eventQueue.push(e),!this.isProcessingEvents){this.isProcessingEvents=!0;try{for(;this.eventQueue.length>0;){const e=this.eventQueue.shift();e&&e()}}finally{this.isProcessingEvents=!1}}}anim(e){let t=`${e.objName}`;this.send(e,t)}animFade(e){let t=`${e.objName} - ${e.property}: ${e.value}`;this.send(e,t)}audioLoaded(e){this.send(e,e.soundName)}clip(e){const t=[];e.clipName&&t.push(e.clipName),"Clip_Fade_Start"!==e.type&&"Clip_Fade_Complete"!==e.type||!e.fadeMode||t.push(`fadeMode: ${e.fadeMode}`),"Clip_Speed_Start"!==e.type&&"Clip_Speed_Complete"!==e.type||!e.action||t.push(`speed: ${e.action.timeScale}`),this.send(e,t.join(" - "))}modelError(e){let t="";t="SyntaxError"==e.error.name?"Model_Error: Invalid GLTF file or wrong path/filename.":`${e.error.name} / ${e.error.message}`,this.send(e,t)}modelLoaded(e){this.send(e)}modelLoading(e){this.send(e,`${e.loading}% loaded`)}sceneRendered(e){this.send(e,"First render complete")}send(e,t){this.enqueue(()=>{const s=this.stateMachine.sendEvent(e,t);"all"!=this.cfg.debug.log||s||console.log(`Event: ${e.type}${t?` - ${t}`:""}`)})}windowResize(e){this.send(e,"Window render size updated.")}},OrbitCtrls=class{cam3D;canvas;engine;events;modules;orbitControls=null;params;orbitCtrlsFirstChange=!0;callback=null;touchPointerIds=new Set;constructor(e,t,s,i,n,o){this.cam3D=e,this.engine=i,this.events=n,this.modules=o,this.canvas=t,this.params={...s}}create(){this.orbitControls||this.modules.orbitControlsClass&&(this.orbitControls=new this.modules.orbitControlsClass(this.cam3D.obj,this.engine.renderer.domElement),this.orbitControls?(this.orbitControls.enabled=!1,this.orbitCtrlsFirstChange=!0,this.orbitControls.addEventListener("start",()=>{this.orbitCtrlsFirstChange=!1,this.events.send({type:"OrbitCtrls_Start"})}),this.orbitControls.addEventListener("change",()=>{this.orbitCtrlsFirstChange||(this.orbitCtrlsFirstChange=!0,this.events.send({type:"OrbitCtrls_Changed"}))}),this.orbitControls.addEventListener("end",()=>{this.events.send({type:"OrbitCtrls_End"})})):console.warn("Module OrbitControls could not be imported."))}disable(){this.orbitControls&&!1!==this.orbitControls.enabled&&(this.orbitControls.enabled=!1,this.touchPointerIds.clear(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.events.send({type:"OrbitCtrls_Disabled"}))}enable(){this.orbitControls||this.create(),this.orbitControls&&(this.orbitControls.enabled||(this.orbitCtrlsFirstChange=!0,this.orbitControls.enabled=!0,this.cam3D.lookMode="target",this.orbitControls.target.copy(this.cam3D.objTarget.position),this.orbitControls.enableDamping=this.params.enableDamping,this.orbitControls.dampingFactor=this.params.dampingFactor,this.orbitControls.minDistance=this.params.minDistance,this.orbitControls.maxDistance=this.params.maxDistance,this.orbitControls.enableZoom=this.params.enableZoom,this.orbitControls.zoomSpeed=this.params.zoomSpeed,this.orbitControls.enableRotate=this.params.enableRotate,this.orbitControls.rotateSpeed=this.params.rotateSpeed,this.orbitControls.enablePan=this.params.enablePan,this.orbitControls.panSpeed=this.params.panSpeed,this.orbitControls.autoRotate=this.params.autoRotate,this.orbitControls.autoRotateSpeed=this.params.autoRotateSpeed,this.orbitControls.minAzimuthAngle=THREE.MathUtils.degToRad(this.params.minAzimuthAngle),this.orbitControls.maxAzimuthAngle=THREE.MathUtils.degToRad(this.params.maxAzimuthAngle),this.orbitControls.minPolarAngle=THREE.MathUtils.degToRad(this.params.minPolarAngle),this.orbitControls.maxPolarAngle=THREE.MathUtils.degToRad(this.params.maxPolarAngle),this.orbitControls.mouseButtons.LEFT=THREE.MOUSE.ROTATE,this.orbitControls.mouseButtons.MIDDLE=THREE.MOUSE.DOLLY,this.orbitControls.mouseButtons.RIGHT=THREE.MOUSE.PAN,this.orbitControls.touches.ONE=THREE.TOUCH.ROTATE,this.orbitControls.touches.TWO=THREE.TOUCH.DOLLY_PAN,this.callback=e=>{this.orbitControls&&(this.orbitControls.update(e),this.cam3D.objTarget.position.copy(this.orbitControls.target))},this.engine.addOnFrameUpdate(this.callback),this.events.send({type:"OrbitCtrls_Enabled"})))}dispose(){this.touchPointerIds.clear(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.orbitControls?.dispose(),this.orbitControls=null,this.events.send({type:"OrbitCtrls_Disposed"})}get(){return{enableDamping:this.params.enableDamping,dampingFactor:this.params.dampingFactor,minDistance:this.params.minDistance,maxDistance:this.params.maxDistance,enableZoom:this.params.enableZoom,zoomSpeed:this.params.zoomSpeed,enableRotate:this.params.enableRotate,rotateSpeed:this.params.rotateSpeed,enablePan:this.params.enablePan,panSpeed:this.params.panSpeed,autoRotate:this.params.autoRotate,autoRotateSpeed:this.params.autoRotateSpeed,minAzimuthAngle:this.params.minAzimuthAngle,maxAzimuthAngle:this.params.maxAzimuthAngle,minPolarAngle:this.params.minPolarAngle,maxPolarAngle:this.params.maxPolarAngle}}isEnabled(){return null!==this.orbitControls&&!0===this.orbitControls?.enabled}set(e){this.orbitControls&&(void 0!==e.enableDamping&&(this.params.enableDamping=e.enableDamping,this.orbitControls.enableDamping=e.enableDamping),void 0!==e.dampingFactor&&(this.params.dampingFactor=e.dampingFactor,this.orbitControls.dampingFactor=e.dampingFactor),void 0!==e.minDistance&&(this.params.minDistance=e.minDistance,this.orbitControls.minDistance=e.minDistance),void 0!==e.maxDistance&&(this.params.maxDistance=e.maxDistance,this.orbitControls.maxDistance=e.maxDistance),void 0!==e.enableZoom&&(this.params.enableZoom=e.enableZoom,this.orbitControls.enableZoom=e.enableZoom),void 0!==e.zoomSpeed&&(this.params.zoomSpeed=e.zoomSpeed,this.orbitControls.zoomSpeed=e.zoomSpeed),void 0!==e.enableRotate&&(this.params.enableRotate=e.enableRotate,this.orbitControls.enableRotate=e.enableRotate),void 0!==e.rotateSpeed&&(this.params.rotateSpeed=e.rotateSpeed,this.orbitControls.rotateSpeed=e.rotateSpeed),void 0!==e.enablePan&&(this.params.enablePan=e.enablePan,this.orbitControls.enablePan=e.enablePan),void 0!==e.panSpeed&&(this.params.panSpeed=e.panSpeed,this.orbitControls.panSpeed=e.panSpeed),void 0!==e.autoRotate&&(this.params.autoRotate=e.autoRotate,this.orbitControls.autoRotate=e.autoRotate),void 0!==e.autoRotateSpeed&&(this.params.autoRotateSpeed=e.autoRotateSpeed,this.orbitControls.autoRotateSpeed=e.autoRotateSpeed),void 0!==e.minAzimuthAngle&&(this.params.minAzimuthAngle=e.minAzimuthAngle,this.orbitControls.minAzimuthAngle=THREE.MathUtils.degToRad(e.minAzimuthAngle)),void 0!==e.maxAzimuthAngle&&(this.params.maxAzimuthAngle=e.maxAzimuthAngle,this.orbitControls.maxAzimuthAngle=THREE.MathUtils.degToRad(e.maxAzimuthAngle)),void 0!==e.minPolarAngle&&(this.params.minPolarAngle=e.minPolarAngle,this.orbitControls.minPolarAngle=THREE.MathUtils.degToRad(e.minPolarAngle)),void 0!==e.maxPolarAngle&&(this.params.maxPolarAngle=e.maxPolarAngle,this.orbitControls.maxPolarAngle=THREE.MathUtils.degToRad(e.maxPolarAngle)))}use(e){e(this)}},FpvCtrls=class{cam3D;canvas;engine;events;modules;pointerLockCtrls=null;params;isMoveForward=!1;isMoveLeft=!1;isMoveBackward=!1;isMoveRight=!1;isMoveUp=!1;isMoveDown=!1;callback=null;onClick=()=>{this.isEnabled()&&(this.isLocked()?this.unlock():this.lock())};onKeyDown=e=>{this.isEnabled()&&(e.code===this.params.keyMoveForward&&(this.isMoveForward=!0),e.code===this.params.keyMoveLeft&&(this.isMoveLeft=!0),e.code===this.params.keyMoveBackward&&(this.isMoveBackward=!0),e.code===this.params.keyMoveRight&&(this.isMoveRight=!0),e.code===this.params.keyMoveUp&&(this.isMoveUp=!0),e.code===this.params.keyMoveDown&&(this.isMoveDown=!0))};onKeyUp=e=>{this.isEnabled()&&(e.code===this.params.keyMoveForward&&(this.isMoveForward=!1),e.code===this.params.keyMoveLeft&&(this.isMoveLeft=!1),e.code===this.params.keyMoveBackward&&(this.isMoveBackward=!1),e.code===this.params.keyMoveRight&&(this.isMoveRight=!1),e.code===this.params.keyMoveUp&&(this.isMoveUp=!1),e.code===this.params.keyMoveDown&&(this.isMoveDown=!1))};constructor(e,t,s,i,n,o){this.cam3D=e,this.canvas=t,this.engine=i,this.events=n,this.modules=o,this.params={...s}}create(){this.pointerLockCtrls||this.modules.pointerLockControlsClass&&(this.pointerLockCtrls=new this.modules.pointerLockControlsClass(this.cam3D.obj,this.engine.renderer.domElement),this.pointerLockCtrls?(this.pointerLockCtrls.enabled=!1,this.pointerLockCtrls.addEventListener("lock",()=>{this.events.send({type:"FpvCtrls_Lock"})}),this.pointerLockCtrls.addEventListener("unlock",()=>{this.events.send({type:"FpvCtrls_Unlock"})}),this.canvas.addEventListener("click",this.onClick),this.canvas.addEventListener("keydown",this.onKeyDown),this.canvas.addEventListener("keyup",this.onKeyUp)):console.warn("Module PointerLockControls could not be imported."))}disable(){this.pointerLockCtrls&&0!=this.pointerLockCtrls.enabled&&(this.pointerLockCtrls.enabled=!1,this.pointerLockCtrls.isLocked&&this.pointerLockCtrls.unlock(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.isMoveForward=!1,this.isMoveLeft=!1,this.isMoveBackward=!1,this.isMoveRight=!1,this.isMoveUp=!1,this.isMoveDown=!1,this.events.send({type:"FpvCtrls_Disabled"}))}enable(){this.pointerLockCtrls||this.create(),this.pointerLockCtrls&&1!=this.pointerLockCtrls.enabled&&(this.pointerLockCtrls.enabled=!0,this.pointerLockCtrls.minPolarAngle=this.params.minPolarAngle,this.pointerLockCtrls.maxPolarAngle=this.params.maxPolarAngle,this.pointerLockCtrls.pointerSpeed=this.params.pointerSpeed,this.callback=e=>{this.pointerLockCtrls?.isLocked&&(this.isMoveForward&&this.moveForward(e),this.isMoveBackward&&this.moveForward(-e),this.isMoveLeft&&this.moveRight(-e),this.isMoveRight&&this.moveRight(e),this.isMoveUp&&this.moveUp(e),this.isMoveDown&&this.moveUp(-e))},this.engine.addOnFrameUpdate(this.callback),this.events.send({type:"FpvCtrls_Enabled"}))}dispose(){this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.canvas.removeEventListener("click",this.onClick),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("keyup",this.onKeyUp),this.isMoveForward=!1,this.isMoveLeft=!1,this.isMoveBackward=!1,this.isMoveRight=!1,this.isMoveUp=!1,this.isMoveDown=!1,this.pointerLockCtrls?.isLocked&&this.pointerLockCtrls.unlock(),this.pointerLockCtrls?.dispose(),this.pointerLockCtrls=null,this.events.send({type:"FpvCtrls_Disposed"})}get(){return{minPolarAngle:this.params.minPolarAngle,maxPolarAngle:this.params.maxPolarAngle,pointerSpeed:this.params.pointerSpeed,keyMoveForward:this.params.keyMoveForward,keyMoveLeft:this.params.keyMoveLeft,keyMoveBackward:this.params.keyMoveBackward,keyMoveRight:this.params.keyMoveRight,keyMoveUp:this.params.keyMoveUp,keyMoveDown:this.params.keyMoveDown}}isEnabled(){return!0===this.pointerLockCtrls?.enabled}isLocked(){return this.pointerLockCtrls?.isLocked??!1}lock(){this.cam3D.lookMode="free",this.pointerLockCtrls?.lock()}moveForward(e){this.pointerLockCtrls?.moveForward(e)}moveRight(e){this.pointerLockCtrls?.moveRight(e)}moveUp(e){this.cam3D.obj.position.y+=e}set(e){this.pointerLockCtrls&&(void 0!==e.minPolarAngle&&(this.params.minPolarAngle=e.minPolarAngle,this.pointerLockCtrls.minPolarAngle=e.minPolarAngle),void 0!==e.maxPolarAngle&&(this.params.maxPolarAngle=e.maxPolarAngle,this.pointerLockCtrls.maxPolarAngle=e.maxPolarAngle),void 0!==e.pointerSpeed&&(this.params.pointerSpeed=e.pointerSpeed,this.pointerLockCtrls.pointerSpeed=e.pointerSpeed),void 0!==e.keyMoveForward&&(this.params.keyMoveForward=e.keyMoveForward),void 0!==e.keyMoveLeft&&(this.params.keyMoveLeft=e.keyMoveLeft),void 0!==e.keyMoveBackward&&(this.params.keyMoveBackward=e.keyMoveBackward),void 0!==e.keyMoveRight&&(this.params.keyMoveRight=e.keyMoveRight),void 0!==e.keyMoveUp&&(this.params.keyMoveUp=e.keyMoveUp),void 0!==e.keyMoveDown&&(this.params.keyMoveDown=e.keyMoveDown))}unlock(){this.pointerLockCtrls?.unlock(),this.events.send({type:"FpvCtrls_Unlock"})}use(e){e(this)}},Raycast=class{cam3D;canvas;cfg;engine;events;objs3D;scene;raycasterPick=new THREE.Raycaster;raycasterVisible=new THREE.Raycaster;colliders=new Map;objsColliders=[];objsOccluders=[];objsOccludees=[];hasPickables=!1;useSceneAsOccluder=!0;objActive=null;objCandidate=null;closestObjCounter=0;indexOccludeeNext=0;pickablesEnabled=!1;timeOccludeeNext=0;callbackOccludees=null;callbackPointerHover=null;listenerClick;listenerCancel;listenerDown;listenerLeave;listenerMove;listenerUp;eventPointerMove=null;posPrevPointerX=0;posPrevPointerY=0;posWorldObj=new THREE.Vector3;dirCamToObj=new THREE.Vector3;posNdcPointer=new THREE.Vector2;constructor(e,t,s,i,n,o,a){this.cam3D=e,this.canvas=t,this.cfg=s,this.engine=i,this.events=o,this.objs3D=a,this.scene=n,this.listenerMove=e=>this.onCanvasPointerMove(e),this.listenerClick=e=>this.onCanvasClick(e),this.listenerCancel=e=>this.onCanvasPointerCancel(e),this.listenerDown=e=>this.onCanvasPointerDown(e),this.listenerLeave=e=>this.onCanvasPointerLeave(e),this.listenerUp=e=>this.onCanvasPointerUp(e)}checkOccludeeVisible(e){e.getWorldPosition(this.posWorldObj),this.dirCamToObj.subVectors(this.posWorldObj,this.cam3D.obj.position);const t=this.dirCamToObj.length();if(t<=0)return!0;this.dirCamToObj.normalize(),this.raycasterVisible.set(this.cam3D.obj.position,this.dirCamToObj),this.raycasterVisible.near=0,this.raycasterVisible.far=Math.max(0,t-1e-4);const s=this.useSceneAsOccluder?this.scene.obj.children:this.objsOccluders;return 0===s.length||!this.raycasterVisible.intersectObjects(s,!0).some(t=>t.object!==e)}clearColliders(e){if(!Array.isArray(e))return;const t=this.pickablesEnabled;t&&this.disablePickables();for(const t of e){for(const[e,s]of this.colliders)s.coll3D===t&&this.colliders.delete(e);t.hidden=!1,t.pickable=!1,t.occluder=!1,t.applyHidden()}this.rebuildColliderCaches(),this.invalidateOccludees(),this.useSceneAsOccluder=!1,t&&this.enablePickables()}enablePickables(){this.pickablesEnabled||this.hasPickables&&(this.canvas.addEventListener("pointermove",this.listenerMove),this.canvas.addEventListener("click",this.listenerClick),this.canvas.addEventListener("pointercancel",this.listenerCancel),this.canvas.addEventListener("pointerdown",this.listenerDown),this.canvas.addEventListener("pointerleave",this.listenerLeave),this.canvas.addEventListener("pointerup",this.listenerUp),null===this.callbackPointerHover&&(this.callbackPointerHover=()=>this.updatePointerHover(),this.engine.addOnFrameUpdate(this.callbackPointerHover)),this.pickablesEnabled=!0)}disablePickables(){this.pickablesEnabled&&(this.canvas.removeEventListener("pointermove",this.listenerMove),this.canvas.removeEventListener("click",this.listenerClick),this.canvas.removeEventListener("pointercancel",this.listenerCancel),this.canvas.removeEventListener("pointerdown",this.listenerDown),this.canvas.removeEventListener("pointerleave",this.listenerLeave),this.canvas.removeEventListener("pointerup",this.listenerUp),null!==this.callbackPointerHover&&(this.engine.removeOnFrameUpdate(this.callbackPointerHover),this.callbackPointerHover=null),this.objActive=null,this.objCandidate=null,this.closestObjCounter=0,this.eventPointerMove=null,this.pickablesEnabled=!1)}getColliderState(e){let t=e;for(;null!==t;){const e=this.colliders.get(t);if(e)return e;t=t.parent}return null}getPickableHit(e){this.raycasterPick.setFromCamera(e,this.cam3D.obj);const t=this.raycasterPick.intersectObjects(this.objsColliders,!0);for(const e of t){const t=this.getColliderState(e.object);if(t){if(t.pickable)return{obj:t.target.obj,point:e.point};if(t.occluder)return null}}return null}getObjAtPointer(){return this.getPickableHit(this.posNdcPointer)?.obj??null}emitPointerEvent(e){const t=this.objs3D.get(e.objName);t?t.emitEvent(e):this.events.send(e,e.objName)}getOccludeeState(e){let t=this.objsOccludees.find(t=>t.obj===e);return t||(t={obj:e,needsCheck:!1,visible:!1},this.objsOccludees.push(t),1===this.objsOccludees.length&&(this.indexOccludeeNext=0),t)}getOccludeeVisible(e){return this.getOccludeeState(e).visible}initColliders(){const e=[];for(const t of this.objs3D.values())t instanceof Coll3D&&(t.resolveTarget(this.objs3D),(t.pickable||t.occluder)&&e.push(t));0!==e.length&&(this.setColliders(e),this.enablePickables())}invalidateOccludees(){for(const e of this.objsOccludees)e.needsCheck=!0;this.indexOccludeeNext=0,this.timeOccludeeNext=0}rebuildColliderCaches(){this.objsColliders=[],this.objsOccluders=[],this.hasPickables=!1;for(const e of this.colliders.values())(e.occluder||e.pickable)&&this.objsColliders.push(e.obj),e.occluder&&this.objsOccluders.push(e.obj),e.pickable&&(this.hasPickables=!0)}onCanvasClick(e){this.updatePointerPosition(e);const t=this.getObjAtPointer();t&&t.name&&this.emitPointerEvent({type:"Obj3D_Click",event:e,objName:t.name})}onCanvasPointerLeave(e){this.onCanvasPointerExit(e)}onCanvasPointerMove(e){this.updatePointerPosition(e),this.eventPointerMove=e}onCanvasPointerCancel(e){this.onCanvasPointerExit(e)}onCanvasPointerDown(e){this.updatePointerPosition(e);const t=this.getObjAtPointer();this.objActive?.name&&t!==this.objActive&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:e,objName:this.objActive.name}),t?.name&&t!==this.objActive&&this.emitPointerEvent({type:"Obj3D_Pointer_Enter",event:e,objName:t.name}),this.objActive=t,this.objCandidate=null,this.closestObjCounter=0,this.objActive?.name&&this.emitPointerEvent({type:"Obj3D_Pointer_Down",event:e,objName:this.objActive.name})}onCanvasPointerExit(e){this.objActive?.name&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:e,objName:this.objActive.name}),this.objActive=null,this.objCandidate=null,this.closestObjCounter=0,this.eventPointerMove=null}onCanvasPointerUp(e){this.objActive?.name&&(this.emitPointerEvent({type:"Obj3D_Pointer_Up",event:e,objName:this.objActive.name}),"touch"===e.pointerType&&this.onCanvasPointerExit(e))}setColliders(e){if(!Array.isArray(e))return;if(0===e.length)return;const t=this.pickablesEnabled;t&&this.disablePickables();for(const t of e){t.applyHidden();for(const[e,s]of this.colliders)s.coll3D===t&&this.colliders.delete(e);const e=t.obj;if(!e)continue;if(!t.occluder&&!t.pickable)continue;const s={obj:e,coll3D:t,target:t.target??t,occluder:t.occluder,pickable:t.pickable};this.colliders.set(e,s)}this.rebuildColliderCaches(),this.invalidateOccludees(),this.useSceneAsOccluder=!1,t&&this.enablePickables()}trackOccludee(e){this.getOccludeeState(e).needsCheck=!0,null===this.callbackOccludees&&(this.timeOccludeeNext=0,this.callbackOccludees=()=>this.updateOccludees(),this.engine.addOnFrameUpdate(this.callbackOccludees))}untrackOccludee(e){const t=this.objsOccludees.findIndex(t=>t.obj===e);-1!==t&&(this.objsOccludees.splice(t,1),this.indexOccludeeNext=0,this.timeOccludeeNext=0,0===this.objsOccludees.length&&null!==this.callbackOccludees&&(this.engine.removeOnFrameUpdate(this.callbackOccludees),this.callbackOccludees=null))}use(e){e(this)}updateOccludees(){const e=this.objsOccludees.length,t=this.cfg.raycast.occludeeInterval;if(0===t){for(const e of this.objsOccludees)e.needsCheck&&(e.visible=this.checkOccludeeVisible(e.obj),e.needsCheck=!1);return}const s=performance.now(),i=t/e;let n=0;for((0===this.timeOccludeeNext||s-this.timeOccludeeNext>=t)&&(this.timeOccludeeNext=s);s>=this.timeOccludeeNext&&n<e;){const t=this.objsOccludees[this.indexOccludeeNext];this.indexOccludeeNext=(this.indexOccludeeNext+1)%e,this.timeOccludeeNext+=i,n++,t.needsCheck&&(t.visible=this.checkOccludeeVisible(t.obj),t.needsCheck=!1)}}updatePointerHover(){if(!this.hasPickables)return;if(!this.eventPointerMove)return;let e=null,t=1/0;for(let s=0;s<this.cfg.raycast.circleSteps;s++){const i=s/this.cfg.raycast.circleSteps*Math.PI*2,n=this.canvas.getBoundingClientRect(),o=Math.cos(i)*this.cfg.raycast.circleRadius/n.width*2,a=Math.sin(i)*this.cfg.raycast.circleRadius/n.height*2,r=new THREE.Vector2(this.posNdcPointer.x+o,this.posNdcPointer.y+a),l=this.getPickableHit(r);if(l){const s=l.point.clone().project(this.cam3D.obj),i=this.posNdcPointer.distanceTo(s);i<t&&(t=i,e=l.obj)}}if(e!==this.objActive)e===this.objCandidate?this.closestObjCounter++:(this.objCandidate=e,this.closestObjCounter=1),this.closestObjCounter>=this.cfg.raycast.countClosestObjs&&(this.objActive?.name&&this.eventPointerMove&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:this.eventPointerMove,objName:this.objActive.name}),this.objCandidate?.name&&this.eventPointerMove&&this.emitPointerEvent({type:"Obj3D_Pointer_Enter",event:this.eventPointerMove,objName:this.objCandidate.name}),this.objActive=this.objCandidate,this.objCandidate=null,this.closestObjCounter=0);else{if(this.closestObjCounter=0,this.objCandidate=null,!this.eventPointerMove)return;const e=this.eventPointerMove;e.clientX===this.posPrevPointerX&&e.clientY===this.posPrevPointerY||!this.objActive?.name||this.emitPointerEvent({type:"Obj3D_Pointer_Move",event:e,objName:this.objActive.name}),this.posPrevPointerX=e.clientX,this.posPrevPointerY=e.clientY}}updatePointerPosition(e){const t=this.canvas.getBoundingClientRect(),s=(e.clientX-t.left)/t.width,i=(e.clientY-t.top)/t.height;this.posNdcPointer.x=2*s-1,this.posNdcPointer.y=-(2*i-1)}},ActionCtrls=class{mixer;events;actions=new Map;constructor(e,t){this.mixer=e,this.events=t,this.mixer.addEventListener("finished",this.onFinished)}play(e,t){const s="additive"===t.blendMode?THREE.AdditiveAnimationBlendMode:THREE.NormalAnimationBlendMode,i=this.mixer.clipAction(e,void 0,s),n=this.actions.get(i);let o,a,r;if(n)if(n.finished)o=i.enabled?this.getWeight(i):0,a="out"===n.fadeMode,r=t.reset,this.cancelFade(n),this.cancelSpeed(n);else{if("out"!==n.fadeMode)return void(n.startSpeed===t.startSpeed&&n.endSpeed===t.endSpeed&&n.speedDuration===t.speedDuration&&n.speedEase===t.speedEase&&n.reverse===t.reverse||(n.startSpeed=t.startSpeed,n.endSpeed=t.endSpeed,n.speedDuration=t.speedDuration,n.speedEase=t.speedEase,n.reverse=t.reverse,t.speedDuration>0?this.speedAction(i,n,this.signedSpeed(t.startSpeed,t.reverse),this.signedSpeed(t.endSpeed,t.reverse),t.speedDuration,t.speedEase):(this.cancelSpeed(n),i.timeScale=this.signedSpeed(t.endSpeed,t.reverse))));o=i.enabled?this.getWeight(i):0,a=!0,r=!1,this.cancelFade(n),this.cancelSpeed(n)}else o=0,a=!1,r=t.reset;r?(i.reset(),i.time=t.reverse?i.getClip().duration:0):(i.stopFading(),i.enabled=!0,i.paused=!1),"infinite"===t.loopMode?(i.setLoop(THREE.LoopRepeat,1/0),i.clampWhenFinished=!1):1===t.loopMode?(i.setLoop(THREE.LoopOnce,1),i.clampWhenFinished=!0):(i.setLoop(THREE.LoopRepeat,t.loopMode),i.clampWhenFinished=!0),this.actions.delete(i),this.actions.set(i,t);const l=t.fadeDuration>0?t.fadeDuration*(1-o):0,d=this.stopLayerActions(t.layer,t.stopMode,i,l);t.fadeDuration>0&&(d||a)?this.fadeInAction(i,t,l,o):this.fadeInAction(i,t,0,1),t.speedDuration>0?this.speedAction(i,t,this.signedSpeed(t.startSpeed,t.reverse),this.signedSpeed(t.endSpeed,t.reverse),t.speedDuration,t.speedEase):i.timeScale=this.signedSpeed(t.endSpeed,t.reverse),i.play(),t.started=!0,this.clipEvent("Clip_Start",i,t),this.mixer.update(0),t.hooks?.onUpdate?.()}stop(e,{clipName:t,fct:s,duration:i=0,ease:n="power1.inOut"}){const o=this.mixer.existingAction(e);if(!o)return void console.warn(`${s}: "${t}" is not currently playing.`);const a=this.actions.get(o);if(!a)return o.stop(),void this.events.clip({type:"Clip_Cancel",clipName:t,action:o});a.clipName=t,i>0?this.speedAction(o,a,o.getEffectiveTimeScale(),0,i,n,()=>{this.cancel(o)}):this.cancel(o)}cancel(e){const t=this.actions.get(e);if(!t)return void e.stop();const s=!t.finished;this.cancelFade(t),this.cancelSpeed(t),e.stop(),this.actions.delete(e),s&&this.clipEvent("Clip_Cancel",e,t)}isStarted(e){return!0===this.actions.get(e)?.started}isFinished(e){return!0===this.actions.get(e)?.finished}dispose(){this.mixer.removeEventListener("finished",this.onFinished);for(const e of this.actions.values())e.tweenFade?.kill(),e.tweenSpeed?.kill();this.actions.clear()}update(){for(const[e,t]of this.actions)!e.enabled||e.paused||e.getEffectiveWeight()<=0||t.hooks?.onUpdate?.()}cancelFade(e){e.tweenFade?.kill(),e.tweenFade=void 0,e.fadeMode=void 0}cancelSpeed(e){e.tweenSpeed?.kill(),e.tweenSpeed=void 0}clipEvent(e,t,s){this.events.clip({type:e,clipName:s.clipName,action:t})}fadeEvent(e,t,s,i){this.events.clip({type:e,clipName:s.clipName,action:t,fadeMode:i})}fadeAction(e,t,s,i,n,o,a){if(e.stopFading(),e.setEffectiveWeight(i),o<=0||i===n)return e.setEffectiveWeight(n),t.fadeMode=void 0,void a?.();const r={weight:i};let l;l=gsap.gsap.to(r,{weight:n,duration:o,ease:"none",onStart:()=>{this.fadeEvent("Clip_Fade_Start",e,t,s)},onUpdate:()=>{e.setEffectiveWeight(r.weight)},onComplete:()=>{e.setEffectiveWeight(n),t.tweenFade===l&&(t.tweenFade=void 0,t.fadeMode=void 0),this.fadeEvent("Clip_Fade_Complete",e,t,s),a?.()}}),t.tweenFade=l}fadeInAction(e,t,s,i){this.cancelFade(t),t.fadeMode="in",e.enabled=!0,this.fadeAction(e,t,"in",i,1,s)}fadeOutAction(e,t,s){const i=this.getWeight(e);this.cancelFade(t),t.fadeMode="out",this.fadeAction(e,t,"out",i,0,s,()=>{e.enabled=!1,this.remove(e,t,!t.finished)})}finishAction(e,t){if("hold"===t.finishMode)return;const s=t.fadeDurationFinish>0?t.fadeDurationFinish*this.getWeight(e):0;this.fadeOutAction(e,t,s)}getWeight(e){return Math.min(Math.max(e.getEffectiveWeight(),0),1)}remove(e,t,s){this.cancelFade(t),this.cancelSpeed(t),this.actions.get(e)===t&&(this.actions.delete(e),s&&this.clipEvent("Clip_Cancel",e,t))}signedSpeed(e,t){return t?-e:e}speedAction(e,t,s,i,n,o,a){if(this.cancelSpeed(t),e.timeScale=s,n<=0)return e.timeScale=i,void a?.();const r={timeScale:s};let l;l=gsap.gsap.to(r,{timeScale:i,duration:n,ease:o,onStart:()=>{this.events.clip({type:"Clip_Speed_Start",clipName:t.clipName,action:e})},onUpdate:()=>{e.timeScale=r.timeScale},onComplete:()=>{e.timeScale=i,t.tweenSpeed===l&&(t.tweenSpeed=void 0),this.events.clip({type:"Clip_Speed_Complete",clipName:t.clipName,action:e}),a?.()}}),t.tweenSpeed=l}stopLayerActions(e,t,s,i){let n=!1;for(const[o,a]of[...this.actions].reverse())if(a.layer===e&&o!==s&&o.enabled&&!(o.getEffectiveWeight()<=0)){if("none"===t)return!0;if(this.fadeOutAction(o,a,i),"last"===t)return!0;n=!0}return n}onFinished=e=>{const t=this.actions.get(e.action);t&&!t.finished&&(t.finished=!0,this.finishAction(e.action,t),this.clipEvent("Clip_Complete",e.action,t))}},Scene=class{actionCtrls=null;cfg;cam3D;events;objs3D;gltf=null;mixer=null;groundReflector=null;reflectivesSSR=[];ambientLight=null;hemisphereLight=null;obj;constructor(e,t,s,i){this.cam3D=e,this.cfg=t,this.events=s,this.objs3D=i,this.obj=new THREE.Scene,this.obj.backgroundBlurriness=t.envCtrls.backgroundBlurriness,this.obj.backgroundIntensity=t.envCtrls.backgroundIntensity,this.obj.environmentIntensity=t.envCtrls.environmentIntensity,this.obj.add(e.obj),t.scene.fog.enable&&this.setFog({color:t.scene.fog.color,near:t.scene.fog.near,far:t.scene.fog.far}),t.scene.ambientlight.enable&&this.setAmbientLight({color:t.scene.ambientlight.color,intensity:t.scene.ambientlight.intensity}),t.scene.hemisphere.enable&&this.setHemisphereLight({skyColor:t.scene.hemisphere.skyColor,groundColor:t.scene.hemisphere.groundColor,intensity:t.scene.hemisphere.intensity})}initFirstScene(e){this.actionCtrls?.dispose(),this.actionCtrls=null,this.gltf=e,this.mixer=null,this.obj.add(e.scene);const t=new Map;return e.animations&&e.animations.length>0&&(this.mixer=new THREE.AnimationMixer(e.scene),this.actionCtrls=new ActionCtrls(this.mixer,this.events)),e.scene.traverse(e=>{const s=this.objs3D.get(e.name);e instanceof THREE.Mesh?(t.set(e.name,e),e.castShadow=this.cfg.mesh.castShadow,e.receiveShadow=this.cfg.mesh.receiveShadow,e.frustumCulled=this.cfg.mesh.frustumCulled,s instanceof Mesh3D?(s.traverse(e),!this.groundReflector&&s.groundReflector&&(this.groundReflector=s.groundReflector)):e.material instanceof THREE.MeshStandardMaterial&&e.material.roughness<this.cfg.post.webgl.ssr.maxRoughness&&this.reflectivesSSR.push(e)):e instanceof THREE.Light?(e.castShadow=this.cfg.light.castShadow,(e instanceof THREE.DirectionalLight||e instanceof THREE.SpotLight||e instanceof THREE.PointLight)&&(e.shadow.mapSize.width=this.cfg.light.mapWidth,e.shadow.mapSize.height=this.cfg.light.mapHeight,e.shadow.bias=this.cfg.light.bias,e.shadow.normalBias=this.cfg.light.normalBias,(e.shadow.camera instanceof THREE.PerspectiveCamera||e.shadow.camera instanceof THREE.OrthographicCamera)&&(e.shadow.camera.near=this.cfg.light.near,e.shadow.camera.far=this.cfg.light.far)),s instanceof Light3D&&s.traverse(e)):e instanceof THREE.Camera?this.cam3D.traverse(e):e instanceof THREE.Object3D&&s instanceof Obj3D&&s.traverse(e)}),t}initObjs3D(e,t){for(const s of this.objs3D.values())s instanceof Mesh3D&&(s.setModel(t),s.setReflectivesSSR(this.reflectivesSSR)),s.start(e,this),s instanceof Mesh3D&&s.groundReflector&&(this.groundReflector=s.groundReflector)}animCamCurveTo({camTarget:e,aimTarget:t,radiusOut:s=1,duration:i=2,ease:n="power1.inOut"}){const o=this.animCamCurveTo.name,a=e=>{for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e},r=e=>{if("string"==typeof e){const t=this.obj.getObjectByName(e);return t?t.getWorldPosition(new THREE.Vector3):(console.warn(`${o}: Object with name "${e}" not found.`),null)}return e instanceof Obj3D?e.obj?e.obj.getWorldPosition(new THREE.Vector3):(console.warn(`${o}: Obj3D not found.`),null):e instanceof THREE.Vector3?e.clone():(console.warn(`${o}: Invalid target.`),null)},l=e=>{const t=Math.max(e.length(),1e-4);return{radius:t,lat:Math.asin(THREE.MathUtils.clamp(e.y/t,-1,1)),lon:Math.atan2(e.x,e.z)}};this.cam3D.lookMode="target";const d=this.cam3D.objTarget.position.clone(),c=r(e);if(!c)return void console.warn(`Camera object with name "${e}" was not found.`);const h=t?r(t):d;if(!h)return void console.warn(`Aim object with name "${t}" was not found.`);const m=this.cam3D.obj.getWorldPosition(new THREE.Vector3).clone().sub(d),p=c.clone().sub(h),u=l(m),g=l(p),b=u.lat,f=g.lat,v=a(u.lon),C=a(a(g.lon)-v),w=u.radius,y=g.radius,x=Math.max(w,y)*s,P={t:0};gsap.gsap.to(P,{t:1,duration:i,ease:n,onStart:()=>{this.events.anim({type:"Anim_Start",objName:"Camera",fct:o})},onUpdate:()=>{const e=P.t,t=d.clone().lerp(h,e),s=THREE.MathUtils.lerp(b,f,e),i=a(v+C*e),n=THREE.MathUtils.lerp(w,y,e),o=Math.sin(Math.PI*e)*x,r=((e,t,s)=>{const i=Math.cos(t);return new THREE.Vector3(e*i*Math.sin(s),e*Math.sin(t),e*i*Math.cos(s))})(Math.max(1e-4,n+o),s,i),l=t.clone().add(r);this.cam3D.obj.position.copy(l),this.cam3D.objTarget.position.copy(t)},onComplete:()=>{this.events.anim({type:"Anim_Complete",objName:"Camera",fct:o})}})}animCamTo({target:e,duration:t=1,ease:s="power2.inOut",dist:i=1.25}){const n="animCamTo";this.cam3D.lookMode="target";const o=(e=>{if("string"==typeof e){const t=this.obj.getObjectByName(e);return t||(console.warn(`${n}: Object with name "${e}" not found.`),null)}return e instanceof Obj3D?e.obj?e.obj:(console.warn(`${n}: Obj3D object not found.`),null):(console.warn(`${n}: Invalid target.`),null)})(e);if(!o)return;const a=((e,t)=>{const s=(new THREE.Box3).setFromObject(e,!0);if(s.isEmpty())return console.warn(`${n}: Object bounding box is empty.`),null;const i=s.getBoundingSphere(new THREE.Sphere),o=this.cam3D.obj,a=THREE.MathUtils.degToRad(o.fov),r=2*Math.atan(Math.tan(a/2)*o.aspect),l=Math.min(a,r),d=i.radius/Math.sin(l/2)*t;return{center:i.center.clone(),camDistance:d}})(o,i);if(!a)return;const r=a.center,l=this.cam3D.objTarget.position.clone(),d=this.cam3D.obj.position.clone(),c=d.clone().sub(r);0===c.lengthSq()&&c.set(0,0,1);const h=r.clone().add(c.normalize().multiplyScalar(a.camDistance)),m={t:0};gsap.gsap.to(m,{t:1,duration:t,ease:s,onStart:()=>{this.events.anim({type:"Anim_Start",objName:"Camera",fct:n})},onUpdate:()=>{const e=m.t,t=l.clone().lerp(r,e),s=d.clone().lerp(h,e);this.cam3D.obj.position.copy(s),this.cam3D.objTarget.position.copy(t)},onComplete:()=>{this.cam3D.obj.position.copy(h),this.cam3D.objTarget.position.copy(r),this.events.anim({type:"Anim_Complete",objName:"Camera",fct:n})}})}animMaterialColor({mesh:e,duration:t=0,ease:s="power1.inOut",...i}){const n=this.animMaterialColor.name;if(!e)return void console.warn(`${n}: Missing object name.`);const o="string"==typeof e?this.obj.getObjectByName(e):e.obj,a="string"==typeof e?e:[...this.objs3D].find(([,t])=>t===e)?.[0]??e.obj.name;if(!o)return void console.warn(`${n}: Object with name "${a}" not found.`);if(!o.material)return void console.warn(`${n}: Object "${a}" has no material.`);const r=o.material,l=Object.keys(i);0!==l.length?l.forEach(e=>{const o=i[e];if(!(e in r)||!r[e].isColor)return void console.warn(`${n}: Material property "${e}" is not a color.`);if(null==o)return void console.warn(`${n}: Color value for "${e}" is null or undefined.`);const l=r[e],d=new THREE.Color(o);gsap.gsap.to(l,{r:d.r,g:d.g,b:d.b,duration:t,ease:s,onStart:()=>{this.events.animFade({type:"Anim_Fade_Start",objName:a,fct:n,property:e,value:l.getHexString()})},onUpdate:()=>{r[e].copy(l)},onComplete:()=>{this.events.animFade({type:"Anim_Fade_Complete",objName:a,fct:n,property:e,value:l.getHexString()})}})}):console.warn(`${n}: No color property provided to animate.`)}animMaterialNumeric({mesh:e,needsUpdate:t=!1,startValue:s=null,infinite:i=!1,duration:n=0,ease:o="power1.inOut",...a}){const r=this.animMaterialNumeric.name;if(!e)return void console.warn(`${r}: Missing object name.`);const l="string"==typeof e?this.obj.getObjectByName(e):e.obj,d="string"==typeof e?e:[...this.objs3D].find(([,t])=>t===e)?.[0]??e.obj.name;if(!l)return void console.warn(`${r}: Object with name "${d}" not found.`);if(!l.material)return void console.warn(`${r}: Object "${d}" has no material.`);const c=l.material,h=Object.keys(a);if(0===h.length)return void console.warn(`${r}: No property provided to animate.`);const m=h[0],p=a[m];if(!(m in c))return void console.warn(`${r}: Material property "${m}" does not exist.`);const u=c[m];if("number"!=typeof u)return void console.warn(`${r}: Material property "${m}" is not a number.`);if(null==p||"number"!=typeof p)return void console.warn(`${r}: Material property "${m}" endValue is null or undefined or not a number.`);const g={[m]:null===s?u:s};gsap.gsap.to(g,{[m]:p,duration:n,delay:0,ease:o,repeat:i?-1:0,onStart:()=>{t&&(c.needsUpdate=!0),this.events.animFade({type:"Anim_Fade_Start",objName:d,fct:r,property:m,value:g[m]})},onUpdate:()=>{c[m]=g[m]},onComplete:()=>{this.events.animFade({type:"Anim_Fade_Complete",objName:d,fct:r,property:m,value:g[m]})}})}calcEaseArea(e){const t=gsap.gsap.parseEase(e);return function(e=100){let s=0;for(let i=0;i<=e;i++){s+=t(i/e)}return s/e}()}playClip({layer:e,clip:t,blendMode:s="normal",finishMode:i="hold",loopMode:n=1,stopMode:o="all",fadeDuration:a=0,fadeDurationFinish:r=0,reverse:l=!1,reset:d=!1,startSpeed:c=0,endSpeed:h=1,duration:m=0,ease:p="power1.inOut"}){const u=this.playClip.name;if(!e)return void console.warn(`${u}: Missing layer.`);if(!t)return void console.warn(`${u}: Missing clipname.`);if("infinite"!==n&&(!Number.isInteger(n)||n<1))return void console.warn(`${u}: loopMode must be a positive integer or "infinite".`);if(!this.gltf?.animations?.length)return void console.warn(`${u}: gltf has no animations.`);const g=THREE.AnimationClip.findByName(this.gltf.animations,t);g?this.mixer?this.actionCtrls&&this.actionCtrls.play(g,{clipName:t,layer:e,blendMode:s,loopMode:n,finishMode:i,stopMode:o,fadeDuration:a,fadeDurationFinish:r,reverse:l,reset:d,startSpeed:c,endSpeed:h,speedDuration:m,speedEase:p,started:!1,finished:!1}):console.warn(`${u}: Mixer not found.`):console.warn(`${u}: ClipAnimation "${t}" not found`)}playClipCam({layer:e,clip:t,blendMode:s="normal",loopMode:i=1,stopMode:n="all",fadeDuration:o=0,reverse:a=!1,reset:r=!1,startSpeed:l=0,endSpeed:d=1,duration:c=0,ease:h="power1.inOut"}){const m=this.playClipCam.name;if(!e)return void console.warn(`${m}: Missing layer.`);const p=this.cam3D.targetGltf,u=this.cam3D.objGltf;if(!p)return void console.warn(`${m}: Aim object not found.`);if(!u)return void console.warn(`${m}: Gltf object not found.`);if(!t)return void console.warn(`${m}: Missing clipname.`);if("infinite"!==i&&(!Number.isInteger(i)||i<1))return void console.warn(`${m}: loopMode must be a positive integer or "infinite".`);if(!this.gltf?.animations?.length)return void console.warn(`${m}: gltf has no animations.`);const g=THREE.AnimationClip.findByName(this.gltf.animations,t);if(!g)return void console.warn(`${m}: ClipAnimation "${t}" not found`);if(!this.mixer)return void console.warn(`${m}: Mixer not found.`);if(!this.actionCtrls)return;this.cam3D.lookMode="target";const b=new THREE.Vector3,f=new THREE.Vector3;this.actionCtrls.play(g,{clipName:t,layer:e,blendMode:s,loopMode:i,finishMode:"hold",stopMode:n,fadeDuration:o,fadeDurationFinish:0,reverse:a,reset:r,startSpeed:l,endSpeed:d,speedDuration:c,speedEase:h,started:!1,finished:!1,hooks:{onUpdate:()=>{this.cam3D.obj.position.copy(u.getWorldPosition(b)),this.cam3D.objTarget.position.copy(p.getWorldPosition(f))}}})}removeAmbientLight(){this.ambientLight&&(this.obj.remove(this.ambientLight),this.ambientLight.dispose(),this.ambientLight=null)}removeFog(){this.obj.fog&&(this.obj.fog=null)}removeHemisphereLight(){this.hemisphereLight&&(this.obj.remove(this.hemisphereLight),this.hemisphereLight.dispose(),this.hemisphereLight=null)}setAmbientLight({color:e,intensity:t}){if(!this.ambientLight){if(void 0===e||void 0===t)return;return this.ambientLight=new THREE.AmbientLight(e,t),void this.obj.add(this.ambientLight)}void 0!==e&&this.ambientLight.color.set(e),void 0!==t&&(this.ambientLight.intensity=t)}setFog({color:e,near:t,far:s}){if(this.obj.fog)void 0!==e&&this.obj.fog.color.set(e),this.obj.fog instanceof THREE.Fog&&(void 0!==t&&(this.obj.fog.near=t),void 0!==s&&(this.obj.fog.far=s));else{if(void 0===e||void 0===t||void 0===s)return;this.obj.fog=new THREE.Fog(e,t,s)}}setHemisphereLight({skyColor:e,groundColor:t,intensity:s}){if(!this.hemisphereLight){if(void 0===e||void 0===t||void 0===s)return;return this.hemisphereLight=new THREE.HemisphereLight(e,t,s),void this.obj.add(this.hemisphereLight)}void 0!==e&&this.hemisphereLight.color.set(e),void 0!==t&&this.hemisphereLight.groundColor.set(t),void 0!==s&&(this.hemisphereLight.intensity=s)}setMaterialProps({obj:e,recursive:t=!1,needsUpdate:s=!1,...i}){const n=this.setMaterialProps.name;if(!e)return void console.warn(`${n}: Missing objName`);const o="string"==typeof e?this.obj.getObjectByName(e):e.obj;if(!o)return void console.warn(`${n}: Object with name "${e}" not found.`);let a=!1;const r=e=>{if(!(e instanceof THREE.Mesh))return;a=!0;const t=new Set(Array.isArray(e.material)?e.material:[e.material]);if(0===t.size)return void console.warn(`${n}: Mesh has no material.`);const o=Object.keys(i);if(0===o.length)return void console.warn(`${n}: No material properties provided.`);let r=null;for(const e of t){const t=e;for(const e of o){const s=i[e];if(("map"===e||"emissiveMap"===e)&&"string"==typeof s){r||(r=new THREE.TextureLoader),r.load(s,s=>{t[e]=s,t.needsUpdate=!0},void 0,t=>{console.error(`${n}: Failed to load texture "${s}" for "${e}":`,t)});continue}if(!(e in t)){console.warn(`${n}: Material property "${e}" does not exist.`);continue}const o=t[e];o instanceof THREE.Color?o.set(s):typeof o==typeof s?t[e]=s:console.warn(`${n}: Type mismatch for "${e}": expected ${typeof o}, got ${typeof s}`)}s&&(t.needsUpdate=!0)}};t?o.traverse(r):r(o),a||console.warn(`${n}: Object "${"string"==typeof e?e:e.obj.name}" has no mesh.`)}stopAnimClip({clipName:e,fadeOut:t=0,ease:s="power1.inOut"}){let i=this.stopAnimClip.name;if(!e)return void console.warn(`${i}: Missing clipName.`);if(!this.gltf?.animations?.length)return void console.warn(`${i}: glb has no animations.`);const n=THREE.AnimationClip.findByName(this.gltf.animations,e);n?this.mixer?this.actionCtrls&&this.actionCtrls.stop(n,{clipName:e,fct:i,duration:t,ease:s}):console.warn(`${i}: Mixer not exists.`):console.warn(`${i}: ClipAnimation "${e}" not found.`)}},StateMachine=class{cfg;modules;actor=null;lastState="";snapshot=null;stateMachine=null;constructor(e,t){this.cfg=e,this.modules=t}sendEvent(e,t){if(!this.actor)return null;let s=!1;return(null!=this.snapshot?this.snapshot:this.actor.getSnapshot?.())?.can?.(e)&&(s=!0,"none"!=this.cfg.debug.log&&console.log(`Event: ${e.type}${t?` - ${t}`:""}`),this.actor.send(e)),s}start(e){if(this.stateMachine=e,this.stateMachine)if(this.actor)console.warn("Actor is already started.");else{if(this.cfg.stateMachine.inspector&&this.modules.createBrowserInspector){const{inspect:e}=this.modules.createBrowserInspector();this.actor=(0,xstate.createActor)(this.stateMachine,{inspect:e})}else this.actor=(0,xstate.createActor)(this.stateMachine);this.actor.subscribe(e=>{if(this.snapshot=e,"none"==this.cfg.debug.log)return;const t=e.value,s=JSON.stringify(t);if(s!==this.lastState)if(this.lastState=s,"object"==typeof t&&null!==t){const e=(t,s="")=>{if("string"==typeof t)return[s?`${s} > ${t}`:t];const i=[];for(const[n,o]of Object.entries(t)){const t=s?`${s} > ${n}`:n;i.push(...e(o,t))}return i};e(t).forEach(e=>{console.log(`State: ${e}`)})}else console.log(`State: ${t}`)}),this.actor.start()}else console.warn("State Machine not found.")}};function isPlainObject(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function merge(e,t){const s=e;for(const[e,i]of Object.entries(t)){const t=s[e];isPlainObject(t)&&isPlainObject(i)?merge(t,i):s[e]=Array.isArray(i)?[...i]:i}}var cfg={audio:{enable:!1,guiOpened:!1,delayPlaySound:200,refDistance:1,rolloffFactor:1,maxDistance:1e3,distanceModel:"inverse",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0},cam:{type:"perspective",near:.1,far:1e3,lookAt:{x:0,y:0,z:0},position:{x:0,y:.5,z:.5},perspective:{fov:75},orthographic:{left:-1,right:1,top:1,bottom:-1}},comps:{overlap:{padding:20}},debug:{log:"xstate"},envCtrls:{backgroundBlurriness:0,backgroundIntensity:0,dataType:"halfFloat",enable:!1,environmentIntensity:1.8,load:!1,map:[],rotation:{x:0,y:0,z:0},rotationSpeed:0,type:"exr"},fpvCtrls:{enable:!1,load:!1,minPolarAngle:0,maxPolarAngle:Math.PI,pointerSpeed:.1,keyMoveForward:"KeyW",keyMoveLeft:"KeyA",keyMoveBackward:"KeyS",keyMoveRight:"KeyD",keyMoveUp:"KeyQ",keyMoveDown:"KeyE"},gui:{infoBox:{enable:!1,fps:!0,cpu:!0,frame:!0,calls:!0,triangles:!0,lines:!0,points:!0,geometries:!0,textures:!0,programs:!0,logsPerSecond:10},inspector:{enable:!1},menuBar:{enable:!0,backgroundColor:"#ffffff29",logo:""}},light:{castShadow:!0,rectArea:!1,mapWidth:512,mapHeight:512,bias:0,normalBias:0,near:.5,far:500},mesh:{castShadow:!0,receiveShadow:!0,frustumCulled:!1},model:{compress:{mesh:"none",texture:"none"},decoderPath:"draco/",file:[],progressBar:!0},orbitCtrls:{autoRotate:!1,autoRotateSpeed:2,dampingFactor:.1,enable:!1,enableDamping:!1,enablePan:!0,enableRotate:!0,enableZoom:!0,load:!1,maxAzimuthAngle:1/0,maxDistance:1/0,maxPolarAngle:180,minAzimuthAngle:-1/0,minDistance:0,minPolarAngle:0,panSpeed:1,rotateSpeed:1,zoomSpeed:1},post:{guiOpened:!1,aa:{guiOpened:!1},ssl:{guiOpened:!1},ssr:{guiOpened:!1,maxDistance:180,thickness:.018,resolutionScale:1},webgl:{aa:{fxaa:{sharpness:.5}},ssao:{kernelRadius:8,minDistance:.005,maxDistance:.1},ssr:{bouncing:!1,distanceAttenuation:!0,fresnel:!0,infiniteThick:!1,opacity:.5,blur:!0,output:0,selective:!1,clear:!0,maxRoughness:.5}},webgpu:{gtao:{radius:.25,thickness:1,scale:1,samples:16,resolutionScale:1},ssgi:{guiOpened:!1,sliceCount:2,stepCount:8,aoIntensity:1,giIntensity:10,radius:12,useScreenSpaceSampling:!0,expFactor:2,thickness:1,useLinearThickness:!1,backfaceLighting:0},ssr:{intensity:.5,quality:.5,blurQuality:1}}},raycast:{occludeeInterval:0,occlusionMoveFactor:.01,circleRadius:10,circleSteps:12,countClosestObjs:5},render:{adaptiveGfx:!1,api:"auto",autoResize:!0,deltaTimesMax:20,ecoMode:!0,fpsMin:30,guiOpened:!1,outputColorSpace:THREE.SRGBColorSpace,pixelRatio:1,shadowMapEnabled:!0,shadowMapType:THREE.PCFShadowMap,toneMapping:THREE.ACESFilmicToneMapping,toneMappingExposure:1,params:{alpha:!1},profile:{webgl:{msaa:"none",aa:"none",ssl:"none",ssr:!1},webgpu:{msaa:"none",aa:"none",ssl:"none",ssr:!1}},webgl:{params:{}},webgpu:{params:{}}},scene:{guiOpened:!1,canvas:"ilu-canvas",fog:{enable:!1,color:0,near:0,far:100},ambientlight:{enable:!1,color:16777215,intensity:1},hemisphere:{enable:!1,skyColor:16777147,groundColor:526368,intensity:1}},stateMachine:{inspector:!1}};function setCfg(e){return merge(cfg,e),cfg}var WebCtrls=class{cam3D;engine;padding;posCamWorld=new THREE.Vector3;websTracked=[];updateRequired=!1;callback=()=>{this.update()};requestUpdate=()=>{this.updateRequired=!0};constructor(e,t,s){this.cam3D=e,this.engine=t,this.padding=Math.max(0,s)}applyOverlaps(){this.cam3D.obj.getWorldPosition(this.posCamWorld);const e=[];for(const t of this.websTracked){const s=t.web.getObj3DFollow();if(!t.web.isConnected||!t.web.isVisibleFollow()||!s?.obj){t.web.setVisibleOverlap(!0);continue}s.obj.getWorldPosition(t.posWorld);const i=t.web.getBoundingClientRect();0!==i.width&&0!==i.height?e.push({web:t.web,distanceSquared:t.posWorld.distanceToSquared(this.posCamWorld),rect:i}):t.web.setVisibleOverlap(!0)}e.sort((e,t)=>e.distanceSquared-t.distanceSquared);const t=[];for(const s of e){const e=!t.some(e=>this.rectsOverlap(s.rect,e));s.web.setVisibleOverlap(e),e&&t.push(s.rect)}}rectsOverlap(e,t){return e.left<t.right+this.padding&&e.right+this.padding>t.left&&e.top<t.bottom+this.padding&&e.bottom+this.padding>t.top}subWebTracked(e){e.posScreen=null;const t=e.web.getObj3DFollow();t&&e.unSubs.push(t.addEventListener("Obj3D_Pos_Screen_Changed",t=>{const s=Math.round(t.posScreen.x),i=Math.round(t.posScreen.y);if(null!==e.posScreen){if(e.posScreen.x===s&&e.posScreen.y===i)return;e.posScreen.set(s,i)}else e.posScreen=new THREE.Vector2(s,i);this.requestUpdate()}),t.addEventListener("Obj3D_Visible_Changed",()=>{this.requestUpdate()}))}refreshOverlap(e){const t=this.websTracked.find(t=>t.web===e);t&&(this.unsubWebTracked(t),this.subWebTracked(t),this.requestUpdate(),this.update())}trackOverlap(e){if(this.websTracked.some(t=>t.web===e))return;const t={web:e,posWorld:new THREE.Vector3,posScreen:null,unSubs:[]};this.websTracked.push(t),this.subWebTracked(t),1===this.websTracked.length&&this.engine.addOnFrameUpdate(this.callback),this.requestUpdate(),this.update()}unsubWebTracked(e){for(const t of e.unSubs)t();e.unSubs=[]}untrackOverlap(e){const t=this.websTracked.findIndex(t=>t.web===e);if(-1===t)return;const s=this.websTracked[t];if(this.unsubWebTracked(s),this.websTracked.splice(t,1),e.setVisibleOverlap(!0),0===this.websTracked.length)return this.engine.removeOnFrameUpdate(this.callback),void(this.updateRequired=!1);this.requestUpdate(),this.update()}update(){0!==this.websTracked.length&&this.updateRequired&&(this.updateRequired=!1,this.applyOverlaps())}},inspector_default="/* nur Chrome / Edge / Safari */\r\n.illutions-pane {\r\n font-family: monospace;\r\n font-size: 12px;\r\n\r\n --tp-base-background-color: hsla(230, 20%, 11%, 1.00);\r\n --tp-base-shadow-color: hsla(0, 0%, 0%, 0.2);\r\n --tp-button-background-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-button-background-color-active: hsla(230, 10%, 95%, 1.00);\r\n --tp-button-background-color-focus: hsla(230, 10%, 90%, 1.00);\r\n --tp-button-background-color-hover: hsla(230, 10%, 85%, 1.00);\r\n --tp-button-foreground-color: hsla(230, 20%, 11%, 1.00);\r\n --tp-container-background-color: hsla(230, 25%, 16%, 1.00);\r\n --tp-container-background-color-active: hsla(230, 25%, 31%, 1.00);\r\n --tp-container-background-color-focus: hsla(230, 25%, 26%, 1.00);\r\n --tp-container-background-color-hover: hsla(230, 25%, 21%, 1.00);\r\n --tp-container-foreground-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-groove-foreground-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-input-background-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-input-background-color-active: hsla(230, 28%, 23%, 1.00);\r\n --tp-input-background-color-focus: hsla(230, 28%, 18%, 1.00);\r\n --tp-input-background-color-hover: hsla(230, 20%, 13%, 1.00);\r\n --tp-input-foreground-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-label-foreground-color: hsla(230, 12%, 48%, 1.00);\r\n --tp-monitor-background-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-monitor-foreground-color: hsla(230, 12%, 48%, 1.00);\r\n\r\n max-height: 95vh;\r\n overflow-y: auto;\r\n scrollbar-width: thin;\r\n scrollbar-color: #F40B5780 #1e1e1e;\r\n}\r\n\r\n/* WebKit Hover + Fallback for older Chrome / Edge / Safari */\r\n.illutions-pane::-webkit-scrollbar {\r\n width: 10px;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-track {\r\n background: #1e1e1e;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-thumb {\r\n background: #F40B5780;\r\n border-radius: 6px;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-thumb:hover {\r\n background: #F40B57;\r\n}\r\n",outputColorSpaceParam={SRGB:THREE.SRGBColorSpace,LinearSRGB:THREE.LinearSRGBColorSpace},shadowMapTypeParam={Basic:THREE.BasicShadowMap,PCF:THREE.PCFShadowMap,PCFSoft:THREE.PCFShadowMap,VSM:THREE.VSMShadowMap},toneMappingParam={None:THREE.NoToneMapping,Linear:THREE.LinearToneMapping,Reinhard:THREE.ReinhardToneMapping,Cineon:THREE.CineonToneMapping,ACESFilmic:THREE.ACESFilmicToneMapping,AgX:THREE.AgXToneMapping,Neutral:THREE.NeutralToneMapping,Custom:THREE.CustomToneMapping},Inspector=class{engine;scene;envCtrls;pane=null;modules;orbitCtrls;fpvCtrls;audio;cfg;webGpuPost=null;webGpuAaModeBinding=null;webGpuSslModeBinding=null;gtaoWebGpuFolder=null;ssgiWebGpuFolder=null;constructor(e,t,s,i,n,o,a,r){if(this.audio=t,this.engine=s,this.scene=i,this.envCtrls=n,this.modules=o,this.orbitCtrls=a,this.fpvCtrls=r,this.cfg=e,!this.modules.paneClass)return void console.warn("Module tweakpane could not be imported.");if(this.pane=new this.modules.paneClass({title:"illutions"}),!this.pane)return;const l=this.pane.element;l.style.position="fixed",l.style.top="8px",l.style.right="8px",l.style.zIndex="1000",l.classList.add("illutions-pane");for(const e of["click","pointerdown","pointermove","pointerup","pointercancel","wheel"])l.addEventListener(e,e=>e.stopPropagation());const d=document.createElement("style");if(d.textContent=inspector_default,document.head.appendChild(d),this.cfg.audio.enable){const e=this.audio.get(),t=this.pane.addFolder({title:"Audio",expanded:this.cfg.audio.guiOpened});t.addBinding(e,"delayPlaySound",{min:0,max:2e3,step:10}).on("change",e=>this.audio.set({delayPlaySound:e.value})),t.addBinding(e,"refDistance",{min:.1,max:20,step:.1}).on("change",e=>this.audio.set({refDistance:e.value})),t.addBinding(e,"rolloffFactor",{min:0,max:100,step:.1}).on("change",e=>this.audio.set({rolloffFactor:e.value})),t.addBinding(e,"maxDistance",{min:1,max:5e3,step:10}).on("change",e=>this.audio.set({maxDistance:e.value})),t.addBinding(e,"distanceModel",{options:{linear:"linear",inverse:"inverse",exponential:"exponential"}}).on("change",e=>this.audio.set({distanceModel:e.value})),t.addBinding(e,"coneInnerAngle",{min:0,max:360,step:1}).on("change",e=>this.audio.set({coneInnerAngle:e.value})),t.addBinding(e,"coneOuterAngle",{min:0,max:360,step:1}).on("change",e=>this.audio.set({coneOuterAngle:e.value})),t.addBinding(e,"coneOuterGain",{min:0,max:1,step:.01}).on("change",e=>this.audio.set({coneOuterGain:e.value}))}const c=this.pane.addFolder({title:"Navigation",expanded:!1});if(this.cfg.orbitCtrls.enable||this.cfg.orbitCtrls.load){const e=c.addFolder({title:"Orbit",expanded:!0});e.addBinding(this.cfg.orbitCtrls,"enableDamping").on("change",e=>this.orbitCtrls.set({enableDamping:e.value})),e.addBinding(this.cfg.orbitCtrls,"dampingFactor",{min:0,max:1,step:.01}).on("change",e=>this.orbitCtrls.set({dampingFactor:e.value})),e.addBinding(this.cfg.orbitCtrls,"minDistance",{min:0,max:500,step:.1}).on("change",e=>this.orbitCtrls.set({minDistance:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxDistance",{min:0,max:2e3,step:.1}).on("change",e=>this.orbitCtrls.set({maxDistance:e.value})),e.addBinding(this.cfg.orbitCtrls,"minAzimuthAngle",{step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({minAzimuthAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxAzimuthAngle",{step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({maxAzimuthAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"minPolarAngle",{min:0,max:180,step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({minPolarAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxPolarAngle",{min:0,max:180,step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({maxPolarAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"enableZoom").on("change",e=>this.orbitCtrls.set({enableZoom:e.value})),e.addBinding(this.cfg.orbitCtrls,"zoomSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({zoomSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"enableRotate"),e.addBinding(this.cfg.orbitCtrls,"rotateSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({rotateSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"enablePan").on("change",e=>this.orbitCtrls.set({enablePan:e.value})),e.addBinding(this.cfg.orbitCtrls,"panSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({panSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"autoRotate").on("change",e=>this.orbitCtrls.set({autoRotate:e.value})),e.addBinding(this.cfg.orbitCtrls,"autoRotateSpeed",{min:.1,max:10,step:.1}).on("change",e=>this.orbitCtrls.set({autoRotateSpeed:e.value}))}if(this.cfg.fpvCtrls.enable){const e=c.addFolder({title:"FirstPerson",expanded:!0});e.addBinding(this.cfg.fpvCtrls,"minPolarAngle",{min:0,max:Math.PI,step:.01}).on("change",e=>this.fpvCtrls.set({minPolarAngle:e.value})),e.addBinding(this.cfg.fpvCtrls,"maxPolarAngle",{min:0,max:Math.PI,step:.01}).on("change",e=>this.fpvCtrls.set({maxPolarAngle:e.value})),e.addBinding(this.cfg.fpvCtrls,"pointerSpeed",{min:.01,max:1,step:.01}).on("change",e=>this.fpvCtrls.set({pointerSpeed:e.value}))}const h=this.pane.addFolder({title:"Renderer",expanded:this.cfg.render.guiOpened});h.addBinding(this.cfg.render,"deltaTimesMax",{min:1,max:120,step:1}),h.addBinding(this.cfg.render,"pixelRatio",{min:.25,max:2,step:.05}).on("change",e=>{this.engine.renderer.setPixelRatio(e.value)});const m={outputColorSpace:Object.keys(outputColorSpaceParam).find(e=>outputColorSpaceParam[e]===this.cfg.render.outputColorSpace)},p=Object.keys(outputColorSpaceParam).reduce((e,t)=>(e[t]=t,e),{});h.addBinding(m,"outputColorSpace",{options:p}).on("change",e=>{const t=outputColorSpaceParam[e.value];this.cfg.render.outputColorSpace=t,this.engine.renderer.outputColorSpace=t});const u=h.addFolder({title:"ShadowMap",expanded:!1});u.addBinding(this.cfg.render,"shadowMapEnabled").on("change",e=>{this.engine.renderer.shadowMap.enabled=e.value});const g={shadowMapType:Object.keys(shadowMapTypeParam).find(e=>shadowMapTypeParam[e]===this.cfg.render.shadowMapType)},b=Object.keys(shadowMapTypeParam).reduce((e,t)=>(e[t]=t,e),{});u.addBinding(g,"shadowMapType",{options:b}).on("change",e=>{const t=shadowMapTypeParam[e.value];this.engine.renderer.shadowMap.type=t});const f=h.addFolder({title:"ToneMapping",expanded:!1}),v={toneMapping:Object.keys(toneMappingParam).find(e=>toneMappingParam[e]===this.cfg.render.toneMapping)},C=Object.keys(toneMappingParam).reduce((e,t)=>(e[t]=t,e),{});f.addBinding(v,"toneMapping",{options:C}).on("change",e=>{const t=e.value;this.engine.renderer.toneMapping=toneMappingParam[t]}),f.addBinding(this.cfg.render,"toneMappingExposure",{min:0,max:5}).on("change",e=>{this.engine.renderer.toneMappingExposure=e.value});const w=this.modules.webGpuRendererClass?this.cfg.render.profile.webgpu:this.cfg.render.profile.webgl;if(!this.cfg.render.adaptiveGfx&&("none"!==w.ssl||w.ssr||"none"!==w.aa)){const e=h.addFolder({title:"Postprocessing",expanded:this.cfg.post.guiOpened}),t={sslMode:w.ssl,ssrEnable:w.ssr,aaMode:w.aa},s=this.cfg.post.ssl;if(this.modules.webGpuRendererClass){this.webGpuPost=t;const i=this.cfg.post.webgpu.gtao,n=this.cfg.post.webgpu.ssgi,o=e.addFolder({title:"SSL",expanded:s.guiOpened||n.guiOpened}),a=o.addBinding(t,"sslMode",{label:"Mode",options:{None:"none",GTAO:"gtao",SSGI:"ssgi"}});this.webGpuSslModeBinding=a,a.on("change",async e=>{await this.engine.enableSslMode(e.value),this.setWebGpuPostState()});const r=o.addFolder({title:"GTAO",expanded:s.guiOpened});this.gtaoWebGpuFolder=r,r.addBinding(i,"radius",{min:0,max:10,step:.01,label:"Radius"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"thickness",{min:0,max:10,step:.01,label:"Thickness"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"scale",{min:0,max:5,step:.01,label:"Scale"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"samples",{min:1,max:64,step:1,label:"Samples"}).on("change",()=>this.engine.setPostSslParams()),this.setChildrenDisabled(r,null,"gtao"!==w.ssl);const l=o.addFolder({title:"SSGI",expanded:n.guiOpened});this.ssgiWebGpuFolder=l,l.addBinding(n,"sliceCount",{min:1,max:4,step:1,label:"SliceCount"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"stepCount",{min:1,max:32,step:1,label:"StepCount"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"aoIntensity",{min:0,max:4,step:.01,label:"AOIntensity"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"giIntensity",{min:0,max:100,step:.1,label:"GIIntensity"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"radius",{min:1,max:25,step:.1,label:"Radius"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"useScreenSpaceSampling",{label:"ScreenSpaceSampling"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"expFactor",{min:1,max:3,step:.01,label:"ExpFactor"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"thickness",{min:.01,max:10,step:.01,label:"Thickness"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"useLinearThickness",{label:"LinearThickness"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"backfaceLighting",{min:0,max:1,step:.01,label:"BackfaceLighting"}).on("change",()=>this.engine.setPostSslParams())}else{const i=this.cfg.post.webgl.ssao,n=e.addFolder({title:"SSL",expanded:s.guiOpened});n.addBinding(t,"sslMode",{label:"Mode",options:{None:"none",SSAO:"ssao"}}).on("change",async e=>{await this.engine.enableSslMode(e.value),this.setChildrenDisabled(o,null,"ssao"!==e.value)});const o=n.addFolder({title:"SSAO",expanded:s.guiOpened});o.addBinding(i,"kernelRadius",{min:0,max:32,step:1,label:"KernelRadius"}).on("change",()=>this.engine.setPostSslParams()),o.addBinding(i,"minDistance",{min:0,max:.5,step:.001,label:"MinDistance"}).on("change",()=>this.engine.setPostSslParams()),o.addBinding(i,"maxDistance",{min:0,max:1,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSslParams()),this.setChildrenDisabled(o,null,"ssao"!==w.ssl)}const i=this.cfg.post.ssr;if(this.modules.webGpuRendererClass){const s=this.cfg.post.webgpu.ssr,n=e.addFolder({title:"SSR",expanded:i.guiOpened}),o=n.addBinding(t,"ssrEnable",{label:"Enable"}).on("change",async e=>{await this.engine.enableSsr(e.value),this.setChildrenDisabled(n,o,!e.value)});n.addBinding(i,"maxDistance",{min:0,max:180,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"intensity",{min:0,max:1,step:.01,label:"Intensity"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"thickness",{min:0,max:.1,step:.001,label:"Thickness"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"resolutionScale",{min:0,max:1,step:.01,label:"ResolutionScale"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"quality",{min:0,max:1,step:.01,label:"Quality"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"blurQuality",{min:1,max:3,step:1,label:"BlurQuality"}).on("change",()=>this.engine.setPostSsrParams()),this.setChildrenDisabled(n,o,!w.ssr)}else{const s=this.cfg.post.webgl.ssr,n=e.addFolder({title:"SSR",expanded:i.guiOpened});let o=!1;const a=()=>{if(o)return;if(!this.modules.ssrPassClass)return;const e={Default:this.modules.ssrPassClass.OUTPUT.Default,"SSR Only":this.modules.ssrPassClass.OUTPUT.SSR,Beauty:this.modules.ssrPassClass.OUTPUT.Beauty,Depth:this.modules.ssrPassClass.OUTPUT.Depth,Normal:this.modules.ssrPassClass.OUTPUT.Normal,Metalness:this.modules.ssrPassClass.OUTPUT.Metalness};n.addBinding(s,"output",{label:"Output",options:e}).on("change",()=>this.engine.setPostSsrParams()),o=!0},r=n.addBinding(t,"ssrEnable",{label:"Enable"}).on("change",async e=>{await this.engine.enableSsr(e.value),a(),this.setChildrenDisabled(n,r,!e.value)});n.addBinding(s,"fresnel",{label:"Fresnel"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"distanceAttenuation",{label:"DistanceAttenuation"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"maxDistance",{min:0,max:180,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"opacity",{min:0,max:1,step:.01,label:"Opacity"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"thickness",{min:0,max:.1,step:.001,label:"Thickness"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"infiniteThick",{label:"InfiniteThick"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"blur",{label:"Blur"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"resolutionScale",{min:0,max:1,step:.01,label:"ResolutionScale"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"bouncing",{label:"Bouncing"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"clear",{label:"Clear"}).on("change",()=>this.engine.setPostSsrParams()),a(),this.setChildrenDisabled(n,r,!w.ssr)}const n=e.addFolder({title:"AA",expanded:this.cfg.post.aa.guiOpened});let o=null;const a=n.addBinding(t,"aaMode",{label:"Mode",options:this.modules.webGpuRendererClass?{None:"none",FXAA:"fxaa",SMAA:"smaa",TRAA:"traa"}:{None:"none",FXAA:"fxaa",SMAA:"smaa"}});this.modules.webGpuRendererClass&&(this.webGpuAaModeBinding=a,this.setWebGpuPostState()),a.on("change",async e=>{const t=e.value;await this.engine.enableAaMode(t),this.modules.webGpuRendererClass&&this.setWebGpuPostState(),o&&(o.hidden="fxaa"!==t)}),this.modules.webGpuRendererClass||(o=n.addBinding(this.cfg.post.webgl.aa.fxaa,"sharpness",{min:.1,max:1,step:.05,label:"Sharpness"}).on("change",()=>this.engine.setPostAaParams()),o.hidden="fxaa"!==w.aa)}const y=this.pane.addFolder({title:"Scene",expanded:this.cfg.scene.guiOpened});if(this.cfg.scene.ambientlight.enable){const e=y.addFolder({title:"Ambient Light",expanded:!0});e.addBinding(this.cfg.scene.ambientlight,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setAmbientLight({color:this.cfg.scene.ambientlight.color,intensity:this.cfg.scene.ambientlight.intensity}):this.scene.removeAmbientLight()}),e.addBinding(this.cfg.scene.ambientlight,"color",{label:"Color",view:"color"}).on("change",e=>{this.scene.setAmbientLight({color:e.value})}),e.addBinding(this.cfg.scene.ambientlight,"intensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.scene.setAmbientLight({intensity:e.value})})}if(this.cfg.scene.hemisphere.enable){const e=y.addFolder({title:"Hemisphere Light",expanded:!0});e.addBinding(this.cfg.scene.hemisphere,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setHemisphereLight({skyColor:this.cfg.scene.hemisphere.skyColor,groundColor:this.cfg.scene.hemisphere.groundColor,intensity:this.cfg.scene.hemisphere.intensity}):this.scene.removeHemisphereLight()}),e.addBinding(this.cfg.scene.hemisphere,"skyColor",{label:"Sky Color",view:"color"}).on("change",e=>{this.scene.setHemisphereLight({skyColor:e.value})}),e.addBinding(this.cfg.scene.hemisphere,"groundColor",{label:"Ground Color",view:"color"}).on("change",e=>{this.scene.setHemisphereLight({groundColor:e.value})}),e.addBinding(this.cfg.scene.hemisphere,"intensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.scene.setHemisphereLight({intensity:e.value})})}if(this.cfg.scene.fog.enable){const e=y.addFolder({title:"Fog",expanded:!0});e.addBinding(this.cfg.scene.fog,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setFog({color:this.cfg.scene.fog.color,near:this.cfg.scene.fog.near,far:this.cfg.scene.fog.far}):this.scene.removeFog()}),e.addBinding(this.cfg.scene.fog,"color",{label:"Color",view:"color"}).on("change",e=>{this.scene.setFog({color:e.value})}),e.addBinding(this.cfg.scene.fog,"near",{min:0,max:50,label:"Near"}).on("change",e=>{this.scene.setFog({near:e.value})}),e.addBinding(this.cfg.scene.fog,"far",{min:0,max:100,label:"Far"}).on("change",e=>{this.scene.setFog({far:e.value})})}if(this.cfg.envCtrls.enable||this.cfg.envCtrls.load){const e=y.addBinding(this.cfg.envCtrls,"enable",{label:"Enabled"}),t=y.addFolder({title:"Background",expanded:!1}),s=y.addFolder({title:"Environment",expanded:!1});e.on("change",e=>{e.value?this.envCtrls.enable():this.envCtrls.disable(),t.disabled=!e.value,s.disabled=!e.value}),t.disabled=!this.cfg.envCtrls.enable,s.disabled=!this.cfg.envCtrls.enable,t.addBinding(this.cfg.envCtrls,"backgroundBlurriness",{min:0,max:1,label:"Blurriness"}).on("change",e=>{this.envCtrls.set({backgroundBlurriness:e.value})}),t.addBinding(this.cfg.envCtrls,"backgroundIntensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.envCtrls.set({backgroundIntensity:e.value})}),s.addBinding(this.cfg.envCtrls,"environmentIntensity",{min:0,max:10,label:"Intensity"}).on("change",e=>{this.envCtrls.set({environmentIntensity:e.value})});const i=this.envCtrls.get().rotation;if(i){const e={x:i.x,y:i.y,z:i.z};s.addBinding(e,"x",{min:0,max:360,label:"Rotate X"}).on("change",()=>{this.envCtrls.set({rotation:e})}),s.addBinding(e,"y",{min:0,max:360,label:"Rotate Y"}).on("change",()=>{this.envCtrls.set({rotation:e})}),s.addBinding(e,"z",{min:0,max:360,label:"Rotate Z"}).on("change",()=>{this.envCtrls.set({rotation:e})})}}}setChildrenDisabled(e,t,s){for(const i of e.children)i!==t&&(i.disabled=s)}setWebGpuPostState(){if(!(this.webGpuPost&&this.webGpuAaModeBinding&&this.webGpuSslModeBinding&&this.gtaoWebGpuFolder&&this.ssgiWebGpuFolder))return;const e=[{text:"None",value:"none"}],t=[...e,{text:"GTAO",value:"gtao"}],s=[...t,{text:"SSGI",value:"ssgi"}],i=[{text:"None",value:"none"},{text:"FXAA",value:"fxaa"},{text:"SMAA",value:"smaa"}],n=[{text:"TRAA",value:"traa"}],o=[...i,...n];switch(`${this.cfg.render.profile.webgpu.msaa}:${this.webGpuPost.aaMode}`){case"post:none":case"post:fxaa":case"post:smaa":default:this.webGpuSslModeBinding.options=e;break;case"none:none":case"none:fxaa":case"none:smaa":case"render:none":case"render:fxaa":case"render:smaa":this.webGpuSslModeBinding.options=t;break;case"none:traa":case"render:traa":this.webGpuSslModeBinding.options=s}switch(`${this.cfg.render.profile.webgpu.msaa}:${this.webGpuPost.sslMode}`){case"none:ssgi":case"render:ssgi":this.webGpuAaModeBinding.options=n;break;case"none:none":case"none:gtao":case"render:none":case"render:gtao":this.webGpuAaModeBinding.options=o;break;default:this.webGpuAaModeBinding.options=i}this.setChildrenDisabled(this.gtaoWebGpuFolder,null,"gtao"!==this.webGpuPost.sslMode),this.setChildrenDisabled(this.ssgiWebGpuFolder,null,"ssgi"!==this.webGpuPost.sslMode)}},progressbar_default=':host {\r\n position: absolute;\r\n display: block;\r\n top: 50%; left: 50%;\r\n width: 25%; height: 5px;\r\n transform: translate(-50%, -50%);\r\n background: #ffffff30;\r\n border-radius: 3px;\r\n pointer-events: none;\r\n z-index: 1;\r\n overflow: hidden;\r\n}\r\n\r\n#bar {\r\n position: relative;\r\n width: 0%; height: 100%;\r\n background: #F40B57;\r\n border-radius: 3px;\r\n transition: width 0.3s ease-in;\r\n overflow: hidden;\r\n}\r\n\r\n#bar::after {\r\n content: "";\r\n position: absolute;\r\n top: 0;\r\n left: -40%;\r\n width: 40%;\r\n height: 100%;\r\n\r\n background: linear-gradient(\r\n 90deg,\r\n transparent,\r\n rgba(255, 255, 255, 0.5),\r\n transparent\r\n );\r\n\r\n animation: progress-active 1s linear infinite;\r\n}\r\n\r\n@keyframes progress-active {\r\n from {\r\n transform: translateX(0);\r\n }\r\n to {\r\n transform: translateX(350%);\r\n }\r\n}',ProgressBar=class extends HTMLElement{bar;events;constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("div");t.id="bar";const s=document.createElement("style");s.textContent=progressbar_default,e.append(s,t),this.bar=t}setProgress(e){this.bar.style.width=e+"%",e>=100&&setTimeout(()=>{if("100%"===this.bar.style.width){const e=t=>{t.target===this&&"opacity"===t.propertyName&&(this.events.send({type:"ProgressBar_Hidden"},"Progress bar finished hiding"),this.removeEventListener("transitionend",e),this.remove())};this.addEventListener("transitionend",e),this.style.transition="opacity 0.3s ease",this.style.opacity="0"}},300)}},TAG="ilu-progressbar";function loadProgressBar(e,t){const s=document.createElement(TAG);return s.events=t,e.appendChild(s),s}customElements.get(TAG)||customElements.define(TAG,ProgressBar);var Model=class{canvas;cfg;events;modules;renderer;modelReady=Promise.resolve(!1);sceneReady;resolveSceneReady;rejectSceneReady;meshes=new Map;scene=null;imageNamesUnused=new Set;imageTexturesUnused=new Map;textures=[];constructor(e,t,s,i,n){this.canvas=e,this.cfg=t,this.events=s,this.modules=i,this.renderer=n,this.sceneReady=new Promise((e,t)=>{this.resolveSceneReady=e,this.rejectSceneReady=t})}addImageUnusedName(e){this.imageNamesUnused.add(e)}addMaterialsFromMesh(e,t){for(const s of Array.isArray(e.material)?e.material:[e.material])t.add(s)}addTexturesFromMaterial(e,t){for(const s of Object.values(e))s instanceof THREE.Texture&&t.add(s)}addTexture(e,t){const s=this.textures.find(t=>t.texture===e);s?s.source=t:this.textures.push({texture:e,source:t,pending:null})}disposeGeometries(e){const t=new Set;for(const e of this.meshes.values())t.add(e.geometry);for(const s of e)t.has(s)||s.dispose()}disposeMaterialsAndTextures(e){const t=new Set,s=new Set,i=new Set,n=new Set;for(const e of this.meshes.values())this.addMaterialsFromMesh(e,t);for(const e of this.textures)i.add(e.texture);e.scene.traverse(e=>{e instanceof THREE.Mesh&&this.addMaterialsFromMesh(e,s)});for(const e of t)this.addTexturesFromMaterial(e,i);for(const e of s)this.addTexturesFromMaterial(e,n);for(const e of s)t.has(e)||e.dispose();for(const e of n)i.has(e)||e.dispose()}getTextureFromImageUnused(e){const t=this.imageTexturesUnused.get(e);if(!t)throw new Error(`Image texture "${e}" is unavailable. Request it with requestImageTexture() during onStart().`);return t}async initTextureFromImageUnused(e,t){const s=t.parser.json.images,i=s?s.findIndex(t=>t.name===e):-1;if(!s||i<0)throw new Error(`Image "${e}" was not found in the GLTF.`);const n=s[i];let o=t.parser.textureLoader;if("image/ktx2"===n.mimeType&&t.parser.options.ktx2Loader)o=t.parser.options.ktx2Loader;else if(n.uri){const e=t.parser.options.manager.getHandler(n.uri);e&&(o=e)}const a=await t.parser.loadImageSource(i,o);if(!a)throw new Error(`Unused image "${e}" could not be initialized from the GLTF.`);return a}async initTexturesFromImagesUnused(e){await Promise.all([...this.imageNamesUnused].map(async t=>{const s=await this.initTextureFromImageUnused(t,e);s.name=t,s.flipY=!1,this.imageTexturesUnused.set(t,s),this.addTexture(s,{type:"image",name:t})}))}async initTexturesGltf(e){const t=await e.parser.getDependencies("texture");for(let e=0;e<t.length;e++){const s=t[e];s&&this.addTexture(s,{type:"texture",index:e})}}async load(e,t,s){const i=this.modules.gltfLoader;if(!i)return console.warn("Three.js GLTFLoader could not be started."),this.resolveSceneReady(),!1;if(0===e.length)return this.resolveSceneReady(),!0;let n=!1,o=!1;try{if("ktx2"===this.cfg.model.compress.texture){const e=this.modules.ktx2Loader;e?(e.setTranscoderPath("ktx2/").detectSupport(this.renderer),i.setKTX2Loader(e)):console.warn("KTX2Loader not imported.")}"draco"===this.cfg.model.compress.mesh?this.modules.dracoLoader?this.cfg.model.decoderPath?(this.modules.dracoLoader.setDecoderPath(this.cfg.model.decoderPath),i.setDRACOLoader(this.modules.dracoLoader)):console.warn("Draco decoderPath is empty."):console.warn("DRACOLoader not imported."):"meshopt"===this.cfg.model.compress.mesh&&(this.modules.meshoptDecoder?i.setMeshoptDecoder(this.modules.meshoptDecoder):console.warn("MeshoptDecoder not imported."));let a=null;this.cfg.model.progressBar&&(a=loadProgressBar(this.canvas,this.events));const r=e.length>1;let l=this.loadGltf(i,e[0],a,1,r);for(let d=0;d<e.length;d++){let c;try{c=await l}catch(t){const s=e[d+1];if(!s){if(!n)throw o=!0,t;return!0}l=this.loadGltf(i,s,n?null:a,d+2,r);continue}const h=e[d+1],m=h?this.loadGltf(i,h,null,d+2,r):null;m&&m.catch(()=>{});try{n?(await this.prepareTextureImages(c),this.updateGeometries(c),this.updateTextureImages(),this.disposeMaterialsAndTextures(c)):(this.scene=c.scene,await Promise.all([this.initTexturesGltf(c),this.initTexturesFromImagesUnused(c)]),this.meshes=s.initFirstScene(c),n=!0,a?.setProgress(100),this.resolveSceneReady()),await t.waitForRender(),this.events.sceneRendered({type:r?`Scene${d+1}_Rendered`:"Scene_Rendered"})}catch(e){if(!n)throw e;if(this.reportError(e),!m)return!0}if(!m)return r&&this.events.send({type:"Model_Ready"},"Applied and rendered final model"),!0;l=m}return n}catch(e){throw o||this.reportError(e),this.rejectSceneReady(e),e}}async loadGltf(e,t,s,i,n){let o=-1;try{const a=await e.loadAsync(t,e=>{if(e.total>0&&s){const t=e.loaded/e.total,i=Math.round(90*t);i<90&&s.setProgress(i)}const t=e.total>0?Math.round(e.loaded/e.total*100):0;t!==o&&(o=t,this.events.modelLoading({type:n?`Model${i}_Loading`:"Model_Loading",loading:t}))});return this.events.modelLoaded({type:n?`Model${i}_Loaded`:"Model_Loaded"}),a}catch(e){throw this.reportError(e),e}}async prepareTextureImages(e){await Promise.all(this.textures.map(async t=>{t.pending=null;try{let s;s="texture"===t.source.type?await e.parser.getDependency("texture",t.source.index):await this.initTextureFromImageUnused(t.source.name,e),t.pending={image:s.image,mipmaps:s.mipmaps.slice()}}catch(e){const s="texture"===t.source.type?`GLTF texture index ${t.source.index}`:`unused image "${t.source.name}"`;console.warn(`Progressive image for ${s} could not be initialized.`,e)}}))}reportError(e){const t=e instanceof Error?e:new Error(String(e));this.events.modelError({type:"Model_Error",error:t})}updateGeometries(e){if(!this.scene)return;const t=new Set;let s=0,i=0;e.scene.traverse(e=>{if(!(e instanceof THREE.Mesh))return;s++;const n=this.meshes.get(e.name);e.name&&n?(t.add(n.geometry),n.geometry=e.geometry,n.updateMorphTargets(),i++):t.add(e.geometry)}),this.disposeGeometries(t),i!==s&&console.warn(`Progressive GLTF level replaced ${i} of ${s} meshes. Mesh names and scene structures must match.`)}updateTextureImages(){for(const e of this.textures)e.pending&&(e.texture.dispose(),e.texture.image=e.pending.image,e.texture.mipmaps=e.pending.mipmaps,e.texture.needsUpdate=!0,e.pending=null)}},Ctrl=class{engine;scene;model;envCtrls;events;orbitCtrls;fpvCtrls;raycast;objs3D;webs;webCtrls;constructor(e,t,s,i,n,o,a,r,l,d,c){this.engine=e,this.events=n,this.envCtrls=i,this.fpvCtrls=a,this.model=s,this.orbitCtrls=o,this.objs3D=l,this.raycast=r,this.scene=t,this.webs=d,this.webCtrls=c}async init(e){await this.engine.initRenderer(),this.scene.initObjs3D(this.engine.renderer,this.model);for(const e of this.webs.values())for(const t of e)t.start(this.webs,this.webCtrls);this.model&&(this.model.modelReady=this.model.load(e.model.file,this.engine,this.scene),this.model.modelReady.catch(()=>{})),this.envCtrls.init(),this.model&&await this.model.sceneReady,this.raycast.initColliders(),await this.envCtrls.envReady;for(const e of this.objs3D.values())e.ready(this.objs3D);for(const e of this.webs.values())for(const t of e)t.ready(this.objs3D);e.orbitCtrls.enable&&this.orbitCtrls.enable(),e.fpvCtrls.enable&&this.fpvCtrls.enable(),this.events.send({type:"Scene_Ready"},"Scene is set up and ready"),await this.engine.init(),this.model||this.events.sceneRendered({type:"Scene_Rendered"}),this.engine.setAnimationLoop();try{this.model&&!await this.model.modelReady||(e.render.adaptiveGfx?this.engine.updateGfx("idle"):this.engine.gfxEvents.emit({type:"Gfx_Ready",gfxLevel:null}))}catch(e){console.error("Error during model loading.",e)}}},Modules=class{fxaaNode=null;fxaaShader=null;smaaPassClass=null;smaaNode=null;traaNode=null;ssaoPassClass=null;gtaoNodeClass=null;ssgiNodeClass=null;ssrNode=null;ssrPassClass=null;paneClass=null;createBrowserInspector=null;effectComposerClass=null;envLoader=null;dracoLoader=null;gltfLoader=null;ktx2Loader=null;meshoptDecoder=null;outputPassClass=null;renderPassClass=null;shaderPassClass=null;rectAreaLightNodeClass=null;rectAreaLightTexturesLib=null;rectAreaLightUniformsLib=null;orbitControlsClass=null;pointerLockControlsClass=null;webGpuRendererClass=null;renderPipelineClass=null;tslPass=null;tslRtt=null;tslMrt=null;tslContext=null;tslOutput=null;tslDiffuseColor=null;tslVelocity=null;tslRenderOutput=null;tslNormalView=null;tslMetalness=null;tslRoughness=null;tslSample=null;tslVec2=null;tslVec3=null;tslVec4=null;tslFloat=null;packNormalToRGB=null;unpackRGBToNormal=null;cfg;constructor(e){this.cfg=e}consoleLog(e){"none"!==this.cfg.debug.log&&console.log(`Module: ${e} successfully imported`)}async importDracoLoader(){if(!this.dracoLoader&&"draco"===this.cfg.model.compress.mesh)try{const e=await(import("three/addons/loaders/DRACOLoader.js"));this.consoleLog("DRACOLoader"),this.dracoLoader=new e.DRACOLoader,this.dracoLoader.setDecoderPath("draco/")}catch{console.warn("DRACOLoader could not be imported")}}async importEffectComposer(){if(!this.effectComposerClass)try{const e=await(import("three/addons/postprocessing/EffectComposer.js"));this.effectComposerClass=e.EffectComposer,this.consoleLog("EffectComposer")}catch{console.warn("EffectComposer could not be imported")}}async importENVLoader(){if(!this.envLoader&&(this.cfg.envCtrls.enable||this.cfg.envCtrls.load))if("exr"===this.cfg.envCtrls.type)try{const e=await(import("three/addons/loaders/EXRLoader.js"));this.consoleLog("EXRLoader");const t=new e.EXRLoader;this.envLoader=t}catch{console.warn("EXRLoader could not be imported")}else if("hdr"===this.cfg.envCtrls.type)try{const e=await(import("three/addons/loaders/HDRLoader.js"));this.consoleLog("HDRLoader");const t=new e.HDRLoader;this.envLoader=t}catch{console.warn("HDRLoader could not be imported")}}async importFpvCtrls(){if(this.cfg.fpvCtrls.enable||this.cfg.fpvCtrls.load)try{const e=await(import("three/addons/controls/PointerLockControls.js"));this.pointerLockControlsClass=e.PointerLockControls,this.consoleLog("PointerLockControls")}catch{console.warn("PointerLockControls could not be imported")}}async importFXAANode(e){if(!this.fxaaNode&&"fxaa"===e)try{const e=await(import("three/addons/tsl/display/FXAANode.js"));this.fxaaNode=e.fxaa,this.consoleLog("FXAANode")}catch{console.warn("FXAANode could not be imported")}}async importFXAAShader(e){if(!this.fxaaShader&&"fxaa"===e){try{const e=await(import("three/addons/shaders/FXAAShader.js"));this.fxaaShader=e.FXAAShader,this.consoleLog("FXAAShader")}catch{console.warn("FXAAShader could not be imported")}if(!this.shaderPassClass)try{const e=await(import("three/addons/postprocessing/ShaderPass.js"));this.shaderPassClass=e.ShaderPass,this.consoleLog("ShaderPass")}catch{console.warn("ShaderPass could not be imported")}}}async importGLTFLoader(){if(0!==this.cfg.model.file.length)try{const e=await(import("three/addons/loaders/GLTFLoader.js"));this.consoleLog("GLTFLoader"),this.gltfLoader=new e.GLTFLoader}catch{console.warn("GLTFLoader could not be imported")}}async importGtaoNode(e){if(!this.gtaoNodeClass&&e)try{const e=await(import("three/addons/tsl/display/GTAONode.js"));this.gtaoNodeClass=e.ao,this.consoleLog("GTAONode")}catch{console.warn("GTAONode could not be imported")}}async importKTX2Loader(){if(!this.ktx2Loader&&"ktx2"===this.cfg.model.compress.texture)try{const e=await(import("three/addons/loaders/KTX2Loader.js"));this.ktx2Loader=new e.KTX2Loader,this.consoleLog("KTX2Loader")}catch{console.warn("KTX2Loader could not be imported")}}async importMeshoptDecoder(){if(!this.meshoptDecoder&&"meshopt"===this.cfg.model.compress.mesh)try{const e=await(import("three/addons/libs/meshopt_decoder.module.js"));this.meshoptDecoder=e.MeshoptDecoder,this.consoleLog("MeshoptDecoder")}catch{console.warn("MeshoptDecoder could not be imported")}}async importOrbitCtrls(){if(this.cfg.orbitCtrls.enable||this.cfg.orbitCtrls.load)try{const e=await(import("three/addons/controls/OrbitControls.js"));this.orbitControlsClass=e.OrbitControls,this.consoleLog("OrbitControls")}catch{console.warn("OrbitControls could not be imported")}}async importOutputPass(){if(!this.outputPassClass)try{const e=await(import("three/addons/postprocessing/OutputPass.js"));this.outputPassClass=e.OutputPass,this.consoleLog("OutputPass")}catch{console.warn("OutputPass could not be imported")}}async importRectAreaLight(e){if(this.cfg.light.rectArea)if(e){if(this.rectAreaLightTexturesLib)return;try{const e=await(import("three/addons/lights/RectAreaLightTexturesLib.js"));this.rectAreaLightTexturesLib=e.RectAreaLightTexturesLib,this.consoleLog("RectAreaLightTexturesLib")}catch{console.warn("RectAreaLightTexturesLib could not be imported")}}else{if(this.rectAreaLightUniformsLib)return;try{const e=await(import("three/addons/lights/RectAreaLightUniformsLib.js"));this.rectAreaLightUniformsLib=e.RectAreaLightUniformsLib,this.consoleLog("RectAreaLightUniformsLib")}catch{console.warn("RectAreaLightUniformsLib could not be imported")}}}async importRenderPass(){if(!this.renderPassClass)try{const e=await(import("three/addons/postprocessing/RenderPass.js"));this.renderPassClass=e.RenderPass,this.consoleLog("RenderPass")}catch{console.warn("RenderPass could not be imported")}}async importSMAANode(e){if(!this.smaaNode&&"smaa"===e)try{const e=await(import("three/addons/tsl/display/SMAANode.js"));this.smaaNode=e.smaa,this.consoleLog("SMAANode")}catch{console.warn("SMAANode could not be imported")}}async importSMAAPass(e){if(!this.smaaPassClass&&"smaa"===e)try{const e=await(import("three/addons/postprocessing/SMAAPass.js"));this.smaaPassClass=e.SMAAPass,this.consoleLog("SMAAPass")}catch{console.warn("SMAAPass could not be imported")}}async importSSAOPass(e){if(!this.ssaoPassClass&&e)try{const e=await(import("three/addons/postprocessing/SSAOPass.js"));this.ssaoPassClass=e.SSAOPass,this.consoleLog("SSAOPass")}catch{console.warn("SSAOPass could not be imported")}}async importSsgiNode(e,t){if(!this.ssgiNodeClass&&"ssgi"===e&&"traa"===t)try{const e=await(import("three/addons/tsl/display/SSGINode.js"));this.ssgiNodeClass=e.ssgi,this.consoleLog("SSGINode")}catch{console.warn("SSGINode could not be imported")}}async importSsrNode(e){if(!this.ssrNode&&e)try{const e=await(import("three/addons/tsl/display/SSRNode.js"));this.ssrNode=e.ssr,this.consoleLog("SSRNode")}catch{console.warn("SSRNode could not be imported")}}async importSsrPass(e){if(!this.ssrPassClass&&e)try{const e=await(import("three/addons/postprocessing/SSRPass.js"));this.ssrPassClass=e.SSRPass,this.consoleLog("SSRPass")}catch{console.warn("SSRPass could not be imported")}}async importStatelyAi(){if(!this.createBrowserInspector&&this.cfg.stateMachine.inspector)try{const e=await(import("@statelyai/inspect"));this.createBrowserInspector=e.createBrowserInspector,this.consoleLog("StatelyAi Inspector")}catch{console.warn("StatelyAi Inspector could not be imported")}}async importThreeTsl(){if(!this.tslPass)try{const e=await(import("three/tsl"));this.tslPass=e.pass,this.tslRtt=e.rtt,this.tslMrt=e.mrt,this.tslContext=e.context,this.tslOutput=e.output,this.tslDiffuseColor=e.diffuseColor,this.tslVelocity=e.velocity,this.tslRenderOutput=e.renderOutput,this.tslNormalView=e.normalView,this.tslMetalness=e.metalness,this.tslRoughness=e.roughness,this.tslSample=e.sample,this.tslVec2=e.vec2,this.tslVec3=e.vec3,this.tslVec4=e.vec4,this.tslFloat=e.float,this.packNormalToRGB=e.packNormalToRGB,this.unpackRGBToNormal=e.unpackRGBToNormal,this.consoleLog("Three TSL")}catch{console.warn("Three TSL could not be imported")}}async importThreeWebGpu(){try{const e=await(import("three/webgpu"));this.webGpuRendererClass=e.WebGPURenderer,this.renderPipelineClass=e.RenderPipeline,this.rectAreaLightNodeClass=e.RectAreaLightNode,this.consoleLog("WebGPU")}catch{console.warn("Three WebGPU could not be imported")}}async importTRAANode(e){if(!this.traaNode&&"traa"===e)try{const e=await(import("three/addons/tsl/display/TRAANode.js"));this.traaNode=e.traa,this.consoleLog("TRAANode")}catch{console.warn("TRAANode could not be imported")}}async importTweakpane(){if(this.cfg.gui.inspector.enable)try{const e=await(import("tweakpane"));this.paneClass=e.Pane,this.consoleLog("Tweakpane")}catch{console.warn("Tweakpane could not be imported")}}},_0x1a71ae=_0x5746;!function(){const e=_0x5746,t=_0x1562();for(;;)try{if(-parseInt(e(303))/1+-parseInt(e(216))/2*(parseInt(e(238))/3)+-parseInt(e(269))/4*(-parseInt(e(300))/5)+-parseInt(e(214))/6*(parseInt(e(301))/7)+parseInt(e(234))/8*(parseInt(e(249))/9)+-parseInt(e(282))/10+parseInt(e(287))/11==815679)break;t.push(t.shift())}catch(e){t.push(t.shift())}}();var e=class extends HTMLElement{[_0x1a71ae(221)];[_0x1a71ae(237)];[_0x1a71ae(263)];[_0x1a71ae(259)];[_0x1a71ae(285)];[_0x1a71ae(290)];[_0x1a71ae(271)];constructor(){const e=_0x1a71ae;super(),this[e(290)]=this[e(266)]({mode:e(291)}),this[e(290)][e(289)]=e(235);const t=document[e(256)](e(294));t[e(261)]=e(299),this[e(290)][e(260)](t);for(const t of[e(250),e(231),e(222),e(233)])this[e(304)](t,t=>t[e(220)]());const s=this[e(290)][e(245)](e(307));s[e(304)](e(250),()=>this[e(254)](s));const i=this[e(290)][e(245)](e(253));i&&i[e(304)](e(250),()=>{const t=e,s=t(293)===i[t(252)](t(283));i[t(284)](t(283),!s),i[t(281)]=t(s?217:241),this[t(276)](!s)})}[_0x1a71ae(224)](){const e=_0x1a71ae,t=this[e(290)][e(245)](e(307));t&&(t[e(286)]=!0)}[_0x1a71ae(229)](e){const t=_0x1a71ae;this[t(237)]=e,this[t(263)][t(236)][t(244)]&&this[t(275)](0),this[t(237)][t(227)][t(304)](t(274),e=>{const s=t;this[s(275)](e[s(297)])}),this[t(237)][t(227)][t(304)](t(223),e=>{const s=t;this[s(277)](this[s(263)][s(236)][s(257)]),this[s(275)](e[s(297)])})}[_0x1a71ae(277)](e){const t=_0x1a71ae,s=this[t(290)][t(245)](t(307));if(s&&(s[t(286)]=!e,!e)){s[t(284)](t(283),t(213));const e=s[t(245)](t(296));e&&(e[t(289)]=t(306))}}[_0x1a71ae(275)](e){const t=_0x1a71ae,s=this[t(290)][t(245)](t(298));if(!s)return;if(s[t(268)]=null===e,null===e)return;const i=this[t(237)][t(258)]();if(s[t(240)]!==i[t(280)]){s[t(242)]();for(let e=0;e<i[t(280)];e++){const e=document[t(256)](t(270));e[t(279)][t(247)](t(215)),s[t(260)](e)}}for(const[n,o]of i[t(272)]())s[t(292)][n][t(279)][t(239)](t(273),o<=e)}[_0x1a71ae(226)](e){const t=_0x1a71ae;if(!e||!this[t(290)])return;const s=this[t(290)][t(245)](t(308));s&&(s[t(294)][t(259)]=this[t(259)])}[_0x1a71ae(264)](e){const t=_0x1a71ae;if(!e||!this[t(290)])return;const s=this[t(290)][t(245)](t(278));s&&(s[t(294)][t(232)]=this[t(285)])}[_0x1a71ae(295)](e){const t=_0x1a71ae;if(e||!this[t(290)])return;const s=this[t(290)][t(245)](t(262));s&&(s[t(261)]=t(243))}[_0x1a71ae(254)](e){const t=_0x1a71ae;e[t(279)][t(230)](t(251))||e[t(279)][t(247)](t(251));const s=!(t(293)===e[t(252)](t(283)));e[t(284)](t(283),s),this[t(237)][t(305)](s);const i=e[t(245)](t(296));i&&(i[t(289)]=t(s?255:306))}[_0x1a71ae(276)](e){const t=_0x1a71ae;e?this[t(221)][t(288)]():document[t(302)]()}};function _0x5746(e,t){e-=213;const s=_0x1562();let i=s[e];if(void 0===_0x5746.EyGPHJ){_0x5746.megtnk=function(e){let t="",s="";for(let s,i,n=0,o=0;i=e.charAt(o++);~i&&(s=n%4?64*s+i:i,n++%4)&&(t+=String.fromCharCode(255&s>>(-2*n&6))))i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(i);for(let e=0,i=t.length;e<i;e++)s+="%"+("00"+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(s)},_0x5746.ShGwkT={},_0x5746.EyGPHJ=!0}const n=s[0];_0x5746.HFXnMO!==n&&(_0x5746.ShGwkT={},_0x5746.HFXnMO=n);const o=_0x5746.ShGwkT[e];return void 0===o?(i=_0x5746.megtnk(i),_0x5746.ShGwkT[e]=i):i=o,i}function _0x1562(){const e=["C3rVCfbYB3bHz2f0Aw9U","y2fUDMfZ","Cg9PBNrLCM1VDMu","r2z4x1jLywr5","y29UBMvJDgvKq2fSBgjHy2S","z3vP","C2v0qMfJA2DYB3vUzenVBg9Y","z2z4rxzLBNrZ","BwvUDujHCG","C2v0rw5NAw5L","y29UDgfPBNm","Cg9PBNrLCMrVD24","yMfJA2DYB3vUzeLTywDL","Cg9PBNrLCNvW","mJrozuLjCKq","pgrPDIbPzd0IBwvUDwjHCIi+dqOGidXKAxyGAwq9iM1LBNvIDxr0B25ZiJ4ncIaGica8ysbPzd0IBg9NBYiGAhjLzJ0IAhr0Chm6lY9PBgX1DgLVBNmUy29TiIb0yxjNzxq9iL9IBgfUAYiGCMvSpsjUB29Wzw5LCIbUB3jLzMvYCMvYiJ48l2e+dqOGicaGpgj1DhrVBIb0ExbLpsjIDxr0B24IigLKpsjLy28IigfYAweTChjLC3nLzd0IzMfSC2uIigrPC2fIBgvKpG0kicaGicaGphnWyw4GAwq9iMvJBY1RBM9IiJ48l3nWyw4+dqOGicaGica8C3bHBIbPzd0IzwnVlxrLEhqIpKvJBZXICJ5ptJWVC3bHBJ4ncIaGica8l2j1DhrVBJ4ncIaGica8zgL2igLKpsjNzNGIigHPzgrLBJ48l2rPDJ4ncIaGica8yNv0Dg9Uihr5Cgu9iMj1DhrVBIiGAwq9iNnPEMuIigfYAweTChjLC3nLzd0IzMfSC2uIihrPDgXLpsjnyxHPBwL6zsi+pc9IDxr0B24+dqOGidWVzgL2pG0kica8zgL2igLKpsjSAwnLBNnLiJ48l2rPDJ4ncJWVzgL2pG","CMvUzgvY","zw5NAw5L","m2DtzgvUCq","Dg9Nz2XL","y2HPBgrfBgvTzw50q291BNq","twLUAw1PEMu","CMvWBgfJzunOAwXKCMvU","WQKGAwXSDxrPB25Zig5VBI1JB21TzxjJAwfSihvZzsbVBMX5","ywrHChrPDMvhzNG","CxvLCNLtzwXLy3rVCG","zgvMAw5L","ywrK","AwX1lw1I","mZKXmZi5zfD0vvvI","y2XPy2S","Aw50zxjHy3rLza","z2v0qxr0CMLIDxrL","i3nPEMu","Dg9Nz2XLrwnVtw9Kzq","rwnVpgjYpK9grG","y3jLyxrLrwXLBwvUDa","zwnVtw9Kzq","z2v0r2z4tgv2zwXZ","yMfJA2DYB3vUzenVBg9Y","yxbWzw5K","Dgv4DenVBNrLBNq","i2XPy2vUC2u","y2zN","C2v0tg9NBW","z2v0","yxr0ywnOu2HHzg93","zw5HyMXL","AgLKzgvU","nezfzvf4yW","C3bHBG","DMfSAwq","zw50CMLLCW","ywn0AxzL","r2z4x0nOyw5Nzwq","C2v0r2z4sw5KAwnHDg9Y","Dg9Nz2XLu2nYzwvUu2L6zq","C2v0rwnVqxzHAwXHyMXL","i2XVz28","y2XHC3nmAxn0","BgvUz3rO","DgL0Bgu","nta1mZe0me5cCwTpCq","yxjPys1WCMvZC2vK","C2v0qxr0CMLIDxrL","Bg9NBW","zgLZywjSzwq","mZCXmJe0ntHNEhryAg4","CMvXDwvZDez1BgXZy3jLzw4","Aw5Uzxjive1m","C2HHzg93uM9VDa","y2XVC2vK","y2HPBgrYzw4","Dhj1zq","C3r5Bgu","C2HVD0XPy2vUC2u","i2vJBY10zxH0","z2z4tgv2zwW","i2DMEa","i21LBNvIyxiGEW0kicb6lwLUzgv4oIaXmdaWoW0kicbWB3nPDgLVBJOGzML4zwq7ic8Qie9YAwvUDgf0zxmGDg8GDMLZDwfSihzPzxDWB3j0ig9UigfUzhjVAwqGzgv2AwnLCYWGywjZB2X1DguGBM90icOVdqOGigjVDhrVBtOGmJbWEdSGBgvMDdOGntaLoW0kicb0CMfUC2zVCM06ihrYyw5ZBgf0zvGOltuWjsK7ia0kicbKAxnWBgf5oIbMBgv4oW0kicbMBgv4lwrPCMvJDgLVBJOGy29SDw1UoYaGicaGia0kicbHBgLNBI1PDgvTCZOGy2vUDgvYoW0kicbMB250lxnPEMu6ideYChG7dqOGigzVBNqTzMfTAwX5oIbbCMLHBcWGsgvSDMv0AwnHlcbZyw5ZlxnLCMLMoYaGicaGdqOGigDHCdOGnhb4oW0kFq0kdqOJBwvUDwj1DhrVBNmGEW0kicbKAxnWBgf5oIbMBgv4oW0kicbHBgLNBI1PDgvTCZOGy2vUDgvYoW0kicbNyxa6idm1ChG7dqOGihbHzgrPBMC6idvWEcaYmhb4oW0kicbMB250lwzHBwLSEtOGqxjPywWSieHLBhzLDgLJysWGC2fUCY1ZzxjPzJSncIaGzM9UDc1ZAxPLoIaXCMvToW0kicbJB2XVCJOGi2zMzJSncIaGyMfJA2DYB3vUzdOGi2zMzMzMzJi5oW0kicbIB3jKzxi6idfWEcbZB2XPzcaJzMzMzMzMmgq7dqOGigjVCMrLCI1YywrPDxm6idjLBtSncIaGyM94lxnOywrVDZOGAw5ZzxqGmcaXChGGm3b4icnMzMzMzMy0mcWGAw5ZzxqGmcaTmtbWEcaXohb4icmWmdaWmdaYmdSncIaGyMfJA2rYB3aTzMLSDgvYoIbIBhvYkdeYChGPoW0kicaTD2vIA2L0lwjHy2TKCM9WlwzPBhrLCJOGyMX1CIGXmNb4ktSncIaGy3vYC29YoIbKzwzHDwX0oW0kicbWB2LUDgvYlwv2zw50CZOGyxv0BZSncN0ncG0ki2XVz28GEW0kicbVCgfJAxr5oIaWlJG7dqOGign1CNnVCJOGCg9PBNrLCJSncIaGzgLZCgXHEtOGAw5SAw5LlwjSB2nRoW0kicb3Awr0AdOGms44zw07igHLAwDODdOGms44zw07dqOGigjHy2TNCM91BMqTC2L6ztOGy29UDgfPBJSncIaGyMfJA2DYB3vUzc1YzxbLyxq6ig5VlxjLCgvHDdSncIaGyMfJA2DYB3vUzc1WB3nPDgLVBJOGy2vUDgvYoW0kicaVkIbfBMnVzgvKihzPysbODhrWCZOVl3LVA3nLBc5NAxrODwiUAw8VDxjSlwvUy29KzxiVicOVdqOGigjHy2TNCM91BMqTAw1Hz2u6ihvYBcGIzgf0ytPPBwfNzs9ZDMCREg1SlcuZq3n2zYb2zxjZAw9UpsCXlJiNihHTBg5ZpsDODhrWoI8VD3D3lNCZlM9YzY8YmdaWl3n2zYCGDMLLD0jVEd0NmcaWidi0ncaYoduNihDPzhrOpsCYndqNigHLAwDODd0NmJG1jYuZrsuZq3n0EwXLjtnfic5ZmcaLn0iGzMLSBdOGjtiZzJqWyJu3icu3rcaLm0mVC3r5BguLm0uLm0nWyxrOigLKpsDtAgfWzsaXjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBtuYidb2mJG1Bc01ms02mI4Yn3yTmtyWlJq2EICVjtnfjtndCgf0AcbPzd0Nu2HHCguGmsbJB3b5jYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBte0ocaWDJi4nwWTnteTnJiUmJD2lte2mc40nNONlYuZrsuZq3bHDgGGAwq9j1nOyxbLideGy29WEsaYjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBti0ncaWDJi4nwWTnteTnJiUmJD2lte2mc40nNONlYuZrsuZqY9ZDMCLm0uIktSncN0ncG0ki2vJBYb7dqOGigrPC3bSyxK6igzSzxG7dqOGigfSAwDUlwL0zw1ZoIbJzw50zxi7dqOGihbVC2L0Aw9UoIbYzwXHDgL2ztSncIaGCgfKzgLUzZOGmdSncIaGD2LKDgG6idGWChG7igHLAwDODdOGmZzWEdSncIaGyMfJA2DYB3vUzc1JB2XVCJOGiZaWmdaWmdq0oW0kicbIB3jKzxiTCMfKAxvZoIaYmhb4oW0kicbIB3jKzxi6ig5VBMu7dqOGign1CNnVCJOGCg9PBNrLCJSncIaGDhjHBNnPDgLVBJOGyMfJA2DYB3vUzc1JB2XVCIaWlJnZigvHC2u7dqP9dqOncInLy286zgLZywjSzwqGEW0kicbVCgfJAxr5oIaWlJm1oW0kicbJDxjZB3i6ig5VDc1HBgXVD2vKoW0kFq0kdqOJzwnVlwTUB2iGEW0kicb6lwLUzgv4oIaYoW0kicbVCgfJAxr5oIaWlJK7dqOGihbVC2L0Aw9UoIbHyNnVBhv0ztSncIaGBgvMDdOGnNb4oYaVkIbtDgfYDhbVC2L0Aw9UigXLzNqGkI8ncIaGD2LKDgG6idi1ChG7igHLAwDODdOGmJvWEdSncIaGyMfJA2DYB3vUzc1JB2XVCJOGD2HPDgu7dqOGigjVCMrLCI1YywrPDxm6iduWjtSncIaGDhjHBNnPDgLVBJOGDhjHBNnMB3jTidaUm3mGzwfZzs1PBI1VDxq7dqP9dqOncInLy28TDgv4Dcb7dqOGihOTAw5KzxG6ide7ic8QiejLAgLUzcbRBM9IicOVdqOGig9WywnPDhK6idaUodSncIaGzgLZCgXHEtOGzMXLEdSncIaGCgfKzgLUzZOGmcaXnhb4oW0kicb3Awr0AdOGmtaWjtSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lwvUzdSGlYOGvgv4DcbYAwDODcaQlW0kicbMB250lxDLAwDODdOGyM9SzdSncIaGzM9UDc1ZAxPLoIaWlJLLBtSncIaGDhjHBNnPDgLVBJOGy29SB3iGm3m7dqOGignVBg9YoIb3AgL0ztSncN0ncG0klYOGrwnVigfJDgL2zsbIywnRz3jVDw5KicOVdqOJzwnVw2fYAweTChjLC3nLzd0IDhj1zsjDihSncIaGyMfJA2DYB3vUzc1JB2XVCJOGi2y0mgi1nZK5oW0kFq0kdqOVkIbfy28Gywn0AxzLihrLEhqGkI8ncInLy29ByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY10zxH0ihSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lxn0yxj0oW0kFq0kdqOVkIbfy28Gywn0AxzLigTUB2iGkI8ncInLy29ByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY1RBM9IihSncIaGDhjHBNnMB3jToIb0CMfUC2XHDgvykdqYChGPoYancN0ncG0klYOGrwnVigLUywn0AxzLicOVdqOJzwnVw2fYAweTChjLC3nLzd0IzMfSC2uIxsaJzwnVlxrLEhqGEW0kicbQDxn0Awz5lwnVBNrLBNq6igzSzxGTzw5KoW0kicb0zxH0lwfSAwDUoIbSzwz0oW0kFq0kdqOJzwnVlMLUDgvYywn0zwrByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY10zxH0ihSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lxn0yxj0oW0kicbHBMLTyxrPB246igzHzguTDg8TzwnVlw9MzIaWlJrZigvHC2uTAw4TB3v0oW0kFq0kdqOJzwnVlMLUDgvYywn0zwrByxjPys1WCMvZC2vKpsjMywXZzsjDicnLy28TDgv4Dcb7dqOGigP1C3rPzNKTy29UDgvUDdOGzMXLEc1LBMq7dqOGigfUAw1HDgLVBJOGzMfKzs10BY1Ly28TB24Gmc40CYbLyxnLlwLUlw91DdSncN0ncG0kqgTLEwzYyw1LCYbMywrLlxrVlwvJBY1VzMyGEW0kicaWjsb7ig9WywnPDhK6idaUodSGFq0kicaYmcuGEYbVCgfJAxr5oIaWoYb9dqOGideWmcuGEYbVCgfJAxr5oIaWlJG7ih0ncN0ncG0kqgTLEwzYyw1LCYbMywrLlxrVlwvJBY1VBIb7dqOGidaLihSGB3bHy2L0EtOGmc44oYb9dqOGidiWjsb7ig9WywnPDhK6ida7ih0ncIaGmtaWjsb7ig9WywnPDhK6idaUodSGFq0kFq0kdqOJz2z4ihSncIaGD2LKDgG6idiWChG7dqOGigHLAwDODdOGmJvWEdSncIaGzgLZCgXHEtOGzMXLEdSncIaGzMXLEc1KAxjLy3rPB246ignVBhvTBI1YzxzLCNnLoW0kicbQDxn0Awz5lwnVBNrLBNq6ignLBNrLCJSncIaGz2fWoIaZChG7dqOGihbVAw50zxiTzxzLBNrZoIbUB25LoW0kFq0kdqOJz2z4w2HPzgrLBL0GEW0kicbKAxnWBgf5oIbUB25LoW0kFq0kdqOUz2z4lwXLDMvSihSncIaGzMXLEdOGmcaWidnWEdSncIaGD2LKDgG6ideWmcu7dqOGigjHy2TNCM91BMqTy29SB3i6icmWmdaWmda0ndSncN0ncG0klMDMEc1SzxzLBc5Hy3rPDMuGEW0kicbVCgfJAxr5oIaWlJC7dqOGigjHy2TNCM91BMqTy29SB3i6ihDOAxrLoW0kFq0kdqOJC2L6zsb7dqOGig9WywnPDhK6idaUodSncIaGD2LKDgG6idjLBtSGAgvPz2H0oIaYzw07dqOGigjHy2TNCM91BMq6ig5VBMu7dqOGigjVCMrLCJOGBM9UztSncIaGy3vYC29YoIbWB2LUDgvYoW0kicbIywnRz3jVDw5KlxnPEMu6ignVBNrHAw47dqOGigjHy2TNCM91BMqTCMvWzwf0oIbUBY1YzxbLyxq7dqOGigjHy2TNCM91BMqTCg9ZAxrPB246ignLBNrLCJSncIaGlYOGrw5JB2rLzcb2AweGAhr0Chm6lY95B2TZzwWUz2L0AhvIlMLVl3vYBc1LBMnVzgvYlYaQlW0kicbIywnRz3jVDw5KlwLTywDLoIb1CMWOiMrHDge6Aw1Hz2uVC3zNk3HTBcWLm0nZDMCGDMvYC2LVBJ0Nms4YjYb4BwXUCZ0NAhr0CdOVl3D3DY53mY5VCMCVmJaWmc9ZDMCNihzPzxDcB3G9jZaGmcaZmdGGmZeYjYb3Awr0Ad0NmZa4jYbOzwLNAhq9jZmXmICLm0uLm0nZDhLSzsuZrsaUCZaGjtDcigzPBgW6icuYm2zMzMzMzIaLn0qGjtndl3n0EwXLjtnfjtndCgf0AcbPzd0Nq29SB3iGrMLSBcaXjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBteZlJy3idCUmdvSnZmUmtCTmc4XmYa0lJyGnc42m2mYlJuZidiUntuGnc42idyUmtiGnc42idCUotuGmcaXlJGYlteUntiGns4ZnY0ZlJm2idCUodGTmY4Zmsa0lJq5ltmUnJKGnc41nY00mI44mIa1lJm5Bdm2lJK5idm3lJm0yZi5lJK2idmWlJi0idm3lJaXidm4lJiXidm3lJa2idqXlJKGmc4WncaYlJuXlteUnJeGnI40ns0ZlJy1idGUnZuTmI42nYaZlJaXltuUmZqGnc4XnY05lJq5idqUmtmTns4Yos0WlJa3ltGUodmTmY4Xnc03os4Yns03mY44nMWWlJaYide3lJG0yZaUmdeGos44ms0WlJCZide5lJmZlteUnJmGmJeUmtuTmc45msaXlJGZltmUodGGnc40nc02lJyXiduUodeTmI43mIaXlJm3ltuUmZiGmI40os01lJC3idiUndKTmc40nIaWltmUndmTmI4Ync0XmI4Zoc05lJK2Bc0WlJm4ltCXlJf6BtiWnY45ncaWBdCZlJe3ltaUmtiGos4YidKUmJuTmc4Wmsa3ms4ZnI00lJe4idqUntzJltiUndiGmI42nc01lJKYidqUntyToc4Zmsa0lJu2ltiUmJCGmc01lJK4lteUmtiToc4Yns0YlJq5ltqUmdiTmI40mI00lJeZltiUotGTnc4XmY0Yms41nYaWlteYlJG4ltaUntKTmtKUmdGTms44mY0Xos4Woc0XlJaXidaTmtCUosaXnI4Wnc0ZnY41ncaZns42ns0Zmc4ZncaZmc4Yos0ZnI40nIaZns42nI00mc42nYaZns43ms0ZlJi0idaUmdqTnI41nY0XlJuYltKUnJqTnc41mY0ZlJG1ltmUnZGTnc40os01lJq5ltmUntKTos41ocaWlJC4ltmUntuGmteUmJyTmtuUmJqGmZyUndqTndaUnJyGmtKUndqTmtKUnJiGmZuUmZyTmZyUmJqGmZuUmZyTmZyUotiGmc4Wms0WlJy5ltCUnZGTms4Yns0XnY4Zms0XlJi1ltKUntmGmc0Xoc41ns0WlJu2ltiWlJa0lteUmJqTms40os0WlJy5ltmUnZeTmY4ZltqUotuTns44ms0XlJiZltiUnteTmI4ZmY01lJi1ltiUndmTnI4Wos0WlJeTmc44nsaXlJGXltmUodmGnc4YnI02lJy0EM0TmteXlJe3ide4mc44ogmZlJy0idaGnI41nYaXlJqXidKUndyGnc41nYaYlJmGmI41msa0lJeZidyUndmGnc4Woca4lJCXltaUmdGGmY4XmY05lJmXideZlJqYltC1lJeGnZKUnZfSndaUndmTmc4WnIaZlJmGnc45ogmYlJaZidmUmdCGmI45osa2lJu4idiUndGGos4XmY0WlJq1idiUmJGTmI41iduUnJyTnc41nca3lJuTmY40osaZlJe1ltuUotiGmY4Zns03nI4ZmYaZlJm2Bc05lJaYltKUmI0WlJaZltm0lJq0yY0WlJaXltiYlJK5idaUnJeTmZuUnJCGms45ltm4lJe2ideUmduTmI4WnIaZlJa5ltqUnJuGnc41mY01lJC2ideUndqTms4Xmsa0lJy2ltiUmduGnY4XnI0YlJa3idiUnJKTmc4Wnca2lJiYideUnJmGoc42nIa0lJa5idmUodCGmY44osa0lJe1iduUmZqGnc43oca0ms4ZowWZnI40oc0ZnI44n2mZmI4Zoc0ZmI43ncaZnY4WnY0ZnI44oca0ms43nI0ZnI44ohPTodGUndmGmc4Wm2m0lJq4idaUmdmGos43mIa0lJyYidqWlJyYidm1lJy2ide5lJuYide5lJyGmZyUndiGmZuUnJqGmZCUntuGmZuUnJuGms41msaWlJaYidiUmtCTns4XnIaYlJG5ltm4lJu5BduUnZCTmY4WmMm0lJq1ltiUmZmGnI41nc0YlJyYidKUmdGTms4YnsaXlJGYidaUotGGnc41ocaZlJm3idyUmtuGns4ZmIaYlJuGmY4XidiUodCGnY45ocaZlJa1idC0lJLSltGUodiGos4XmY0ZnI41ltaUmdzJlti2lJa4ltaUmdqTmZCUmJqTmc42mY0Zos4Xms0YlJa3lteUndqTms4Xms0ZlJq5ltmUnY00lJu0ltuUnZyTms4WnI0YlJa1lteUotuTnc42nI0XlJK4ltuUodeTmc4WmY0XlJe0ideUodmTnc4XmIa0lJeZltyUnJmGnc4Xms00lJq4idqUntmTnc41nYa0mI45nI00lJu2Bc0Zns43mI0ZnI4XyY0Xos42nc0Xos44ns0ZnI41nc0ZnY43nY0ZnY41nc0Zos44mY0XlJaXltiUmduTms45mY00lJC1ltiUmduTnI0WlJeZlteUmJqGms44mY00lJiZidqUmZuTnI42mYaYlJK2ltiUodmGnI4Zos00lJm3idKUnZeTnc4ZnxONlYuZrsuZqY9ZDMCLm0uIktSncN0ncG0ki3nPEMvByxjPys1WCMvZC2vKpsj0CNvLiL0GEW0kicaVkIbfBMnVzgvKihzPysbODhrWCZOVl3LVA3nLBc5NAxrODwiUAw8VDxjSlwvUy29KzxiVicOVdqOGigjHy2TNCM91BMqTAw1Hz2u6ihvYBcGIzgf0ytPPBwfNzs9ZDMCREg1SlcuZq3n2zYb2zxjZAw9UpsCXlJiNihHTBg5ZpsDODhrWoI8VD3D3lNCZlM9YzY8YmdaWl3n2zYCGDMLLD0jVEd0NmcaWidmWocaZmtiNihDPzhrOpsCZmdGNigHLAwDODd0NmZeYjYuZrsuZq3n0EwXLjtnfic5ZmcaLn0iGzMLSBdOGjtiZzMzMzMzMicu3rcaLm0mVC3r5BguLm0uLm0nWyxrOigLKpsDdB2XVCIbgAwXSidiNigzPBgWTCNvSzt0NzxzLBM9KzcCGy2XHC3m9j3mWjYbKpsDTos4ZmsaXmc40nMmTmY41idiUnJqTnc41mIa0lJC1ltqUnca5lJeXidaUmtqGns4XmYaZlJC5idKUmZiGmZCUmdmGndiUntzSmZyUodGGmZyUodHJltm4lJu5idaUodiTmZKUmdeGmc45ms00mI4ZmIa1lJm5lteUoduGmI41ms0ZlJm3idyUmduTmY4ZnYa3lJG3idaGms44mIaXlJuYiduUmZCGmY4ZnYa3lJG3BdmUmZCGnc41nMm3nc43ocaWlJa5idC1lJq4idaUmdiGnZKUmteTmY42ocaZlJyTmY42ocaZlJCTnc43ncaZlJCZltqXlJq4BdaUmdqTmZCUnZfJltCUmdCTns4YmY0Xmc42ms02lJC1lteYlJq0ltyUnZuTms44mIaWltuUmZyGms41mI03lJG3idmUmZGTnc41msaZlJm0ltqUntyGmY41nI00lJu2idiYlJqZidaGmtaUndGTmc41nIaXos4Wns0XlJi0ide5lJa1ltaUnJGTmc4Wms0XnY42ns0XnI40ms0ZnY43ms0ZnI40nc0Yoc42nc0Yoc42ms0ZnY4Zoc0ZnI40mY00mc43nY0ZnI40ns0YlJm2ltaUmdeTnI4ZnsaXlJuYltGUoduGmY40mxPTmJm5lJqGmZqUmtLSltm3lJu5idm3lJyZyY0WlJuZltqWlJi0ltaUntGTndaUndKTns4Wos00mY44mI0YlJuTms44nI02lJa5ltmUmZuTnY45nY0ZlJmYlteUodCGmc4WmY01lJqYideUntuTnY44nYaZlJm3Bc00lJq2idmUmZjJltaUmdKGnZqUnZGTmc4WmIa3ns40ocaZlJy5idC5lJeXidmUnJCGmY41osa0lJC4idmUnJKGndeUmdyGmY43nYaZnI42nIaWlJa4idm3lJm2idaUmdeGndaUotKTmY42osaYlJaZltiUmdGGmY43mY01lJy0idmUnZGTnY45mIaWlJa2ltiUmJGTms40mI02lJe5ltmUmJGToc43ltmUmZqTnc41mY0ZlJuXltqUntyTmJiUodqTnc41m2WTmtKUndGGmc4WmMm3ms41os03ms43nca3mY42nI03nc4Xnsa3mY43ms04mc4WmIaWlJa0ltqUodKTmc45mI02lJK0ltqUnteTos41os0YlJuXlteUoduTnI4Zns0ZlJm1ltGUntuTmY4Zms0YlJK3idaUmdqTmtmUnJKGos43nI00ms41osaZnY42ohPTltiWnc40ide0mY4WngmTmI40msaWlJq1ltuUodGGmI4XmY03lJCYidmUnZmTmI4WnsaXlJC3ltmUmZyGnc45oc0ZlJm5idGUmJGTmc4WmYaZlJq3ideUmYa2lJy5idmUnZmGos4WnsaZlJm3idmUmJyGns43osaZlJCGmJiUodmGnc4XngWXos4WnIaWlJq5yY02nc44nsa2ns41oc03mY43nYa3ns41oc03mY44msa3oc43mY0WlJaZidiUmJCGms40nIa2lJe5idmUmZeGoc43idiUmJCGmY4WnYa0lJG3idqUntuGnY45mYa0lJuZidiUnteTmc4Wmsa1lJq2ltaUntCGnI41ns0XlJi0ideUmdKTmc42nYaXoc4Ync0XnY4YnIaZoc4XmI0ZnI44nMWZnI4Xnc0Zns42m2mWlJGYidm4lJu5idaUoteGmZKUmdeGns4Zoca0mI4ZmIaYlJuXideUodyGnI4WnsaZlJm3idCUodCGmY4ZnYaXlJGZidaGns4ZnY0XlJuXidCUodGTmY4Zn2W0lJu2ltmUmZDJmc4Woc03nc44idaUmdiTnZuUndCTmY42os03os4WmY0ZlJu4ltmUndiTns41ltmUnJmTmZCUmdGTnc4Xnc0Xoc4Zms0WlJi5ltm1lJi3ltaUmtyTmZCUnJCGmc4ZEM0XndqUnYaZlJGZyY0ZlJKXidmUodmTmY45msaZlJKYltmUnIa0ms40ngWWlJmYidm3lJzJnY4WnIa1lJiZideWlJyXidyUnZqGmtiUndmGnI43ncaXlJGYidaGns4ZnY0XlJuXidCUodCTmY4ZnYa0lJu1ltmUmZyGnc41nI0ZlJqZidqUntmTmJmUnJHSltaUmdiTmJaUm2m2os43osa2os42nsa3nI4Ymsa3ns4ZmYa4mc40nca3ns40msaZlJa4idaUmdyGnI4Zoc0XlJm1idGUnJyTmY42ocaYlJqXltiUndyGmY43ltuUocaZlJy5ltKUntCTmc4Wms01lJm1ltiUodGToc42oc0ZnI40mI00mI4Yn2WTmZyUndiTmZyUndzJmZCUnZeTmc44mIaZoc4Xoc0WlJKZidqXlJq4ltuUmZKGms44nI0YlJuXidmUmZGTnI4WnsaZlJm4ltCUodCGmc0XlJGZlteUntiTns4ZnY0ZlJm4ltCUodHSltmUmZCTnc41nwmTnZuUmtyGmc03ns43mYaWlJa1ltC5lJu5idmUodn6jY8Lm0uLm0mVC3zNjtnfiIK7ia0kFq0kdqOJBgLJzw5Zzsb7dqOGigzVBNqTC2L6ztOGmc45zw07dqOGihDOAxrLlxnWywnLoIbUB3DYyxa7dqOGihrLEhqTywXPz246ignLBNrLCJSncIaGBgLUzs1OzwLNAhq6ideUnwvToW0kicbJB2XVCJOGi2zMzMzMzJK5oW0kFq0k","mJy2mJyXnvHyD0XxDa","mtaWotmWmZr6sxjzEuO","zxHPDez1BgXZy3jLzw4","oty3ndu3C2f6BvPh","ywrKrxzLBNrmAxn0zw5LCG","C2v0rwnVqNv0Dg9Uqwn0AxzL","rwnVpgjYpK9o","i2vJBW","i21LBNvIDxr0B25Z","zMfSC2u","nNfjzhjkAq","z2z4lwXLDMvS","nJe0nJy0s3H3EMLH","twf4Aw1PEMu","Dw5KzwzPBMvK","yxbWzw5Kq2HPBgq"];return(_0x1562=function(){return e})()}function n(t,s,i,n,o){return function(t,s,i,n,o){const a=_0x5746;let r;if(1==(+!!s[a(225)][a(228)][a(267)]|1^+(!0===i))){const n=a(248);customElements[a(265)](n)||customElements[a(246)](n,e),r=document[a(256)](n),r[a(259)]=s[a(225)][a(228)][a(259)],r[a(285)]=s[a(225)][a(228)][a(285)],r[a(221)]=t,r[a(263)]=s,r[a(264)](i),r[a(226)](i),r[a(295)](i),t[a(219)](r)}const l=new n(...o);return r&&r[a(229)](l[a(237)]),l}(t,s,1===((_0x1a71ae(218)!=typeof _0xb62ff0&&_0xb62ff0)^i),n,o)}var App=class e{audio;ctrl;engine;model;envCtrls;events;orbitCtrls;fpvCtrls;raycast;scene;stateMachine;webCtrls;cam3D;inspector;comps;objs3DMap=new Map;websMap=new Map;constructor(e,t,s,i){this.comps={scene:{},web:{}};const n=s.scene??{};for(const[t,s]of Object.entries(n)){const n=new("function"==typeof s?s:s.class)(e,i,t,"function"==typeof s?void 0:s.params);n instanceof Cam3D&&(this.cam3D=n),this.objs3DMap.set(t,n),this.comps.scene[t]=n}this.cam3D??=new Cam3D(e,i,"Cam3D"),this.stateMachine=new StateMachine(i,t),this.events=new Events(i,this.stateMachine),this.scene=new Scene(this.cam3D,i,this.events,this.objs3DMap),this.engine=new Engine(this.scene,this.cam3D,e,i,this.events,t,this.objs3DMap),this.webCtrls=new WebCtrls(this.cam3D,this.engine,i.comps.overlap.padding),this.envCtrls=new EnvCtrls(i,this.engine,this.scene,this.events,t),this.orbitCtrls=new OrbitCtrls(this.cam3D,e,i.orbitCtrls,this.engine,this.events,t),this.fpvCtrls=new FpvCtrls(this.cam3D,e,i.fpvCtrls,this.engine,this.events,t),this.raycast=new Raycast(this.cam3D,e,i,this.engine,this.scene,this.events,this.objs3DMap),this.audio=new Audio(i.audio,this.scene,this.events),this.inspector=i.gui.inspector.enable?new Inspector(i,this.audio,this.engine,this.scene,this.envCtrls,t,this.orbitCtrls,this.fpvCtrls):null,this.model=i.model.file.length>0?new Model(e,i,this.events,t,this.engine.renderer):null,this.ctrl=new Ctrl(this.engine,this.scene,this.model,this.envCtrls,this.events,this.orbitCtrls,this.fpvCtrls,this.raycast,this.objs3DMap,this.websMap,this.webCtrls);for(const e of this.objs3DMap.values())e.events=this.events,e.raycast=this.raycast,e.scene=this.scene;const o=s.web??{};for(const[t,s]of Object.entries(o)){const n="function"==typeof s?s:s.class,o="function"==typeof s?void 0:s.params,a=`ilu-${t.toLowerCase()}`;customElements.get(a)||customElements.define(a,n);const r=Array.from(document.querySelectorAll(a));this.websMap.set(t,r),this.comps.web[t]=r;for(const t of r)o&&Object.assign(t,o),t.canvas=e,t.cfg=i,t.events=this.events,t.objs3D=this.objs3DMap}}static async run(t,s,i){try{s=s??{},t=null!=t?structuredClone(t):structuredClone(cfg);const o=document.querySelector(t.scene.canvas);if(!o)throw new Error("No canvas tag found in DOM.");const a="undefined"!=typeof _0x4a91c3?Number(_0x4a91c3)%1e8:0,r=new Modules(t);if("webgl"!==t.render.api&&("auto"!==t.render.api||navigator.gpu&&await navigator.gpu.requestAdapter())){const e=t.render.profile.webgpu;("none"!==e.ssl||e.ssr||"none"!==e.aa)&&(await r.importFXAANode(e.aa),await r.importSMAANode(e.aa),await r.importTRAANode(e.aa),await r.importGtaoNode("gtao"===e.ssl),await r.importSsgiNode(e.ssl,e.aa),await r.importSsrNode(e.ssr),await r.importThreeTsl()),await r.importThreeWebGpu(),await r.importRectAreaLight(!0)}else{const e=t.render.profile.webgl;("none"!==e.ssl||e.ssr||"none"!==e.aa)&&(await r.importEffectComposer(),await r.importOutputPass(),await r.importRenderPass(),await r.importFXAAShader(e.aa),await r.importSMAAPass(e.aa),await r.importSSAOPass("ssao"===e.ssl),await r.importSsrPass(e.ssr)),await r.importRectAreaLight(!1)}await r.importDracoLoader(),await r.importENVLoader(),await r.importFpvCtrls(),await r.importGLTFLoader(),await r.importKTX2Loader(),await r.importMeshoptDecoder(),await r.importOrbitCtrls(),await r.importStatelyAi(),await r.importTweakpane();const l=n(o,t,a,e,[o,r,s,t]);if(i){const e=i(l);l.stateMachine.start(e)}await l.ctrl.init(t)}catch(e){console.error("Error during app startup.",e)}}};exports.App=App,exports.Audio=Audio,exports.Cam3D=Cam3D,exports.Coll3D=Coll3D,exports.Engine=Engine,exports.EnvCtrls=EnvCtrls,exports.Events=Events,exports.FpvCtrls=FpvCtrls,exports.Light3D=Light3D,exports.Mesh3D=Mesh3D,exports.Obj3D=Obj3D,exports.OrbitCtrls=OrbitCtrls,exports.Raycast=Raycast,exports.Scene=Scene,exports.StateMachine=StateMachine,exports.Web=Web,exports.cfg=cfg,exports.setCfg=setCfg;
8
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let three=require("three"),gsap=require("gsap"),xstate=require("xstate");var THREE={ACESFilmicToneMapping:three.ACESFilmicToneMapping,AgXToneMapping:three.AgXToneMapping,AmbientLight:three.AmbientLight,AdditiveAnimationBlendMode:three.AdditiveAnimationBlendMode,AnimationAction:three.AnimationAction,AnimationClip:three.AnimationClip,AnimationMixer:three.AnimationMixer,Audio:three.Audio,AudioContext:three.AudioContext,AudioListener:three.AudioListener,AudioLoader:three.AudioLoader,BasicShadowMap:three.BasicShadowMap,Box3:three.Box3,BoxGeometry:three.BoxGeometry,Camera:three.Camera,CatmullRomCurve3:three.CatmullRomCurve3,CineonToneMapping:three.CineonToneMapping,Color:three.Color,CustomToneMapping:three.CustomToneMapping,DataTexture:three.DataTexture,DirectionalLight:three.DirectionalLight,EquirectangularReflectionMapping:three.EquirectangularReflectionMapping,Euler:three.Euler,FloatType:three.FloatType,Fog:three.Fog,Group:three.Group,HalfFloatType:three.HalfFloatType,HemisphereLight:three.HemisphereLight,KeyframeTrack:three.KeyframeTrack,Light:three.Light,LinearSRGBColorSpace:three.LinearSRGBColorSpace,LinearToneMapping:three.LinearToneMapping,NormalAnimationBlendMode:three.NormalAnimationBlendMode,LoopOnce:three.LoopOnce,LoopRepeat:three.LoopRepeat,MathUtils:three.MathUtils,Matrix4:three.Matrix4,Mesh:three.Mesh,MeshBasicMaterial:three.MeshBasicMaterial,MeshPhysicalMaterial:three.MeshPhysicalMaterial,MeshStandardMaterial:three.MeshStandardMaterial,MOUSE:three.MOUSE,NeutralToneMapping:three.NeutralToneMapping,NoColorSpace:three.NoColorSpace,NoToneMapping:three.NoToneMapping,Object3D:three.Object3D,OrthographicCamera:three.OrthographicCamera,PCFShadowMap:three.PCFShadowMap,PMREMGenerator:three.PMREMGenerator,PerspectiveCamera:three.PerspectiveCamera,PointLight:three.PointLight,PositionalAudio:three.PositionalAudio,Quaternion:three.Quaternion,Raycaster:three.Raycaster,ReinhardToneMapping:three.ReinhardToneMapping,RenderTarget:three.RenderTarget,Scene:three.Scene,SpotLight:three.SpotLight,Sphere:three.Sphere,SRGBColorSpace:three.SRGBColorSpace,Texture:three.Texture,TextureLoader:three.TextureLoader,TOUCH:three.TOUCH,UnsignedByteType:three.UnsignedByteType,Vector2:three.Vector2,Vector3:three.Vector3,VSMShadowMap:three.VSMShadowMap,WebGLRenderer:three.WebGLRenderer,WebGLRenderTarget:three.WebGLRenderTarget},EventDispatcher=class{listeners=new Map;addEventListener(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const s=this.listeners.get(e);s&&(s.delete(t),0===s.size&&this.listeners.delete(e))}emit(e){const t=this.listeners.get(e.type);if(t)for(const s of[...t])s(e)}listenerCount(e){return this.listeners.get(e)?.size??0}},Obj3D=class{canvas;cfg;events;name;obj=null;objs3D=null;raycast;hidden=!1;renderer;scene;eventDispatcher=new EventDispatcher;posNdc=new THREE.Vector3;posScreen=new THREE.Vector2;posScreenLast=null;posWorld=new THREE.Vector3;posWorldLast=null;posCamWorld=new THREE.Vector3;posWorldOccl=null;posCamWorldOccl=null;quatWorld=new THREE.Quaternion;quatWorldLast=null;rotWorld=new THREE.Euler;visible=!1;inFrustum=!1;inFrustumLast=null;visibleLast=null;occluded=!1;objHidden=null;visibleBeforeHidden=!0;constructor(e,t,s,i={}){this.canvas=e,this.cfg=t,this.name=s,void 0!==i.hidden&&(this.hidden=i.hidden)}addEventListener(e,t){const s=this.eventDispatcher.addEventListener(e,t);return()=>{s(),0===this.eventDispatcher.listenerCount(e)&&this.resetEventState(e)}}calcFrustumVisibility(){this.inFrustum=this.posNdc.x>=-1&&this.posNdc.x<=1&&this.posNdc.y>=-1&&this.posNdc.y<=1&&this.posNdc.z>=-1&&this.posNdc.z<=1;const e=this.inFrustum!==this.inFrustumLast;return e&&(this.inFrustumLast=this.inFrustum),e}calcPosScreen(e){this.posNdc.copy(this.posWorld).project(e.obj);const t=this.canvas.getBoundingClientRect();this.posScreen.set((.5*this.posNdc.x+.5)*t.width,(.5*-this.posNdc.y+.5)*t.height);const s=null===this.posScreenLast||!this.posScreen.equals(this.posScreenLast);return s&&(null===this.posScreenLast?this.posScreenLast=this.posScreen.clone():this.posScreenLast.copy(this.posScreen)),s}calcPosWorld(e){e.getWorldPosition(this.posWorld);const t=null===this.posWorldLast||!this.posWorld.equals(this.posWorldLast);return t&&(null===this.posWorldLast?this.posWorldLast=this.posWorld.clone():this.posWorldLast.copy(this.posWorld)),t}calcPosOccl(e){e.obj.getWorldPosition(this.posCamWorld);const t=this.posCamWorld.distanceTo(this.posWorld)*Math.max(0,this.cfg.raycast.occlusionMoveFactor),s=t*t,i=null===this.posWorldOccl||this.posWorldOccl.distanceToSquared(this.posWorld)>s,n=null===this.posCamWorldOccl||this.posCamWorldOccl.distanceToSquared(this.posCamWorld)>s;return i&&(null===this.posWorldOccl?this.posWorldOccl=this.posWorld.clone():this.posWorldOccl.copy(this.posWorld)),n&&(null===this.posCamWorldOccl?this.posCamWorldOccl=this.posCamWorld.clone():this.posCamWorldOccl.copy(this.posCamWorld)),{posWorldOcclChanged:i,posCamWorldOcclChanged:n}}calcRotWorld(e){return e.getWorldQuaternion(this.quatWorld),(null===this.quatWorldLast||!this.quatWorld.equals(this.quatWorldLast))&&(null===this.quatWorldLast?this.quatWorldLast=this.quatWorld.clone():this.quatWorldLast.copy(this.quatWorld),this.rotWorld.setFromQuaternion(this.quatWorld),!0)}calcVisibility(e,t){if(this.inFrustum)t&&this.raycast.trackOccludee(e),this.occluded=!this.raycast.getOccludeeVisible(e);else{this.occluded=!1;const t=this.raycast.getOccludeeState(e);t.needsCheck=!1,t.visible=!1}this.visible=!this.hidden&&e.visible&&this.inFrustum&&!this.occluded,this.visible!==this.visibleLast&&(this.visibleLast=this.visible,this.emitEvent({type:"Obj3D_Visible_Changed",visible:this.visible}))}emitEvent(e){this.events.send(e,this.name),this.eventDispatcher.emit(e)}getScreenPos(e){if(!this.obj)return null;this.obj.getWorldPosition(this.posWorld),this.posNdc.copy(this.posWorld).project(e.obj);const t=this.canvas.getBoundingClientRect();return{x:(.5*this.posNdc.x+.5)*t.width,y:(.5*-this.posNdc.y+.5)*t.height}}hasEventListener(e){return this.eventDispatcher.listenerCount(e)>0}onReady(){}onStart(){}onTraverse(e){this.obj=e}applyHidden(){this.obj&&(null!==this.objHidden&&this.objHidden!==this.obj&&(this.objHidden.visible=this.visibleBeforeHidden,this.objHidden=null),this.hidden?(null===this.objHidden&&(this.objHidden=this.obj,this.visibleBeforeHidden=this.obj.visible),this.obj.visible=!1):this.objHidden===this.obj&&(this.obj.visible=this.visibleBeforeHidden,this.objHidden=null),this.visible=!this.hidden&&this.obj.visible)}onUpdate(e){}ready(e){this.objs3D=e,this.onReady()}removeEventListener(e,t){this.eventDispatcher.removeEventListener(e,t),0===this.eventDispatcher.listenerCount(e)&&this.resetEventState(e)}resetEventState(e){"Obj3D_Pos_World_Changed"===e&&(this.posWorldLast=null,this.posWorldOccl=null),"Obj3D_Pos_Screen_Changed"===e&&(this.posScreenLast=null),"Obj3D_Rot_World_Changed"===e&&(this.quatWorldLast=null),"Obj3D_Frustum_Changed"===e&&(this.inFrustumLast=null),"Obj3D_Visible_Changed"===e&&(this.visibleLast=null,this.posWorldOccl=null,this.posCamWorldOccl=null,this.obj&&this.raycast.untrackOccludee(this.obj))}start(e,t){this.renderer=e,this.scene=t,this.onStart(),this.applyHidden()}traverse(e){this.onTraverse(e),this.applyHidden()}update(e,t){if(!this.obj)return;this.onUpdate(e);const s=this.hasEventListener("Obj3D_Pos_World_Changed"),i=this.hasEventListener("Obj3D_Pos_Screen_Changed"),n=this.hasEventListener("Obj3D_Rot_World_Changed"),o=this.hasEventListener("Obj3D_Frustum_Changed"),a=this.hasEventListener("Obj3D_Visible_Changed");if(n&&this.calcRotWorld(this.obj)&&this.eventDispatcher.emit({type:"Obj3D_Rot_World_Changed",rotWorld:this.rotWorld.clone()}),!(s||i||o||a))return;const r=this.calcPosWorld(this.obj);if(s&&r&&this.eventDispatcher.emit({type:"Obj3D_Pos_World_Changed",posWorld:this.posWorld.clone()}),!(i||o||a))return;const l=this.calcPosScreen(t);if(i&&l&&this.eventDispatcher.emit({type:"Obj3D_Pos_Screen_Changed",posScreen:this.posScreen.clone()}),!o&&!a)return;const d=this.calcFrustumVisibility();if(o&&d&&this.emitEvent({type:"Obj3D_Frustum_Changed",visibleFrustum:this.inFrustum}),!a)return;const{posWorldOcclChanged:c,posCamWorldOcclChanged:h}=this.calcPosOccl(t);this.calcVisibility(this.obj,c||d||h)}},Web=class extends HTMLElement{canvas;cfg;events;objs3D;webs=null;obj3DFollow=null;visible=null;visibleFollow=!1;visibleOverlap=!0;webCtrls=null;unSubFollow=void 0;unSubVisible=void 0;clearFollow(){this.obj3DFollow=null,this.visibleFollow=!1,this.unSubFollow&&(this.unSubFollow(),this.unSubFollow=void 0),this.unSubVisible&&(this.unSubVisible(),this.unSubVisible=void 0)}emitEvent(e){this.events.send(e,this.constructor.name)}follow({obj:e}){const t=this.follow.name;if(!e)return void console.warn(`${t}: Missing parameter object`);const s=e instanceof Obj3D?e:this.objs3D.get(e);s?s.obj?s!==this.obj3DFollow&&(this.clearFollow(),this.obj3DFollow=s,this.unSubFollow=s.addEventListener("Obj3D_Pos_Screen_Changed",e=>{const{x:t,y:s}=e.posScreen;this.style.left=`${t}px`,this.style.top=`${s}px`}),this.unSubVisible=s.addEventListener("Obj3D_Visible_Changed",e=>{this.visibleFollow=e.visible,this.updateVisibility()}),this.webCtrls?.refreshOverlap(this)):console.warn(`${t}: Obj3D "${e}" has no THREE.Object3D assigned.`):console.warn(`${t}: Obj3D "${e}" is not registered.`)}getObj3DFollow(){return this.obj3DFollow}isVisibleFollow(){return this.visibleFollow}onVisibilityChanged(e){this.style.display=e?"block":"none"}onReady(){}onStart(){}ready(e){this.objs3D=e,this.onReady()}setVisibleOverlap(e){e!==this.visibleOverlap&&(this.visibleOverlap=e,this.emitEvent({type:"Web_Overlap_Changed",web:this,overlapped:!e}),this.updateVisibility())}start(e,t){this.webs=e,this.webCtrls=t,this.onStart()}trackOverlap(){this.webCtrls?.trackOverlap(this)}unfollow(){this.clearFollow(),this.updateVisibility(),this.webCtrls?.refreshOverlap(this)}untrackOverlap(){this.webCtrls?.untrackOverlap(this)}updateVisibility(){const e=this.visibleFollow&&this.visibleOverlap;e!==this.visible&&(this.visible=e,this.onVisibilityChanged(e),this.emitEvent({type:"Web_Visible_Changed",web:this,visible:e}))}},Cam3D=class extends Obj3D{lookMode="target";obj;objGltf=null;objTarget;targetGltf=null;tmpVec=new THREE.Vector3;constructor(e,t,s,i={}){super(e,t,s,i),this.canvas=e;const n=e.getBoundingClientRect();"perspective"===t.cam.type?this.obj=new THREE.PerspectiveCamera(t.cam.perspective.fov,n.width/n.height,t.cam.near,t.cam.far):this.obj=new THREE.OrthographicCamera(t.cam.orthographic.left,t.cam.orthographic.right,t.cam.orthographic.top,t.cam.orthographic.bottom,t.cam.near,t.cam.far),this.objTarget=new THREE.Object3D,this.objTarget.position.copy(t.cam.lookAt),this.obj.position.copy(t.cam.position),this.obj.lookAt(this.objTarget.position)}onTraverse(e){const t=new THREE.Vector3,s=new THREE.Quaternion,i=new THREE.Vector3;e.updateMatrixWorld(!0),e.matrixWorld.decompose(t,s,i),this.obj.copy(e),this.obj.position.copy(t),this.obj.quaternion.copy(s),this.obj.scale.copy(i),this.obj instanceof THREE.PerspectiveCamera&&e instanceof THREE.PerspectiveCamera&&this.obj.updateProjectionMatrix(),this.obj.updateMatrixWorld(!0),this.objGltf=e}traverse(e){if(this.obj instanceof THREE.PerspectiveCamera&&e instanceof THREE.PerspectiveCamera||this.obj instanceof THREE.OrthographicCamera&&e instanceof THREE.OrthographicCamera){this.onTraverse(e),this.applyHidden();let t=this.canvas.getBoundingClientRect();this.updateCanvasResize(t)}else console.warn("Camera type mismatch between cfg and .gltf model.")}update(e){if(this.onUpdate(e),"target"===this.lookMode)this.obj.lookAt(this.objTarget.position);else{let e=this.obj.position.distanceTo(this.objTarget.position);this.objTarget.position.copy(this.obj.position).add(this.tmpVec.set(0,0,-e).applyQuaternion(this.obj.quaternion))}this.obj.updateMatrixWorld(!0),this.hasEventListener("Obj3D_Pos_World_Changed")&&this.calcPosWorld(this.obj)&&this.eventDispatcher.emit({type:"Obj3D_Pos_World_Changed",posWorld:this.obj.getWorldPosition(this.tmpVec).clone()})}updateCanvasResize(e){const t=e.width/e.height;if(this.obj instanceof THREE.PerspectiveCamera)this.obj.aspect=t,this.obj.updateProjectionMatrix();else if(this.obj instanceof THREE.OrthographicCamera){const e=this.obj.top-this.obj.bottom,s=e*t/2,i=e/2;this.obj.left=-s,this.obj.right=s,this.obj.top=i,this.obj.bottom=-i,this.obj.updateProjectionMatrix()}}},Light3D=class extends Obj3D{obj;constructor(e,t,s,i={}){super(e,t,s,i),this.obj=new THREE.PointLight}onTraverse(e){this.obj=e}traverse(e){this.onTraverse(e),this.applyHidden()}},Mesh3D=class extends Obj3D{obj;groundReflector=null;reflectivesSSR=[];model=null;constructor(e,t,s,i={}){super(e,t,s,i),this.obj=new THREE.Mesh(new THREE.BoxGeometry,new THREE.MeshPhysicalMaterial)}animMaterialColor(e){this.scene.animMaterialColor({...e,mesh:this})}animMaterialNumeric({needsUpdate:e=!1,...t}){this.scene.animMaterialNumeric({...t,mesh:this,needsUpdate:e})}getImageTexture(e){if(!this.model)throw new Error(`Image texture "${e}" could not be accessed because no model is available.`);return this.model.getTextureFromImageUnused(e)}onTraverse(e){this.obj=e}requestImageTexture(e){if(!this.model)throw new Error(`Image texture "${e}" could not be requested because no model is available.`);this.model.addImageUnusedName(e)}setMaterialProps({recursive:e=!1,needsUpdate:t=!1,...s}){this.scene.setMaterialProps({...s,obj:this,recursive:e,needsUpdate:t})}setModel(e){this.model=e}setReflectivesSSR(e){this.reflectivesSSR=e}traverse(e){this.onTraverse(e),this.applyHidden()}},Coll3D=class extends Mesh3D{target=null;pickable=!1;occluder=!1;targetName;constructor(e,t,s,i={}){super(e,t,s,i),this.targetName=i.target??null,void 0!==i.pickable&&(this.pickable=i.pickable),void 0!==i.occluder&&(this.occluder=i.occluder)}resolveTarget(e){if(null===this.targetName)return;const t=e.get(this.targetName);t instanceof Mesh3D?this.target=t:console.warn(`Coll3D "${this.name}": Target "${this.targetName}" is not a registered Mesh3D.`)}},Audio=class{ctx=THREE.AudioContext.getContext();listener=null;loader=new THREE.AudioLoader;events;params;scene;sounds=[];constructor(e,t,s){this.events=s,this.params={...e},this.scene=t}attachSoundTo(e,t){if(!e)return void console.warn("No name assigned.");if(!t)return void console.warn("No object to attach provided.");const s="string"==typeof t?this.scene.obj.getObjectByName(t):t.obj;if(!s)return void console.warn(`Object "${t}" not found in scene.`);const i=this.sounds.find(t=>t.name===e);i?s.add(i.audio):console.warn(`Sound "${e}" not found.`)}fadeSound(e,t,s,i,n,o){e.tween?.kill(),e.tween=void 0;const a=e.audio.gain.gain;if(a.cancelScheduledValues(this.ctx.currentTime),i<=0)return a.setValueAtTime(s,this.ctx.currentTime),void o?.();const r={value:t};a.setValueAtTime(t,this.ctx.currentTime),e.tween=gsap.gsap.to(r,{duration:i,value:s,ease:n,onUpdate:()=>{a.setValueAtTime(r.value,this.ctx.currentTime)},onComplete:()=>{e.tween=void 0,o?.()}})}get(){return{refDistance:this.params.refDistance,rolloffFactor:this.params.rolloffFactor,maxDistance:this.params.maxDistance,distanceModel:this.params.distanceModel,coneInnerAngle:this.params.coneInnerAngle,coneOuterAngle:this.params.coneOuterAngle,coneOuterGain:this.params.coneOuterGain}}isLoaded({name:e}){return void 0!==this.sounds.find(t=>t.name===e)}isPlaying({name:e}){let t=this.isPlaying.name;if("running"!==this.ctx.state)return console.warn(`${t}: ctx.state is not running.`),!1;const s=this.sounds.find(t=>t.name===e);return s?s.audio.isPlaying:(console.warn(`${t}: Sound not found.`),!1)}loadSound({name:e,url:t,obj:s,volume:i=0,loop:n=!0,...o},a=!1,r=0,l="none"){if(!this.listener)return void console.warn(`${this.load.name}: No audio listener set.`);if(this.sounds.some(t=>t.name===e))return void console.warn(`${this.load.name}: Sound with name '${e}' is already loaded.`);if(!s&&Object.values(o).some(e=>void 0!==e))return void console.warn("Positional settings require a positional sound.");const d=s?new THREE.PositionalAudio(this.listener):new THREE.Audio(this.listener),c={name:e,audio:d,volume:i,loop:n,positional:o};this.loader.load(t,t=>{d.setBuffer(t),d.setLoop(n),d.gain.gain.setValueAtTime(0,this.ctx.currentTime),d instanceof THREE.PositionalAudio&&this.setSoundParamsPos(c),this.sounds.push(c),s&&this.attachSoundTo(e,s),this.events.audio({type:"Audio_Loaded",soundName:e}),a&&this.play({name:e,fade:r,ease:l})},void 0,e=>{throw new Error(`Audio loading error for ${t}: ${e}`)})}load(e){this.loadSound(e)}loadAndPlay({fade:e=0,ease:t="none",...s}){let i=this.loadAndPlay.name;this.listener?"suspended"===this.ctx.state||"running"===this.ctx.state?this.setAudioContext({state:"running"}).then(()=>{setTimeout(()=>{this.loadSound(s,!0,e,t)},this.params.delayLoadSound)}).catch(e=>{throw new Error(`Audio API resume error: ${e}`)}):this.loadSound(s,!0,e,t):console.warn(`${i}: No audio listener set.`)}play({name:e,fade:t=0,ease:s="none"}){let i=this.play.name;if("suspended"===this.ctx.state||"interrupted"===this.ctx.state)return void this.setAudioContext({state:"running"}).then(()=>{"running"===this.ctx.state?this.play({name:e,fade:t,ease:s}):console.warn(`${i}: AudioContext is not running.`)}).catch(e=>{throw new Error(`Audio API resume error: ${e}`)});if("running"!==this.ctx.state)return void console.warn(`${i}: AudioContext is not running.`);const n=this.sounds.find(t=>t.name===e);if(!n)return void console.warn(`${i}: Sound with name '${e}' is not loaded.`);if(n.audio.isPlaying)return;const o=n.audio.gain.gain;if(o.cancelScheduledValues(this.ctx.currentTime),o.setValueAtTime(t>0?0:n.volume,this.ctx.currentTime),n.audio.play(),!n.audio.isPlaying||!n.audio.source)return;n.paused=!1;const a=n.audio.source;if(!(a instanceof AudioBufferSourceNode))return;const r=a.onended;a.onended=t=>{r&&r(t),n.tween?.kill(),n.tween=void 0,n.stopping=!1,this.events.audio({type:"Audio_Complete",soundName:e})},t>0&&this.fadeSound(n,0,n.volume,t,s),this.events.audio({type:"Audio_Start",soundName:e})}pause({name:e,fade:t=0,ease:s="none"}){if("running"!==this.ctx.state)return void console.warn(`${this.pause.name}: AudioContext is not running.`);const i=this.sounds.find(t=>t.name===e);i?i.audio.isPlaying&&!i.stopping&&this.fadeSound(i,i.audio.getVolume(),0,t,s,()=>{i.audio.pause(),i.paused=!0}):console.warn(`${this.pause.name}: Sound '${e}' not found.`)}resume(){"suspended"!==this.ctx.state&&"interrupted"!==this.ctx.state||this.setAudioContext({state:"running"}).catch(e=>{throw new Error(`Audio API resume error: ${e}`)})}set(e){for(const t of Object.keys(this.get())){const s=e[t];void 0!==s&&Object.assign(this.params,{[t]:s})}for(const e of this.sounds)this.setSoundParamsPos(e)}async setAudioContext({state:e}){if(this.ctx.state!==e)switch(e){case"running":await this.ctx.resume();break;case"suspended":await this.ctx.suspend();break;case"closed":await this.ctx.close();break;default:throw new Error(`Unknown AudioContext state: ${e}`)}}setListener({obj:e}){const t="string"==typeof e?this.scene.obj.getObjectByName(e):e.obj;if(!t)return void console.warn(`${this.setListener.name}: Listener object not found.`);const s=new THREE.AudioListener;t.add(s),this.listener=s}setSoundParams({name:e,volume:t,...s}){const i=this.sounds.find(t=>t.name===e);if(!i)return void console.warn(`Sound '${e}' not found.`);const n={...i.positional};for(const e of Object.keys(this.get())){const t=s[e];void 0!==t&&Object.assign(n,{[e]:t})}if(Object.values(s).some(e=>void 0!==e)&&(i.audio instanceof THREE.PositionalAudio?(i.positional=n,this.setSoundParamsPos(i)):console.warn(`Sound '${e}' is not positional; spatial settings were ignored.`)),void 0!==t&&(i.volume=t,!i.tween)){const e=i.audio.gain.gain;e.cancelScheduledValues(this.ctx.currentTime),e.setValueAtTime(t,this.ctx.currentTime)}}setSoundParamsPos(e){if(!(e.audio instanceof THREE.PositionalAudio))return;const t=this.get();for(const s of Object.keys(t)){const i=e.positional[s];void 0!==i&&Object.assign(t,{[s]:i})}e.audio.setRefDistance(t.refDistance),e.audio.setRolloffFactor(t.rolloffFactor),e.audio.setMaxDistance(t.maxDistance),e.audio.setDistanceModel(t.distanceModel),e.audio.setDirectionalCone(t.coneInnerAngle,t.coneOuterAngle,t.coneOuterGain)}stop({name:e,fade:t=0,ease:s="none"}){let i=this.stop.name;if("running"!==this.ctx.state)return void console.warn(`${i}: AudioContext is not running.`);const n=this.sounds.find(t=>t.name===e);n?n.stopping||!n.audio.isPlaying&&!n.paused||(n.stopping=!0,this.fadeSound(n,n.audio.getVolume(),0,n.audio.isPlaying?t:0,s,()=>{n.audio.stop(),n.paused=!1,n.stopping=!1,this.events.audio({type:"Audio_Stop",soundName:e})})):console.warn(`${i}: Sound '${e}' not found.`)}use(e){e(this)}},infobox_default=":host {\r\n z-index: 999;\r\n position: absolute;\r\n left: 8px; top: 8px;\r\n font-family: monospace;\r\n font-size: 12px;\r\n color: #ffffff;\r\n pointer-events: none;\r\n}\r\n\r\n#infobox {\r\n padding: 8px;\r\n border-radius: 8px;\r\n background: hsla(230, 25%, 16%, 1.00);\r\n box-sizing: border-box;\r\n}\r\n\r\n.row {\r\n display: flex;\r\n justify-content: space-between;\r\n gap: 1em;\r\n line-height: 1.45;\r\n white-space: nowrap;\r\n}\r\n\r\n.label {\r\n opacity: 0.75;\r\n}\r\n\r\n.value {\r\n text-align: right;\r\n}\r\n\r\n.separator {\r\n height: 1px;\r\n margin: 5px 0;\r\n background: rgba(255, 255, 255, 0.18);\r\n}",InfoBox=class extends HTMLElement{cfg;rendererApi="WebGL";values=new Map;timeBegin=0;timeLastFrame=0;timeFrameMs=0;timeCpuMs=0;fps=0;timeLastUpdate=0;updateInterval=100;constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=infobox_default;const s=document.createElement("div");s.id="infobox",this.addRow(s,"Api","api"),this.addSeparator(s),this.addRow(s,"Fps","fps"),this.addRow(s,"Cpu","cpu"),this.addRow(s,"Frame","frame"),this.addSeparator(s),this.addRow(s,"Calls","calls"),this.addRow(s,"Triangles","triangles"),this.addRow(s,"Lines","lines"),this.addRow(s,"Points","points"),this.addSeparator(s),this.addRow(s,"Geometries","geometries"),this.addRow(s,"Textures","textures"),this.addRow(s,"Programs","programs"),e.append(t,s)}applyCfg(){this.setValue("api",this.rendererApi);const e=this.cfg?.gui.infoBox;e&&(this.setVisible("fps",e.fps),this.setVisible("cpu",e.cpu),this.setVisible("frame",e.frame),this.setVisible("calls",e.calls),this.setVisible("triangles",e.triangles),this.setVisible("lines",e.lines),this.setVisible("points",e.points),this.setVisible("geometries",e.geometries),this.setVisible("textures",e.textures),this.setVisible("programs",e.programs),this.updateInterval=1e3/Math.max(1,e.logsPerSecond))}begin(e){this.timeLastFrame>0&&(this.timeFrameMs=e-this.timeLastFrame,this.timeFrameMs>0&&(this.fps=1e3/this.timeFrameMs)),this.timeLastFrame=e,this.timeBegin=e}end(e,t){if(this.timeCpuMs=e-this.timeBegin,e-this.timeLastUpdate<this.updateInterval)return;this.timeLastUpdate=e;const s=t.info,i=Array.isArray(s.programs)?s.programs.length:s.memory.programs??0;this.setValue("fps",this.fps.toFixed(0)),this.setValue("cpu",`${this.timeCpuMs.toFixed(2)} ms`),this.setValue("frame",`${this.timeFrameMs.toFixed(2)} ms`),this.setValue("calls",String(s.render.drawCalls??s.render.calls??0)),this.setValue("triangles",this.formatNumber(s.render.triangles??0)),this.setValue("lines",this.formatNumber(s.render.lines??0)),this.setValue("points",this.formatNumber(s.render.points??0)),this.setValue("geometries",String(s.memory.geometries??0)),this.setValue("textures",String(s.memory.textures??0)),this.setValue("programs",String(i))}setUpdateInterval(e){this.updateInterval=Math.max(0,e)}addRow(e,t,s){const i=document.createElement("div");i.className="row";const n=document.createElement("span");n.className="label",n.textContent=t;const o=document.createElement("span");o.className="value",o.textContent="-",i.append(n,o),e.appendChild(i),this.values.set(s,o)}addSeparator(e){const t=document.createElement("div");t.className="separator",e.appendChild(t)}setValue(e,t){const s=this.values.get(e);s&&(s.textContent=t)}setVisible(e,t){const s=this.values.get(e);s?.parentElement&&(s.parentElement.style.display=t?"":"none")}formatNumber(e){return Math.round(e).toLocaleString("de-DE")}};function loadInfoBox(e,t){const s="ilu-infobox";customElements.get(s)||customElements.define(s,InfoBox);const i=document.createElement(s);return i.cfg=e,i.rendererApi=t,i.applyCfg(),document.body.appendChild(i),i}var Engine=class{cam3D;cfg;events;modules;objs3D;scene;infoBox=null;callbacks=[];resolveWaitForRender=null;rendererReady=null;canvas;composer=null;renderer;renderPipeline=null;postProfile={aa:"none",ssl:"none",ssr:!1};postProfileLast=null;fxaaPass=null;outputPass=null;renderPass=null;smaaPass=null;tslPass=null;aaNode=null;rttNode=null;traaWarmupContext=null;ssaoPass=null;gtaoNode=null;ssgiNode=null;ssrPass=null;ssrNode=null;ecoButtonActive=!1;gfxEvents=new EventDispatcher;gfxLevelChanges=!1;gfxLevel=0;gfxMode="off";gfxPostProfiles=[{aa:"none",ssl:"none",ssr:!1}];gfxState="idle";gfxDownOnly=!1;dTs=[];dT=0;timeGsap=0;timeLast=performance.now();timeLastFrame=0;resizeTimeout=null;resizeDelay=100;constructor(e,t,s,i,n,o,a){this.canvas=s,this.cam3D=t,this.cfg=i,this.events=n,this.modules=o,this.objs3D=a,this.scene=e;const r=this.modules.webGpuRendererClass;if(r){const e=this.cfg.render.profile.webgpu;this.postProfile={aa:e.aa,ssl:e.ssl,ssr:e.ssr};const t={...this.cfg.render.params,...this.cfg.render.webgpu.params,antialias:"none"!==e.msaa};if("ssgi"===this.postProfile.ssl&&this.postProfile.ssr){const e=t.requiredLimits||{};t.requiredLimits={...e,maxColorAttachmentBytesPerSample:Math.max(e.maxColorAttachmentBytesPerSample||0,40)}}if(this.renderer=new r(t),this.cfg.light.rectArea){const e=this.modules.rectAreaLightNodeClass,t=this.modules.rectAreaLightTexturesLib;e&&t?e.setLTC(t.init()):console.warn("RectAreaLight WebGPU modules could not be initialized.")}"none"!==this.cfg.debug.log&&console.log("Info: WebGPU Renderer")}else{const e=this.cfg.render.profile.webgl;this.postProfile={aa:e.aa,ssl:e.ssl,ssr:e.ssr};const t={...this.cfg.render.params,...this.cfg.render.webgl.params,antialias:"none"!==e.msaa};this.renderer=new THREE.WebGLRenderer(t),this.cfg.light.rectArea&&(this.modules.rectAreaLightUniformsLib?this.modules.rectAreaLightUniformsLib.init():console.warn("RectAreaLight WebGL module could not be initialized.")),this.rendererReady=Promise.resolve(),"none"!==this.cfg.debug.log&&console.log("Info: "+this.renderer.getContext().getParameter(this.renderer.getContext().VERSION))}let l=this.gfxPostProfiles[0];if("none"!==this.postProfile.aa&&(l={...l,aa:this.postProfile.aa},this.gfxPostProfiles.push(l)),"none"!==this.postProfile.ssl){const e=this.modules.webGpuRendererClass?"gtao":"ssao";l={...l,ssl:e},this.gfxPostProfiles.push(l)}this.postProfile.ssr&&(l={...l,ssr:!0},this.gfxPostProfiles.push(l)),"ssgi"===this.postProfile.ssl&&this.gfxPostProfiles.push({...l,ssl:"ssgi"});const d=this.canvas.getBoundingClientRect();this.renderer.setPixelRatio(this.cfg.render.pixelRatio),this.renderer.setSize(d.width,d.height,!1),this.renderer.shadowMap.enabled=this.cfg.render.shadowMapEnabled,this.renderer.shadowMap.type=this.cfg.render.shadowMapType,this.renderer.toneMapping=this.cfg.render.toneMapping,this.renderer.toneMappingExposure=this.cfg.render.toneMappingExposure,this.renderer.outputColorSpace=this.cfg.render.outputColorSpace;const c=this.renderer.domElement;c.style.display="block",c.style.width="100%",c.style.height="100%",c.style.boxSizing="border-box",this.canvas.tabIndex=0;const h={pointerId:null,downX:0,downY:0,moved:!1};this.canvas.addEventListener("pointerdown",e=>{e.isPrimary&&0===e.button&&(h.pointerId=e.pointerId,h.downX=e.clientX,h.downY=e.clientY,h.moved=!1)}),this.canvas.addEventListener("pointermove",e=>{if(e.pointerId!==h.pointerId||h.moved)return;const t=e.clientX-h.downX,s=e.clientY-h.downY;h.moved=Math.hypot(t,s)>5}),this.canvas.addEventListener("pointercancel",e=>{e.pointerId===h.pointerId&&(h.pointerId=null,h.moved=!1)}),this.canvas.addEventListener("click",e=>{this.canvas.focus(),null===h.pointerId||h.moved||this.events.send({type:"Canvas_Click",event:e}),h.pointerId=null,h.moved=!1}),this.canvas.addEventListener("pointerleave",e=>{this.events.send({type:"Canvas_Pointer_Leave",event:e})}),this.canvas.addEventListener("pointerenter",e=>{this.events.send({type:"Canvas_Pointer_Enter",event:e})}),this.canvas.addEventListener("keydown",e=>{this.events.send({type:"Canvas_Key_Down",event:e})}),this.canvas.addEventListener("keyup",e=>{this.events.send({type:"Canvas_Key_Up",event:e})}),this.canvas.prepend(this.renderer.domElement),this.cfg.gui.infoBox.enable&&(loadInfoBox(this.cfg,r?"WebGPU":"WebGL"),this.infoBox=document.querySelector("ilu-infobox"),this.renderer.info.autoReset=!1),this.timeLastFrame=performance.now()/1e3,this.updateCanvasResize(),window.addEventListener("resize",()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{!1===this.cfg.render.autoResize?this.events.windowResize({type:"Window_Resize"}):this.updateCanvasResize()},this.resizeDelay)}),gsap.gsap.ticker.remove(gsap.gsap.updateRoot),gsap.gsap.ticker.lagSmoothing(0)}async init(){this.renderer instanceof THREE.WebGLRenderer&&!this.renderer.extensions.has("KHR_parallel_shader_compile")?this.renderer.compile(this.scene.obj,this.cam3D.obj):await this.renderer.compileAsync(this.scene.obj,this.cam3D.obj);const e=this.isPostCfg();this.cfg.render.adaptiveGfx&&(this.gfxLevel=0,this.postProfile={...this.gfxPostProfiles[0]},this.scene.groundReflector&&(this.scene.groundReflector.visible=!1)),e&&(this.modules.webGpuRendererClass?(this.setPostWebGpu(this.postProfile),this.cfg.render.adaptiveGfx||this.renderPipeline?.render()):(this.setPostWebGl(this.postProfile),this.composer?.render())),!this.cfg.render.adaptiveGfx&&e||this.renderer.render(this.scene.obj,this.cam3D.obj),!this.cfg.render.adaptiveGfx&&this.cfg.render.ecoMode&&(this.gfxMode="eco"),this.resolveWaitForRender&&(this.resolveWaitForRender(),this.resolveWaitForRender=null)}async initRenderer(){if(null===this.rendererReady){const e=this.modules.webGpuRendererClass;e&&this.renderer instanceof e&&(this.rendererReady=this.renderer.init())}await this.rendererReady}addOnFrameUpdate(e){this.callbacks.push(e)}async enableAaMode(e){if(this.modules.webGpuRendererClass)"fxaa"===e?await this.modules.importFXAANode(e):"smaa"===e?await this.modules.importSMAANode(e):"traa"===e&&(await this.modules.importTRAANode(e),await this.modules.importSsgiNode(this.postProfile.ssl,e)),this.postProfile.aa=e,this.setPostWebGpu(this.postProfile);else{if("traa"===e)return;await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.fxaaPass||"fxaa"!==e?this.smaaPass||"smaa"!==e||await this.modules.importSMAAPass(e):await this.modules.importFXAAShader(e),this.postProfile.aa=e,this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.aa=e)}}async enableSslMode(e){if(this.modules.webGpuRendererClass){if("ssao"===e)return;"gtao"===e?await this.modules.importGtaoNode(!0):"ssgi"===e&&"traa"===this.postProfile.aa&&await this.modules.importSsgiNode(e,this.postProfile.aa),this.postProfile.ssl=e,this.setPostWebGpu(this.postProfile)}else{if("gtao"===e||"ssgi"===e)return;await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.postProfile.ssl=e,await this.modules.importSSAOPass("ssao"===e),this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.ssl=e)}}async enableSsr(e){this.modules.webGpuRendererClass?(await this.modules.importSsrNode(e),this.postProfile.ssr=e,this.setPostWebGpu(this.postProfile)):(await this.modules.importEffectComposer(),await this.modules.importOutputPass(),await this.modules.importRenderPass(),this.postProfile.ssr=e,e&&!this.ssrPass?await this.modules.importSsrPass(e):!e&&this.scene.groundReflector&&(this.scene.groundReflector.visible=!1),this.setPostWebGl(this.postProfile),this.cfg.render.adaptiveGfx||(this.cfg.render.profile.webgl.ssr=e))}getGfxLevels(){return this.gfxPostProfiles.map((e,t)=>t)}isPostCfg(){return"none"!==this.postProfile.ssl||this.postProfile.ssr||"none"!==this.postProfile.aa}removeOnFrameUpdate(e){this.callbacks=this.callbacks.filter(t=>t!==e)}setAnimationLoop(){this.renderer.setAnimationLoop(e=>this.update(e))}setEcoButtonActive(e){this.ecoButtonActive=e,this.cfg.render.adaptiveGfx&&(e?"complete"===this.gfxState?this.gfxMode="eco":this.updateGfx("complete"):(this.dTs.length=0,this.gfxMode="complete"===this.gfxState&&this.gfxLevel>0?"graphics":"off"))}setGfxLevel(e){this.gfxLevelChanges=!0,this.gfxMode="off";try{const t=this.gfxPostProfiles[e];if(!t)return;this.postProfile={...t},this.modules.webGpuRendererClass?this.setPostWebGpu(this.postProfile):(this.setPostWebGl(this.postProfile),e>0&&this.composer?.render()),this.gfxLevel=e,this.gfxEvents.emit({type:"Gfx_Changed",gfxLevel:this.gfxLevel})}catch(e){console.error("Graphics level could not be applied.",e),this.updateGfx("complete")}}setPostAaParams(){if(this.modules.webGpuRendererClass||!this.fxaaPass)return;const e=this.renderer.getSize(new THREE.Vector2),t=this.renderer.getPixelRatio(),s=this.cfg.post.webgl.aa.fxaa.sharpness,i=this.fxaaPass.material.uniforms;i.resolution.value.x=s/(e.x*t),i.resolution.value.y=s/(e.y*t)}setPostSslParams(){if(this.modules.webGpuRendererClass){if(this.gtaoNode){const e=this.cfg.post.webgpu.gtao;this.gtaoNode.radius.value=e.radius,this.gtaoNode.thickness.value=e.thickness,this.gtaoNode.scale.value=e.scale,this.gtaoNode.samples.value=Math.round(e.samples),this.gtaoNode.resolutionScale=e.resolutionScale,this.gtaoNode.useTemporalFiltering="traa"===this.postProfile.aa}if(this.ssgiNode){const e=this.cfg.post.webgpu.ssgi;this.ssgiNode.sliceCount.value=Math.round(e.sliceCount),this.ssgiNode.stepCount.value=Math.round(e.stepCount),this.ssgiNode.aoIntensity.value=e.aoIntensity,this.ssgiNode.giIntensity.value=e.giIntensity,this.ssgiNode.radius.value=e.radius,this.ssgiNode.useScreenSpaceSampling.value=e.useScreenSpaceSampling,this.ssgiNode.expFactor.value=e.expFactor,this.ssgiNode.thickness.value=e.thickness,this.ssgiNode.useLinearThickness.value=e.useLinearThickness,this.ssgiNode.backfaceLighting.value=e.backfaceLighting,this.ssgiNode.useTemporalFiltering=!0}}else if(this.ssaoPass){const e=this.cfg.post.webgl.ssao;this.ssaoPass.kernelRadius=e.kernelRadius,this.ssaoPass.minDistance=e.minDistance,this.ssaoPass.maxDistance=e.maxDistance}}setPostSsrParams(){const e=this.cfg.post.ssr;if(this.modules.webGpuRendererClass){if(!this.ssrNode)return;const t=this.cfg.post.webgpu.ssr;this.ssrNode.quality.value=t.quality,this.ssrNode.blurQuality=Math.round(t.blurQuality),this.ssrNode.maxDistance.value=e.maxDistance,this.ssrNode.intensity.value=t.intensity,this.ssrNode.thickness.value=e.thickness,this.ssrNode.resolutionScale=e.resolutionScale}else{const t=this.cfg.post.webgl.ssr;this.ssrPass&&(this.ssrPass.clear=t.clear,this.ssrPass.selective=t.selective,this.ssrPass.fresnel=t.fresnel,this.ssrPass.distanceAttenuation=t.distanceAttenuation,this.ssrPass.infiniteThick=t.infiniteThick,this.ssrPass.maxDistance=e.maxDistance,this.ssrPass.opacity=t.opacity,this.ssrPass.thickness=e.thickness,this.ssrPass.resolutionScale=e.resolutionScale,this.ssrPass.blur=t.blur,this.ssrPass.output=t.output,this.ssrPass.bouncing=t.bouncing),this.scene.groundReflector&&(this.scene.groundReflector.fresnel=t.fresnel,this.scene.groundReflector.distanceAttenuation=t.distanceAttenuation,this.scene.groundReflector.maxDistance=e.maxDistance,this.scene.groundReflector.opacity=t.opacity)}}setPostWebGl(e){if(!(this.renderer instanceof THREE.WebGLRenderer))return;const t=this.canvas.getBoundingClientRect();if(!this.composer){const e=this.modules.effectComposerClass;if(e)if("post"===this.cfg.render.profile.webgl.msaa){const s=this.renderer.getContext(),i=s.getParameter(s.SAMPLES),n="number"==typeof i?i:0,o=new THREE.WebGLRenderTarget(1,1,{type:THREE.HalfFloatType,samples:n});this.composer=new e(this.renderer,o),this.composer.setSize(t.width,t.height)}else this.composer=new e(this.renderer);else console.warn("EffectComposer could not be started.")}if(this.composer){if(this.composer.passes.length=0,!this.renderPass){const e=this.modules.renderPassClass;e?this.renderPass=new e(this.scene.obj,this.cam3D.obj):console.warn("Module Three.js RenderPass could not be imported.")}if(this.renderPass&&this.composer.addPass(this.renderPass),e.ssr){if(!this.ssrPass)if(this.modules.ssrPassClass){this.scene.groundReflector&&!this.scene.groundReflector.parent&&this.scene.obj.add(this.scene.groundReflector);const e=this.cfg.post.webgl.ssr;this.ssrPass=new this.modules.ssrPassClass({renderer:this.renderer,scene:this.scene.obj,camera:this.cam3D.obj,width:t.width,height:t.height,bouncing:e.bouncing,groundReflector:this.scene.groundReflector,selects:e.selective?this.scene.reflectivesSSR:null}),this.ssrPass.enabled=!0}else console.warn("Module Three.js SSRPass could not be imported.");this.setPostSsrParams(),this.ssrPass&&this.composer.addPass(this.ssrPass)}if("ssao"===e.ssl&&(this.ssaoPass||(this.modules.ssaoPassClass?(this.ssaoPass=new this.modules.ssaoPassClass(this.scene.obj,this.cam3D.obj,t.width,t.height),this.ssaoPass.enabled=!0):console.warn("Module Three.js SSAOPass could not be imported.")),this.setPostSslParams(),this.ssaoPass&&this.composer.addPass(this.ssaoPass)),"smaa"===e.aa&&(this.smaaPass||(this.modules.smaaPassClass?(this.smaaPass=new this.modules.smaaPassClass,this.smaaPass.enabled=!0):console.warn("Module Three.js SMAAPass could not be imported.")),this.smaaPass&&this.composer.addPass(this.smaaPass)),!this.outputPass){const e=this.modules.outputPassClass;e?this.outputPass=new e:console.warn("Module Three.js OutputPass could not be imported.")}if(this.outputPass&&this.composer.addPass(this.outputPass),"fxaa"===e.aa){if(!this.fxaaPass){const e=this.modules.shaderPassClass;e&&this.modules.fxaaShader?(this.fxaaPass=new e(this.modules.fxaaShader),this.fxaaPass.enabled=!0,this.setPostAaParams()):console.warn("Module Three.js FXAAShader could not be imported.")}this.fxaaPass&&this.composer.addPass(this.fxaaPass)}}}setPostWebGpu(e){const t=this.modules.webGpuRendererClass;if(!(t&&this.renderer instanceof t))return;const{aa:s,ssl:i,ssr:n}=e,o="post"===this.cfg.render.profile.webgpu.msaa&&"traa"!==s,a="gtao"===i&&!o,r="ssgi"===i&&"traa"===s&&this.renderer.hasFeature("rg11b10ufloat-renderable"),l=a||r||n,d=!this.postProfileLast||this.postProfileLast.aa!==s||this.postProfileLast.ssl!==i||this.postProfileLast.ssr!==n;if(!this.renderPipeline){const e=this.modules.renderPipelineClass;e?this.renderPipeline=new e(this.renderer):console.warn("EffectComposer could not be started.")}if(!this.renderPipeline)return;const{tslPass:c,tslRtt:h,tslMrt:m,tslContext:p,tslOutput:u,tslDiffuseColor:g,tslVelocity:b,tslRenderOutput:f,tslNormalView:v,tslMetalness:C,tslRoughness:w,tslSample:y,tslVec2:x,tslVec3:P,tslVec4:M,packNormalToRGB:S,unpackRGBToNormal:L}=this.modules;if(!(c&&h&&m&&u&&f&&v&&C&&w&&y&&x&&P&&M&&S&&L))return;if("traa"===s&&!b)return;if(d&&(this.aaNode?.dispose(),this.rttNode?.dispose(),this.gtaoNode?.dispose(),this.ssgiNode?.dispose(),this.ssrNode?.dispose(),this.tslPass?.dispose(),this.aaNode=null,this.rttNode=null,this.gtaoNode=null,this.ssgiNode=null,this.ssrNode=null,this.tslPass=null,this.postProfileLast={...e}),!this.tslPass){const e=o?c(this.scene.obj,this.cam3D.obj):c(this.scene.obj,this.cam3D.obj,{samples:0});this.tslPass=e;const t={output:u};l&&(t.normal=S(v)),n&&(t.metalrough=x(C,w)),r&&g&&(t.diffuse=g),"traa"===s&&b&&(t.velocity=b),e.setMRT(m(t)),l&&(e.getTexture("normal").type=THREE.UnsignedByteType),n&&(e.getTexture("metalrough").type=THREE.UnsignedByteType),r&&g&&(e.getTexture("diffuse").type=THREE.UnsignedByteType)}const T=this.tslPass,E=T.getTextureNode("output"),j=T.getTextureNode("depth"),A=l?T.getTextureNode("normal"):null,D=n?T.getTextureNode("metalrough"):null,G=r&&g?T.getTextureNode("diffuse"):null;if(!this.gtaoNode&&a&&A)if(this.modules.gtaoNodeClass){const e=y(e=>L(A.sample(e)));this.gtaoNode=this.modules.gtaoNodeClass(j,e,this.cam3D.obj)}else console.warn("Module Three.js GTAONode could not be imported.");if(!this.ssgiNode&&r&&A&&this.cam3D.obj instanceof THREE.PerspectiveCamera)if(this.modules.ssgiNodeClass){const e=y(e=>L(A.sample(e)));this.ssgiNode=this.modules.ssgiNodeClass(E,j,e,this.cam3D.obj)}else console.warn("Module Three.js SSGINode could not be imported.");if(!this.ssrNode&&n&&A&&D)if(this.modules.ssrNode){const e=y(e=>L(A.sample(e)));this.ssrNode=this.modules.ssrNode(E,j,e,{metalnessNode:D.r,roughnessNode:D.g,camera:this.cam3D.obj})}else console.warn("Module Three.js SSRNode could not be imported.");this.rttNode||"none"===s||(this.rttNode=h(E)),!this.aaNode&&this.rttNode&&("smaa"===s&&this.modules.smaaNode?this.aaNode=this.modules.smaaNode(this.rttNode):"traa"===s&&this.modules.traaNode?this.aaNode=this.modules.traaNode(this.rttNode,j,T.getTextureNode("velocity"),this.cam3D.obj):"fxaa"===s&&this.modules.fxaaNode&&(this.aaNode=this.modules.fxaaNode(this.rttNode)));let R=E;if(this.setPostSslParams(),this.gtaoNode&&a){const e=this.gtaoNode.getTextureNode();R=R.mul(M(P(e.r),1))}if(this.ssgiNode&&r&&G){const e=this.ssgiNode.getAONode(),t=this.ssgiNode.getGINode();R=R.mul(M(P(e.r),1)).add(M(G.rgb.mul(t.rgb),0))}this.setPostSsrParams(),this.ssrNode&&n&&(R=R.add(M(this.ssrNode.rgb,0))),this.rttNode&&(this.rttNode.node="fxaa"===s?f(R):R,this.rttNode.needsUpdate=!0),this.aaNode&&(this.aaNode.needsUpdate=!0,R=this.aaNode),this.renderPipeline.outputColorTransform="fxaa"!==s||!this.aaNode,this.renderPipeline.outputNode=R,this.renderPipeline.needsUpdate=!0;const k=this.renderPipeline,O=k.renderer,B=O.getDrawingBufferSize(new THREE.Vector2),N="traa"===s&&null!==this.rttNode;this.rttNode&&N&&B.x>0&&B.y>0&&this.rttNode.setSize(B.x,B.y);const U=new THREE.RenderTarget(B.x,B.y,{depthBuffer:!1,type:THREE.HalfFloatType}),I=O.getRenderTarget(),W=O.getActiveCubeFace(),z=O.getActiveMipmapLevel(),J=T.getMRT(),F=T.contextNode;try{O.setRenderTarget(U);const e=N?2:1;for(let t=0;t<e;t++){if(0===t&&N&&this.rttNode){if(!J||!p)throw new Error("TRAA warmup requires the scene MRT and TSL context module.");const e=m({...J.outputNodes,velocity:x(0)});for(const t of Object.keys(J.outputNodes))e.setBlendMode(t,J.getBlendMode(t));null===this.traaWarmupContext&&(this.traaWarmupContext=p({})),T.setMRT(e),T.contextNode=this.traaWarmupContext,k.outputNode=this.rttNode,k.needsUpdate=!0}else N&&(T.setMRT(J),T.contextNode=F,k.outputNode=R,k.needsUpdate=!0);k.render()}}finally{T.setMRT(J),T.contextNode=F,k.outputNode!==R&&(k.outputNode=R,k.needsUpdate=!0),O.setRenderTarget(I,W,z),U.dispose()}}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.canvas.requestFullscreen()}update(e){this.dT=(e-this.timeLast)/1e3,this.timeLast=e;let t=!0,s=this.dT;if(("graphics"===this.gfxMode||"eco"===this.gfxMode&&this.ecoButtonActive)&&(this.dTs.push(this.dT),this.dTs.length>this.cfg.render.deltaTimesMax&&this.dTs.shift(),this.dTs.length===this.cfg.render.deltaTimesMax)){const i=[...this.dTs].sort((e,t)=>e-t),n=i[Math.floor(.25*(i.length-1))];if("graphics"===this.gfxMode){const e=i[Math.floor(.5*(i.length-1))],t=i[Math.floor(.8*(i.length-1))],s=e<=1.2*n&&t<=1.2*e?"up":e>=1.4*n||t>=1.4*e?"down":"neutral";"complete"===this.gfxState?"down"===s?this.updateGfx("complete",s):this.dTs.length=0:(this.gfxMode="off",this.updateGfx(this.gfxState,s))}else if("eco"===this.gfxMode){const i=2*n;if(i<=1/this.cfg.render.fpsMin&&this.ecoButtonActive){t=!1,s=(e-this.timeLastFrame)/1e3;const o=s+n;(s>=i||o>=i&&o-i>i-s)&&(t=!0)}}}if(this.gfxLevelChanges)this.gfxLevelChanges=!1;else if(t){this.infoBox&&this.infoBox.begin(e),this.timeGsap+=s,gsap.gsap.updateRoot(this.timeGsap),this.scene.mixer&&this.scene.actionCtrls&&(this.scene.actionCtrls.update(),this.scene.mixer.update(s));for(const e of this.callbacks)e(s);for(const e of this.objs3D.values())e.update(s,this.cam3D);let t=!1;!this.isPostCfg()||this.cfg.render.adaptiveGfx&&0===this.gfxLevel?(this.renderer.render(this.scene.obj,this.cam3D.obj),t=!0):this.modules.webGpuRendererClass?this.renderPipeline&&(this.renderPipeline.render(),t=!0):this.composer&&(this.composer.render(),t=!0),t&&("next"!==this.gfxState&&"back"!==this.gfxState||this.updateGfx(this.gfxState),this.resolveWaitForRender&&(this.resolveWaitForRender(),this.resolveWaitForRender=null)),this.timeLastFrame=e,this.infoBox&&(this.infoBox.end(performance.now(),this.renderer),this.renderer.info.reset())}}updateCanvasResize(){const e=this.canvas.getBoundingClientRect(),t=e.width,s=e.height;this.renderer.setSize(t,s,!1),this.modules.webGpuRendererClass?(this.tslPass?.setSize(t,s),this.gtaoNode?.setSize(t,s),this.ssrNode?.setSize(t,s),this.renderPipeline&&(this.renderPipeline.needsUpdate=!0)):(this.composer?.setSize(t,s),this.smaaPass?.setSize(t,s),this.fxaaPass&&this.setPostAaParams()),this.dTs.length=0,this.cam3D.updateCanvasResize(e),this.scene.groundReflector&&(this.scene.groundReflector.getRenderTarget().setSize(t,s),this.scene.groundReflector.resolution.set(t,s))}updateGfx(e,t){switch(e){case"idle":if(this.gfxState="idle",this.gfxDownOnly=!1,1===this.gfxPostProfiles.length)return void this.updateGfx("complete");this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0;break;case"current":if(void 0===t)return;if(this.gfxDownOnly&&"down"!==t)return void this.updateGfx("complete");if("up"===t){if(this.gfxLevel===this.gfxPostProfiles.length-1)return void this.updateGfx("complete");this.gfxState="next",this.setGfxLevel(this.gfxLevel+1)}else if("down"===t){if(0===this.gfxLevel)return void this.updateGfx("complete");this.gfxState="back",this.setGfxLevel(this.gfxLevel-1)}else this.updateGfx("complete");break;case"next":this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0;break;case"back":this.gfxDownOnly?(this.gfxState="current",this.gfxMode="graphics",this.dTs.length=0):this.updateGfx("complete");break;case"complete":if("down"===t&&this.gfxLevel>0){this.gfxDownOnly=!0,this.gfxState="back",this.setGfxLevel(this.gfxLevel-1);break}this.gfxState="complete",this.gfxDownOnly=!1,this.dTs.length=0,this.gfxMode=this.cfg.render.ecoMode&&this.ecoButtonActive?"eco":this.gfxLevel>0?"graphics":"off",this.gfxEvents.emit({type:"Gfx_Ready",gfxLevel:this.gfxLevel})}}use(e){e(this)}waitForRender(){return new Promise(e=>{this.resolveWaitForRender=e})}},EnvCtrls=class{cfg;engine;events;modules;scene;envReady=Promise.resolve();textReady=Promise.resolve(null);bgdReady=Promise.resolve();envEnabled=!1;envInit=!1;envLoadId=0;envIntensity;bgdIntensity;bgdBlurriness;rotation;rotationSpeed;envType;envMaps;envText=null;bgdText=null;callback=null;frameWaiters=[];timeBgdRot=0;constructor(e,t,s,i,n){this.cfg=e,this.engine=t,this.scene=s,this.events=i,this.modules=n,this.envIntensity=this.cfg.envCtrls.environmentIntensity,this.bgdIntensity=this.cfg.envCtrls.backgroundIntensity,this.bgdBlurriness=this.cfg.envCtrls.backgroundBlurriness,this.rotationSpeed=this.cfg.envCtrls.rotationSpeed,this.envType=this.cfg.envCtrls.type,this.envMaps=[...this.cfg.envCtrls.map],this.rotation=new THREE.Euler(THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.x),THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.y),THREE.MathUtils.degToRad(this.cfg.envCtrls.rotation.z))}init(){if(!this.cfg.envCtrls.enable||this.envEnabled||this.envInit)return this.envReady;this.envInit=!0;const e=this.envMaps.length>0?this.envMaps[0]:"";return this.textReady=this.loadText(this.envType,e),this.startEnv(),this.envReady}async applyBgds(e,t,s,i){let n=i;for(const i of s){const s=await this.loadText(t,i);if(s){if(this.envLoadId!==e)return void this.disposeText(s);if(await this.waitFrames(2),this.envLoadId!==e)return void this.disposeText(s);if(this.setBgd(s),await this.waitFrames(1),this.envLoadId!==e)return this.disposeText(s),void this.disposePrevBgd(n);this.disposePrevBgd(n),n=s}}this.envLoadId===e&&this.events.send({type:"Env_Loaded"},"Environment and background maps loaded")}async applyEnv(e,t,s){const i=await this.textReady;if(!i||this.envLoadId!==e)return;const n=this.modules.webGpuRendererClass;if(n&&this.engine.renderer instanceof n)this.setEnv(i);else{const e=new THREE.PMREMGenerator(this.engine.renderer);try{e.compileEquirectangularShader();const t=e.fromEquirectangular(i).texture;this.setEnv(t,i)}finally{e.dispose()}}this.callback||(this.callback=e=>this.update(e),this.engine.addOnFrameUpdate(this.callback)),this.bgdReady=this.applyBgds(e,t,s.slice(1),i).catch(e=>{console.warn("Failed to apply background map:",e)})}disposePrevBgd(e){e&&this.envText!==e&&this.scene.obj.environment!==e&&(this.bgdText===e&&(this.bgdText=null),this.disposeText(e))}disposeText(e){e&&(this.envText===e&&(this.envText=null),this.bgdText===e&&(this.bgdText=null),e.dispose())}enable(e){if(this.envEnabled)return;const t=e?.type??this.cfg.envCtrls.type,s=[...e?.map??this.cfg.envCtrls.map];this.cfg.envCtrls.enable=!0,this.envEnabled=!0,this.envType=t,this.envMaps=s,this.textReady=this.loadText(t,s[0]??""),this.startEnv(t,s)}disable(){if(!this.envEnabled&&!this.envInit&&!this.isEnabled())return;this.cfg.envCtrls.enable=!1,this.envEnabled=!1,this.envInit=!1,this.envLoadId++,this.resolveFrameWaiters(!0),this.engine&&this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null);const e=this.envText,t=this.bgdText;this.disposeText(e),t!==e&&this.disposeText(t),this.scene.obj.environment=null,this.scene.obj.environmentRotation.set(0,0,0),this.scene.obj.environmentIntensity=this.envIntensity,this.scene.obj.background=null,this.scene.obj.backgroundRotation.set(0,0,0),this.scene.obj.backgroundIntensity=this.bgdIntensity,this.scene.obj.backgroundBlurriness=this.bgdBlurriness,this.rotationSpeed=this.cfg.envCtrls.rotationSpeed,this.timeBgdRot=0}get(){return{rotationSpeed:this.rotationSpeed,environmentIntensity:this.envIntensity,backgroundIntensity:this.bgdIntensity,backgroundBlurriness:this.bgdBlurriness,rotation:{x:THREE.MathUtils.radToDeg(this.rotation.x),y:THREE.MathUtils.radToDeg(this.rotation.y),z:THREE.MathUtils.radToDeg(this.rotation.z)}}}isEnabled(){return null!==this.scene.obj.environment||null!==this.scene.obj.background}async loadText(e,t){if(!t)return console.warn("Environment map is empty."),null;try{let s;if("hdr"===e||"exr"===e){if(!this.modules.envLoader)return console.warn("Modules EXRLoader or ENVLoader could not be imported."),null;const e=this.modules.webGpuRendererClass,i="float"===this.cfg.envCtrls.dataType&&(e&&this.engine.renderer instanceof e||this.engine.renderer.extensions.has("OES_texture_float_linear"));this.modules.envLoader.setDataType(i?THREE.FloatType:THREE.HalfFloatType),s=await this.modules.envLoader.loadAsync(t)}else s=await(new THREE.TextureLoader).loadAsync(t);return s.mapping=THREE.EquirectangularReflectionMapping,s}catch(e){return console.warn("Failed to load environment map:",t,e),null}}set(e){void 0!==e.rotationSpeed&&(this.rotationSpeed=e.rotationSpeed),void 0!==e.environmentIntensity&&(this.envIntensity=e.environmentIntensity,this.scene.obj.environmentIntensity=this.envIntensity),void 0!==e.backgroundIntensity&&(this.bgdIntensity=e.backgroundIntensity,this.scene.obj.backgroundIntensity=this.bgdIntensity),void 0!==e.backgroundBlurriness&&(this.bgdBlurriness=e.backgroundBlurriness,this.scene.obj.backgroundBlurriness=this.bgdBlurriness),void 0!==e.rotation&&(this.rotation.set(THREE.MathUtils.degToRad(e.rotation.x),THREE.MathUtils.degToRad(e.rotation.y),THREE.MathUtils.degToRad(e.rotation.z)),this.scene.obj.environmentRotation.copy(this.rotation),this.scene.obj.backgroundRotation.copy(this.rotation))}setEnv(e,t=e){this.envText=e,this.scene.obj.environment=e,this.scene.obj.environmentRotation.copy(this.rotation),this.scene.obj.environmentIntensity=this.envIntensity,this.setBgd(t)}setBgd(e){this.bgdText=e,this.scene.obj.background=e,this.scene.obj.backgroundRotation.copy(this.rotation),this.scene.obj.backgroundIntensity=this.bgdIntensity,this.scene.obj.backgroundBlurriness=this.bgdBlurriness}startEnv(e=this.envType,t=this.envMaps){const s=++this.envLoadId;this.envReady=this.applyEnv(s,e,t).catch(e=>{console.warn("Failed to apply environment:",e),this.envLoadId===s&&this.setEnv(null)})}waitFrames(e){return e<=0?Promise.resolve():new Promise(t=>{this.frameWaiters.push({remaining:e,resolve:t})})}resolveFrameWaiters(e=!1){const t=[];for(const s of this.frameWaiters)e||s.remaining--,e||s.remaining<=0?s.resolve():t.push(s);this.frameWaiters=t}update(e){if(0===this.rotationSpeed)this.scene.obj.environmentRotation.copy(this.rotation);else{this.timeBgdRot+=e*this.rotationSpeed;const t=THREE.MathUtils.degToRad(this.timeBgdRot);this.scene.obj.environmentRotation.set(this.rotation.x,this.rotation.y+t,this.rotation.z)}this.scene.obj.backgroundRotation.copy(this.scene.obj.environmentRotation),this.resolveFrameWaiters()}},Events=class{cfg;stateMachine;eventQueue=[];isProcessingEvents=!1;constructor(e,t){this.cfg=e,this.stateMachine=t}enqueue(e){if(this.eventQueue.push(e),!this.isProcessingEvents){this.isProcessingEvents=!0;try{for(;this.eventQueue.length>0;){const e=this.eventQueue.shift();e&&e()}}finally{this.isProcessingEvents=!1}}}anim(e){let t=`${e.objName}`;this.send(e,t)}animFade(e){let t=`${e.objName} - ${e.property}: ${e.value}`;this.send(e,t)}audio(e){this.send(e,e.soundName)}clip(e){const t=[];e.clipName&&t.push(e.clipName),"Clip_Fade_Start"!==e.type&&"Clip_Fade_Complete"!==e.type||!e.fadeMode||t.push(`fadeMode: ${e.fadeMode}`),"Clip_Speed_Start"!==e.type&&"Clip_Speed_Complete"!==e.type||!e.action||t.push(`speed: ${e.action.timeScale}`),this.send(e,t.join(" - "))}modelError(e){let t="";t="SyntaxError"==e.error.name?"Model_Error: Invalid GLTF file or wrong path/filename.":`${e.error.name} / ${e.error.message}`,this.send(e,t)}modelLoaded(e){this.send(e)}modelLoading(e){this.send(e,`${e.loading}% loaded`)}sceneRendered(e){this.send(e,"First render complete")}send(e,t){this.enqueue(()=>{const s=this.stateMachine.sendEvent(e,t);"all"!=this.cfg.debug.log||s||console.log(`Event: ${e.type}${t?` - ${t}`:""}`)})}windowResize(e){this.send(e,"Window render size updated.")}},OrbitCtrls=class{cam3D;engine;events;modules;orbitControls=null;params;orbitCtrlsFirstChange=!0;callback=null;touchPointerIds=new Set;constructor(e,t,s,i,n){this.cam3D=e,this.engine=s,this.events=i,this.modules=n,this.params={...t}}create(){this.orbitControls||this.modules.orbitControlsClass&&(this.orbitControls=new this.modules.orbitControlsClass(this.cam3D.obj,this.engine.renderer.domElement),this.orbitControls?(this.orbitControls.enabled=!1,this.orbitCtrlsFirstChange=!0,this.orbitControls.addEventListener("start",()=>{this.orbitCtrlsFirstChange=!1,this.events.send({type:"OrbitCtrls_Start"})}),this.orbitControls.addEventListener("change",()=>{this.orbitCtrlsFirstChange||(this.orbitCtrlsFirstChange=!0,this.events.send({type:"OrbitCtrls_Changed"}))}),this.orbitControls.addEventListener("end",()=>{this.events.send({type:"OrbitCtrls_End"})})):console.warn("Module OrbitControls could not be imported."))}disable(){this.orbitControls&&!1!==this.orbitControls.enabled&&(this.orbitControls.enabled=!1,this.touchPointerIds.clear(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.events.send({type:"OrbitCtrls_Disabled"}))}enable(){this.orbitControls||this.create(),this.orbitControls&&(this.orbitControls.enabled||(this.orbitCtrlsFirstChange=!0,this.orbitControls.enabled=!0,this.cam3D.lookMode="target",this.orbitControls.target.copy(this.cam3D.objTarget.position),this.orbitControls.enableDamping=this.params.enableDamping,this.orbitControls.dampingFactor=this.params.dampingFactor,this.orbitControls.minDistance=this.params.minDistance,this.orbitControls.maxDistance=this.params.maxDistance,this.orbitControls.enableZoom=this.params.enableZoom,this.orbitControls.zoomSpeed=this.params.zoomSpeed,this.orbitControls.enableRotate=this.params.enableRotate,this.orbitControls.rotateSpeed=this.params.rotateSpeed,this.orbitControls.enablePan=this.params.enablePan,this.orbitControls.panSpeed=this.params.panSpeed,this.orbitControls.autoRotate=this.params.autoRotate,this.orbitControls.autoRotateSpeed=this.params.autoRotateSpeed,this.orbitControls.minAzimuthAngle=THREE.MathUtils.degToRad(this.params.minAzimuthAngle),this.orbitControls.maxAzimuthAngle=THREE.MathUtils.degToRad(this.params.maxAzimuthAngle),this.orbitControls.minPolarAngle=THREE.MathUtils.degToRad(this.params.minPolarAngle),this.orbitControls.maxPolarAngle=THREE.MathUtils.degToRad(this.params.maxPolarAngle),this.orbitControls.mouseButtons.LEFT=THREE.MOUSE.ROTATE,this.orbitControls.mouseButtons.MIDDLE=THREE.MOUSE.DOLLY,this.orbitControls.mouseButtons.RIGHT=THREE.MOUSE.PAN,this.orbitControls.touches.ONE=THREE.TOUCH.ROTATE,this.orbitControls.touches.TWO=THREE.TOUCH.DOLLY_PAN,this.callback=e=>{this.orbitControls&&(this.orbitControls.update(e),this.cam3D.objTarget.position.copy(this.orbitControls.target))},this.engine.addOnFrameUpdate(this.callback),this.events.send({type:"OrbitCtrls_Enabled"})))}dispose(){this.touchPointerIds.clear(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.orbitControls?.dispose(),this.orbitControls=null,this.events.send({type:"OrbitCtrls_Disposed"})}get(){return{enableDamping:this.params.enableDamping,dampingFactor:this.params.dampingFactor,minDistance:this.params.minDistance,maxDistance:this.params.maxDistance,enableZoom:this.params.enableZoom,zoomSpeed:this.params.zoomSpeed,enableRotate:this.params.enableRotate,rotateSpeed:this.params.rotateSpeed,enablePan:this.params.enablePan,panSpeed:this.params.panSpeed,autoRotate:this.params.autoRotate,autoRotateSpeed:this.params.autoRotateSpeed,minAzimuthAngle:this.params.minAzimuthAngle,maxAzimuthAngle:this.params.maxAzimuthAngle,minPolarAngle:this.params.minPolarAngle,maxPolarAngle:this.params.maxPolarAngle}}isEnabled(){return null!==this.orbitControls&&!0===this.orbitControls?.enabled}set(e){this.orbitControls&&(void 0!==e.enableDamping&&(this.params.enableDamping=e.enableDamping,this.orbitControls.enableDamping=e.enableDamping),void 0!==e.dampingFactor&&(this.params.dampingFactor=e.dampingFactor,this.orbitControls.dampingFactor=e.dampingFactor),void 0!==e.minDistance&&(this.params.minDistance=e.minDistance,this.orbitControls.minDistance=e.minDistance),void 0!==e.maxDistance&&(this.params.maxDistance=e.maxDistance,this.orbitControls.maxDistance=e.maxDistance),void 0!==e.enableZoom&&(this.params.enableZoom=e.enableZoom,this.orbitControls.enableZoom=e.enableZoom),void 0!==e.zoomSpeed&&(this.params.zoomSpeed=e.zoomSpeed,this.orbitControls.zoomSpeed=e.zoomSpeed),void 0!==e.enableRotate&&(this.params.enableRotate=e.enableRotate,this.orbitControls.enableRotate=e.enableRotate),void 0!==e.rotateSpeed&&(this.params.rotateSpeed=e.rotateSpeed,this.orbitControls.rotateSpeed=e.rotateSpeed),void 0!==e.enablePan&&(this.params.enablePan=e.enablePan,this.orbitControls.enablePan=e.enablePan),void 0!==e.panSpeed&&(this.params.panSpeed=e.panSpeed,this.orbitControls.panSpeed=e.panSpeed),void 0!==e.autoRotate&&(this.params.autoRotate=e.autoRotate,this.orbitControls.autoRotate=e.autoRotate),void 0!==e.autoRotateSpeed&&(this.params.autoRotateSpeed=e.autoRotateSpeed,this.orbitControls.autoRotateSpeed=e.autoRotateSpeed),void 0!==e.minAzimuthAngle&&(this.params.minAzimuthAngle=e.minAzimuthAngle,this.orbitControls.minAzimuthAngle=THREE.MathUtils.degToRad(e.minAzimuthAngle)),void 0!==e.maxAzimuthAngle&&(this.params.maxAzimuthAngle=e.maxAzimuthAngle,this.orbitControls.maxAzimuthAngle=THREE.MathUtils.degToRad(e.maxAzimuthAngle)),void 0!==e.minPolarAngle&&(this.params.minPolarAngle=e.minPolarAngle,this.orbitControls.minPolarAngle=THREE.MathUtils.degToRad(e.minPolarAngle)),void 0!==e.maxPolarAngle&&(this.params.maxPolarAngle=e.maxPolarAngle,this.orbitControls.maxPolarAngle=THREE.MathUtils.degToRad(e.maxPolarAngle)))}use(e){e(this)}},FpvCtrls=class{cam3D;canvas;engine;events;modules;pointerLockCtrls=null;params;isMoveForward=!1;isMoveLeft=!1;isMoveBackward=!1;isMoveRight=!1;isMoveUp=!1;isMoveDown=!1;callback=null;onClick=()=>{this.isEnabled()&&(this.isLocked()?this.unlock():this.lock())};onKeyDown=e=>{this.isEnabled()&&(e.code===this.params.keyMoveForward&&(this.isMoveForward=!0),e.code===this.params.keyMoveLeft&&(this.isMoveLeft=!0),e.code===this.params.keyMoveBackward&&(this.isMoveBackward=!0),e.code===this.params.keyMoveRight&&(this.isMoveRight=!0),e.code===this.params.keyMoveUp&&(this.isMoveUp=!0),e.code===this.params.keyMoveDown&&(this.isMoveDown=!0))};onKeyUp=e=>{this.isEnabled()&&(e.code===this.params.keyMoveForward&&(this.isMoveForward=!1),e.code===this.params.keyMoveLeft&&(this.isMoveLeft=!1),e.code===this.params.keyMoveBackward&&(this.isMoveBackward=!1),e.code===this.params.keyMoveRight&&(this.isMoveRight=!1),e.code===this.params.keyMoveUp&&(this.isMoveUp=!1),e.code===this.params.keyMoveDown&&(this.isMoveDown=!1))};constructor(e,t,s,i,n,o){this.cam3D=e,this.canvas=t,this.engine=i,this.events=n,this.modules=o,this.params={...s}}create(){this.pointerLockCtrls||this.modules.pointerLockControlsClass&&(this.pointerLockCtrls=new this.modules.pointerLockControlsClass(this.cam3D.obj,this.engine.renderer.domElement),this.pointerLockCtrls?(this.pointerLockCtrls.enabled=!1,this.pointerLockCtrls.addEventListener("lock",()=>{this.events.send({type:"FpvCtrls_Lock"})}),this.pointerLockCtrls.addEventListener("unlock",()=>{this.events.send({type:"FpvCtrls_Unlock"})}),this.canvas.addEventListener("click",this.onClick),this.canvas.addEventListener("keydown",this.onKeyDown),this.canvas.addEventListener("keyup",this.onKeyUp)):console.warn("Module PointerLockControls could not be imported."))}disable(){this.pointerLockCtrls&&0!=this.pointerLockCtrls.enabled&&(this.pointerLockCtrls.enabled=!1,this.pointerLockCtrls.isLocked&&this.pointerLockCtrls.unlock(),this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.isMoveForward=!1,this.isMoveLeft=!1,this.isMoveBackward=!1,this.isMoveRight=!1,this.isMoveUp=!1,this.isMoveDown=!1,this.events.send({type:"FpvCtrls_Disabled"}))}enable(){this.pointerLockCtrls||this.create(),this.pointerLockCtrls&&1!=this.pointerLockCtrls.enabled&&(this.pointerLockCtrls.enabled=!0,this.pointerLockCtrls.minPolarAngle=this.params.minPolarAngle,this.pointerLockCtrls.maxPolarAngle=this.params.maxPolarAngle,this.pointerLockCtrls.pointerSpeed=this.params.pointerSpeed,this.callback=e=>{this.pointerLockCtrls?.isLocked&&(this.isMoveForward&&this.moveForward(e),this.isMoveBackward&&this.moveForward(-e),this.isMoveLeft&&this.moveRight(-e),this.isMoveRight&&this.moveRight(e),this.isMoveUp&&this.moveUp(e),this.isMoveDown&&this.moveUp(-e))},this.engine.addOnFrameUpdate(this.callback),this.events.send({type:"FpvCtrls_Enabled"}))}dispose(){this.callback&&(this.engine.removeOnFrameUpdate(this.callback),this.callback=null),this.canvas.removeEventListener("click",this.onClick),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("keyup",this.onKeyUp),this.isMoveForward=!1,this.isMoveLeft=!1,this.isMoveBackward=!1,this.isMoveRight=!1,this.isMoveUp=!1,this.isMoveDown=!1,this.pointerLockCtrls?.isLocked&&this.pointerLockCtrls.unlock(),this.pointerLockCtrls?.dispose(),this.pointerLockCtrls=null,this.events.send({type:"FpvCtrls_Disposed"})}get(){return{minPolarAngle:this.params.minPolarAngle,maxPolarAngle:this.params.maxPolarAngle,pointerSpeed:this.params.pointerSpeed,keyMoveForward:this.params.keyMoveForward,keyMoveLeft:this.params.keyMoveLeft,keyMoveBackward:this.params.keyMoveBackward,keyMoveRight:this.params.keyMoveRight,keyMoveUp:this.params.keyMoveUp,keyMoveDown:this.params.keyMoveDown}}isEnabled(){return!0===this.pointerLockCtrls?.enabled}isLocked(){return this.pointerLockCtrls?.isLocked??!1}lock(){this.cam3D.lookMode="free",this.pointerLockCtrls?.lock()}moveForward(e){this.pointerLockCtrls?.moveForward(e)}moveRight(e){this.pointerLockCtrls?.moveRight(e)}moveUp(e){this.cam3D.obj.position.y+=e}set(e){this.pointerLockCtrls&&(void 0!==e.minPolarAngle&&(this.params.minPolarAngle=e.minPolarAngle,this.pointerLockCtrls.minPolarAngle=e.minPolarAngle),void 0!==e.maxPolarAngle&&(this.params.maxPolarAngle=e.maxPolarAngle,this.pointerLockCtrls.maxPolarAngle=e.maxPolarAngle),void 0!==e.pointerSpeed&&(this.params.pointerSpeed=e.pointerSpeed,this.pointerLockCtrls.pointerSpeed=e.pointerSpeed),void 0!==e.keyMoveForward&&(this.params.keyMoveForward=e.keyMoveForward),void 0!==e.keyMoveLeft&&(this.params.keyMoveLeft=e.keyMoveLeft),void 0!==e.keyMoveBackward&&(this.params.keyMoveBackward=e.keyMoveBackward),void 0!==e.keyMoveRight&&(this.params.keyMoveRight=e.keyMoveRight),void 0!==e.keyMoveUp&&(this.params.keyMoveUp=e.keyMoveUp),void 0!==e.keyMoveDown&&(this.params.keyMoveDown=e.keyMoveDown))}unlock(){this.pointerLockCtrls?.unlock(),this.events.send({type:"FpvCtrls_Unlock"})}use(e){e(this)}},Raycast=class{cam3D;canvas;cfg;engine;events;objs3D;scene;raycasterPick=new THREE.Raycaster;raycasterVisible=new THREE.Raycaster;colliders=new Map;objsColliders=[];objsOccluders=[];objsOccludees=[];hasPickables=!1;useSceneAsOccluder=!0;objActive=null;objCandidate=null;closestObjCounter=0;indexOccludeeNext=0;pickablesEnabled=!1;timeOccludeeNext=0;callbackOccludees=null;callbackPointerHover=null;listenerClick;listenerCancel;listenerDown;listenerLeave;listenerMove;listenerUp;eventPointerMove=null;posPrevPointerX=0;posPrevPointerY=0;posWorldObj=new THREE.Vector3;dirCamToObj=new THREE.Vector3;posNdcPointer=new THREE.Vector2;constructor(e,t,s,i,n,o,a){this.cam3D=e,this.canvas=t,this.cfg=s,this.engine=i,this.events=o,this.objs3D=a,this.scene=n,this.listenerMove=e=>this.onCanvasPointerMove(e),this.listenerClick=e=>this.onCanvasClick(e),this.listenerCancel=e=>this.onCanvasPointerCancel(e),this.listenerDown=e=>this.onCanvasPointerDown(e),this.listenerLeave=e=>this.onCanvasPointerLeave(e),this.listenerUp=e=>this.onCanvasPointerUp(e)}checkOccludeeVisible(e){e.getWorldPosition(this.posWorldObj),this.dirCamToObj.subVectors(this.posWorldObj,this.cam3D.obj.position);const t=this.dirCamToObj.length();if(t<=0)return!0;this.dirCamToObj.normalize(),this.raycasterVisible.set(this.cam3D.obj.position,this.dirCamToObj),this.raycasterVisible.near=0,this.raycasterVisible.far=Math.max(0,t-1e-4);const s=this.useSceneAsOccluder?this.scene.obj.children:this.objsOccluders;return 0===s.length||!this.raycasterVisible.intersectObjects(s,!0).some(t=>t.object!==e)}clearColliders(e){if(!Array.isArray(e))return;const t=this.pickablesEnabled;t&&this.disablePickables();for(const t of e){for(const[e,s]of this.colliders)s.coll3D===t&&this.colliders.delete(e);t.hidden=!1,t.pickable=!1,t.occluder=!1,t.applyHidden()}this.rebuildColliderCaches(),this.invalidateOccludees(),this.useSceneAsOccluder=!1,t&&this.enablePickables()}enablePickables(){this.pickablesEnabled||this.hasPickables&&(this.canvas.addEventListener("pointermove",this.listenerMove),this.canvas.addEventListener("click",this.listenerClick),this.canvas.addEventListener("pointercancel",this.listenerCancel),this.canvas.addEventListener("pointerdown",this.listenerDown),this.canvas.addEventListener("pointerleave",this.listenerLeave),this.canvas.addEventListener("pointerup",this.listenerUp),null===this.callbackPointerHover&&(this.callbackPointerHover=()=>this.updatePointerHover(),this.engine.addOnFrameUpdate(this.callbackPointerHover)),this.pickablesEnabled=!0)}disablePickables(){this.pickablesEnabled&&(this.canvas.removeEventListener("pointermove",this.listenerMove),this.canvas.removeEventListener("click",this.listenerClick),this.canvas.removeEventListener("pointercancel",this.listenerCancel),this.canvas.removeEventListener("pointerdown",this.listenerDown),this.canvas.removeEventListener("pointerleave",this.listenerLeave),this.canvas.removeEventListener("pointerup",this.listenerUp),null!==this.callbackPointerHover&&(this.engine.removeOnFrameUpdate(this.callbackPointerHover),this.callbackPointerHover=null),this.objActive=null,this.objCandidate=null,this.closestObjCounter=0,this.eventPointerMove=null,this.pickablesEnabled=!1)}getColliderState(e){let t=e;for(;null!==t;){const e=this.colliders.get(t);if(e)return e;t=t.parent}return null}getPickableHit(e){this.raycasterPick.setFromCamera(e,this.cam3D.obj);const t=this.raycasterPick.intersectObjects(this.objsColliders,!0);for(const e of t){const t=this.getColliderState(e.object);if(t){if(t.pickable)return{obj:t.target.obj,point:e.point};if(t.occluder)return null}}return null}getObjAtPointer(){return this.getPickableHit(this.posNdcPointer)?.obj??null}emitPointerEvent(e){const t=this.objs3D.get(e.objName);t?t.emitEvent(e):this.events.send(e,e.objName)}getOccludeeState(e){let t=this.objsOccludees.find(t=>t.obj===e);return t||(t={obj:e,needsCheck:!1,visible:!1},this.objsOccludees.push(t),1===this.objsOccludees.length&&(this.indexOccludeeNext=0),t)}getOccludeeVisible(e){return this.getOccludeeState(e).visible}initColliders(){const e=[];for(const t of this.objs3D.values())t instanceof Coll3D&&(t.resolveTarget(this.objs3D),(t.pickable||t.occluder)&&e.push(t));0!==e.length&&(this.setColliders(e),this.enablePickables())}invalidateOccludees(){for(const e of this.objsOccludees)e.needsCheck=!0;this.indexOccludeeNext=0,this.timeOccludeeNext=0}rebuildColliderCaches(){this.objsColliders=[],this.objsOccluders=[],this.hasPickables=!1;for(const e of this.colliders.values())(e.occluder||e.pickable)&&this.objsColliders.push(e.obj),e.occluder&&this.objsOccluders.push(e.obj),e.pickable&&(this.hasPickables=!0)}onCanvasClick(e){this.updatePointerPosition(e);const t=this.getObjAtPointer();t&&t.name&&this.emitPointerEvent({type:"Obj3D_Click",event:e,objName:t.name})}onCanvasPointerLeave(e){this.onCanvasPointerExit(e)}onCanvasPointerMove(e){this.updatePointerPosition(e),this.eventPointerMove=e}onCanvasPointerCancel(e){this.onCanvasPointerExit(e)}onCanvasPointerDown(e){this.updatePointerPosition(e);const t=this.getObjAtPointer();this.objActive?.name&&t!==this.objActive&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:e,objName:this.objActive.name}),t?.name&&t!==this.objActive&&this.emitPointerEvent({type:"Obj3D_Pointer_Enter",event:e,objName:t.name}),this.objActive=t,this.objCandidate=null,this.closestObjCounter=0,this.objActive?.name&&this.emitPointerEvent({type:"Obj3D_Pointer_Down",event:e,objName:this.objActive.name})}onCanvasPointerExit(e){this.objActive?.name&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:e,objName:this.objActive.name}),this.objActive=null,this.objCandidate=null,this.closestObjCounter=0,this.eventPointerMove=null}onCanvasPointerUp(e){this.objActive?.name&&(this.emitPointerEvent({type:"Obj3D_Pointer_Up",event:e,objName:this.objActive.name}),"touch"===e.pointerType&&this.onCanvasPointerExit(e))}setColliders(e){if(!Array.isArray(e))return;if(0===e.length)return;const t=this.pickablesEnabled;t&&this.disablePickables();for(const t of e){t.applyHidden();for(const[e,s]of this.colliders)s.coll3D===t&&this.colliders.delete(e);const e=t.obj;if(!e)continue;if(!t.occluder&&!t.pickable)continue;const s={obj:e,coll3D:t,target:t.target??t,occluder:t.occluder,pickable:t.pickable};this.colliders.set(e,s)}this.rebuildColliderCaches(),this.invalidateOccludees(),this.useSceneAsOccluder=!1,t&&this.enablePickables()}trackOccludee(e){this.getOccludeeState(e).needsCheck=!0,null===this.callbackOccludees&&(this.timeOccludeeNext=0,this.callbackOccludees=()=>this.updateOccludees(),this.engine.addOnFrameUpdate(this.callbackOccludees))}untrackOccludee(e){const t=this.objsOccludees.findIndex(t=>t.obj===e);-1!==t&&(this.objsOccludees.splice(t,1),this.indexOccludeeNext=0,this.timeOccludeeNext=0,0===this.objsOccludees.length&&null!==this.callbackOccludees&&(this.engine.removeOnFrameUpdate(this.callbackOccludees),this.callbackOccludees=null))}use(e){e(this)}updateOccludees(){const e=this.objsOccludees.length,t=this.cfg.raycast.occludeeInterval;if(0===t){for(const e of this.objsOccludees)e.needsCheck&&(e.visible=this.checkOccludeeVisible(e.obj),e.needsCheck=!1);return}const s=performance.now(),i=t/e;let n=0;for((0===this.timeOccludeeNext||s-this.timeOccludeeNext>=t)&&(this.timeOccludeeNext=s);s>=this.timeOccludeeNext&&n<e;){const t=this.objsOccludees[this.indexOccludeeNext];this.indexOccludeeNext=(this.indexOccludeeNext+1)%e,this.timeOccludeeNext+=i,n++,t.needsCheck&&(t.visible=this.checkOccludeeVisible(t.obj),t.needsCheck=!1)}}updatePointerHover(){if(!this.hasPickables)return;if(!this.eventPointerMove)return;let e=null,t=1/0;for(let s=0;s<this.cfg.raycast.circleSteps;s++){const i=s/this.cfg.raycast.circleSteps*Math.PI*2,n=this.canvas.getBoundingClientRect(),o=Math.cos(i)*this.cfg.raycast.circleRadius/n.width*2,a=Math.sin(i)*this.cfg.raycast.circleRadius/n.height*2,r=new THREE.Vector2(this.posNdcPointer.x+o,this.posNdcPointer.y+a),l=this.getPickableHit(r);if(l){const s=l.point.clone().project(this.cam3D.obj),i=this.posNdcPointer.distanceTo(s);i<t&&(t=i,e=l.obj)}}if(e!==this.objActive)e===this.objCandidate?this.closestObjCounter++:(this.objCandidate=e,this.closestObjCounter=1),this.closestObjCounter>=this.cfg.raycast.countClosestObjs&&(this.objActive?.name&&this.eventPointerMove&&this.emitPointerEvent({type:"Obj3D_Pointer_Leave",event:this.eventPointerMove,objName:this.objActive.name}),this.objCandidate?.name&&this.eventPointerMove&&this.emitPointerEvent({type:"Obj3D_Pointer_Enter",event:this.eventPointerMove,objName:this.objCandidate.name}),this.objActive=this.objCandidate,this.objCandidate=null,this.closestObjCounter=0);else{if(this.closestObjCounter=0,this.objCandidate=null,!this.eventPointerMove)return;const e=this.eventPointerMove;e.clientX===this.posPrevPointerX&&e.clientY===this.posPrevPointerY||!this.objActive?.name||this.emitPointerEvent({type:"Obj3D_Pointer_Move",event:e,objName:this.objActive.name}),this.posPrevPointerX=e.clientX,this.posPrevPointerY=e.clientY}}updatePointerPosition(e){const t=this.canvas.getBoundingClientRect(),s=(e.clientX-t.left)/t.width,i=(e.clientY-t.top)/t.height;this.posNdcPointer.x=2*s-1,this.posNdcPointer.y=-(2*i-1)}},ActionCtrls=class{mixer;events;actions=new Map;constructor(e,t){this.mixer=e,this.events=t,this.mixer.addEventListener("finished",this.finished)}play(e,t){const s="additive"===t.blendMode?THREE.AdditiveAnimationBlendMode:THREE.NormalAnimationBlendMode,i=this.mixer.clipAction(e,void 0,s),n=this.actions.get(i);let o,a,r;if(n)if(n.finished)o=i.enabled?this.getWeight(i):0,a="out"===n.fadeMode,r=t.reset,this.cancelFade(n),this.cancelSpeed(n);else{if("out"!==n.fadeMode)return void(n.startSpeed===t.startSpeed&&n.endSpeed===t.endSpeed&&n.speedDuration===t.speedDuration&&n.speedEase===t.speedEase&&n.reverse===t.reverse||(n.startSpeed=t.startSpeed,n.endSpeed=t.endSpeed,n.speedDuration=t.speedDuration,n.speedEase=t.speedEase,n.reverse=t.reverse,t.speedDuration>0?this.speedAction(i,n,this.signedSpeed(t.startSpeed,t.reverse),this.signedSpeed(t.endSpeed,t.reverse),t.speedDuration,t.speedEase):(this.cancelSpeed(n),i.timeScale=this.signedSpeed(t.endSpeed,t.reverse))));o=i.enabled?this.getWeight(i):0,a=!0,r=!1,this.cancelFade(n),this.cancelSpeed(n)}else o=0,a=!1,r=t.reset;r?(i.reset(),i.time=t.reverse?i.getClip().duration:0):(i.stopFading(),i.enabled=!0,i.paused=!1),"infinite"===t.loopMode?(i.setLoop(THREE.LoopRepeat,1/0),i.clampWhenFinished=!1):1===t.loopMode?(i.setLoop(THREE.LoopOnce,1),i.clampWhenFinished=!0):(i.setLoop(THREE.LoopRepeat,t.loopMode),i.clampWhenFinished=!0),this.actions.delete(i),this.actions.set(i,t);const l=t.fadeDuration>0?t.fadeDuration*(1-o):0,d=this.stopLayerActions(t.layer,t.stopMode,i,l);t.fadeDuration>0&&(d||a)?this.fadeInAction(i,t,l,o):this.fadeInAction(i,t,0,1),t.speedDuration>0?this.speedAction(i,t,this.signedSpeed(t.startSpeed,t.reverse),this.signedSpeed(t.endSpeed,t.reverse),t.speedDuration,t.speedEase):i.timeScale=this.signedSpeed(t.endSpeed,t.reverse),i.play(),t.started=!0,this.clipEvent("Clip_Start",i,t),this.mixer.update(0),t.hooks?.onUpdate?.()}stop(e,{clipName:t,fct:s,duration:i=0,ease:n="power1.inOut"}){const o=this.mixer.existingAction(e);if(!o)return void console.warn(`${s}: "${t}" is not currently playing.`);const a=this.actions.get(o);if(!a)return o.stop(),void this.events.clip({type:"Clip_Cancel",clipName:t,action:o});a.clipName=t,i>0?this.speedAction(o,a,o.getEffectiveTimeScale(),0,i,n,()=>{this.cancel(o)}):this.cancel(o)}cancel(e){const t=this.actions.get(e);if(!t)return void e.stop();const s=!t.finished;this.cancelFade(t),this.cancelSpeed(t),e.stop(),this.actions.delete(e),s&&this.clipEvent("Clip_Cancel",e,t)}dispose(){this.mixer.removeEventListener("finished",this.finished);for(const e of this.actions.values())e.tweenFade?.kill(),e.tweenSpeed?.kill();this.actions.clear()}cancelFade(e){e.tweenFade?.kill(),e.tweenFade=void 0,e.fadeMode=void 0}cancelSpeed(e){e.tweenSpeed?.kill(),e.tweenSpeed=void 0}clipEvent(e,t,s){this.events.clip({type:e,clipName:s.clipName,action:t})}fadeEvent(e,t,s,i){this.events.clip({type:e,clipName:s.clipName,action:t,fadeMode:i})}fadeAction(e,t,s,i,n,o,a){if(e.stopFading(),e.setEffectiveWeight(i),o<=0||i===n)return e.setEffectiveWeight(n),t.fadeMode=void 0,void a?.();const r={weight:i};let l;l=gsap.gsap.to(r,{weight:n,duration:o,ease:"none",onStart:()=>{this.fadeEvent("Clip_Fade_Start",e,t,s)},onUpdate:()=>{e.setEffectiveWeight(r.weight)},onComplete:()=>{e.setEffectiveWeight(n),t.tweenFade===l&&(t.tweenFade=void 0,t.fadeMode=void 0),this.fadeEvent("Clip_Fade_Complete",e,t,s),a?.()}}),t.tweenFade=l}fadeInAction(e,t,s,i){this.cancelFade(t),t.fadeMode="in",e.enabled=!0,this.fadeAction(e,t,"in",i,1,s)}fadeOutAction(e,t,s){const i=this.getWeight(e);this.cancelFade(t),t.fadeMode="out",this.fadeAction(e,t,"out",i,0,s,()=>{e.enabled=!1,this.remove(e,t,!t.finished)})}finished=e=>{const t=this.actions.get(e.action);if(t&&!t.finished){if(t.finished=!0,"hold"!==t.finishMode){const s=t.fadeDurationFinish>0?t.fadeDurationFinish*this.getWeight(e.action):0;this.fadeOutAction(e.action,t,s)}this.clipEvent("Clip_Complete",e.action,t)}};getWeight(e){return Math.min(Math.max(e.getEffectiveWeight(),0),1)}remove(e,t,s){this.cancelFade(t),this.cancelSpeed(t),this.actions.get(e)===t&&(this.actions.delete(e),s&&this.clipEvent("Clip_Cancel",e,t))}signedSpeed(e,t){return t?-e:e}speedAction(e,t,s,i,n,o,a){if(this.cancelSpeed(t),e.timeScale=s,n<=0)return e.timeScale=i,void a?.();const r={timeScale:s};let l;l=gsap.gsap.to(r,{timeScale:i,duration:n,ease:o,onStart:()=>{this.events.clip({type:"Clip_Speed_Start",clipName:t.clipName,action:e})},onUpdate:()=>{e.timeScale=r.timeScale},onComplete:()=>{e.timeScale=i,t.tweenSpeed===l&&(t.tweenSpeed=void 0),this.events.clip({type:"Clip_Speed_Complete",clipName:t.clipName,action:e}),a?.()}}),t.tweenSpeed=l}stopLayerActions(e,t,s,i){let n=!1;for(const[o,a]of[...this.actions].reverse())if(a.layer===e&&o!==s&&o.enabled&&!(o.getEffectiveWeight()<=0)){if("none"===t)return!0;if(this.fadeOutAction(o,a,i),"last"===t)return!0;n=!0}return n}update(){for(const[e,t]of this.actions)!e.enabled||e.paused||e.getEffectiveWeight()<=0||t.hooks?.onUpdate?.()}},Scene=class{actionCtrls=null;cfg;cam3D;events;objs3D;tweens=new WeakMap;gltf=null;mixer=null;groundReflector=null;reflectivesSSR=[];ambientLight=null;hemisphereLight=null;obj;constructor(e,t,s,i){this.cam3D=e,this.cfg=t,this.events=s,this.objs3D=i,this.obj=new THREE.Scene,this.obj.backgroundBlurriness=t.envCtrls.backgroundBlurriness,this.obj.backgroundIntensity=t.envCtrls.backgroundIntensity,this.obj.environmentIntensity=t.envCtrls.environmentIntensity,this.obj.add(e.obj),t.scene.fog.enable&&this.setFog({color:t.scene.fog.color,near:t.scene.fog.near,far:t.scene.fog.far}),t.scene.ambientlight.enable&&this.setAmbientLight({color:t.scene.ambientlight.color,intensity:t.scene.ambientlight.intensity}),t.scene.hemisphere.enable&&this.setHemisphereLight({skyColor:t.scene.hemisphere.skyColor,groundColor:t.scene.hemisphere.groundColor,intensity:t.scene.hemisphere.intensity})}initFirstScene(e){this.actionCtrls?.dispose(),this.actionCtrls=null,this.gltf=e,this.mixer=null,this.obj.add(e.scene);const t=new Map;return e.animations&&e.animations.length>0&&(this.mixer=new THREE.AnimationMixer(e.scene),this.actionCtrls=new ActionCtrls(this.mixer,this.events)),e.scene.traverse(e=>{const s=this.objs3D.get(e.name);e instanceof THREE.Mesh?(t.set(e.name,e),e.castShadow=this.cfg.mesh.castShadow,e.receiveShadow=this.cfg.mesh.receiveShadow,e.frustumCulled=this.cfg.mesh.frustumCulled,s instanceof Mesh3D?(s.traverse(e),!this.groundReflector&&s.groundReflector&&(this.groundReflector=s.groundReflector)):e.material instanceof THREE.MeshStandardMaterial&&e.material.roughness<this.cfg.post.webgl.ssr.maxRoughness&&this.reflectivesSSR.push(e)):e instanceof THREE.Light?(e.castShadow=this.cfg.light.castShadow,(e instanceof THREE.DirectionalLight||e instanceof THREE.SpotLight||e instanceof THREE.PointLight)&&(e.shadow.mapSize.width=this.cfg.light.mapWidth,e.shadow.mapSize.height=this.cfg.light.mapHeight,e.shadow.bias=this.cfg.light.bias,e.shadow.normalBias=this.cfg.light.normalBias,e.shadow.camera.near=this.cfg.light.near,e.shadow.camera.far=this.cfg.light.far),s instanceof Light3D&&s.traverse(e)):e instanceof THREE.Camera?this.cam3D.traverse(e):e instanceof THREE.Object3D&&s instanceof Obj3D&&s.traverse(e)}),t}initObjs3D(e,t){for(const s of this.objs3D.values())s instanceof Mesh3D&&(s.setModel(t),s.setReflectivesSSR(this.reflectivesSSR)),s.start(e,this),s instanceof Mesh3D&&s.groundReflector&&(this.groundReflector=s.groundReflector)}animCamCurveTo({camTarget:e,aimTarget:t,radiusOut:s=1,duration:i=2,ease:n="power1.inOut"}){const o=this.animCamCurveTo.name,a=e=>{for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e},r=e=>{if("string"==typeof e){const t=this.obj.getObjectByName(e);return t?t.getWorldPosition(new THREE.Vector3):(console.warn(`${o}: Object with name "${e}" not found.`),null)}return e instanceof Obj3D?e.obj?e.obj.getWorldPosition(new THREE.Vector3):(console.warn(`${o}: Obj3D not found.`),null):e instanceof THREE.Vector3?e.clone():(console.warn(`${o}: Invalid target.`),null)},l=e=>{const t=Math.max(e.length(),1e-4);return{radius:t,lat:Math.asin(THREE.MathUtils.clamp(e.y/t,-1,1)),lon:Math.atan2(e.x,e.z)}};this.cam3D.lookMode="target";const d=this.cam3D.objTarget.position.clone(),c=r(e);if(!c)return void console.warn(`Camera object with name "${e}" was not found.`);const h=t?r(t):d;if(!h)return void console.warn(`Aim object with name "${t}" was not found.`);const m=this.cam3D.obj.getWorldPosition(new THREE.Vector3).clone().sub(d),p=c.clone().sub(h),u=l(m),g=l(p),b=u.lat,f=g.lat,v=a(u.lon),C=a(a(g.lon)-v),w=u.radius,y=g.radius,x=Math.max(w,y)*s,P={t:0};gsap.gsap.to(P,{t:1,duration:i,ease:n,onStart:()=>{this.events.anim({type:"Anim_Start",objName:"Camera",fct:o})},onUpdate:()=>{const e=P.t,t=d.clone().lerp(h,e),s=THREE.MathUtils.lerp(b,f,e),i=a(v+C*e),n=THREE.MathUtils.lerp(w,y,e),o=Math.sin(Math.PI*e)*x,r=((e,t,s)=>{const i=Math.cos(t);return new THREE.Vector3(e*i*Math.sin(s),e*Math.sin(t),e*i*Math.cos(s))})(Math.max(1e-4,n+o),s,i),l=t.clone().add(r);this.cam3D.obj.position.copy(l),this.cam3D.objTarget.position.copy(t)},onComplete:()=>{this.events.anim({type:"Anim_Complete",objName:"Camera",fct:o})}})}animCamTo({target:e,duration:t=1,ease:s="power2.inOut",dist:i=1.25}){const n="animCamTo";this.cam3D.lookMode="target";const o=(e=>{if("string"==typeof e){const t=this.obj.getObjectByName(e);return t||(console.warn(`${n}: Object with name "${e}" not found.`),null)}return e instanceof Obj3D?e.obj?e.obj:(console.warn(`${n}: Obj3D object not found.`),null):(console.warn(`${n}: Invalid target.`),null)})(e);if(!o)return;const a=((e,t)=>{const s=(new THREE.Box3).setFromObject(e,!0);if(s.isEmpty())return console.warn(`${n}: Object bounding box is empty.`),null;const i=s.getBoundingSphere(new THREE.Sphere),o=this.cam3D.obj,a=THREE.MathUtils.degToRad(o.fov),r=2*Math.atan(Math.tan(a/2)*o.aspect),l=Math.min(a,r),d=i.radius/Math.sin(l/2)*t;return{center:i.center.clone(),camDistance:d}})(o,i);if(!a)return;const r=a.center,l=this.cam3D.objTarget.position.clone(),d=this.cam3D.obj.position.clone(),c=d.clone().sub(r);0===c.lengthSq()&&c.set(0,0,1);const h=r.clone().add(c.normalize().multiplyScalar(a.camDistance)),m={t:0};gsap.gsap.to(m,{t:1,duration:t,ease:s,onStart:()=>{this.events.anim({type:"Anim_Start",objName:"Camera",fct:n})},onUpdate:()=>{const e=m.t,t=l.clone().lerp(r,e),s=d.clone().lerp(h,e);this.cam3D.obj.position.copy(s),this.cam3D.objTarget.position.copy(t)},onComplete:()=>{this.cam3D.obj.position.copy(h),this.cam3D.objTarget.position.copy(r),this.events.anim({type:"Anim_Complete",objName:"Camera",fct:n})}})}animMaterialColor({mesh:e,duration:t=0,ease:s="power1.inOut",...i}){const n=this.animMaterialColor.name;if(!e)return void console.warn(`${n}: Missing object name.`);const o="string"==typeof e?this.obj.getObjectByName(e):e.obj,a=this.getObjectName(e,o?.name);if(!o)return void console.warn(`${n}: Object with name "${a}" not found.`);if(!o.material)return void console.warn(`${n}: Object "${a}" has no material.`);const r=o.material,l=Object.keys(i);0!==l.length?l.forEach(e=>{const o=i[e];if(!(e in r)||!r[e].isColor)return void console.warn(`${n}: Material property "${e}" is not a color.`);if(null==o)return void console.warn(`${n}: Color value for "${e}" is null or undefined.`);const l=r[e],d=new THREE.Color(o);gsap.gsap.to(l,{r:d.r,g:d.g,b:d.b,duration:t,ease:s,onStart:()=>{this.events.animFade({type:"Anim_Fade_Start",objName:a,fct:n,property:e,value:l.getHexString()})},onUpdate:()=>{r[e].copy(l)},onComplete:()=>{this.events.animFade({type:"Anim_Fade_Complete",objName:a,fct:n,property:e,value:l.getHexString()})}})}):console.warn(`${n}: No color property provided to animate.`)}animMaterialNumeric({mesh:e,needsUpdate:t=!1,startValue:s=null,infinite:i=!1,duration:n=0,ease:o="power1.inOut",...a}){const r=this.animMaterialNumeric.name;if(!e)return void console.warn(`${r}: Missing object name.`);const l="string"==typeof e?this.obj.getObjectByName(e):e.obj,d=this.getObjectName(e,l?.name);if(!l)return void console.warn(`${r}: Object with name "${d}" not found.`);if(!l.material)return void console.warn(`${r}: Object "${d}" has no material.`);const c=l.material,h=Object.keys(a);if(0===h.length)return void console.warn(`${r}: No property provided to animate.`);const m=h[0],p=a[m];if(!(m in c))return void console.warn(`${r}: Material property "${m}" does not exist.`);const u=c[m];if("number"!=typeof u)return void console.warn(`${r}: Material property "${m}" is not a number.`);if(null==p||"number"!=typeof p)return void console.warn(`${r}: Material property "${m}" endValue is null or undefined or not a number.`);const g={[m]:null===s?u:s};gsap.gsap.to(g,{[m]:p,duration:n,delay:0,ease:o,repeat:i?-1:0,onStart:()=>{t&&(c.needsUpdate=!0),this.events.animFade({type:"Anim_Fade_Start",objName:d,fct:r,property:m,value:g[m]})},onUpdate:()=>{c[m]=g[m]},onComplete:()=>{this.events.animFade({type:"Anim_Fade_Complete",objName:d,fct:r,property:m,value:g[m]})}})}animTransformTo({obj:e,pos:t,rot:s,scale:i,duration:n=1,ease:o="power2.inOut"}){const a=this.animTransformTo.name,r="string"==typeof e?this.obj.getObjectByName(e):e.obj;if(!r)return void console.warn(`${a}: Object not found.`);const l=["x","y","z"];if(!l.some(e=>void 0!==t?.[e]||void 0!==s?.[e]||void 0!==i?.[e]))return void console.warn(`${a}: No transformation values provided.`);const d=this.tweens.get(r);this.tweens.delete(r),d?.kill(),(e instanceof Cam3D||r===this.cam3D.obj)&&((e instanceof Cam3D?e:this.cam3D).lookMode="free");const c=r.position.clone(),h=r.scale.clone(),m=r.quaternion.clone(),p=r.rotation.clone();for(const e of l)void 0!==s?.[e]&&(p[e]=THREE.MathUtils.degToRad(s[e]));const u=(new THREE.Quaternion).setFromEuler(p),g=l.some(e=>void 0!==s?.[e]),b=this.getObjectName(e,r.name),f={t:0},v=gsap.gsap.to(f,{t:1,duration:n,ease:o,paused:!0,onUpdate:()=>{for(const e of l)void 0!==t?.[e]&&(r.position[e]=THREE.MathUtils.lerp(c[e],t[e],f.t)),void 0!==i?.[e]&&(r.scale[e]=THREE.MathUtils.lerp(h[e],i[e],f.t));g&&r.quaternion.slerpQuaternions(m,u,f.t)},onComplete:()=>{this.tweens.delete(r),this.events.anim({type:"Anim_Complete",objName:b,fct:a})},onInterrupt:()=>{this.tweens.delete(r),this.events.anim({type:"Anim_Cancel",objName:b,fct:a})}});this.tweens.set(r,v),this.events.anim({type:"Anim_Start",objName:b,fct:a}),v.play(0)}getObjectName(e,t=""){let s=t;if("string"==typeof e)s=e;else for(const[t,i]of this.objs3D)if(i===e){s=t;break}return s}playClip({layer:e,clip:t,blendMode:s="normal",finishMode:i="hold",loopMode:n=1,stopMode:o="all",fadeDuration:a=0,fadeDurationFinish:r=0,reverse:l=!1,reset:d=!1,startSpeed:c=0,endSpeed:h=1,duration:m=0,ease:p="power1.inOut"}){const u=this.playClip.name;if(!e)return void console.warn(`${u}: Missing layer.`);if(!t)return void console.warn(`${u}: Missing clipname.`);if("infinite"!==n&&(!Number.isInteger(n)||n<1))return void console.warn(`${u}: loopMode must be a positive integer or "infinite".`);if(!this.gltf?.animations?.length)return void console.warn(`${u}: gltf has no animations.`);const g=THREE.AnimationClip.findByName(this.gltf.animations,t);g?this.mixer?this.actionCtrls&&this.actionCtrls.play(g,{clipName:t,layer:e,blendMode:s,loopMode:n,finishMode:i,stopMode:o,fadeDuration:a,fadeDurationFinish:r,reverse:l,reset:d,startSpeed:c,endSpeed:h,speedDuration:m,speedEase:p,started:!1,finished:!1}):console.warn(`${u}: Mixer not found.`):console.warn(`${u}: ClipAnimation "${t}" not found`)}playClipCam({layer:e,clip:t,blendMode:s="normal",loopMode:i=1,stopMode:n="all",fadeDuration:o=0,reverse:a=!1,reset:r=!1,startSpeed:l=0,endSpeed:d=1,duration:c=0,ease:h="power1.inOut"}){const m=this.playClipCam.name;if(!e)return void console.warn(`${m}: Missing layer.`);const p=this.cam3D.targetGltf,u=this.cam3D.objGltf;if(!p)return void console.warn(`${m}: Aim object not found.`);if(!u)return void console.warn(`${m}: Gltf object not found.`);if(!t)return void console.warn(`${m}: Missing clipname.`);if("infinite"!==i&&(!Number.isInteger(i)||i<1))return void console.warn(`${m}: loopMode must be a positive integer or "infinite".`);if(!this.gltf?.animations?.length)return void console.warn(`${m}: gltf has no animations.`);const g=THREE.AnimationClip.findByName(this.gltf.animations,t);if(!g)return void console.warn(`${m}: ClipAnimation "${t}" not found`);if(!this.mixer)return void console.warn(`${m}: Mixer not found.`);if(!this.actionCtrls)return;this.cam3D.lookMode="target";const b=new THREE.Vector3,f=new THREE.Vector3;this.actionCtrls.play(g,{clipName:t,layer:e,blendMode:s,loopMode:i,finishMode:"hold",stopMode:n,fadeDuration:o,fadeDurationFinish:0,reverse:a,reset:r,startSpeed:l,endSpeed:d,speedDuration:c,speedEase:h,started:!1,finished:!1,hooks:{onUpdate:()=>{this.cam3D.obj.position.copy(u.getWorldPosition(b)),this.cam3D.objTarget.position.copy(p.getWorldPosition(f))}}})}removeAmbientLight(){this.ambientLight&&(this.obj.remove(this.ambientLight),this.ambientLight.dispose(),this.ambientLight=null)}removeFog(){this.obj.fog&&(this.obj.fog=null)}removeHemisphereLight(){this.hemisphereLight&&(this.obj.remove(this.hemisphereLight),this.hemisphereLight.dispose(),this.hemisphereLight=null)}setAmbientLight({color:e,intensity:t}){if(!this.ambientLight){if(void 0===e||void 0===t)return;return this.ambientLight=new THREE.AmbientLight(e,t),void this.obj.add(this.ambientLight)}void 0!==e&&this.ambientLight.color.set(e),void 0!==t&&(this.ambientLight.intensity=t)}setFog({color:e,near:t,far:s}){if(this.obj.fog)void 0!==e&&this.obj.fog.color.set(e),this.obj.fog instanceof THREE.Fog&&(void 0!==t&&(this.obj.fog.near=t),void 0!==s&&(this.obj.fog.far=s));else{if(void 0===e||void 0===t||void 0===s)return;this.obj.fog=new THREE.Fog(e,t,s)}}setHemisphereLight({skyColor:e,groundColor:t,intensity:s}){if(!this.hemisphereLight){if(void 0===e||void 0===t||void 0===s)return;return this.hemisphereLight=new THREE.HemisphereLight(e,t,s),void this.obj.add(this.hemisphereLight)}void 0!==e&&this.hemisphereLight.color.set(e),void 0!==t&&this.hemisphereLight.groundColor.set(t),void 0!==s&&(this.hemisphereLight.intensity=s)}setMaterialProps({obj:e,recursive:t=!1,needsUpdate:s=!1,...i}){const n=this.setMaterialProps.name;if(!e)return void console.warn(`${n}: Missing objName`);const o="string"==typeof e?this.obj.getObjectByName(e):e.obj;if(!o)return void console.warn(`${n}: Object with name "${e}" not found.`);let a=!1;const r=e=>{if(!(e instanceof THREE.Mesh))return;a=!0;const t=new Set(Array.isArray(e.material)?e.material:[e.material]);if(0===t.size)return void console.warn(`${n}: Mesh has no material.`);const o=Object.keys(i);if(0===o.length)return void console.warn(`${n}: No material properties provided.`);let r=null;for(const e of t){const t=e;for(const e of o){const s=i[e];if(("map"===e||"emissiveMap"===e)&&"string"==typeof s){r||(r=new THREE.TextureLoader),r.load(s,s=>{t[e]=s,t.needsUpdate=!0},void 0,t=>{console.error(`${n}: Failed to load texture "${s}" for "${e}":`,t)});continue}if(!(e in t)){console.warn(`${n}: Material property "${e}" does not exist.`);continue}const o=t[e];o instanceof THREE.Color?o.set(s):typeof o==typeof s?t[e]=s:console.warn(`${n}: Type mismatch for "${e}": expected ${typeof o}, got ${typeof s}`)}s&&(t.needsUpdate=!0)}};t?o.traverse(r):r(o),a||console.warn(`${n}: Object "${"string"==typeof e?e:e.obj.name}" has no mesh.`)}stopAnimClip({clipName:e,fadeOut:t=0,ease:s="power1.inOut"}){let i=this.stopAnimClip.name;if(!e)return void console.warn(`${i}: Missing clipName.`);if(!this.gltf?.animations?.length)return void console.warn(`${i}: glb has no animations.`);const n=THREE.AnimationClip.findByName(this.gltf.animations,e);n?this.mixer?this.actionCtrls&&this.actionCtrls.stop(n,{clipName:e,fct:i,duration:t,ease:s}):console.warn(`${i}: Mixer not exists.`):console.warn(`${i}: ClipAnimation "${e}" not found.`)}},StateMachine=class{cfg;modules;actor=null;lastState="";snapshot=null;stateMachine=null;constructor(e,t){this.cfg=e,this.modules=t}sendEvent(e,t){if(!this.actor)return null;let s=!1;return(null!=this.snapshot?this.snapshot:this.actor.getSnapshot?.())?.can?.(e)&&(s=!0,"none"!=this.cfg.debug.log&&console.log(`Event: ${e.type}${t?` - ${t}`:""}`),this.actor.send(e)),s}start(e){if(this.stateMachine=e,this.stateMachine)if(this.actor)console.warn("Actor is already started.");else{if(this.cfg.stateMachine.inspector&&this.modules.createBrowserInspector){const{inspect:e}=this.modules.createBrowserInspector();this.actor=(0,xstate.createActor)(this.stateMachine,{inspect:e})}else this.actor=(0,xstate.createActor)(this.stateMachine);this.actor.subscribe(e=>{if(this.snapshot=e,"none"==this.cfg.debug.log)return;const t=e.value,s=JSON.stringify(t);if(s!==this.lastState)if(this.lastState=s,"object"==typeof t&&null!==t){const e=(t,s="")=>{if("string"==typeof t)return[s?`${s} > ${t}`:t];const i=[];for(const[n,o]of Object.entries(t)){const t=s?`${s} > ${n}`:n;i.push(...e(o,t))}return i};e(t).forEach(e=>{console.log(`State: ${e}`)})}else console.log(`State: ${t}`)}),this.actor.start()}else console.warn("State Machine not found.")}};function isPlainObject(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function merge(e,t){const s=e;for(const[e,i]of Object.entries(t)){const t=s[e];isPlainObject(t)&&isPlainObject(i)?merge(t,i):s[e]=Array.isArray(i)?[...i]:i}}var cfg={audio:{enable:!1,guiOpened:!1,delayLoadSound:200,refDistance:1,rolloffFactor:1,maxDistance:1e3,distanceModel:"inverse",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0},cam:{type:"perspective",near:.1,far:1e3,lookAt:{x:0,y:0,z:0},position:{x:0,y:.5,z:.5},perspective:{fov:75},orthographic:{left:-1,right:1,top:1,bottom:-1}},comps:{overlap:{padding:20}},debug:{log:"xstate"},envCtrls:{backgroundBlurriness:0,backgroundIntensity:0,dataType:"halfFloat",enable:!1,environmentIntensity:1.8,load:!1,map:[],rotation:{x:0,y:0,z:0},rotationSpeed:0,type:"exr"},fpvCtrls:{enable:!1,load:!1,minPolarAngle:0,maxPolarAngle:Math.PI,pointerSpeed:.1,keyMoveForward:"KeyW",keyMoveLeft:"KeyA",keyMoveBackward:"KeyS",keyMoveRight:"KeyD",keyMoveUp:"KeyQ",keyMoveDown:"KeyE"},gui:{infoBox:{enable:!1,fps:!0,cpu:!0,frame:!0,calls:!0,triangles:!0,lines:!0,points:!0,geometries:!0,textures:!0,programs:!0,logsPerSecond:10},inspector:{enable:!1},menuBar:{enable:!0,backgroundColor:"#ffffff29",logo:""}},light:{castShadow:!0,rectArea:!1,mapWidth:512,mapHeight:512,bias:0,normalBias:0,near:.5,far:500},mesh:{castShadow:!0,receiveShadow:!0,frustumCulled:!1},model:{compress:{mesh:"none",texture:"none"},decoderPath:"draco/",file:[],progressBar:!0},orbitCtrls:{autoRotate:!1,autoRotateSpeed:2,dampingFactor:.1,enable:!1,enableDamping:!1,enablePan:!0,enableRotate:!0,enableZoom:!0,load:!1,maxAzimuthAngle:1/0,maxDistance:1/0,maxPolarAngle:180,minAzimuthAngle:-1/0,minDistance:0,minPolarAngle:0,panSpeed:1,rotateSpeed:1,zoomSpeed:1},post:{guiOpened:!1,aa:{guiOpened:!1},ssl:{guiOpened:!1},ssr:{guiOpened:!1,maxDistance:180,thickness:.018,resolutionScale:1},webgl:{aa:{fxaa:{sharpness:.5}},ssao:{kernelRadius:8,minDistance:.005,maxDistance:.1},ssr:{bouncing:!1,distanceAttenuation:!0,fresnel:!0,infiniteThick:!1,opacity:.5,blur:!0,output:0,selective:!1,clear:!0,maxRoughness:.5}},webgpu:{gtao:{radius:.25,thickness:1,scale:1,samples:16,resolutionScale:1},ssgi:{guiOpened:!1,sliceCount:2,stepCount:8,aoIntensity:1,giIntensity:10,radius:12,useScreenSpaceSampling:!0,expFactor:2,thickness:1,useLinearThickness:!1,backfaceLighting:0},ssr:{intensity:.5,quality:.5,blurQuality:1}}},raycast:{occludeeInterval:0,occlusionMoveFactor:.01,circleRadius:10,circleSteps:12,countClosestObjs:5},render:{adaptiveGfx:!1,api:"auto",autoResize:!0,deltaTimesMax:20,ecoMode:!0,fpsMin:30,guiOpened:!1,outputColorSpace:THREE.SRGBColorSpace,pixelRatio:1,shadowMapEnabled:!0,shadowMapType:THREE.PCFShadowMap,toneMapping:THREE.ACESFilmicToneMapping,toneMappingExposure:1,params:{alpha:!1},profile:{webgl:{msaa:"none",aa:"none",ssl:"none",ssr:!1},webgpu:{msaa:"none",aa:"none",ssl:"none",ssr:!1}},webgl:{params:{}},webgpu:{params:{}}},scene:{guiOpened:!1,canvas:"ilu-canvas",fog:{enable:!1,color:0,near:0,far:100},ambientlight:{enable:!1,color:16777215,intensity:1},hemisphere:{enable:!1,skyColor:16777147,groundColor:526368,intensity:1}},stateMachine:{inspector:!1}};function setCfg(e){return merge(cfg,e),cfg}var WebCtrls=class{cam3D;engine;padding;posCamWorld=new THREE.Vector3;websTracked=[];updateRequired=!1;callback=()=>{this.update()};requestUpdate=()=>{this.updateRequired=!0};constructor(e,t,s){this.cam3D=e,this.engine=t,this.padding=Math.max(0,s)}applyOverlaps(){this.cam3D.obj.getWorldPosition(this.posCamWorld);const e=[];for(const t of this.websTracked){const s=t.web.getObj3DFollow();if(!t.web.isConnected||!t.web.isVisibleFollow()||!s?.obj){t.web.setVisibleOverlap(!0);continue}s.obj.getWorldPosition(t.posWorld);const i=t.web.getBoundingClientRect();0!==i.width&&0!==i.height?e.push({web:t.web,distanceSquared:t.posWorld.distanceToSquared(this.posCamWorld),rect:i}):t.web.setVisibleOverlap(!0)}e.sort((e,t)=>e.distanceSquared-t.distanceSquared);const t=[];for(const s of e){const e=!t.some(e=>this.rectsOverlap(s.rect,e));s.web.setVisibleOverlap(e),e&&t.push(s.rect)}}rectsOverlap(e,t){return e.left<t.right+this.padding&&e.right+this.padding>t.left&&e.top<t.bottom+this.padding&&e.bottom+this.padding>t.top}subWebTracked(e){e.posScreen=null;const t=e.web.getObj3DFollow();t&&e.unSubs.push(t.addEventListener("Obj3D_Pos_Screen_Changed",t=>{const s=Math.round(t.posScreen.x),i=Math.round(t.posScreen.y);if(null!==e.posScreen){if(e.posScreen.x===s&&e.posScreen.y===i)return;e.posScreen.set(s,i)}else e.posScreen=new THREE.Vector2(s,i);this.requestUpdate()}),t.addEventListener("Obj3D_Visible_Changed",()=>{this.requestUpdate()}))}refreshOverlap(e){const t=this.websTracked.find(t=>t.web===e);t&&(this.unsubWebTracked(t),this.subWebTracked(t),this.requestUpdate(),this.update())}trackOverlap(e){if(this.websTracked.some(t=>t.web===e))return;const t={web:e,posWorld:new THREE.Vector3,posScreen:null,unSubs:[]};this.websTracked.push(t),this.subWebTracked(t),1===this.websTracked.length&&this.engine.addOnFrameUpdate(this.callback),this.requestUpdate(),this.update()}unsubWebTracked(e){for(const t of e.unSubs)t();e.unSubs=[]}untrackOverlap(e){const t=this.websTracked.findIndex(t=>t.web===e);if(-1===t)return;const s=this.websTracked[t];if(this.unsubWebTracked(s),this.websTracked.splice(t,1),e.setVisibleOverlap(!0),0===this.websTracked.length)return this.engine.removeOnFrameUpdate(this.callback),void(this.updateRequired=!1);this.requestUpdate(),this.update()}update(){0!==this.websTracked.length&&this.updateRequired&&(this.updateRequired=!1,this.applyOverlaps())}},inspector_default="/* nur Chrome / Edge / Safari */\r\n.illutions-pane {\r\n font-family: monospace;\r\n font-size: 12px;\r\n\r\n --tp-base-background-color: hsla(230, 20%, 11%, 1.00);\r\n --tp-base-shadow-color: hsla(0, 0%, 0%, 0.2);\r\n --tp-button-background-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-button-background-color-active: hsla(230, 10%, 95%, 1.00);\r\n --tp-button-background-color-focus: hsla(230, 10%, 90%, 1.00);\r\n --tp-button-background-color-hover: hsla(230, 10%, 85%, 1.00);\r\n --tp-button-foreground-color: hsla(230, 20%, 11%, 1.00);\r\n --tp-container-background-color: hsla(230, 25%, 16%, 1.00);\r\n --tp-container-background-color-active: hsla(230, 25%, 31%, 1.00);\r\n --tp-container-background-color-focus: hsla(230, 25%, 26%, 1.00);\r\n --tp-container-background-color-hover: hsla(230, 25%, 21%, 1.00);\r\n --tp-container-foreground-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-groove-foreground-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-input-background-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-input-background-color-active: hsla(230, 28%, 23%, 1.00);\r\n --tp-input-background-color-focus: hsla(230, 28%, 18%, 1.00);\r\n --tp-input-background-color-hover: hsla(230, 20%, 13%, 1.00);\r\n --tp-input-foreground-color: hsla(230, 10%, 80%, 1.00);\r\n --tp-label-foreground-color: hsla(230, 12%, 48%, 1.00);\r\n --tp-monitor-background-color: hsla(230, 20%, 8%, 1.00);\r\n --tp-monitor-foreground-color: hsla(230, 12%, 48%, 1.00);\r\n\r\n max-height: 95vh;\r\n overflow-y: auto;\r\n scrollbar-width: thin;\r\n scrollbar-color: #F40B5780 #1e1e1e;\r\n}\r\n\r\n/* WebKit Hover + Fallback for older Chrome / Edge / Safari */\r\n.illutions-pane::-webkit-scrollbar {\r\n width: 10px;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-track {\r\n background: #1e1e1e;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-thumb {\r\n background: #F40B5780;\r\n border-radius: 6px;\r\n}\r\n\r\n.illutions-pane::-webkit-scrollbar-thumb:hover {\r\n background: #F40B57;\r\n}\r\n",outputColorSpaceParam={SRGB:THREE.SRGBColorSpace,LinearSRGB:THREE.LinearSRGBColorSpace},shadowMapTypeParam={Basic:THREE.BasicShadowMap,PCF:THREE.PCFShadowMap,PCFSoft:THREE.PCFShadowMap,VSM:THREE.VSMShadowMap},toneMappingParam={None:THREE.NoToneMapping,Linear:THREE.LinearToneMapping,Reinhard:THREE.ReinhardToneMapping,Cineon:THREE.CineonToneMapping,ACESFilmic:THREE.ACESFilmicToneMapping,AgX:THREE.AgXToneMapping,Neutral:THREE.NeutralToneMapping,Custom:THREE.CustomToneMapping},Inspector=class{engine;scene;envCtrls;pane=null;modules;orbitCtrls;fpvCtrls;audio;cfg;webGpuPost=null;webGpuAaModeBinding=null;webGpuSslModeBinding=null;gtaoWebGpuFolder=null;ssgiWebGpuFolder=null;constructor(e,t,s,i,n,o,a,r){if(this.audio=t,this.engine=s,this.scene=i,this.envCtrls=n,this.modules=o,this.orbitCtrls=a,this.fpvCtrls=r,this.cfg=e,!this.modules.paneClass)return void console.warn("Module tweakpane could not be imported.");if(this.pane=new this.modules.paneClass({title:"illutions"}),!this.pane)return;const l=this.pane.element;l.style.position="fixed",l.style.top="8px",l.style.right="8px",l.style.zIndex="1000",l.classList.add("illutions-pane");for(const e of["click","pointerdown","pointermove","pointerup","pointercancel","wheel"])l.addEventListener(e,e=>e.stopPropagation());const d=document.createElement("style");if(d.textContent=inspector_default,document.head.appendChild(d),this.cfg.audio.enable){const e=this.audio.get(),t=this.pane.addFolder({title:"Audio",expanded:this.cfg.audio.guiOpened});t.addBinding(e,"refDistance",{min:.1,max:20,step:.1}).on("change",e=>this.audio.set({refDistance:e.value})),t.addBinding(e,"rolloffFactor",{min:0,max:100,step:.1}).on("change",e=>this.audio.set({rolloffFactor:e.value})),t.addBinding(e,"maxDistance",{min:1,max:5e3,step:10}).on("change",e=>this.audio.set({maxDistance:e.value})),t.addBinding(e,"distanceModel",{options:{linear:"linear",inverse:"inverse",exponential:"exponential"}}).on("change",e=>this.audio.set({distanceModel:e.value})),t.addBinding(e,"coneInnerAngle",{min:0,max:360,step:1}).on("change",e=>this.audio.set({coneInnerAngle:e.value})),t.addBinding(e,"coneOuterAngle",{min:0,max:360,step:1}).on("change",e=>this.audio.set({coneOuterAngle:e.value})),t.addBinding(e,"coneOuterGain",{min:0,max:1,step:.01}).on("change",e=>this.audio.set({coneOuterGain:e.value}))}const c=this.pane.addFolder({title:"Navigation",expanded:!1});if(this.cfg.orbitCtrls.enable||this.cfg.orbitCtrls.load){const e=c.addFolder({title:"Orbit",expanded:!0});e.addBinding(this.cfg.orbitCtrls,"enableDamping").on("change",e=>this.orbitCtrls.set({enableDamping:e.value})),e.addBinding(this.cfg.orbitCtrls,"dampingFactor",{min:0,max:1,step:.01}).on("change",e=>this.orbitCtrls.set({dampingFactor:e.value})),e.addBinding(this.cfg.orbitCtrls,"minDistance",{min:0,max:500,step:.1}).on("change",e=>this.orbitCtrls.set({minDistance:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxDistance",{min:0,max:2e3,step:.1}).on("change",e=>this.orbitCtrls.set({maxDistance:e.value})),e.addBinding(this.cfg.orbitCtrls,"minAzimuthAngle",{step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({minAzimuthAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxAzimuthAngle",{step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({maxAzimuthAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"minPolarAngle",{min:0,max:180,step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({minPolarAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"maxPolarAngle",{min:0,max:180,step:1,format:e=>`${e}°`,parse:e=>Number(e.replace("°",""))}).on("change",e=>this.orbitCtrls.set({maxPolarAngle:e.value})),e.addBinding(this.cfg.orbitCtrls,"enableZoom").on("change",e=>this.orbitCtrls.set({enableZoom:e.value})),e.addBinding(this.cfg.orbitCtrls,"zoomSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({zoomSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"enableRotate"),e.addBinding(this.cfg.orbitCtrls,"rotateSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({rotateSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"enablePan").on("change",e=>this.orbitCtrls.set({enablePan:e.value})),e.addBinding(this.cfg.orbitCtrls,"panSpeed",{min:.1,max:5,step:.1}).on("change",e=>this.orbitCtrls.set({panSpeed:e.value})),e.addBinding(this.cfg.orbitCtrls,"autoRotate").on("change",e=>this.orbitCtrls.set({autoRotate:e.value})),e.addBinding(this.cfg.orbitCtrls,"autoRotateSpeed",{min:.1,max:10,step:.1}).on("change",e=>this.orbitCtrls.set({autoRotateSpeed:e.value}))}if(this.cfg.fpvCtrls.enable){const e=c.addFolder({title:"FirstPerson",expanded:!0});e.addBinding(this.cfg.fpvCtrls,"minPolarAngle",{min:0,max:Math.PI,step:.01}).on("change",e=>this.fpvCtrls.set({minPolarAngle:e.value})),e.addBinding(this.cfg.fpvCtrls,"maxPolarAngle",{min:0,max:Math.PI,step:.01}).on("change",e=>this.fpvCtrls.set({maxPolarAngle:e.value})),e.addBinding(this.cfg.fpvCtrls,"pointerSpeed",{min:.01,max:1,step:.01}).on("change",e=>this.fpvCtrls.set({pointerSpeed:e.value}))}const h=this.pane.addFolder({title:"Renderer",expanded:this.cfg.render.guiOpened});h.addBinding(this.cfg.render,"deltaTimesMax",{min:1,max:120,step:1}),h.addBinding(this.cfg.render,"pixelRatio",{min:.25,max:2,step:.05}).on("change",e=>{this.engine.renderer.setPixelRatio(e.value)});const m={outputColorSpace:Object.keys(outputColorSpaceParam).find(e=>outputColorSpaceParam[e]===this.cfg.render.outputColorSpace)},p=Object.keys(outputColorSpaceParam).reduce((e,t)=>(e[t]=t,e),{});h.addBinding(m,"outputColorSpace",{options:p}).on("change",e=>{const t=outputColorSpaceParam[e.value];this.cfg.render.outputColorSpace=t,this.engine.renderer.outputColorSpace=t});const u=h.addFolder({title:"ShadowMap",expanded:!1});u.addBinding(this.cfg.render,"shadowMapEnabled").on("change",e=>{this.engine.renderer.shadowMap.enabled=e.value});const g={shadowMapType:Object.keys(shadowMapTypeParam).find(e=>shadowMapTypeParam[e]===this.cfg.render.shadowMapType)},b=Object.keys(shadowMapTypeParam).reduce((e,t)=>(e[t]=t,e),{});u.addBinding(g,"shadowMapType",{options:b}).on("change",e=>{const t=shadowMapTypeParam[e.value];this.engine.renderer.shadowMap.type=t});const f=h.addFolder({title:"ToneMapping",expanded:!1}),v={toneMapping:Object.keys(toneMappingParam).find(e=>toneMappingParam[e]===this.cfg.render.toneMapping)},C=Object.keys(toneMappingParam).reduce((e,t)=>(e[t]=t,e),{});f.addBinding(v,"toneMapping",{options:C}).on("change",e=>{const t=e.value;this.engine.renderer.toneMapping=toneMappingParam[t]}),f.addBinding(this.cfg.render,"toneMappingExposure",{min:0,max:5}).on("change",e=>{this.engine.renderer.toneMappingExposure=e.value});const w=this.modules.webGpuRendererClass?this.cfg.render.profile.webgpu:this.cfg.render.profile.webgl;if(!this.cfg.render.adaptiveGfx&&("none"!==w.ssl||w.ssr||"none"!==w.aa)){const e=h.addFolder({title:"Postprocessing",expanded:this.cfg.post.guiOpened}),t={sslMode:w.ssl,ssrEnable:w.ssr,aaMode:w.aa},s=this.cfg.post.ssl;if(this.modules.webGpuRendererClass){this.webGpuPost=t;const i=this.cfg.post.webgpu.gtao,n=this.cfg.post.webgpu.ssgi,o=e.addFolder({title:"SSL",expanded:s.guiOpened||n.guiOpened}),a=o.addBinding(t,"sslMode",{label:"Mode",options:{None:"none",GTAO:"gtao",SSGI:"ssgi"}});this.webGpuSslModeBinding=a,a.on("change",async e=>{await this.engine.enableSslMode(e.value),this.setWebGpuPostState()});const r=o.addFolder({title:"GTAO",expanded:s.guiOpened});this.gtaoWebGpuFolder=r,r.addBinding(i,"radius",{min:0,max:10,step:.01,label:"Radius"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"thickness",{min:0,max:10,step:.01,label:"Thickness"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"scale",{min:0,max:5,step:.01,label:"Scale"}).on("change",()=>this.engine.setPostSslParams()),r.addBinding(i,"samples",{min:1,max:64,step:1,label:"Samples"}).on("change",()=>this.engine.setPostSslParams()),this.setChildrenDisabled(r,null,"gtao"!==w.ssl);const l=o.addFolder({title:"SSGI",expanded:n.guiOpened});this.ssgiWebGpuFolder=l,l.addBinding(n,"sliceCount",{min:1,max:4,step:1,label:"SliceCount"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"stepCount",{min:1,max:32,step:1,label:"StepCount"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"aoIntensity",{min:0,max:4,step:.01,label:"AOIntensity"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"giIntensity",{min:0,max:100,step:.1,label:"GIIntensity"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"radius",{min:1,max:25,step:.1,label:"Radius"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"useScreenSpaceSampling",{label:"ScreenSpaceSampling"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"expFactor",{min:1,max:3,step:.01,label:"ExpFactor"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"thickness",{min:.01,max:10,step:.01,label:"Thickness"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"useLinearThickness",{label:"LinearThickness"}).on("change",()=>this.engine.setPostSslParams()),l.addBinding(n,"backfaceLighting",{min:0,max:1,step:.01,label:"BackfaceLighting"}).on("change",()=>this.engine.setPostSslParams())}else{const i=this.cfg.post.webgl.ssao,n=e.addFolder({title:"SSL",expanded:s.guiOpened});n.addBinding(t,"sslMode",{label:"Mode",options:{None:"none",SSAO:"ssao"}}).on("change",async e=>{await this.engine.enableSslMode(e.value),this.setChildrenDisabled(o,null,"ssao"!==e.value)});const o=n.addFolder({title:"SSAO",expanded:s.guiOpened});o.addBinding(i,"kernelRadius",{min:0,max:32,step:1,label:"KernelRadius"}).on("change",()=>this.engine.setPostSslParams()),o.addBinding(i,"minDistance",{min:0,max:.5,step:.001,label:"MinDistance"}).on("change",()=>this.engine.setPostSslParams()),o.addBinding(i,"maxDistance",{min:0,max:1,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSslParams()),this.setChildrenDisabled(o,null,"ssao"!==w.ssl)}const i=this.cfg.post.ssr;if(this.modules.webGpuRendererClass){const s=this.cfg.post.webgpu.ssr,n=e.addFolder({title:"SSR",expanded:i.guiOpened}),o=n.addBinding(t,"ssrEnable",{label:"Enable"}).on("change",async e=>{await this.engine.enableSsr(e.value),this.setChildrenDisabled(n,o,!e.value)});n.addBinding(i,"maxDistance",{min:0,max:180,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"intensity",{min:0,max:1,step:.01,label:"Intensity"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"thickness",{min:0,max:.1,step:.001,label:"Thickness"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"resolutionScale",{min:0,max:1,step:.01,label:"ResolutionScale"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"quality",{min:0,max:1,step:.01,label:"Quality"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"blurQuality",{min:1,max:3,step:1,label:"BlurQuality"}).on("change",()=>this.engine.setPostSsrParams()),this.setChildrenDisabled(n,o,!w.ssr)}else{const s=this.cfg.post.webgl.ssr,n=e.addFolder({title:"SSR",expanded:i.guiOpened});let o=!1;const a=()=>{if(o)return;if(!this.modules.ssrPassClass)return;const e={Default:this.modules.ssrPassClass.OUTPUT.Default,"SSR Only":this.modules.ssrPassClass.OUTPUT.SSR,Beauty:this.modules.ssrPassClass.OUTPUT.Beauty,Depth:this.modules.ssrPassClass.OUTPUT.Depth,Normal:this.modules.ssrPassClass.OUTPUT.Normal,Metalness:this.modules.ssrPassClass.OUTPUT.Metalness};n.addBinding(s,"output",{label:"Output",options:e}).on("change",()=>this.engine.setPostSsrParams()),o=!0},r=n.addBinding(t,"ssrEnable",{label:"Enable"}).on("change",async e=>{await this.engine.enableSsr(e.value),a(),this.setChildrenDisabled(n,r,!e.value)});n.addBinding(s,"fresnel",{label:"Fresnel"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"distanceAttenuation",{label:"DistanceAttenuation"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"maxDistance",{min:0,max:180,step:.01,label:"MaxDistance"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"opacity",{min:0,max:1,step:.01,label:"Opacity"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"thickness",{min:0,max:.1,step:.001,label:"Thickness"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"infiniteThick",{label:"InfiniteThick"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"blur",{label:"Blur"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(i,"resolutionScale",{min:0,max:1,step:.01,label:"ResolutionScale"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"bouncing",{label:"Bouncing"}).on("change",()=>this.engine.setPostSsrParams()),n.addBinding(s,"clear",{label:"Clear"}).on("change",()=>this.engine.setPostSsrParams()),a(),this.setChildrenDisabled(n,r,!w.ssr)}const n=e.addFolder({title:"AA",expanded:this.cfg.post.aa.guiOpened});let o=null;const a=n.addBinding(t,"aaMode",{label:"Mode",options:this.modules.webGpuRendererClass?{None:"none",FXAA:"fxaa",SMAA:"smaa",TRAA:"traa"}:{None:"none",FXAA:"fxaa",SMAA:"smaa"}});this.modules.webGpuRendererClass&&(this.webGpuAaModeBinding=a,this.setWebGpuPostState()),a.on("change",async e=>{const t=e.value;await this.engine.enableAaMode(t),this.modules.webGpuRendererClass&&this.setWebGpuPostState(),o&&(o.hidden="fxaa"!==t)}),this.modules.webGpuRendererClass||(o=n.addBinding(this.cfg.post.webgl.aa.fxaa,"sharpness",{min:.1,max:1,step:.05,label:"Sharpness"}).on("change",()=>this.engine.setPostAaParams()),o.hidden="fxaa"!==w.aa)}const y=this.pane.addFolder({title:"Scene",expanded:this.cfg.scene.guiOpened});if(this.cfg.scene.ambientlight.enable){const e=y.addFolder({title:"Ambient Light",expanded:!0});e.addBinding(this.cfg.scene.ambientlight,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setAmbientLight({color:this.cfg.scene.ambientlight.color,intensity:this.cfg.scene.ambientlight.intensity}):this.scene.removeAmbientLight()}),e.addBinding(this.cfg.scene.ambientlight,"color",{label:"Color",view:"color"}).on("change",e=>{this.scene.setAmbientLight({color:e.value})}),e.addBinding(this.cfg.scene.ambientlight,"intensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.scene.setAmbientLight({intensity:e.value})})}if(this.cfg.scene.hemisphere.enable){const e=y.addFolder({title:"Hemisphere Light",expanded:!0});e.addBinding(this.cfg.scene.hemisphere,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setHemisphereLight({skyColor:this.cfg.scene.hemisphere.skyColor,groundColor:this.cfg.scene.hemisphere.groundColor,intensity:this.cfg.scene.hemisphere.intensity}):this.scene.removeHemisphereLight()}),e.addBinding(this.cfg.scene.hemisphere,"skyColor",{label:"Sky Color",view:"color"}).on("change",e=>{this.scene.setHemisphereLight({skyColor:e.value})}),e.addBinding(this.cfg.scene.hemisphere,"groundColor",{label:"Ground Color",view:"color"}).on("change",e=>{this.scene.setHemisphereLight({groundColor:e.value})}),e.addBinding(this.cfg.scene.hemisphere,"intensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.scene.setHemisphereLight({intensity:e.value})})}if(this.cfg.scene.fog.enable){const e=y.addFolder({title:"Fog",expanded:!0});e.addBinding(this.cfg.scene.fog,"enable",{label:"Enabled"}).on("change",e=>{e.value?this.scene.setFog({color:this.cfg.scene.fog.color,near:this.cfg.scene.fog.near,far:this.cfg.scene.fog.far}):this.scene.removeFog()}),e.addBinding(this.cfg.scene.fog,"color",{label:"Color",view:"color"}).on("change",e=>{this.scene.setFog({color:e.value})}),e.addBinding(this.cfg.scene.fog,"near",{min:0,max:50,label:"Near"}).on("change",e=>{this.scene.setFog({near:e.value})}),e.addBinding(this.cfg.scene.fog,"far",{min:0,max:100,label:"Far"}).on("change",e=>{this.scene.setFog({far:e.value})})}if(this.cfg.envCtrls.enable||this.cfg.envCtrls.load){const e=y.addBinding(this.cfg.envCtrls,"enable",{label:"Enabled"}),t=y.addFolder({title:"Background",expanded:!1}),s=y.addFolder({title:"Environment",expanded:!1});e.on("change",e=>{e.value?this.envCtrls.enable():this.envCtrls.disable(),t.disabled=!e.value,s.disabled=!e.value}),t.disabled=!this.cfg.envCtrls.enable,s.disabled=!this.cfg.envCtrls.enable,t.addBinding(this.cfg.envCtrls,"backgroundBlurriness",{min:0,max:1,label:"Blurriness"}).on("change",e=>{this.envCtrls.set({backgroundBlurriness:e.value})}),t.addBinding(this.cfg.envCtrls,"backgroundIntensity",{min:0,max:5,label:"Intensity"}).on("change",e=>{this.envCtrls.set({backgroundIntensity:e.value})}),s.addBinding(this.cfg.envCtrls,"environmentIntensity",{min:0,max:10,label:"Intensity"}).on("change",e=>{this.envCtrls.set({environmentIntensity:e.value})});const i=this.envCtrls.get().rotation;if(i){const e={x:i.x,y:i.y,z:i.z};s.addBinding(e,"x",{min:0,max:360,label:"Rotate X"}).on("change",()=>{this.envCtrls.set({rotation:e})}),s.addBinding(e,"y",{min:0,max:360,label:"Rotate Y"}).on("change",()=>{this.envCtrls.set({rotation:e})}),s.addBinding(e,"z",{min:0,max:360,label:"Rotate Z"}).on("change",()=>{this.envCtrls.set({rotation:e})})}}}setChildrenDisabled(e,t,s){for(const i of e.children)i!==t&&(i.disabled=s)}setWebGpuPostState(){if(!(this.webGpuPost&&this.webGpuAaModeBinding&&this.webGpuSslModeBinding&&this.gtaoWebGpuFolder&&this.ssgiWebGpuFolder))return;const e=[{text:"None",value:"none"}],t=[...e,{text:"GTAO",value:"gtao"}],s=[...t,{text:"SSGI",value:"ssgi"}],i=[{text:"None",value:"none"},{text:"FXAA",value:"fxaa"},{text:"SMAA",value:"smaa"}],n=[{text:"TRAA",value:"traa"}],o=[...i,...n];switch(`${this.cfg.render.profile.webgpu.msaa}:${this.webGpuPost.aaMode}`){case"post:none":case"post:fxaa":case"post:smaa":default:this.webGpuSslModeBinding.options=e;break;case"none:none":case"none:fxaa":case"none:smaa":case"render:none":case"render:fxaa":case"render:smaa":this.webGpuSslModeBinding.options=t;break;case"none:traa":case"render:traa":this.webGpuSslModeBinding.options=s}switch(`${this.cfg.render.profile.webgpu.msaa}:${this.webGpuPost.sslMode}`){case"none:ssgi":case"render:ssgi":this.webGpuAaModeBinding.options=n;break;case"none:none":case"none:gtao":case"render:none":case"render:gtao":this.webGpuAaModeBinding.options=o;break;default:this.webGpuAaModeBinding.options=i}this.setChildrenDisabled(this.gtaoWebGpuFolder,null,"gtao"!==this.webGpuPost.sslMode),this.setChildrenDisabled(this.ssgiWebGpuFolder,null,"ssgi"!==this.webGpuPost.sslMode)}},progressbar_default=':host {\r\n position: absolute;\r\n display: block;\r\n top: 50%; left: 50%;\r\n width: 25%; height: 5px;\r\n transform: translate(-50%, -50%);\r\n background: #ffffff30;\r\n border-radius: 3px;\r\n pointer-events: none;\r\n z-index: 1;\r\n overflow: hidden;\r\n}\r\n\r\n#bar {\r\n position: relative;\r\n width: 0%; height: 100%;\r\n background: #F40B57;\r\n border-radius: 3px;\r\n transition: width 0.3s ease-in;\r\n overflow: hidden;\r\n}\r\n\r\n#bar::after {\r\n content: "";\r\n position: absolute;\r\n top: 0;\r\n left: -40%;\r\n width: 40%;\r\n height: 100%;\r\n\r\n background: linear-gradient(\r\n 90deg,\r\n transparent,\r\n rgba(255, 255, 255, 0.5),\r\n transparent\r\n );\r\n\r\n animation: progress-active 1s linear infinite;\r\n}\r\n\r\n@keyframes progress-active {\r\n from {\r\n transform: translateX(0);\r\n }\r\n to {\r\n transform: translateX(350%);\r\n }\r\n}',ProgressBar=class extends HTMLElement{bar;events;constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("div");t.id="bar";const s=document.createElement("style");s.textContent=progressbar_default,e.append(s,t),this.bar=t}setProgress(e){this.bar.style.width=e+"%",e>=100&&setTimeout(()=>{if("100%"===this.bar.style.width){const e=t=>{t.target===this&&"opacity"===t.propertyName&&(this.events.send({type:"ProgressBar_Hidden"},"Progress bar finished hiding"),this.removeEventListener("transitionend",e),this.remove())};this.addEventListener("transitionend",e),this.style.transition="opacity 0.3s ease",this.style.opacity="0"}},300)}},TAG="ilu-progressbar";function loadProgressBar(e,t){const s=document.createElement(TAG);return s.events=t,e.appendChild(s),s}customElements.get(TAG)||customElements.define(TAG,ProgressBar);var Model=class{canvas;cfg;events;modules;renderer;modelReady=Promise.resolve(!1);sceneReady;resolveSceneReady;rejectSceneReady;meshes=new Map;scene=null;imageNamesUnused=new Set;imageTexturesUnused=new Map;textures=[];constructor(e,t,s,i,n){this.canvas=e,this.cfg=t,this.events=s,this.modules=i,this.renderer=n,this.sceneReady=new Promise((e,t)=>{this.resolveSceneReady=e,this.rejectSceneReady=t})}addImageUnusedName(e){this.imageNamesUnused.add(e)}addMaterialsFromMesh(e,t){for(const s of Array.isArray(e.material)?e.material:[e.material])t.add(s)}addTexturesFromMaterial(e,t){for(const s of Object.values(e))s instanceof THREE.Texture&&t.add(s)}addTexture(e,t){const s=this.textures.find(t=>t.texture===e);s?s.source=t:this.textures.push({texture:e,source:t,pending:null})}disposeGeometries(e){const t=new Set;for(const e of this.meshes.values())t.add(e.geometry);for(const s of e)t.has(s)||s.dispose()}disposeMaterialsAndTextures(e){const t=new Set,s=new Set,i=new Set,n=new Set;for(const e of this.meshes.values())this.addMaterialsFromMesh(e,t);for(const e of this.textures)i.add(e.texture);e.scene.traverse(e=>{e instanceof THREE.Mesh&&this.addMaterialsFromMesh(e,s)});for(const e of t)this.addTexturesFromMaterial(e,i);for(const e of s)this.addTexturesFromMaterial(e,n);for(const e of s)t.has(e)||e.dispose();for(const e of n)i.has(e)||e.dispose()}getTextureFromImageUnused(e){const t=this.imageTexturesUnused.get(e);if(!t)throw new Error(`Image texture "${e}" is unavailable. Request it with requestImageTexture() during onStart().`);return t}async initTextureFromImageUnused(e,t){const s=t.parser.json.images,i=s?s.findIndex(t=>t.name===e):-1;if(!s||i<0)throw new Error(`Image "${e}" was not found in the GLTF.`);const n=s[i];let o=t.parser.textureLoader;if("image/ktx2"===n.mimeType&&t.parser.options.ktx2Loader)o=t.parser.options.ktx2Loader;else if(n.uri){const e=t.parser.options.manager.getHandler(n.uri);e&&(o=e)}const a=await t.parser.loadImageSource(i,o);if(!a)throw new Error(`Unused image "${e}" could not be initialized from the GLTF.`);return a}async initTexturesFromImagesUnused(e){await Promise.all([...this.imageNamesUnused].map(async t=>{const s=await this.initTextureFromImageUnused(t,e);s.name=t,s.flipY=!1,this.imageTexturesUnused.set(t,s),this.addTexture(s,{type:"image",name:t})}))}async initTexturesGltf(e){const t=await e.parser.getDependencies("texture");for(let e=0;e<t.length;e++){const s=t[e];s&&this.addTexture(s,{type:"texture",index:e})}}async load(e,t,s){const i=this.modules.gltfLoader;if(!i)return console.warn("Three.js GLTFLoader could not be started."),this.resolveSceneReady(),!1;if(0===e.length)return this.resolveSceneReady(),!0;let n=!1,o=!1;try{if("ktx2"===this.cfg.model.compress.texture){const e=this.modules.ktx2Loader;e?(e.setTranscoderPath("ktx2/").detectSupport(this.renderer),i.setKTX2Loader(e)):console.warn("KTX2Loader not imported.")}"draco"===this.cfg.model.compress.mesh?this.modules.dracoLoader?this.cfg.model.decoderPath?(this.modules.dracoLoader.setDecoderPath(this.cfg.model.decoderPath),i.setDRACOLoader(this.modules.dracoLoader)):console.warn("Draco decoderPath is empty."):console.warn("DRACOLoader not imported."):"meshopt"===this.cfg.model.compress.mesh&&(this.modules.meshoptDecoder?i.setMeshoptDecoder(this.modules.meshoptDecoder):console.warn("MeshoptDecoder not imported."));let a=null;this.cfg.model.progressBar&&(a=loadProgressBar(this.canvas,this.events));const r=e.length>1;let l=this.loadGltf(i,e[0],a,1,r);for(let d=0;d<e.length;d++){let c;try{c=await l}catch(t){const s=e[d+1];if(!s){if(!n)throw o=!0,t;return!0}l=this.loadGltf(i,s,n?null:a,d+2,r);continue}const h=e[d+1],m=h?this.loadGltf(i,h,null,d+2,r):null;m&&m.catch(()=>{});try{n?(await this.prepareTextureImages(c),this.updateGeometries(c),this.updateTextureImages(),this.disposeMaterialsAndTextures(c)):(this.scene=c.scene,await Promise.all([this.initTexturesGltf(c),this.initTexturesFromImagesUnused(c)]),this.meshes=s.initFirstScene(c),n=!0,a?.setProgress(100),this.resolveSceneReady()),await t.waitForRender(),this.events.sceneRendered({type:r?`Scene${d+1}_Rendered`:"Scene_Rendered"})}catch(e){if(!n)throw e;if(this.reportError(e),!m)return!0}if(!m)return r&&this.events.send({type:"Model_Ready"},"Applied and rendered final model"),!0;l=m}return n}catch(e){throw o||this.reportError(e),this.rejectSceneReady(e),e}}async loadGltf(e,t,s,i,n){let o=-1;try{const a=await e.loadAsync(t,e=>{if(e.total>0&&s){const t=e.loaded/e.total,i=Math.round(90*t);i<90&&s.setProgress(i)}const t=e.total>0?Math.round(e.loaded/e.total*100):0;t!==o&&(o=t,this.events.modelLoading({type:n?`Model${i}_Loading`:"Model_Loading",loading:t}))});return this.events.modelLoaded({type:n?`Model${i}_Loaded`:"Model_Loaded"}),a}catch(e){throw this.reportError(e),e}}async prepareTextureImages(e){await Promise.all(this.textures.map(async t=>{t.pending=null;try{let s;s="texture"===t.source.type?await e.parser.getDependency("texture",t.source.index):await this.initTextureFromImageUnused(t.source.name,e),t.pending={image:s.image,mipmaps:s.mipmaps.slice()}}catch(e){const s="texture"===t.source.type?`GLTF texture index ${t.source.index}`:`unused image "${t.source.name}"`;console.warn(`Progressive image for ${s} could not be initialized.`,e)}}))}reportError(e){const t=e instanceof Error?e:new Error(String(e));this.events.modelError({type:"Model_Error",error:t})}updateGeometries(e){if(!this.scene)return;const t=new Set;let s=0,i=0;e.scene.traverse(e=>{if(!(e instanceof THREE.Mesh))return;s++;const n=this.meshes.get(e.name);e.name&&n?(t.add(n.geometry),n.geometry=e.geometry,n.updateMorphTargets(),i++):t.add(e.geometry)}),this.disposeGeometries(t),i!==s&&console.warn(`Progressive GLTF level replaced ${i} of ${s} meshes. Mesh names and scene structures must match.`)}updateTextureImages(){for(const e of this.textures)e.pending&&(e.texture.dispose(),e.texture.image=e.pending.image,e.texture.mipmaps=e.pending.mipmaps,e.texture.needsUpdate=!0,e.pending=null)}},Ctrl=class{engine;scene;model;envCtrls;events;orbitCtrls;fpvCtrls;raycast;objs3D;webs;webCtrls;constructor(e,t,s,i,n,o,a,r,l,d,c){this.engine=e,this.events=n,this.envCtrls=i,this.fpvCtrls=a,this.model=s,this.orbitCtrls=o,this.objs3D=l,this.raycast=r,this.scene=t,this.webs=d,this.webCtrls=c}async init(e){await this.engine.initRenderer(),this.scene.initObjs3D(this.engine.renderer,this.model);for(const e of this.webs.values())for(const t of e)t.start(this.webs,this.webCtrls);this.model&&(this.model.modelReady=this.model.load(e.model.file,this.engine,this.scene),this.model.modelReady.catch(()=>{})),this.envCtrls.init(),this.model&&await this.model.sceneReady,this.raycast.initColliders(),await this.envCtrls.envReady;for(const e of this.objs3D.values())e.ready(this.objs3D);for(const e of this.webs.values())for(const t of e)t.ready(this.objs3D);e.orbitCtrls.enable&&this.orbitCtrls.enable(),e.fpvCtrls.enable&&this.fpvCtrls.enable(),this.events.send({type:"Scene_Ready"},"Scene is set up and ready"),await this.engine.init(),this.model||this.events.sceneRendered({type:"Scene_Rendered"}),this.engine.setAnimationLoop();try{this.model&&!await this.model.modelReady||(e.render.adaptiveGfx?this.engine.updateGfx("idle"):this.engine.gfxEvents.emit({type:"Gfx_Ready",gfxLevel:null}))}catch(e){console.error("Error during model loading.",e)}}},Modules=class{fxaaNode=null;fxaaShader=null;smaaPassClass=null;smaaNode=null;traaNode=null;ssaoPassClass=null;gtaoNodeClass=null;ssgiNodeClass=null;ssrNode=null;ssrPassClass=null;paneClass=null;createBrowserInspector=null;effectComposerClass=null;envLoader=null;dracoLoader=null;gltfLoader=null;ktx2Loader=null;meshoptDecoder=null;outputPassClass=null;renderPassClass=null;shaderPassClass=null;rectAreaLightNodeClass=null;rectAreaLightTexturesLib=null;rectAreaLightUniformsLib=null;orbitControlsClass=null;pointerLockControlsClass=null;webGpuRendererClass=null;renderPipelineClass=null;tslPass=null;tslRtt=null;tslMrt=null;tslContext=null;tslOutput=null;tslDiffuseColor=null;tslVelocity=null;tslRenderOutput=null;tslNormalView=null;tslMetalness=null;tslRoughness=null;tslSample=null;tslVec2=null;tslVec3=null;tslVec4=null;tslFloat=null;packNormalToRGB=null;unpackRGBToNormal=null;cfg;constructor(e){this.cfg=e}consoleLog(e){"none"!==this.cfg.debug.log&&console.log(`Module: ${e} successfully imported`)}async importDracoLoader(){if(!this.dracoLoader&&"draco"===this.cfg.model.compress.mesh)try{const e=await(import("three/addons/loaders/DRACOLoader.js"));this.consoleLog("DRACOLoader"),this.dracoLoader=new e.DRACOLoader,this.dracoLoader.setDecoderPath("draco/")}catch{console.warn("DRACOLoader could not be imported")}}async importEffectComposer(){if(!this.effectComposerClass)try{const e=await(import("three/addons/postprocessing/EffectComposer.js"));this.effectComposerClass=e.EffectComposer,this.consoleLog("EffectComposer")}catch{console.warn("EffectComposer could not be imported")}}async importENVLoader(){if(!this.envLoader&&(this.cfg.envCtrls.enable||this.cfg.envCtrls.load))if("exr"===this.cfg.envCtrls.type)try{const e=await(import("three/addons/loaders/EXRLoader.js"));this.consoleLog("EXRLoader");const t=new e.EXRLoader;this.envLoader=t}catch{console.warn("EXRLoader could not be imported")}else if("hdr"===this.cfg.envCtrls.type)try{const e=await(import("three/addons/loaders/HDRLoader.js"));this.consoleLog("HDRLoader");const t=new e.HDRLoader;this.envLoader=t}catch{console.warn("HDRLoader could not be imported")}}async importFpvCtrls(){if(this.cfg.fpvCtrls.enable||this.cfg.fpvCtrls.load)try{const e=await(import("three/addons/controls/PointerLockControls.js"));this.pointerLockControlsClass=e.PointerLockControls,this.consoleLog("PointerLockControls")}catch{console.warn("PointerLockControls could not be imported")}}async importFXAANode(e){if(!this.fxaaNode&&"fxaa"===e)try{const e=await(import("three/addons/tsl/display/FXAANode.js"));this.fxaaNode=e.fxaa,this.consoleLog("FXAANode")}catch{console.warn("FXAANode could not be imported")}}async importFXAAShader(e){if(!this.fxaaShader&&"fxaa"===e){try{const e=await(import("three/addons/shaders/FXAAShader.js"));this.fxaaShader=e.FXAAShader,this.consoleLog("FXAAShader")}catch{console.warn("FXAAShader could not be imported")}if(!this.shaderPassClass)try{const e=await(import("three/addons/postprocessing/ShaderPass.js"));this.shaderPassClass=e.ShaderPass,this.consoleLog("ShaderPass")}catch{console.warn("ShaderPass could not be imported")}}}async importGLTFLoader(){if(0!==this.cfg.model.file.length)try{const e=await(import("three/addons/loaders/GLTFLoader.js"));this.consoleLog("GLTFLoader"),this.gltfLoader=new e.GLTFLoader}catch{console.warn("GLTFLoader could not be imported")}}async importGtaoNode(e){if(!this.gtaoNodeClass&&e)try{const e=await(import("three/addons/tsl/display/GTAONode.js"));this.gtaoNodeClass=e.ao,this.consoleLog("GTAONode")}catch{console.warn("GTAONode could not be imported")}}async importKTX2Loader(){if(!this.ktx2Loader&&"ktx2"===this.cfg.model.compress.texture)try{const e=await(import("three/addons/loaders/KTX2Loader.js"));this.ktx2Loader=new e.KTX2Loader,this.consoleLog("KTX2Loader")}catch{console.warn("KTX2Loader could not be imported")}}async importMeshoptDecoder(){if(!this.meshoptDecoder&&"meshopt"===this.cfg.model.compress.mesh)try{const e=await(import("three/addons/libs/meshopt_decoder.module.js"));this.meshoptDecoder=e.MeshoptDecoder,this.consoleLog("MeshoptDecoder")}catch{console.warn("MeshoptDecoder could not be imported")}}async importOrbitCtrls(){if(this.cfg.orbitCtrls.enable||this.cfg.orbitCtrls.load)try{const e=await(import("three/addons/controls/OrbitControls.js"));this.orbitControlsClass=e.OrbitControls,this.consoleLog("OrbitControls")}catch{console.warn("OrbitControls could not be imported")}}async importOutputPass(){if(!this.outputPassClass)try{const e=await(import("three/addons/postprocessing/OutputPass.js"));this.outputPassClass=e.OutputPass,this.consoleLog("OutputPass")}catch{console.warn("OutputPass could not be imported")}}async importRectAreaLight(e){if(this.cfg.light.rectArea)if(e){if(this.rectAreaLightTexturesLib)return;try{const e=await(import("three/addons/lights/RectAreaLightTexturesLib.js"));this.rectAreaLightTexturesLib=e.RectAreaLightTexturesLib,this.consoleLog("RectAreaLightTexturesLib")}catch{console.warn("RectAreaLightTexturesLib could not be imported")}}else{if(this.rectAreaLightUniformsLib)return;try{const e=await(import("three/addons/lights/RectAreaLightUniformsLib.js"));this.rectAreaLightUniformsLib=e.RectAreaLightUniformsLib,this.consoleLog("RectAreaLightUniformsLib")}catch{console.warn("RectAreaLightUniformsLib could not be imported")}}}async importRenderPass(){if(!this.renderPassClass)try{const e=await(import("three/addons/postprocessing/RenderPass.js"));this.renderPassClass=e.RenderPass,this.consoleLog("RenderPass")}catch{console.warn("RenderPass could not be imported")}}async importSMAANode(e){if(!this.smaaNode&&"smaa"===e)try{const e=await(import("three/addons/tsl/display/SMAANode.js"));this.smaaNode=e.smaa,this.consoleLog("SMAANode")}catch{console.warn("SMAANode could not be imported")}}async importSMAAPass(e){if(!this.smaaPassClass&&"smaa"===e)try{const e=await(import("three/addons/postprocessing/SMAAPass.js"));this.smaaPassClass=e.SMAAPass,this.consoleLog("SMAAPass")}catch{console.warn("SMAAPass could not be imported")}}async importSSAOPass(e){if(!this.ssaoPassClass&&e)try{const e=await(import("three/addons/postprocessing/SSAOPass.js"));this.ssaoPassClass=e.SSAOPass,this.consoleLog("SSAOPass")}catch{console.warn("SSAOPass could not be imported")}}async importSsgiNode(e,t){if(!this.ssgiNodeClass&&"ssgi"===e&&"traa"===t)try{const e=await(import("three/addons/tsl/display/SSGINode.js"));this.ssgiNodeClass=e.ssgi,this.consoleLog("SSGINode")}catch{console.warn("SSGINode could not be imported")}}async importSsrNode(e){if(!this.ssrNode&&e)try{const e=await(import("three/addons/tsl/display/SSRNode.js"));this.ssrNode=e.ssr,this.consoleLog("SSRNode")}catch{console.warn("SSRNode could not be imported")}}async importSsrPass(e){if(!this.ssrPassClass&&e)try{const e=await(import("three/addons/postprocessing/SSRPass.js"));this.ssrPassClass=e.SSRPass,this.consoleLog("SSRPass")}catch{console.warn("SSRPass could not be imported")}}async importStatelyAi(){if(!this.createBrowserInspector&&this.cfg.stateMachine.inspector)try{const e=await(import("@statelyai/inspect"));this.createBrowserInspector=e.createBrowserInspector,this.consoleLog("StatelyAi Inspector")}catch{console.warn("StatelyAi Inspector could not be imported")}}async importThreeTsl(){if(!this.tslPass)try{const e=await(import("three/tsl"));this.tslPass=e.pass,this.tslRtt=e.rtt,this.tslMrt=e.mrt,this.tslContext=e.context,this.tslOutput=e.output,this.tslDiffuseColor=e.diffuseColor,this.tslVelocity=e.velocity,this.tslRenderOutput=e.renderOutput,this.tslNormalView=e.normalView,this.tslMetalness=e.metalness,this.tslRoughness=e.roughness,this.tslSample=e.sample,this.tslVec2=e.vec2,this.tslVec3=e.vec3,this.tslVec4=e.vec4,this.tslFloat=e.float,this.packNormalToRGB=e.packNormalToRGB,this.unpackRGBToNormal=e.unpackRGBToNormal,this.consoleLog("Three TSL")}catch{console.warn("Three TSL could not be imported")}}async importThreeWebGpu(){try{const e=await(import("three/webgpu"));this.webGpuRendererClass=e.WebGPURenderer,this.renderPipelineClass=e.RenderPipeline,this.rectAreaLightNodeClass=e.RectAreaLightNode,this.consoleLog("WebGPU")}catch{console.warn("Three WebGPU could not be imported")}}async importTRAANode(e){if(!this.traaNode&&"traa"===e)try{const e=await(import("three/addons/tsl/display/TRAANode.js"));this.traaNode=e.traa,this.consoleLog("TRAANode")}catch{console.warn("TRAANode could not be imported")}}async importTweakpane(){if(this.cfg.gui.inspector.enable)try{const e=await(import("tweakpane"));this.paneClass=e.Pane,this.consoleLog("Tweakpane")}catch{console.warn("Tweakpane could not be imported")}}},_0x1a71ae=_0x5746;!function(){const e=_0x5746,t=_0x1562();for(;;)try{if(-parseInt(e(303))/1+-parseInt(e(216))/2*(parseInt(e(238))/3)+-parseInt(e(269))/4*(-parseInt(e(300))/5)+-parseInt(e(214))/6*(parseInt(e(301))/7)+parseInt(e(234))/8*(parseInt(e(249))/9)+-parseInt(e(282))/10+parseInt(e(287))/11==815679)break;t.push(t.shift())}catch(e){t.push(t.shift())}}();var e=class extends HTMLElement{[_0x1a71ae(221)];[_0x1a71ae(237)];[_0x1a71ae(263)];[_0x1a71ae(259)];[_0x1a71ae(285)];[_0x1a71ae(290)];[_0x1a71ae(271)];constructor(){const e=_0x1a71ae;super(),this[e(290)]=this[e(266)]({mode:e(291)}),this[e(290)][e(289)]=e(235);const t=document[e(256)](e(294));t[e(261)]=e(299),this[e(290)][e(260)](t);for(const t of[e(250),e(231),e(222),e(233)])this[e(304)](t,t=>t[e(220)]());const s=this[e(290)][e(245)](e(307));s[e(304)](e(250),()=>this[e(254)](s));const i=this[e(290)][e(245)](e(253));i&&i[e(304)](e(250),()=>{const t=e,s=t(293)===i[t(252)](t(283));i[t(284)](t(283),!s),i[t(281)]=t(s?217:241),this[t(276)](!s)})}[_0x1a71ae(224)](){const e=_0x1a71ae,t=this[e(290)][e(245)](e(307));t&&(t[e(286)]=!0)}[_0x1a71ae(229)](e){const t=_0x1a71ae;this[t(237)]=e,this[t(263)][t(236)][t(244)]&&this[t(275)](0),this[t(237)][t(227)][t(304)](t(274),e=>{const s=t;this[s(275)](e[s(297)])}),this[t(237)][t(227)][t(304)](t(223),e=>{const s=t;this[s(277)](this[s(263)][s(236)][s(257)]),this[s(275)](e[s(297)])})}[_0x1a71ae(277)](e){const t=_0x1a71ae,s=this[t(290)][t(245)](t(307));if(s&&(s[t(286)]=!e,!e)){s[t(284)](t(283),t(213));const e=s[t(245)](t(296));e&&(e[t(289)]=t(306))}}[_0x1a71ae(275)](e){const t=_0x1a71ae,s=this[t(290)][t(245)](t(298));if(!s)return;if(s[t(268)]=null===e,null===e)return;const i=this[t(237)][t(258)]();if(s[t(240)]!==i[t(280)]){s[t(242)]();for(let e=0;e<i[t(280)];e++){const e=document[t(256)](t(270));e[t(279)][t(247)](t(215)),s[t(260)](e)}}for(const[n,o]of i[t(272)]())s[t(292)][n][t(279)][t(239)](t(273),o<=e)}[_0x1a71ae(226)](e){const t=_0x1a71ae;if(!e||!this[t(290)])return;const s=this[t(290)][t(245)](t(308));s&&(s[t(294)][t(259)]=this[t(259)])}[_0x1a71ae(264)](e){const t=_0x1a71ae;if(!e||!this[t(290)])return;const s=this[t(290)][t(245)](t(278));s&&(s[t(294)][t(232)]=this[t(285)])}[_0x1a71ae(295)](e){const t=_0x1a71ae;if(e||!this[t(290)])return;const s=this[t(290)][t(245)](t(262));s&&(s[t(261)]=t(243))}[_0x1a71ae(254)](e){const t=_0x1a71ae;e[t(279)][t(230)](t(251))||e[t(279)][t(247)](t(251));const s=!(t(293)===e[t(252)](t(283)));e[t(284)](t(283),s),this[t(237)][t(305)](s);const i=e[t(245)](t(296));i&&(i[t(289)]=t(s?255:306))}[_0x1a71ae(276)](e){const t=_0x1a71ae;e?this[t(221)][t(288)]():document[t(302)]()}};function _0x5746(e,t){e-=213;const s=_0x1562();let i=s[e];if(void 0===_0x5746.EyGPHJ){_0x5746.megtnk=function(e){let t="",s="";for(let s,i,n=0,o=0;i=e.charAt(o++);~i&&(s=n%4?64*s+i:i,n++%4)&&(t+=String.fromCharCode(255&s>>(-2*n&6))))i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(i);for(let e=0,i=t.length;e<i;e++)s+="%"+("00"+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(s)},_0x5746.ShGwkT={},_0x5746.EyGPHJ=!0}const n=s[0];_0x5746.HFXnMO!==n&&(_0x5746.ShGwkT={},_0x5746.HFXnMO=n);const o=_0x5746.ShGwkT[e];return void 0===o?(i=_0x5746.megtnk(i),_0x5746.ShGwkT[e]=i):i=o,i}function _0x1562(){const e=["C3rVCfbYB3bHz2f0Aw9U","y2fUDMfZ","Cg9PBNrLCM1VDMu","r2z4x1jLywr5","y29UBMvJDgvKq2fSBgjHy2S","z3vP","C2v0qMfJA2DYB3vUzenVBg9Y","z2z4rxzLBNrZ","BwvUDujHCG","C2v0rw5NAw5L","y29UDgfPBNm","Cg9PBNrLCMrVD24","yMfJA2DYB3vUzeLTywDL","Cg9PBNrLCNvW","mJrozuLjCKq","pgrPDIbPzd0IBwvUDwjHCIi+dqOGidXKAxyGAwq9iM1LBNvIDxr0B25ZiJ4ncIaGica8ysbPzd0IBg9NBYiGAhjLzJ0IAhr0Chm6lY9PBgX1DgLVBNmUy29TiIb0yxjNzxq9iL9IBgfUAYiGCMvSpsjUB29Wzw5LCIbUB3jLzMvYCMvYiJ48l2e+dqOGicaGpgj1DhrVBIb0ExbLpsjIDxr0B24IigLKpsjLy28IigfYAweTChjLC3nLzd0IzMfSC2uIigrPC2fIBgvKpG0kicaGicaGphnWyw4GAwq9iMvJBY1RBM9IiJ48l3nWyw4+dqOGicaGica8C3bHBIbPzd0IzwnVlxrLEhqIpKvJBZXICJ5ptJWVC3bHBJ4ncIaGica8l2j1DhrVBJ4ncIaGica8zgL2igLKpsjNzNGIigHPzgrLBJ48l2rPDJ4ncIaGica8yNv0Dg9Uihr5Cgu9iMj1DhrVBIiGAwq9iNnPEMuIigfYAweTChjLC3nLzd0IzMfSC2uIihrPDgXLpsjnyxHPBwL6zsi+pc9IDxr0B24+dqOGidWVzgL2pG0kica8zgL2igLKpsjSAwnLBNnLiJ48l2rPDJ4ncJWVzgL2pG","CMvUzgvY","zw5NAw5L","m2DtzgvUCq","Dg9Nz2XL","y2HPBgrfBgvTzw50q291BNq","twLUAw1PEMu","CMvWBgfJzunOAwXKCMvU","WQKGAwXSDxrPB25Zig5VBI1JB21TzxjJAwfSihvZzsbVBMX5","ywrHChrPDMvhzNG","CxvLCNLtzwXLy3rVCG","zgvMAw5L","ywrK","AwX1lw1I","mZKXmZi5zfD0vvvI","y2XPy2S","Aw50zxjHy3rLza","z2v0qxr0CMLIDxrL","i3nPEMu","Dg9Nz2XLrwnVtw9Kzq","rwnVpgjYpK9grG","y3jLyxrLrwXLBwvUDa","zwnVtw9Kzq","z2v0r2z4tgv2zwXZ","yMfJA2DYB3vUzenVBg9Y","yxbWzw5K","Dgv4DenVBNrLBNq","i2XPy2vUC2u","y2zN","C2v0tg9NBW","z2v0","yxr0ywnOu2HHzg93","zw5HyMXL","AgLKzgvU","nezfzvf4yW","C3bHBG","DMfSAwq","zw50CMLLCW","ywn0AxzL","r2z4x0nOyw5Nzwq","C2v0r2z4sw5KAwnHDg9Y","Dg9Nz2XLu2nYzwvUu2L6zq","C2v0rwnVqxzHAwXHyMXL","i2XVz28","y2XHC3nmAxn0","BgvUz3rO","DgL0Bgu","nta1mZe0me5cCwTpCq","yxjPys1WCMvZC2vK","C2v0qxr0CMLIDxrL","Bg9NBW","zgLZywjSzwq","mZCXmJe0ntHNEhryAg4","CMvXDwvZDez1BgXZy3jLzw4","Aw5Uzxjive1m","C2HHzg93uM9VDa","y2XVC2vK","y2HPBgrYzw4","Dhj1zq","C3r5Bgu","C2HVD0XPy2vUC2u","i2vJBY10zxH0","z2z4tgv2zwW","i2DMEa","i21LBNvIyxiGEW0kicb6lwLUzgv4oIaXmdaWoW0kicbWB3nPDgLVBJOGzML4zwq7ic8Qie9YAwvUDgf0zxmGDg8GDMLZDwfSihzPzxDWB3j0ig9UigfUzhjVAwqGzgv2AwnLCYWGywjZB2X1DguGBM90icOVdqOGigjVDhrVBtOGmJbWEdSGBgvMDdOGntaLoW0kicb0CMfUC2zVCM06ihrYyw5ZBgf0zvGOltuWjsK7ia0kicbKAxnWBgf5oIbMBgv4oW0kicbMBgv4lwrPCMvJDgLVBJOGy29SDw1UoYaGicaGia0kicbHBgLNBI1PDgvTCZOGy2vUDgvYoW0kicbMB250lxnPEMu6ideYChG7dqOGigzVBNqTzMfTAwX5oIbbCMLHBcWGsgvSDMv0AwnHlcbZyw5ZlxnLCMLMoYaGicaGdqOGigDHCdOGnhb4oW0kFq0kdqOJBwvUDwj1DhrVBNmGEW0kicbKAxnWBgf5oIbMBgv4oW0kicbHBgLNBI1PDgvTCZOGy2vUDgvYoW0kicbNyxa6idm1ChG7dqOGihbHzgrPBMC6idvWEcaYmhb4oW0kicbMB250lwzHBwLSEtOGqxjPywWSieHLBhzLDgLJysWGC2fUCY1ZzxjPzJSncIaGzM9UDc1ZAxPLoIaXCMvToW0kicbJB2XVCJOGi2zMzJSncIaGyMfJA2DYB3vUzdOGi2zMzMzMzJi5oW0kicbIB3jKzxi6idfWEcbZB2XPzcaJzMzMzMzMmgq7dqOGigjVCMrLCI1YywrPDxm6idjLBtSncIaGyM94lxnOywrVDZOGAw5ZzxqGmcaXChGGm3b4icnMzMzMzMy0mcWGAw5ZzxqGmcaTmtbWEcaXohb4icmWmdaWmdaYmdSncIaGyMfJA2rYB3aTzMLSDgvYoIbIBhvYkdeYChGPoW0kicaTD2vIA2L0lwjHy2TKCM9WlwzPBhrLCJOGyMX1CIGXmNb4ktSncIaGy3vYC29YoIbKzwzHDwX0oW0kicbWB2LUDgvYlwv2zw50CZOGyxv0BZSncN0ncG0ki2XVz28GEW0kicbVCgfJAxr5oIaWlJG7dqOGign1CNnVCJOGCg9PBNrLCJSncIaGzgLZCgXHEtOGAw5SAw5LlwjSB2nRoW0kicb3Awr0AdOGms44zw07igHLAwDODdOGms44zw07dqOGigjHy2TNCM91BMqTC2L6ztOGy29UDgfPBJSncIaGyMfJA2DYB3vUzc1YzxbLyxq6ig5VlxjLCgvHDdSncIaGyMfJA2DYB3vUzc1WB3nPDgLVBJOGy2vUDgvYoW0kicaVkIbfBMnVzgvKihzPysbODhrWCZOVl3LVA3nLBc5NAxrODwiUAw8VDxjSlwvUy29KzxiVicOVdqOGigjHy2TNCM91BMqTAw1Hz2u6ihvYBcGIzgf0ytPPBwfNzs9ZDMCREg1SlcuZq3n2zYb2zxjZAw9UpsCXlJiNihHTBg5ZpsDODhrWoI8VD3D3lNCZlM9YzY8YmdaWl3n2zYCGDMLLD0jVEd0NmcaWidi0ncaYoduNihDPzhrOpsCYndqNigHLAwDODd0NmJG1jYuZrsuZq3n0EwXLjtnfic5ZmcaLn0iGzMLSBdOGjtiZzJqWyJu3icu3rcaLm0mVC3r5BguLm0uLm0nWyxrOigLKpsDtAgfWzsaXjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBtuYidb2mJG1Bc01ms02mI4Yn3yTmtyWlJq2EICVjtnfjtndCgf0AcbPzd0Nu2HHCguGmsbJB3b5jYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBte0ocaWDJi4nwWTnteTnJiUmJD2lte2mc40nNONlYuZrsuZq3bHDgGGAwq9j1nOyxbLideGy29WEsaYjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBti0ncaWDJi4nwWTnteTnJiUmJD2lte2mc40nNONlYuZrsuZqY9ZDMCLm0uIktSncN0ncG0ki2vJBYb7dqOGigrPC3bSyxK6igzSzxG7dqOGigfSAwDUlwL0zw1ZoIbJzw50zxi7dqOGihbVC2L0Aw9UoIbYzwXHDgL2ztSncIaGCgfKzgLUzZOGmdSncIaGD2LKDgG6idGWChG7igHLAwDODdOGmZzWEdSncIaGyMfJA2DYB3vUzc1JB2XVCJOGiZaWmdaWmdq0oW0kicbIB3jKzxiTCMfKAxvZoIaYmhb4oW0kicbIB3jKzxi6ig5VBMu7dqOGign1CNnVCJOGCg9PBNrLCJSncIaGDhjHBNnPDgLVBJOGyMfJA2DYB3vUzc1JB2XVCIaWlJnZigvHC2u7dqP9dqOncInLy286zgLZywjSzwqGEW0kicbVCgfJAxr5oIaWlJm1oW0kicbJDxjZB3i6ig5VDc1HBgXVD2vKoW0kFq0kdqOJzwnVlwTUB2iGEW0kicb6lwLUzgv4oIaYoW0kicbVCgfJAxr5oIaWlJK7dqOGihbVC2L0Aw9UoIbHyNnVBhv0ztSncIaGBgvMDdOGnNb4oYaVkIbtDgfYDhbVC2L0Aw9UigXLzNqGkI8ncIaGD2LKDgG6idi1ChG7igHLAwDODdOGmJvWEdSncIaGyMfJA2DYB3vUzc1JB2XVCJOGD2HPDgu7dqOGigjVCMrLCI1YywrPDxm6iduWjtSncIaGDhjHBNnPDgLVBJOGDhjHBNnMB3jTidaUm3mGzwfZzs1PBI1VDxq7dqP9dqOncInLy28TDgv4Dcb7dqOGihOTAw5KzxG6ide7ic8QiejLAgLUzcbRBM9IicOVdqOGig9WywnPDhK6idaUodSncIaGzgLZCgXHEtOGzMXLEdSncIaGCgfKzgLUzZOGmcaXnhb4oW0kicb3Awr0AdOGmtaWjtSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lwvUzdSGlYOGvgv4DcbYAwDODcaQlW0kicbMB250lxDLAwDODdOGyM9SzdSncIaGzM9UDc1ZAxPLoIaWlJLLBtSncIaGDhjHBNnPDgLVBJOGy29SB3iGm3m7dqOGignVBg9YoIb3AgL0ztSncN0ncG0klYOGrwnVigfJDgL2zsbIywnRz3jVDw5KicOVdqOJzwnVw2fYAweTChjLC3nLzd0IDhj1zsjDihSncIaGyMfJA2DYB3vUzc1JB2XVCJOGi2y0mgi1nZK5oW0kFq0kdqOVkIbfy28Gywn0AxzLihrLEhqGkI8ncInLy29ByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY10zxH0ihSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lxn0yxj0oW0kFq0kdqOVkIbfy28Gywn0AxzLigTUB2iGkI8ncInLy29ByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY1RBM9IihSncIaGDhjHBNnMB3jToIb0CMfUC2XHDgvykdqYChGPoYancN0ncG0klYOGrwnVigLUywn0AxzLicOVdqOJzwnVw2fYAweTChjLC3nLzd0IzMfSC2uIxsaJzwnVlxrLEhqGEW0kicbQDxn0Awz5lwnVBNrLBNq6igzSzxGTzw5KoW0kicb0zxH0lwfSAwDUoIbSzwz0oW0kFq0kdqOJzwnVlMLUDgvYywn0zwrByxjPys1WCMvZC2vKpsj0CNvLiL0Gi2vJBY10zxH0ihSncIaGANvZDgLMEs1JB250zw50oIbMBgv4lxn0yxj0oW0kicbHBMLTyxrPB246igzHzguTDg8TzwnVlw9MzIaWlJrZigvHC2uTAw4TB3v0oW0kFq0kdqOJzwnVlMLUDgvYywn0zwrByxjPys1WCMvZC2vKpsjMywXZzsjDicnLy28TDgv4Dcb7dqOGigP1C3rPzNKTy29UDgvUDdOGzMXLEc1LBMq7dqOGigfUAw1HDgLVBJOGzMfKzs10BY1Ly28TB24Gmc40CYbLyxnLlwLUlw91DdSncN0ncG0kqgTLEwzYyw1LCYbMywrLlxrVlwvJBY1VzMyGEW0kicaWjsb7ig9WywnPDhK6idaUodSGFq0kicaYmcuGEYbVCgfJAxr5oIaWoYb9dqOGideWmcuGEYbVCgfJAxr5oIaWlJG7ih0ncN0ncG0kqgTLEwzYyw1LCYbMywrLlxrVlwvJBY1VBIb7dqOGidaLihSGB3bHy2L0EtOGmc44oYb9dqOGidiWjsb7ig9WywnPDhK6ida7ih0ncIaGmtaWjsb7ig9WywnPDhK6idaUodSGFq0kFq0kdqOJz2z4ihSncIaGD2LKDgG6idiWChG7dqOGigHLAwDODdOGmJvWEdSncIaGzgLZCgXHEtOGzMXLEdSncIaGzMXLEc1KAxjLy3rPB246ignVBhvTBI1YzxzLCNnLoW0kicbQDxn0Awz5lwnVBNrLBNq6ignLBNrLCJSncIaGz2fWoIaZChG7dqOGihbVAw50zxiTzxzLBNrZoIbUB25LoW0kFq0kdqOJz2z4w2HPzgrLBL0GEW0kicbKAxnWBgf5oIbUB25LoW0kFq0kdqOUz2z4lwXLDMvSihSncIaGzMXLEdOGmcaWidnWEdSncIaGD2LKDgG6ideWmcu7dqOGigjHy2TNCM91BMqTy29SB3i6icmWmdaWmda0ndSncN0ncG0klMDMEc1SzxzLBc5Hy3rPDMuGEW0kicbVCgfJAxr5oIaWlJC7dqOGigjHy2TNCM91BMqTy29SB3i6ihDOAxrLoW0kFq0kdqOJC2L6zsb7dqOGig9WywnPDhK6idaUodSncIaGD2LKDgG6idjLBtSGAgvPz2H0oIaYzw07dqOGigjHy2TNCM91BMq6ig5VBMu7dqOGigjVCMrLCJOGBM9UztSncIaGy3vYC29YoIbWB2LUDgvYoW0kicbIywnRz3jVDw5KlxnPEMu6ignVBNrHAw47dqOGigjHy2TNCM91BMqTCMvWzwf0oIbUBY1YzxbLyxq7dqOGigjHy2TNCM91BMqTCg9ZAxrPB246ignLBNrLCJSncIaGlYOGrw5JB2rLzcb2AweGAhr0Chm6lY95B2TZzwWUz2L0AhvIlMLVl3vYBc1LBMnVzgvYlYaQlW0kicbIywnRz3jVDw5KlwLTywDLoIb1CMWOiMrHDge6Aw1Hz2uVC3zNk3HTBcWLm0nZDMCGDMvYC2LVBJ0Nms4YjYb4BwXUCZ0NAhr0CdOVl3D3DY53mY5VCMCVmJaWmc9ZDMCNihzPzxDcB3G9jZaGmcaZmdGGmZeYjYb3Awr0Ad0NmZa4jYbOzwLNAhq9jZmXmICLm0uLm0nZDhLSzsuZrsaUCZaGjtDcigzPBgW6icuYm2zMzMzMzIaLn0qGjtndl3n0EwXLjtnfjtndCgf0AcbPzd0Nq29SB3iGrMLSBcaXjYbMAwXSlxj1Bgu9j2v2zw5VzgqNignSyxnZpsDZmcCGzd0NBteZlJy3idCUmdvSnZmUmtCTmc4XmYa0lJyGnc42m2mYlJuZidiUntuGnc42idyUmtiGnc42idCUotuGmcaXlJGYlteUntiGns4ZnY0ZlJm2idCUodGTmY4Zmsa0lJq5ltmUnJKGnc41nY00mI44mIa1lJm5Bdm2lJK5idm3lJm0yZi5lJK2idmWlJi0idm3lJaXidm4lJiXidm3lJa2idqXlJKGmc4WncaYlJuXlteUnJeGnI40ns0ZlJy1idGUnZuTmI42nYaZlJaXltuUmZqGnc4XnY05lJq5idqUmtmTns4Yos0WlJa3ltGUodmTmY4Xnc03os4Yns03mY44nMWWlJaYide3lJG0yZaUmdeGos44ms0WlJCZide5lJmZlteUnJmGmJeUmtuTmc45msaXlJGZltmUodGGnc40nc02lJyXiduUodeTmI43mIaXlJm3ltuUmZiGmI40os01lJC3idiUndKTmc40nIaWltmUndmTmI4Ync0XmI4Zoc05lJK2Bc0WlJm4ltCXlJf6BtiWnY45ncaWBdCZlJe3ltaUmtiGos4YidKUmJuTmc4Wmsa3ms4ZnI00lJe4idqUntzJltiUndiGmI42nc01lJKYidqUntyToc4Zmsa0lJu2ltiUmJCGmc01lJK4lteUmtiToc4Yns0YlJq5ltqUmdiTmI40mI00lJeZltiUotGTnc4XmY0Yms41nYaWlteYlJG4ltaUntKTmtKUmdGTms44mY0Xos4Woc0XlJaXidaTmtCUosaXnI4Wnc0ZnY41ncaZns42ns0Zmc4ZncaZmc4Yos0ZnI40nIaZns42nI00mc42nYaZns43ms0ZlJi0idaUmdqTnI41nY0XlJuYltKUnJqTnc41mY0ZlJG1ltmUnZGTnc40os01lJq5ltmUntKTos41ocaWlJC4ltmUntuGmteUmJyTmtuUmJqGmZyUndqTndaUnJyGmtKUndqTmtKUnJiGmZuUmZyTmZyUmJqGmZuUmZyTmZyUotiGmc4Wms0WlJy5ltCUnZGTms4Yns0XnY4Zms0XlJi1ltKUntmGmc0Xoc41ns0WlJu2ltiWlJa0lteUmJqTms40os0WlJy5ltmUnZeTmY4ZltqUotuTns44ms0XlJiZltiUnteTmI4ZmY01lJi1ltiUndmTnI4Wos0WlJeTmc44nsaXlJGXltmUodmGnc4YnI02lJy0EM0TmteXlJe3ide4mc44ogmZlJy0idaGnI41nYaXlJqXidKUndyGnc41nYaYlJmGmI41msa0lJeZidyUndmGnc4Woca4lJCXltaUmdGGmY4XmY05lJmXideZlJqYltC1lJeGnZKUnZfSndaUndmTmc4WnIaZlJmGnc45ogmYlJaZidmUmdCGmI45osa2lJu4idiUndGGos4XmY0WlJq1idiUmJGTmI41iduUnJyTnc41nca3lJuTmY40osaZlJe1ltuUotiGmY4Zns03nI4ZmYaZlJm2Bc05lJaYltKUmI0WlJaZltm0lJq0yY0WlJaXltiYlJK5idaUnJeTmZuUnJCGms45ltm4lJe2ideUmduTmI4WnIaZlJa5ltqUnJuGnc41mY01lJC2ideUndqTms4Xmsa0lJy2ltiUmduGnY4XnI0YlJa3idiUnJKTmc4Wnca2lJiYideUnJmGoc42nIa0lJa5idmUodCGmY44osa0lJe1iduUmZqGnc43oca0ms4ZowWZnI40oc0ZnI44n2mZmI4Zoc0ZmI43ncaZnY4WnY0ZnI44oca0ms43nI0ZnI44ohPTodGUndmGmc4Wm2m0lJq4idaUmdmGos43mIa0lJyYidqWlJyYidm1lJy2ide5lJuYide5lJyGmZyUndiGmZuUnJqGmZCUntuGmZuUnJuGms41msaWlJaYidiUmtCTns4XnIaYlJG5ltm4lJu5BduUnZCTmY4WmMm0lJq1ltiUmZmGnI41nc0YlJyYidKUmdGTms4YnsaXlJGYidaUotGGnc41ocaZlJm3idyUmtuGns4ZmIaYlJuGmY4XidiUodCGnY45ocaZlJa1idC0lJLSltGUodiGos4XmY0ZnI41ltaUmdzJlti2lJa4ltaUmdqTmZCUmJqTmc42mY0Zos4Xms0YlJa3lteUndqTms4Xms0ZlJq5ltmUnY00lJu0ltuUnZyTms4WnI0YlJa1lteUotuTnc42nI0XlJK4ltuUodeTmc4WmY0XlJe0ideUodmTnc4XmIa0lJeZltyUnJmGnc4Xms00lJq4idqUntmTnc41nYa0mI45nI00lJu2Bc0Zns43mI0ZnI4XyY0Xos42nc0Xos44ns0ZnI41nc0ZnY43nY0ZnY41nc0Zos44mY0XlJaXltiUmduTms45mY00lJC1ltiUmduTnI0WlJeZlteUmJqGms44mY00lJiZidqUmZuTnI42mYaYlJK2ltiUodmGnI4Zos00lJm3idKUnZeTnc4ZnxONlYuZrsuZqY9ZDMCLm0uIktSncN0ncG0ki3nPEMvByxjPys1WCMvZC2vKpsj0CNvLiL0GEW0kicaVkIbfBMnVzgvKihzPysbODhrWCZOVl3LVA3nLBc5NAxrODwiUAw8VDxjSlwvUy29KzxiVicOVdqOGigjHy2TNCM91BMqTAw1Hz2u6ihvYBcGIzgf0ytPPBwfNzs9ZDMCREg1SlcuZq3n2zYb2zxjZAw9UpsCXlJiNihHTBg5ZpsDODhrWoI8VD3D3lNCZlM9YzY8YmdaWl3n2zYCGDMLLD0jVEd0NmcaWidmWocaZmtiNihDPzhrOpsCZmdGNigHLAwDODd0NmZeYjYuZrsuZq3n0EwXLjtnfic5ZmcaLn0iGzMLSBdOGjtiZzMzMzMzMicu3rcaLm0mVC3r5BguLm0uLm0nWyxrOigLKpsDdB2XVCIbgAwXSidiNigzPBgWTCNvSzt0NzxzLBM9KzcCGy2XHC3m9j3mWjYbKpsDTos4ZmsaXmc40nMmTmY41idiUnJqTnc41mIa0lJC1ltqUnca5lJeXidaUmtqGns4XmYaZlJC5idKUmZiGmZCUmdmGndiUntzSmZyUodGGmZyUodHJltm4lJu5idaUodiTmZKUmdeGmc45ms00mI4ZmIa1lJm5lteUoduGmI41ms0ZlJm3idyUmduTmY4ZnYa3lJG3idaGms44mIaXlJuYiduUmZCGmY4ZnYa3lJG3BdmUmZCGnc41nMm3nc43ocaWlJa5idC1lJq4idaUmdiGnZKUmteTmY42ocaZlJyTmY42ocaZlJCTnc43ncaZlJCZltqXlJq4BdaUmdqTmZCUnZfJltCUmdCTns4YmY0Xmc42ms02lJC1lteYlJq0ltyUnZuTms44mIaWltuUmZyGms41mI03lJG3idmUmZGTnc41msaZlJm0ltqUntyGmY41nI00lJu2idiYlJqZidaGmtaUndGTmc41nIaXos4Wns0XlJi0ide5lJa1ltaUnJGTmc4Wms0XnY42ns0XnI40ms0ZnY43ms0ZnI40nc0Yoc42nc0Yoc42ms0ZnY4Zoc0ZnI40mY00mc43nY0ZnI40ns0YlJm2ltaUmdeTnI4ZnsaXlJuYltGUoduGmY40mxPTmJm5lJqGmZqUmtLSltm3lJu5idm3lJyZyY0WlJuZltqWlJi0ltaUntGTndaUndKTns4Wos00mY44mI0YlJuTms44nI02lJa5ltmUmZuTnY45nY0ZlJmYlteUodCGmc4WmY01lJqYideUntuTnY44nYaZlJm3Bc00lJq2idmUmZjJltaUmdKGnZqUnZGTmc4WmIa3ns40ocaZlJy5idC5lJeXidmUnJCGmY41osa0lJC4idmUnJKGndeUmdyGmY43nYaZnI42nIaWlJa4idm3lJm2idaUmdeGndaUotKTmY42osaYlJaZltiUmdGGmY43mY01lJy0idmUnZGTnY45mIaWlJa2ltiUmJGTms40mI02lJe5ltmUmJGToc43ltmUmZqTnc41mY0ZlJuXltqUntyTmJiUodqTnc41m2WTmtKUndGGmc4WmMm3ms41os03ms43nca3mY42nI03nc4Xnsa3mY43ms04mc4WmIaWlJa0ltqUodKTmc45mI02lJK0ltqUnteTos41os0YlJuXlteUoduTnI4Zns0ZlJm1ltGUntuTmY4Zms0YlJK3idaUmdqTmtmUnJKGos43nI00ms41osaZnY42ohPTltiWnc40ide0mY4WngmTmI40msaWlJq1ltuUodGGmI4XmY03lJCYidmUnZmTmI4WnsaXlJC3ltmUmZyGnc45oc0ZlJm5idGUmJGTmc4WmYaZlJq3ideUmYa2lJy5idmUnZmGos4WnsaZlJm3idmUmJyGns43osaZlJCGmJiUodmGnc4XngWXos4WnIaWlJq5yY02nc44nsa2ns41oc03mY43nYa3ns41oc03mY44msa3oc43mY0WlJaZidiUmJCGms40nIa2lJe5idmUmZeGoc43idiUmJCGmY4WnYa0lJG3idqUntuGnY45mYa0lJuZidiUnteTmc4Wmsa1lJq2ltaUntCGnI41ns0XlJi0ideUmdKTmc42nYaXoc4Ync0XnY4YnIaZoc4XmI0ZnI44nMWZnI4Xnc0Zns42m2mWlJGYidm4lJu5idaUoteGmZKUmdeGns4Zoca0mI4ZmIaYlJuXideUodyGnI4WnsaZlJm3idCUodCGmY4ZnYaXlJGZidaGns4ZnY0XlJuXidCUodGTmY4Zn2W0lJu2ltmUmZDJmc4Woc03nc44idaUmdiTnZuUndCTmY42os03os4WmY0ZlJu4ltmUndiTns41ltmUnJmTmZCUmdGTnc4Xnc0Xoc4Zms0WlJi5ltm1lJi3ltaUmtyTmZCUnJCGmc4ZEM0XndqUnYaZlJGZyY0ZlJKXidmUodmTmY45msaZlJKYltmUnIa0ms40ngWWlJmYidm3lJzJnY4WnIa1lJiZideWlJyXidyUnZqGmtiUndmGnI43ncaXlJGYidaGns4ZnY0XlJuXidCUodCTmY4ZnYa0lJu1ltmUmZyGnc41nI0ZlJqZidqUntmTmJmUnJHSltaUmdiTmJaUm2m2os43osa2os42nsa3nI4Ymsa3ns4ZmYa4mc40nca3ns40msaZlJa4idaUmdyGnI4Zoc0XlJm1idGUnJyTmY42ocaYlJqXltiUndyGmY43ltuUocaZlJy5ltKUntCTmc4Wms01lJm1ltiUodGToc42oc0ZnI40mI00mI4Yn2WTmZyUndiTmZyUndzJmZCUnZeTmc44mIaZoc4Xoc0WlJKZidqXlJq4ltuUmZKGms44nI0YlJuXidmUmZGTnI4WnsaZlJm4ltCUodCGmc0XlJGZlteUntiTns4ZnY0ZlJm4ltCUodHSltmUmZCTnc41nwmTnZuUmtyGmc03ns43mYaWlJa1ltC5lJu5idmUodn6jY8Lm0uLm0mVC3zNjtnfiIK7ia0kFq0kdqOJBgLJzw5Zzsb7dqOGigzVBNqTC2L6ztOGmc45zw07dqOGihDOAxrLlxnWywnLoIbUB3DYyxa7dqOGihrLEhqTywXPz246ignLBNrLCJSncIaGBgLUzs1OzwLNAhq6ideUnwvToW0kicbJB2XVCJOGi2zMzMzMzJK5oW0kFq0k","mJy2mJyXnvHyD0XxDa","mtaWotmWmZr6sxjzEuO","zxHPDez1BgXZy3jLzw4","oty3ndu3C2f6BvPh","ywrKrxzLBNrmAxn0zw5LCG","C2v0rwnVqNv0Dg9Uqwn0AxzL","rwnVpgjYpK9o","i2vJBW","i21LBNvIDxr0B25Z","zMfSC2u","nNfjzhjkAq","z2z4lwXLDMvS","nJe0nJy0s3H3EMLH","twf4Aw1PEMu","Dw5KzwzPBMvK","yxbWzw5Kq2HPBgq"];return(_0x1562=function(){return e})()}function n(t,s,i,n,o){return function(t,s,i,n,o){const a=_0x5746;let r;if(1==(+!!s[a(225)][a(228)][a(267)]|1^+(!0===i))){const n=a(248);customElements[a(265)](n)||customElements[a(246)](n,e),r=document[a(256)](n),r[a(259)]=s[a(225)][a(228)][a(259)],r[a(285)]=s[a(225)][a(228)][a(285)],r[a(221)]=t,r[a(263)]=s,r[a(264)](i),r[a(226)](i),r[a(295)](i),t[a(219)](r)}const l=new n(...o);return r&&r[a(229)](l[a(237)]),l}(t,s,1===((_0x1a71ae(218)!=typeof _0xb62ff0&&_0xb62ff0)^i),n,o)}var App=class e{audio;ctrl;engine;model;envCtrls;events;orbitCtrls;fpvCtrls;raycast;scene;stateMachine;webCtrls;cam3D;comps;objs3DMap=new Map;websMap=new Map;constructor(e,t,s,i){this.comps={scene:{},web:{}};const n=s.scene??{};for(const[t,s]of Object.entries(n)){const n=new("function"==typeof s?s:s.class)(e,i,t,"function"==typeof s?void 0:s.params);n instanceof Cam3D&&(this.cam3D=n),this.objs3DMap.set(t,n),this.comps.scene[t]=n}this.cam3D??=new Cam3D(e,i,"Cam3D"),this.stateMachine=new StateMachine(i,t),this.events=new Events(i,this.stateMachine),this.scene=new Scene(this.cam3D,i,this.events,this.objs3DMap),this.engine=new Engine(this.scene,this.cam3D,e,i,this.events,t,this.objs3DMap),this.webCtrls=new WebCtrls(this.cam3D,this.engine,i.comps.overlap.padding),this.envCtrls=new EnvCtrls(i,this.engine,this.scene,this.events,t),this.orbitCtrls=new OrbitCtrls(this.cam3D,i.orbitCtrls,this.engine,this.events,t),this.fpvCtrls=new FpvCtrls(this.cam3D,e,i.fpvCtrls,this.engine,this.events,t),this.raycast=new Raycast(this.cam3D,e,i,this.engine,this.scene,this.events,this.objs3DMap),this.audio=new Audio(i.audio,this.scene,this.events),this.model=i.model.file.length>0?new Model(e,i,this.events,t,this.engine.renderer):null,this.ctrl=new Ctrl(this.engine,this.scene,this.model,this.envCtrls,this.events,this.orbitCtrls,this.fpvCtrls,this.raycast,this.objs3DMap,this.websMap,this.webCtrls),i.gui.inspector.enable&&new Inspector(i,this.audio,this.engine,this.scene,this.envCtrls,t,this.orbitCtrls,this.fpvCtrls);for(const e of this.objs3DMap.values())e.events=this.events,e.raycast=this.raycast,e.scene=this.scene;const o=s.web??{};for(const[t,s]of Object.entries(o)){const n="function"==typeof s?s:s.class,o="function"==typeof s?void 0:s.params,a=`ilu-${t.toLowerCase()}`;customElements.get(a)||customElements.define(a,n);const r=Array.from(document.querySelectorAll(a));this.websMap.set(t,r),this.comps.web[t]=r;for(const t of r)o&&Object.assign(t,o),t.canvas=e,t.cfg=i,t.events=this.events,t.objs3D=this.objs3DMap}}static async run(t,s,i){try{s=s??{},t=null!=t?structuredClone(t):structuredClone(cfg);const o=document.querySelector(t.scene.canvas);if(!o)throw new Error("No canvas tag found in DOM.");const a="undefined"!=typeof _0x4a91c3?Number(_0x4a91c3)%1e8:0,r=new Modules(t);if("webgl"!==t.render.api&&("auto"!==t.render.api||navigator.gpu&&await navigator.gpu.requestAdapter())){const e=t.render.profile.webgpu;("none"!==e.ssl||e.ssr||"none"!==e.aa)&&(await r.importFXAANode(e.aa),await r.importSMAANode(e.aa),await r.importTRAANode(e.aa),await r.importGtaoNode("gtao"===e.ssl||t.render.adaptiveGfx&&"ssgi"===e.ssl),await r.importSsgiNode(e.ssl,e.aa),await r.importSsrNode(e.ssr),await r.importThreeTsl()),await r.importThreeWebGpu(),await r.importRectAreaLight(!0)}else{const e=t.render.profile.webgl;("none"!==e.ssl||e.ssr||"none"!==e.aa)&&(await r.importEffectComposer(),await r.importOutputPass(),await r.importRenderPass(),await r.importFXAAShader(e.aa),await r.importSMAAPass(e.aa),await r.importSSAOPass("ssao"===e.ssl),await r.importSsrPass(e.ssr)),await r.importRectAreaLight(!1)}await r.importDracoLoader(),await r.importENVLoader(),await r.importFpvCtrls(),await r.importGLTFLoader(),await r.importKTX2Loader(),await r.importMeshoptDecoder(),await r.importOrbitCtrls(),await r.importStatelyAi(),await r.importTweakpane();const l=n(o,t,a,e,[o,r,s,t]);if(i){const e=i(l);l.stateMachine.start(e)}await l.ctrl.init(t)}catch(e){console.error("Error during app startup.",e)}}};exports.App=App,exports.Audio=Audio,exports.Cam3D=Cam3D,exports.Coll3D=Coll3D,exports.Engine=Engine,exports.EnvCtrls=EnvCtrls,exports.Events=Events,exports.FpvCtrls=FpvCtrls,exports.Light3D=Light3D,exports.Mesh3D=Mesh3D,exports.Obj3D=Obj3D,exports.OrbitCtrls=OrbitCtrls,exports.Raycast=Raycast,exports.Scene=Scene,exports.StateMachine=StateMachine,exports.Web=Web,exports.cfg=cfg,exports.setCfg=setCfg;