ohzi-core 5.14.1 → 5.14.2
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/build/index.module.js +1 -1
- package/build/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +12 -2
- package/types/BaseApplication.d.ts +1 -1
- package/types/CameraManager.d.ts +7 -7
- package/types/Capabilities.d.ts +5 -7
- package/types/Configuration.d.ts +5 -7
- package/types/Debug.d.ts +36 -36
- package/types/EventManager.d.ts +41 -43
- package/types/Graphics.d.ts +35 -35
- package/types/Initializer.d.ts +3 -5
- package/types/Input.d.ts +4 -6
- package/types/OS.d.ts +12 -14
- package/types/OrthographicCamera.d.ts +1 -1
- package/types/PerspectiveCamera.d.ts +1 -1
- package/types/ReflectionPlaneContext.d.ts +5 -7
- package/types/RenderLayers.d.ts +1 -1
- package/types/RenderLoop.d.ts +1 -1
- package/types/ResourceContainer.d.ts +7 -9
- package/types/SceneManager.d.ts +9 -9
- package/types/Screen.d.ts +16 -18
- package/types/Time.d.ts +10 -12
- package/types/UI.d.ts +14 -16
- package/types/action_sequencer/ActionEvent.d.ts +1 -1
- package/types/action_sequencer/ActionInterpolator.d.ts +1 -1
- package/types/action_sequencer/ActionSequencer.d.ts +1 -1
- package/types/action_sequencer/NumberInterpolator.d.ts +2 -2
- package/types/action_sequencer/VectorInterpolator.d.ts +2 -2
- package/types/canvas_drawer/CanvasDrawer.d.ts +1 -1
- package/types/canvas_drawer/MultiLineTextDrawer.d.ts +2 -2
- package/types/canvas_drawer/SimpleTextDrawer.d.ts +2 -2
- package/types/components/AudioClip.d.ts +1 -1
- package/types/components/AxisHelper.d.ts +1 -1
- package/types/components/BaseObject.d.ts +1 -1
- package/types/components/EdgeMesh.d.ts +1 -1
- package/types/components/GeometryEdgeVisualizer.d.ts +1 -1
- package/types/components/Grid.d.ts +1 -1
- package/types/components/Line.d.ts +1 -1
- package/types/components/MultiLinePath.d.ts +1 -1
- package/types/components/MultiLineText2D.d.ts +2 -2
- package/types/components/ObjectAxis.d.ts +1 -1
- package/types/components/ObjectOrientedBoundingBox.d.ts +1 -1
- package/types/components/PlaneHelper.d.ts +1 -1
- package/types/components/Shape2D.d.ts +1 -1
- package/types/components/Shape3D.d.ts +1 -1
- package/types/components/Text2D.d.ts +3 -3
- package/types/components/UIElement.d.ts +6 -6
- package/types/components/UpdatableMaterialMesh.d.ts +1 -1
- package/types/components/WorldImage.d.ts +1 -1
- package/types/components/sdf_text/SDFText.d.ts +1 -1
- package/types/components/sdf_text/SDFTextBatch.d.ts +2 -2
- package/types/components/sdf_text/TextGlyph.d.ts +1 -1
- package/types/editor/ManipulatorHandle.d.ts +1 -1
- package/types/editor/ObjectEditor.d.ts +3 -3
- package/types/editor/ObjectManipulator.d.ts +2 -2
- package/types/editor/ObjectPicker.d.ts +1 -1
- package/types/gpu_particles/GPUParticleSystem.d.ts +1 -1
- package/types/gpu_particles/ParticleAttribute.d.ts +1 -1
- package/types/gpu_particles/ParticlePositionAttribute.d.ts +2 -2
- package/types/html_utilities/CSSAnimator.d.ts +2 -2
- package/types/html_utilities/css_animator_states/Animating.d.ts +1 -1
- package/types/html_utilities/css_animator_states/Idle.d.ts +1 -1
- package/types/index.d.ts +2 -2
- package/types/materials/AddMaterial.d.ts +2 -2
- package/types/materials/AlphaFilterMaterial.d.ts +2 -2
- package/types/materials/BaseShaderMaterial.d.ts +1 -1
- package/types/materials/BlitMaterial.d.ts +1 -1
- package/types/materials/BloomComposeMaterial.d.ts +2 -2
- package/types/materials/BoxBlurMaterial.d.ts +2 -2
- package/types/materials/ClearAlphaMaterial.d.ts +1 -1
- package/types/materials/ClearColorMaterial.d.ts +1 -1
- package/types/materials/ClearDepthNormalMaterial.d.ts +2 -2
- package/types/materials/DeferredRendererComposeMaterial.d.ts +2 -2
- package/types/materials/DepthNormalMaterial.d.ts +1 -1
- package/types/materials/DisplayNormalTextureMaterial.d.ts +2 -2
- package/types/materials/DualFilteringBlurMaterial.d.ts +2 -2
- package/types/materials/FXAAMaterial.d.ts +1 -1
- package/types/materials/GaussianBlurMaterial.d.ts +2 -2
- package/types/materials/LuminosityHighPassMaterial.d.ts +2 -2
- package/types/materials/MedianFilterMaterial.d.ts +2 -2
- package/types/materials/NormalMaterial.d.ts +1 -1
- package/types/materials/SDFScreenTextMaterial.d.ts +2 -2
- package/types/materials/SDFTextMaterial.d.ts +2 -2
- package/types/materials/SSAOComposeMaterial.d.ts +2 -2
- package/types/materials/SSAOMaterial.d.ts +2 -2
- package/types/materials/ScreenSpaceTextureMaterial.d.ts +2 -2
- package/types/materials/UIElementMaterial.d.ts +2 -2
- package/types/materials/UnrealBloomComposeMaterial.d.ts +3 -2
- package/types/materials/UnrealBlurMaterial.d.ts +2 -2
- package/types/materials/UnrealComposeMaterial.d.ts +2 -2
- package/types/materials/ViewPositionMaterial.d.ts +2 -1
- package/types/materials/deferred/DeferredPointLightMaterial.d.ts +2 -2
- package/types/materials/gpu_particles/ParticleStorageMaterial.d.ts +1 -1
- package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +2 -2
- package/types/object_pool/Pool.d.ts +1 -1
- package/types/primitives/Arrow.d.ts +1 -1
- package/types/primitives/Cube.d.ts +1 -1
- package/types/primitives/HorizontalPlane.d.ts +1 -1
- package/types/primitives/Sphere.d.ts +1 -1
- package/types/primitives/VerticalPlane.d.ts +1 -1
- package/types/raycast/GroupRaycaster.d.ts +2 -2
- package/types/raycast/PlaneDragResolver.d.ts +3 -3
- package/types/raycast/PlaneRaycastResolver.d.ts +1 -1
- package/types/raycast/PlaneRaycaster.d.ts +1 -1
- package/types/raycast/RaycastResolver.d.ts +1 -1
- package/types/raycast/SurfaceDragResolver.d.ts +3 -3
- package/types/raycast/states/BaseState.d.ts +1 -1
- package/types/raycast/states/IdleState.d.ts +4 -2
- package/types/raycast/states/OnRaycastEnter.d.ts +4 -2
- package/types/raycast/states/OnRaycastExit.d.ts +3 -2
- package/types/raycast/states/OnRaycastHover.d.ts +3 -2
- package/types/render_mode/BaseRender.d.ts +1 -1
- package/types/render_mode/BloomRender.d.ts +4 -4
- package/types/render_mode/DebugNormalsRender.d.ts +3 -2
- package/types/render_mode/DeferredRender.d.ts +3 -3
- package/types/render_mode/NormalAORender.d.ts +6 -6
- package/types/render_mode/NormalRender.d.ts +3 -2
- package/types/render_mode/OutlineRender.d.ts +1 -1
- package/types/render_mode/PlanarReflectionsRender.d.ts +2 -2
- package/types/render_mode/TransparencyMixRender.d.ts +1 -1
- package/types/render_mode/UnrealBloomRender.d.ts +5 -5
- package/types/render_utilities/Blitter.d.ts +3 -2
- package/types/render_utilities/Blurrer.d.ts +3 -2
- package/types/render_utilities/DepthAndNormalsRenderer.d.ts +5 -3
- package/types/render_utilities/DualFilteringBlurrer.d.ts +5 -3
- package/types/render_utilities/GaussianBlurrer.d.ts +3 -2
- package/types/render_utilities/MedianFilter.d.ts +3 -2
- package/types/render_utilities/ViewPositionRenderer.d.ts +3 -2
- package/types/resource_loader/AbstractLoader.d.ts +1 -1
- package/types/resource_loader/AudioLoader.d.ts +3 -2
- package/types/resource_loader/BasisLoader.d.ts +3 -2
- package/types/resource_loader/CubemapLoader.d.ts +3 -2
- package/types/resource_loader/DAELoader.d.ts +3 -2
- package/types/resource_loader/DDSLoader.d.ts +3 -2
- package/types/resource_loader/FileLoader.d.ts +3 -2
- package/types/resource_loader/FontLoader.d.ts +3 -2
- package/types/resource_loader/GLTFDRACOLoader.d.ts +3 -2
- package/types/resource_loader/GLTFLoader.d.ts +1 -1
- package/types/resource_loader/HDRCubeTextureLoader.d.ts +3 -2
- package/types/resource_loader/JSONLoader.d.ts +3 -2
- package/types/resource_loader/OBJLoader.d.ts +3 -2
- package/types/resource_loader/PointArrayLoader.d.ts +3 -2
- package/types/resource_loader/RGBETextureLoader.d.ts +3 -2
- package/types/resource_loader/ResourceBatch.d.ts +1 -1
- package/types/resource_loader/SVGLoader.d.ts +3 -2
- package/types/resource_loader/TextLoader.d.ts +3 -2
- package/types/resource_loader/TextureLoader.d.ts +3 -2
- package/types/static_batcher/GeometryBatch.d.ts +1 -1
- package/types/static_batcher/GeometryBatcher.d.ts +6 -8
- package/types/ui/ui_element_position/ScreenSpacePosition.d.ts +1 -1
- package/types/ui/ui_element_position/WorldSpacePosition.d.ts +1 -1
- package/types/ui/ui_element_state/OnIdle.d.ts +4 -2
- package/types/ui/ui_element_state/OnMouseEnter.d.ts +4 -2
- package/types/ui/ui_element_state/OnMouseExit.d.ts +4 -2
- package/types/ui/ui_element_state/OnMouseHover.d.ts +3 -2
- package/types/ui/ui_element_state/UIElementState.d.ts +1 -1
- package/types/utilities/ArrayUtilities.d.ts +1 -1
- package/types/utilities/CameraUtilities.d.ts +20 -22
- package/types/utilities/EasingFunctions.d.ts +34 -36
- package/types/utilities/FrustumPointFitter.d.ts +4 -2
- package/types/utilities/GeometryUtilities.d.ts +1 -1
- package/types/utilities/ImageUtilities.d.ts +1 -1
- package/types/utilities/MathUtilities.d.ts +1 -1
- package/types/utilities/MeshSampler.d.ts +7 -9
- package/types/utilities/ModelUtilities.d.ts +9 -11
- package/types/utilities/ObjectUtilities.d.ts +1 -1
- package/types/utilities/OrthographicFrustumPointFitter.d.ts +1 -1
- package/types/utilities/PerspectiveFrustumPointFitter.d.ts +1 -1
- package/types/utilities/StringUtilities.d.ts +1 -1
- package/types/utilities/TimeUtilities.d.ts +1 -1
- package/types/utilities/Validation.d.ts +1 -1
- package/types/view_components/ApplicationView.d.ts +1 -1
- package/types/view_components/ViewComponent.d.ts +1 -1
- package/types/view_components/ViewComponentManager.d.ts +9 -11
- package/types/view_components/ViewContext.d.ts +5 -5
- package/types/view_components/ViewManager.d.ts +23 -22
- package/types/view_components/ViewState.d.ts +1 -1
- package/types/view_components/transition/ActionSequencerBuilder.d.ts +3 -2
- package/types/view_components/transition/DrawIOAnimationSheet.d.ts +1 -1
- package/types/view_components/transition/TransitionTable.d.ts +1 -1
- package/types/view_components/transition/ViewStateTransitionHandler.d.ts +3 -2
- package/src/Primitives.js +0 -13
- package/types/Primitives.d.ts +0 -13
package/build/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Math as e,Clock as t,Vector2 as i,ShaderMaterial as r,Color as s,sRGBEncoding as n,NoBlending as a,AlwaysDepth as o,CanvasTexture as _,UVMapping as l,ClampToEdgeWrapping as h,NearestFilter as c,Object3D as u,Vector3 as d,LineBasicMaterial as p,BufferGeometry as m,Line as g,Scene as v,Mesh as f,BoxGeometry as x,MeshBasicMaterial as w,SphereBufferGeometry as b,CylinderBufferGeometry as y,ConeBufferGeometry as T,PerspectiveCamera as S,PlaneBufferGeometry as M,Vector4 as F,Box3 as z,Box3Helper as R,CatmullRomCurve3 as A,SphereGeometry as C,WebGLRenderTarget as D,OrthographicCamera as P,WebGLRenderer as L,DataTexture as I,RGBFormat as O,RGBAFormat as U,FloatType as N,BufferAttribute as k,Matrix4 as E,Plane as j,Ray as B,Sphere as V,FileLoader as G,RepeatWrapping as q,LinearFilter as Y,TextureLoader as W,CubeTextureLoader as H,Audio as Q,AudioLoader as X,FontLoader as J,UnsignedByteType as Z,Line3 as K,Quaternion as $,Skeleton as ee,DoubleSide as te,PlaneGeometry as ie,LinearMipMapLinearFilter as re,Box2 as se,InstancedBufferGeometry as ne,Float32BufferAttribute as ae,InstancedBufferAttribute as oe,DynamicDrawUsage as _e,Points as le}from"three";import{BufferGeometryUtils as he}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{InputController as ce}from"pit-js";import*as ue from"three/examples/jsm/loaders/GLTFLoader.js";import*as de from"three/examples/jsm/loaders/ColladaLoader.js";import*as pe from"three/examples/jsm/loaders/OBJLoader.js";import*as me from"three/examples/jsm/loaders/RGBELoader.js";import*as ge from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import*as ve from"three/examples/jsm/loaders/DRACOLoader.js";var fe=new class{init(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"}}get_os(){let e=window.navigator.userAgent,t=window.navigator.platform,i=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?i=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?i=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?i=this.operating_systems.WINDOWS:/Android/.test(e)?i=this.operating_systems.ANDROID:!i&&/Linux/.test(t)&&(i=this.operating_systems.LINUX),i}get is_android(){return this.get_os()===this.operating_systems.ANDROID}get is_ios(){return navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad}get is_safari(){let e=navigator.userAgent.toLowerCase();return-1!==e.indexOf("safari")&&!(e.indexOf("chrome")>-1)}get is_ipad(){return navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2}get is_mobile(){return!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/)}get is_linux(){return this.get_os()===this.operating_systems.LINUX}get is_mac(){return this.get_os()===this.operating_systems.MAC}get is_windows(){return this.get_os()===this.operating_systems.WINDOWS}};class xe{constructor(){}static is_int(e){return Number(e)===e&&e%1==0}static is_float(e){return Number(e)===e&&e%1!=0}static is_number(e){return this.is_int(e)||this.is_float(e)}static is_json(e){try{JSON.parse(e)}catch(e){return!1}return!0}}class we{constructor(e,t,i=1){this.resource_id=e,this.url=t,this.loaded_bytes=0,this.total_bytes=i,this.has_finished=!1,this.has_error=!1,this.error_message="none"}__update_downloaded_bytes(e,t){e=xe.is_number(e)?e:1,t=xe.is_number(t)?t:1,this.loaded_bytes=e,t>0&&(this.total_bytes=t),this.loaded_bytes>this.total_bytes&&console.warn("Total bytes is smaller than loaded ones. Please set total bytes by hand to:",this.url)}__loading_ended(){this.has_finished=!0}__set_error(e){this.has_error=!0,this.error_message=e}print_error(){console.error("Error while loading "+this.resource_id+"\n\t path: "+this.url+"\n\t\t"+this.error_message)}load(e){const t=fe.is_safari?"no-cache":"default";fetch(this.url,{method:"GET",mode:"cors",cache:t,credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}async on_progress(e,t){const i=t.body.getReader();let r=+t.headers.get("Content-Length"),s=0;for(;;){const{done:e,value:t}=await i.read();if(e)break;s+=t.length,this.__update_downloaded_bytes(s,r)}this.on_preloaded_finished(e)}on_preloaded_finished(e){}__on_error(e){console.error(e)}}class be{constructor(e){this.elapsed_time=-1e-5,this.playing=!1,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};let t=Object.keys(e);for(let e=0;e<t.length;e++)this.channels[t[e]]=[];this.duration=0}play(){this.playing=!0}stop(){this.playing=!1}reset(){this.elapsed_time=-1e-5}skip(){this.elapsed_time=this.get_duration(),this.__play_clips(this.elapsed_time,this.elapsed_time+.01)}update(e){this.playing&&(this.__play_clips(this.elapsed_time,this.elapsed_time+e),this.elapsed_time=this.elapsed_time+e)}set_progress(t){this.elapsed_time=e.clamp(t,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)}set_normalized_progress(t){this.elapsed_time=e.clamp(t,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return e.clamp(this.elapsed_time/this.get_duration(),0,1)}is_finished(){return this.elapsed_time>this.get_duration()}add_action_event(e,t){this.action_events.push({trigger_time:e,action:t}),this.duration=Math.max(this.duration,e)}add_action_interpolator(e,t,i,r=!1){if(r){let e=this.channels[i.attribute_name];void 0===e&&console.error(`${i.attribute_name} missing in initial state data.`),0===e.length?i.from=this.initial_context[i.attribute_name]:i.from=e[e.length-1].interpolator.to}let s={from:e,to:t,interpolator:i};this.duration=Math.max(this.duration,t),this.channels[i.attribute_name].push(s)}get_property_target_value(e){let t=this.__get_nearest_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1)}get_duration(){return this.duration}__play_clips(e,t){for(let i=0;i<this.action_events.length;i++)this.action_events[i].trigger_time>=e&&this.action_events[i].trigger_time<t&&this.action_events[i].action.trigger();let i=Object.keys(this.initial_context);for(let t=0;t<i.length;t++){let r=i[t],s=this.__get_nearest_keyframe(r,e);this.context[r]=this.evaluate_keyframe(s,e)}}evaluate_keyframe(t,i){return this.tmp_t=this.__linear_map_01(i,t.from,t.to),t.interpolator.evaluate(e.clamp(this.tmp_t,0,1))}__linear_map_01(e,t,i){return(e-t)/(i-t)*1+0}__get_nearest_keyframe(e,t){let i,r=9999999,s=this.channels[e];for(let e=0;e<s.length;e++){let n=s[e],a=Math.min(Math.abs(n.from-t),Math.abs(n.to-t));a<r&&(r=a,i=n)}return i}}var ye=new class{constructor(){}linear(e){return e}triangular(e){return 1-Math.abs(2*e%2-1)}ease_in_sine(e){return 1-Math.cos(3.1415926*e/2)}ease_out_sine(e){return Math.sin(3.1415926*e/2)}ease_in_out_sine(e){return-(Math.cos(3.1415926*e)-1)/2}ease_in_cubic(e){return e*e*e}ease_out_cubic(e){return 1-Math.pow(1-e,3)}ease_in_out_cubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}ease_in_quad(e){return e*e}ease_out_quad(e){return 1-(1-e)*(1-e)}ease_in_out_quad(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}ease_in_quart(e){return e*e*e*e}ease_out_quart(e){return 1-Math.pow(1-e,4)}ease_in_out_quart(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2}ease_in_quint(e){return e*e*e*e*e}ease_out_quint(e){return 1-Math.pow(1-e,5)}ease_in_out_quint(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2}ease_in_expo(e){return 0===e?0:Math.pow(2,10*e-10)}ease_out_expo(e){return 1===e?1:1-Math.pow(2,-10*e)}ease_in_out_expo(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}ease_in_circ(e){return 1-Math.sqrt(1-Math.pow(e,2))}ease_out_circ(e){return Math.sqrt(1-Math.pow(e-1,2))}ease_in_out_circ(e){return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2}ease_in_back(e){return 2.7015*e*e*e-1.7015*e*e}ease_out_back(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)}ease_in_out_back(e){return e<.5?Math.pow(2*e,2)*(7.189819*e-2.5949095)/2:(Math.pow(2*e-2,2)*(3.5949095*(2*e-2)+2.5949095)+2)/2}ease_in_elastic(e){const t=2*Math.PI/3;return 0===e?0:1===e?1:-Math.pow(2,10*e-10)*Math.sin((10*e-10.75)*t)}ease_out_elastic(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1}ease_in_out_elastic(e){return 0===e?0:1===e?1:e<.5?-Math.pow(2,20*e-10)*Math.sin(1.3962633*(20*e-11.125))/2:Math.pow(2,-20*e+10)*Math.sin(1.3962633*(20*e-11.125))/2+1}ease_in_bounce(e){return 1-this.ease_out_bounce(1-e)}ease_out_bounce(e){const t=7.5625,i=2.75;return e<1/i?t*e*e:e<2/i?t*(e-=1.5/i)*e+.75:e<2.5/i?t*(e-=2.25/i)*e+.9375:t*(e-=2.625/i)*e+.984375}ease_in_out_bounce(e){return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2}heartbeat(e){return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8}};class Te{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?ye[e]:e}update(e,t){}}class Se extends Te{constructor(e,t=0,i=1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=i}update(t,i){t[this.attribute_name]=e.lerp(this.from,this.to,this.easing_function(i))}evaluate(t){return e.lerp(this.from,this.to,this.easing_function(t))}}var Me=new class{constructor(){this.app=void 0}set_app(e){this.app=e}};class Fe{constructor(e,t){this.name=e,this.method=t}trigger(){Me.app[this.name][this.method]()}}class ze{constructor(){}parse(e){let t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),i=[],r=[];for(let e=0;e<t.length;e++){let s=t[e],n=s.parentElement,a=n.getAttribute("value"),o=this.get_node_x_position(s)/100,_=parseFloat(s.getAttribute("width"))/100;if(n.getAttribute("style").includes("rhombus;")){let e=a.split("."),t=e[0],i=e[1];r.push({name:t,method:i,at_time:o+.5*_})}if(n.getAttribute("style").includes("rounded=0;")&&!n.getAttribute("style").includes("text;")&&""!==a&&!a.includes(" ")){let e=a.split("="),t=e[0],r=e[1].split("--"),s=parseFloat(r[0]),n=r[1];2!==e.length&&console.error("DrawIO data is malformed:",a),2!==r.length&&console.error("DrawIO data is malformed:",a),i.push({attribute_name:t,from_time:o,to_time:o+_,to_value:s,easing_function:n})}}return i.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:i,triggers:r}}get_node_x_position(e){let t=e.getAttribute("x");return null===t?0:parseFloat(t)}}class Re{constructor(e){this.initial_state_data=e}from_animation_sheet(e,t,i){i=i||this.initial_state_data;let r=e.animation_tracks,s=e.triggers,n=this.state_to_tracks(this.initial_state_data);for(let e=0;e<n.length;e++)void 0===r.find((t=>t.attribute_name===n[e].attribute_name))&&r.push(n[e]);let a=new be(t);for(let e=0;e<r.length;e++){let i=r[e],s=new Se(i.attribute_name,t[i.attribute_name],i.to_value,i.easing_function);a.add_action_interpolator(i.from_time,i.to_time,s,!0)}for(let e=0;e<s.length;e++){let t=s[e],i=new Fe(t.name,t.method);a.add_action_event(t.at_time,i)}return a}state_to_tracks(e){let t=[],i=Object.keys(e);for(let r=0;r<i.length;r++)t.push({attribute_name:i[r],from_time:0,to_time:1,to_value:e[i[r]],easing_function:"ease_in_out_cubic"});return t}from_draw_io(e,t){let i=(new ze).parse(e),r=i.animation_tracks,s=i.triggers,n=new be(t);for(let e=0;e<r.length;e++){let i=r[e],s=new Se(i.attribute_name,t[i.attribute_name],i.to_value,i.easing_function);n.add_action_interpolator(i.from_time,i.to_time,s,!0)}for(let e=0;e<s.length;e++){let t=s[e],i=new Fe(t.name,t.method);n.add_action_event(t.at_time,i)}return n}}var Ae=new class{init(){this.queue={},this.zoom_changed_evt="zoom_changed",this.store_clickd_evt="store_clicked",this.point_selected_evt="point_selected",this.config_changed="config_changed",this.path_substep_completed="path_substep_completed",this.path_completed="path_completed",this.go_to_store_requested_evt="go_to_store_requested",this.resource_loaded_evt="resource_loaded",this.service_clicked_evt="service_clicked",this.unit_pos_updated_evt="unit_position_updated",this.floor_changed_evt="floor_changed",this.on_enter_floor_navigation="on_enter_floor_navigation",this.on_exit_floor_navigation="on_exit_floor_navigation",this.on_enter_floor_selection="on_enter_floor_selection",this.on_exit_floor_selection="on_exit_floor_selection",this.on_enter_outside_navigation="on_enter_outside_navigation",this.on_exit_outside_navigation="on_exit_outside_navigation",this.step_selected_evt="step_selected"}fire(e,t){let i=this.queue[e];if(void 0===i)return;let r=i.length;for(;r--;)i[r](t)}on(e,t){void 0===this.queue[e]&&(this.queue[e]=[]),this.queue[e].push(t)}fire_zoom_changed(e){this.fire(this.zoom_changed_evt,e)}fire_store_selected(e){this.fire(this.store_clickd_evt,e)}fire_point_selected(e){this.fire(this.point_selected_evt,e)}fire_config_changed(){this.fire(this.config_changed)}fire_path_substep_completed(e){this.fire(this.path_substep_completed,e)}fire_path_completed(){this.fire(this.path_completed)}fire_step_selected(e){this.fire(this.step_selected_evt,e)}fire_go_to_store_requested(e){this.fire(this.go_to_store_requested_evt,e)}fire_resource_loaded(e){this.fire(this.resource_loaded_evt,e)}fire_service_clicked(e){this.fire(this.service_clicked_evt,e)}fire_unit_position_updated(e){this.fire(this.unit_pos_updated_evt,e)}fire_floor_switched(e){this.fire(this.floor_changed_evt,e)}fire_on_enter_floor_navigation(e){this.fire(this.on_enter_floor_navigation,e)}fire_on_exit_floor_navigation(e){this.fire(this.on_exit_floor_navigation,e)}fire_on_enter_floor_selection(e){this.fire(this.on_enter_floor_selection,e)}fire_on_exit_floor_selection(e){this.fire(this.on_exit_floor_selection,e)}fire_on_enter_outside_navigation(e){this.fire(this.on_enter_outside_navigation,e)}fire_on_exit_outside_navigation(e){this.fire(this.on_exit_outside_navigation,e)}};var Ce=new class{init(){this.resources={},this.resources_by_url={}}set_resource(e,t,i){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=i,this.resources_by_url[t]=i),Ae.fire_resource_loaded({name:e,value:i})}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}};class De{constructor(){this.transitions=[],this.initial_state_data={}}get(e,t){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].to===e){return new Re(this.initial_state_data).from_animation_sheet(this.transitions[i].data,t)}console.error("TransitionTable.get no data found for: ",e)}add_transitions(e){for(let t=0;t<e.length;t++)this.transitions.push(e[t])}set_transitions(e){this.transitions=e}set_initial_state_data(e){this.initial_state_data=e}}var Pe=new class{init(){this.___time=new t,this.__delta_time=0,this.__elapsed_time=0,this.__allocated_time=new i(0,0)}get delta_time(){return this.__delta_time<.4?this.__delta_time:.016}get elapsed_time(){return this.__elapsed_time}get shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_time}__update(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime()}};class Le{constructor(e){this.name=e}start(){}show(){}hide(){}before_enter(){}on_enter(){}update(){}update_enter_transition(e,t,i){this.update_transition(e,t,i)}update_exit_transition(e,t,i){}update_transition(e,t,i){}before_exit(){}on_exit(){}}class Ie{constructor(e){this.last_state=new Le,this.current_state=new Le,this.initial_state_data={},this.current_state_data={},this.transition_table=e,this.transitioning=!1}go_to_state(e,t=!1){this.last_state=this.current_state,this.current_state=e,this.last_state.before_exit(),this.current_state.show(),this.current_state.before_enter(),this.action_sequencer=this.transition_table.get(this.current_state.name,this.current_state_data),this.action_sequencer.play(),this.transitioning=!0,t&&(this.action_sequencer.skip(),this.update())}update(){this.transitioning?(this.action_sequencer.update(Pe.delta_time),this.last_state.update_exit_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.current_state.update_enter_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.action_sequencer.is_finished()&&(this.transitioning=!1,this.action_sequencer.update(Pe.delta_time),this.last_state.update_exit_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.current_state.update_enter_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.last_state.name!==this.current_state.name&&this.last_state.hide(),this.last_state.on_exit(),this.current_state.on_enter())):this.current_state.update()}set_state(e){this.current_state=e}set_initial_state_data(e){Object.assign(this.initial_state_data,e),Object.assign(this.current_state_data,e)}}var Oe=new class{constructor(){this.views=[],this.transition_table=new De,this.transition_handler=new Ie(this.transition_table)}update(){this.transition_handler.update()}go_to_view(e,t=!0,i=!1){let r=this.get(e);this.transition_handler.go_to_state(r,i),t&&this.__change_browser_url(r.url)}register_view(e){this.views.push(e)}has_view(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1}add_transitions(e){this.transition_table.add_transitions(e)}set_transitions(e){this.transition_table.set_transitions(e)}set_view(e){let t=this.get(e);this.transition_handler.set_state(t)}get_current_view(){return this.transition_handler.current_state}get_view_by_name(e){console.warn("DEPRECATED. Use ViewManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return this.views[t];console.error("[ViewManager.get] no view found for: ",e)}get_view_by_url(e){console.warn("DEPRECATED. Use ViewManager.get_by_url instead"),this.get_by_url(e)}get_by_url(e){for(let t=0;t<this.views.length;t++)if(this.views[t].url===e)return this.views[t];console.error("[ViewManager.get_by_url] no view found for: ",e)}set_initial_state_data(e){this.transition_table.set_initial_state_data(e),this.transition_handler.set_initial_state_data(e)}__change_browser_url(e){window.history.pushState("","",e)}};class Ue extends Le{constructor({name:e,url:t,container:i}){super(e),this.container=i,this.url=t;let r=[{to:e,data:(new ze).parse(Ce.get(`${e}_data`))}];Oe.register_view(this),Oe.add_transitions(r)}show(){this.container.classList.add("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}on_enter(){this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}before_exit(){this.container.classList.add("before_exit"),this.container.classList.remove("before_enter"),this.container.classList.remove("hidden")}hide(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")}set_opacity(e){this.container.style.opacity=e}}class Ne{on_post_start(){}on_enter(){}on_exit(){}update(){}on_post_render(){}on_pre_render(){}}class ke{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}var Ee="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",je="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class Be extends r{constructor(e,t,i){super({vertexShader:e||Ee,fragmentShader:t||je,uniforms:i||{_Color:{value:new s("#FF0000")}}})}}class Ve extends we{constructor(e,t,i,r,s){super(e,t,s),this.loader=r,this.loader.setWorkerLimit(1),this.loader.setTranscoderPath("libs/basis/"),this.loader.detectSupport(i)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{i.encoding=n,e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ge extends r{constructor(e,t,r){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new i(0,0)},_TargetResolution:{value:new i(0,0)}},defines:r||{},vertexShader:t||"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}",fragmentShader:e||"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);}",depthWrite:!1,blending:a,depthTest:!1,depthFunc:o})}}var qe=new class{init(){this._current=void 0}set current(e){this._current=e}get current(){return this._current}};var Ye=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class We{constructor(e){this.uses_dynamic_font=e,this.__textHeight=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}getFontHeight(e="Arial"){if(null==this.__textHeight||this.uses_dynamic_font){let t=document.getElementsByTagName("body")[0],i=document.createElement("div"),r=document.createTextNode("MÉqgOLAKTAL");i.appendChild(r),i.setAttribute("style",`font:${e};position:absolute;top:0;left:0`),t.appendChild(i),this.__textHeight=i.offsetHeight,t.removeChild(i)}return this.__textHeight}get_text_size(e,t="24px Arial"){let r=new i;return this.ctx.font=t,r.x=Math.ceil(this.ctx.measureText(e).width),r.y=Math.ceil(this.getFontHeight(t)),r}draw_canvas(e,t={}){return t.font=t.font||"24px Arial",t.font_color=t.font_color||"#000000",this.__draw(e,t,this.canvas,this.ctx),this.canvas}draw_on_texture(e,t){let i=this.draw_canvas(e,t),r=new _(i,l,h,h,c,c);return r.generateMipMaps=!1,r.needsUpdate=!0,r}__draw(e,t){}roundRect(e,t,i,r,s,n,a,o){if(void 0===o&&(o=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{let e={tl:0,tr:0,br:0,bl:0};for(let t in e)n[t]=n[t]||e[t]}e.beginPath(),e.moveTo(t+n.tl,i),e.lineTo(t+r-n.tr,i),e.quadraticCurveTo(t+r,i,t+r,i+n.tr),e.lineTo(t+r,i+s-n.br),e.quadraticCurveTo(t+r,i+s,t+r-n.br,i+s),e.lineTo(t+n.bl,i+s),e.quadraticCurveTo(t,i+s,t,i+s-n.bl),e.lineTo(t,i+n.tl),e.quadraticCurveTo(t,i,t+n.tl,i),e.closePath(),a&&e.fill(),o&&e.stroke()}}var He=new class{init(e={}){this.dpr=1,this.app={}}from_json(e){}};class Qe{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Xe{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(t){this.t+=Pe.delta_time/t.duration,this.easing_function_t=t.easing_function(this.t),this.easing_function_t=e.clamp(this.easing_function_t,0,1),t.set_property_value(e.lerp(t.from,t.to,this.easing_function_t)),this.easing_function_t>=.9999&&(t.set_property_value(t.to),t.set_current_state(new Qe),t.finished_callback(t))}on_exit(e){}}class Je{constructor({element:e,css_property:t,from:i=0,to:r=1,duration:s=1,value_prefix:n="",value_suffix:a="",easing_function:o=ye.ease_in_out_cubic,finished_callback:_=(()=>{})}){this.element=e,this.css_property=t,this.from=i,this.to=r,this.value_prefix=n,this.value_suffix=a,this.duration=s,this.easing_function=o,this.finished_callback=_,this.current_state=new Qe}animate(){this.set_current_state(new Xe)}stop(){this.set_current_state(new Qe)}set_property_value(e){this.element.style[this.css_property]=`${this.value_prefix}${e}${this.value_suffix}`}update(){this.current_state.update(this)}get is_animating(){return this.current_state.is_animating}set_current_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}}class Ze extends u{constructor(e=1){super();const t=[];t.push(new d(0,0,0)),t.push(new d(0,0,1e3));const i=new p({color:4474111,depthFunc:o}),r=(new m).setFromPoints(t),s=new g(r,i);s.renderOrder=5e4;const n=[];n.push(new d(0,0,0)),n.push(new d(0,1e3,0));const a=new p({color:4521796,depthFunc:o}),_=(new m).setFromPoints(n),l=new g(_,a);l.renderOrder=5e4;const h=[];h.push(new d(0,0,0)),h.push(new d(1e3,0,0));const c=new p({color:16729156,depthFunc:o}),u=(new m).setFromPoints(h),v=new g(u,c);v.renderOrder=5e4,this.renderOrder=1e5,this.add(s),this.add(l),this.add(v),this.scale.set(e,e,e)}update(){}dispose(){}}var Ke=new class{init(){this._current=new v,this._current.name="default_scene"}add_scene(e){}get current(){return this._current}set current(e){this._current=e}dispose(){for(this.current.traverse((e=>{e.geometry&&(e.geometry.dispose(),e.material.dispose())}));this.current.children.length>0;)this.current.remove(this.current.children[0])}};class $e extends f{constructor(e,t,i){e=e||new d(1,1,1),t=t||new d(1,1,1),i=i||16711680,super(new x(e.x,e.y,e.z,t.x,t.y,t.z),new w({color:i}))}}class et extends f{constructor(e,t){t=t||"#FF0000",super(new b(e=e||1,64,64),new w({color:t}))}}class tt extends f{constructor(e,t,i){e=e||"#FF0000";let r=(t=t||1)-.4,s=new y(.01,.01,r,32);s.translate(0,r/2,0);let n=new T(.1,.4,32);n.translate(0,r+.2,0);let a=he.mergeBufferGeometries([s,n]);a.rotateX(1.57),super(a,new w({color:e})),i&&this.quaternion.setFromUnitVectors(new d(0,0,1),i),this._dir=i}set dir(e){this.quaternion.setFromUnitVectors(new d(0,0,1),e),this._dir=e}get dir(){return this._dir}set length(e){this.scale.z=e}get length(){return this.scale.z}}var it=new class{init(){this.width=1,this.height=1,this.position=new i,this.render_width=1,this.render_height=1,this.width_height=new i(this.width,this.height),this.dpr=1,this.pixel_size=new i(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update_size(e,t){this.width=e,this.height=t,this.pixel_size=new i(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=t,this.render_width=e*this.dpr,this.render_height=t*this.dpr}apply_pixel_density_v2(e){return e.multiplyScalar(1/this.dpr),e}apply_pixel_density(e){return e*(1/this.dpr)}get_pixel_size(){return this.pixel_size}get aspect_ratio(){return this.width/this.height}};class rt extends Be{constructor(e,t,r,s){super("\n uniform vec2 _ScreenSpacePosition;\n uniform vec2 _ScreenSize;\n uniform vec2 _TextureSize;\n varying vec2 vUv;\n void main()\n {\n vec2 pos = uv * vec2(_TextureSize.x / _ScreenSize.x, _TextureSize.y / _ScreenSize.y);\n pos += vec2(_ScreenSpacePosition.x / _ScreenSize.x, _ScreenSpacePosition.y / _ScreenSize.y);\n\n pos.x = pos.x * 2.0 - 1.0;\n pos.y = pos.y * 2.0 - 1.0;\n\n gl_Position = vec4(pos, 0.0, 1.0);\n vUv = uv;\n }\n ","\n uniform sampler2D _MainTex;\n varying vec2 vUv;\n\n void main()\n {\n gl_FragColor = texture2D(_MainTex, vUv);\n }\n ",{_MainTex:{value:void 0},_ScreenSpacePosition:{value:new i},_ScreenSize:{value:new i},_TextureSize:{value:new i}})}set_position(e,t){this.uniforms._ScreenSpacePosition.value.set(e,t)}set_texture(e,t,i){this.uniforms._MainTex.value=e,this.uniforms._TextureSize.value.set(e.image.width,e.image.height),void 0!==t&&(this.uniforms._TextureSize.value.x=t),void 0!==i&&(this.uniforms._TextureSize.value.y=i)}set_screen_size(e,t){this.uniforms._ScreenSize.value.set(e,t)}}class st extends S{constructor(e,t,i,r){super(e,t,i,r),this.clear_color=new s("#000000"),this.clear_alpha=1}}var nt=new class{init(){this.Vector3_one=new d(1,1,1),this.Vector3_zero=new d(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new v,this.camera=new st}draw_arrow(e,t,i=16711680){let r=new tt(i,t.length(),t.clone().normalize());return r.position.copy(e),Ke.current.add(r),r}draw_axis(){let e=new Ze;return Ke.current.add(e),e}set_debug_RT(e){this.rt_debug=e}draw_rectangle(e,t,i,r){t=t||100,i=i||100,this.ctx.fillStyle=r||"rgba(255, 0, 0, 1)",this.ctx.fillRect(e.x-t/2,this.ctx.canvas.height-e.y-i/2,t,i)}clear(){this.ctx&&this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}draw_line_2D(e,t,i){this.ctx.strokeStyle=i||"rgba(255, 0, 0, 1)",this.ctx.beginPath(),this.ctx.moveTo(e.x,e.y),this.ctx.lineTo(t.x,t.y),this.ctx.closePath(),this.ctx.stroke()}draw_line(e,t=16711680){let i=new p({color:t}),r=(new m).setFromPoints(e),s=new g(r,i);return s.frustumCulled=!1,Ke.current.add(s),s}draw_cube(e,t,i){t=t||1,i=i||16711680,e=e||new d;let r=new $e(new d(t,t,t),void 0,i);return r.position.copy(e),Ke.current.add(r),r}draw_oriented_cube(e,t,i=1,r="#FF0000",s=.1){let n=e.distanceTo(t),a=new $e(new d(s,i,n),void 0,r),o=t.clone().sub(e).multiplyScalar(.5),_=o.clone().normalize();return o.add(e),a.position.copy(o),a.quaternion.setFromUnitVectors(new d(0,0,-1),_),Ke.current.add(a),a}draw_plane(e,t,i){let s=new M(e,t),n=new r({uniforms:{_Color:{value:new F(0,1,0,.2)}},vertexShader:Ee,fragmentShader:je,transparent:!0,depthWrite:!1}),a=new f(s,n);return a.renderOrder=-1e4,Ke.current.add(a),a}draw_empty_cube(e,t,i){t=t||1,i=i||16711680;let r=(new z).setFromCenterAndSize(new d,new d(t,t,t)),s=new R(r,i);return s.position.copy(e||new d),s}draw_sphere(e,t,i){t=t||1,i=i||16711680,e=e||new d;let r=new et(t,i);return r.position.copy(e),Ke.current.add(r),r}draw_point_array(e,t=!1,i=16711680){let r=new A(e,t);r.updateArcLengths();let s=r.getSpacedPoints(200);return this.draw_line(s,65280)}draw_sphere_helper(e,t){t=t||16711680;let i=new C(e.radius,32,32),r=new w({color:t}),s=new f(i,r);return s.position.copy(e.center),Ke.current.add(s),s}draw_math_sphere(e){let t=new C(e.radius,32,32),i=new r({uniforms:{_Color:{value:new F(1,0,0,.2)}},vertexShader:Ee,fragmentShader:je,transparent:!0}),s=new f(t,i);s.position.copy(e.center),Ke.current.add(s)}draw_bounding_box(e){let t=new R(e,16776960);Ke.current.add(t)}draw_curve(e,t){let i=new d(0,0,0);t&&(i.y=t.offset||0);for(let t=0;t<e.length-1;t++)this.draw_line(e[t].clone().add(i),e[t+1].clone().add(i))}draw_texture(e,t,i){let r=new f(new M(1,1),new rt);return this.display_texture_meshes.push(r),this.scene.add(r),r.material.set_texture(e,t,i),r}render(e){for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(it.width,it.height);this.scene.children.length>0&&e.render(this.scene,this.camera)}};class at extends Ge{constructor(e,t){super("#define GLSLIFY 1\nuniform vec4 _DepthNormal;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(_DepthNormal.x),EncodeNormal(normalize(_DepthNormal.yzw)));}"),this.uniforms._DepthNormal={value:new F(e,t.x,t.y,t.z)}}}class ot extends r{constructor(){super({uniforms:{_FarPlane:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;v_normal=(modelViewMatrix*vec4(normal,0.0)).xyz;v_pos=(modelViewMatrix*vec4(pos,1.0)).xyz;gl_Position=MVP*vec4(pos,1.0);}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;uniform float _FarPlane;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(length(v_pos.z)/_FarPlane),EncodeNormal(normalize(v_normal)));}"})}set far_plane(e){this.uniforms._FarPlane.value=e}get far_plane(){return this.uniforms._FarPlane.value}}class _t{constructor(){this.RT=new D(it.width,it.height),this.clear_depth_normal_mat=new at(1,new d(0,0,1)),this.depth_normal_material=new ot}render(e){this.__resize_RT_if_necessary(),e.clear(this.RT,void 0,!0,!0),e.blit_clear_with_material(this.RT,this.clear_depth_normal_mat),this.depth_normal_material.far_plane=qe.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===it.width&&this.RT.height===it.height||this.RT.setSize(it.width,it.height)}get render_target(){return this.RT}}class lt{constructor(e){this.renderer=e,this._blit_scene=new v,this._blit_material=new Ge,this._blit_quad=new f(new M(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new P(-1,1,1,-1,-1e4,1e4)}blit(e,t){this._blit_quad.material=this._blit_material;let i=!0===e.isWebGLRenderTarget?e.texture:e,r=!0===e.isWebGLRenderTarget?e.width:e.image.width,s=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=i,this._blit_quad.material.uniforms._Resolution.value.set(r,s),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}material_pass(e,t){this._blit_quad.material=e,this.__render(t)}blit_with_material(e,t,i){let r=!0===e.isWebGLRenderTarget?e.texture:e,s=!0===e.isWebGLRenderTarget?e.width:e.image.width,n=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material=i,this._blit_quad.material.uniforms._MainTex.value=r,this._blit_quad.material.uniforms._Resolution.value.set(s,n),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}blit_clear_with_material(e,t){this._blit_quad.material=t,this.__render(e)}dispose(){this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose()}__render(e){e=void 0===e?null:e;let t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(void 0===e?null:e),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(t)}}var ht=new class{init(e,t){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.context_attributes=t||{alpha:!0,depth:!0,desynchronized:!1,stencil:!1,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1},t.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,console.log("Using WebGL "+(this.is_webgl2?2:1)),this._renderer=new L({canvas:e,context:this.canvas_context}),this._renderer.autoClear=!1,this._renderer.setPixelRatio(1),it.dpr=He.dpr,this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new lt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new ke,this.current_render_mode=this.no_render,Ye.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),Ye.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,Ye.fp_textures_available=this._renderer.capabilities.floatVertexTextures,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new _t}get dom_element(){return this._renderer.domElement}get depth_normals_RT(){return this.depth_and_normals_renderer.render_target}set_state(e){this.current_render_mode.on_exit(this,this._renderer),this.current_render_mode=e,this.current_render_mode.on_enter(this,this._renderer)}update(){this.check_for_resize(),this.generateDepthNormalTexture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),qe.current&&this.current_render_mode.render()}__update_current_camera(){qe.current&&(qe.current.aspect=it.aspect_ratio,qe.current.updateProjectionMatrix(),qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0))}render(e,t,i,r){this.__apply_override_material(e,r),this._renderer.setRenderTarget(void 0===i?null:i),this._renderer.render(e||Ke.current,t||qe.current),this.__apply_override_material(e,void 0)}render_scene(e){e.on_before_render&&e.on_before_render(),e.render&&e.render(),e.on_post_render&&e.on_post_render()}__apply_override_material(e,t){t=void 0===t?null:t,e?e.overrideMaterial=t:Ke.current.overrideMaterial=t}readback_RT(e,t){this._renderer.readRenderTargetPixels(e,0,0,e.width,e.height,t)}clear(e,t,i,r){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!i,!!r)}check_for_resize(){let e=this.canvas.clientWidth,t=this.canvas.clientHeight;if(e!==it.width||t!==it.height||He.dpr!==it.dpr){let i=this.canvas.getBoundingClientRect();it.dpr=He.dpr,it.update_position(i.x,i.y),it.update_size(e,t),this.canvas.width=it.render_width,this.canvas.height=it.render_height,this._renderer.setViewport(0,0,it.render_width,it.render_height),this.__update_current_camera()}}on_resize(){console.error("Graphics.on_resize call no longer needed.")}material_pass(e,t){this.blitter.material_pass(e,t)}blit(e,t,i){i?this.blitter.blit_with_material(e,t,i):this.blitter.blit(e,t)}blit_clear_with_material(e,t){this.blitter.blit_clear_with_material(e,t)}take_screenshot(e,t=it.width,i=it.height){let r=it.width,s=it.height,n=t,a=i,o=1024,_=1024,l=parseInt(Math.ceil(n/o)),h=parseInt(Math.ceil(a/_));it.update_size(o,_),this._renderer.setPixelRatio(1),this._renderer.setSize(o,_,!1);let c=document.createElement("canvas").getContext("2d");c.canvas.width=n,c.canvas.height=a,qe.current.aspect=it.aspect_ratio,qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)qe.current.setViewOffset(n,a,it.width*e,it.height*t,it.width,it.height),this.current_render_mode.render(),c.drawImage(this._renderer.domElement,it.width*e,it.height*t);c.canvas.toBlob(e,"image/png;base64;"),qe.current.clearViewOffset(),it.update_size(r,s),this._renderer.setPixelRatio(He.dpr),this._renderer.setSize(r,s,!1),qe.current.aspect=it.aspect_ratio,qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0)}download_screenshot(e){let t=document.createElement("a");t.download="Snapshot.png",t.href=URL.createObjectURL(e),t.click(),t.onclick=function(){requestAnimationFrame((function(){URL.revokeObjectURL(t.href)})),t.removeAttribute("href")}}dispose(){this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose()}};class ct extends r{constructor(){super({uniforms:{},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);v_normal=(modelMatrix*vec4(normal,0.0)).xyz;}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_FragColor=vec4(v_normal*0.5+vec3(0.5),1.0);}"})}}class ut extends ke{constructor(){super()}render(){ht.clear(void 0,qe.current,!0,!0),ht.render(Ke.current,qe.current,void 0,new ct)}}var dt=new class extends ce{constructor(){super(),this.left_mouse_button_clicked=!1,this.captured_NDC={x:0,y:0}}clear(){super.clear(),this.left_mouse_button_clicked=!1}};var pt=new class{init(){this.target_geometry=void 0,this.target_position=new d}set_target_geometry(e){this.target_geometry=e}};class mt{constructor(e,t){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=t,this.data_textures=[],this.object_names=void 0,this.zero_offset=new i,this.write_offset=new i,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(e,t,i){this.material=new r({uniforms:this.uniforms,vertexShader:t,fragmentShader:i}),this.object_names=e}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){let i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(this.batch_width),s=this.__create_rgb_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){let i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(this.batch_width),s=this.__create_rgba_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){let i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(this.batch_width),s=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,i,r,s,n){let a=this.__get_object_index(e),o=this.__get_data_texture(t);this.__set_pixel_rgb(o.src,a,i,r,s,n),this.__set_pixel_rgb(o.one_pixel,0,i,r,s,n),o.last_accessed_index=a,o.dirty_count++}set_object_uniform_v4(e,t,i,r,s,n,a){let o=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,o,i,r,s,n,a),this.__set_pixel_rgba(_.one_pixel,0,i,r,s,n,a),_.last_accessed_index=o,_.dirty_count++}upload_texture_data(e,t){for(let i=0;i<this.data_textures.length;i++)t>0&&this.data_textures[i].dirty_count>0&&(1===this.data_textures[i].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[i]),this.data_textures[i].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[i]),this.data_textures[i].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){let i=t.last_accessed_index;-1!==i&&(this.write_offset.y=Math.floor(i/this.batch_width),this.write_offset.x=i-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new f(this.geometry,this.material)}__set_pixel_rgb(e,t,i,r,s,n){r&&(e.image.data[3*t+0]=i.x),s&&(e.image.data[3*t+1]=i.y),n&&(e.image.data[3*t+2]=i.z)}__set_pixel_rgba(e,t,i,r,s,n,a){r&&(e.image.data[4*t+0]=i.x),s&&(e.image.data[4*t+1]=i.y),n&&(e.image.data[4*t+2]=i.z),a&&(e.image.data[4*t+3]=i.w)}__flood_data_texture_rgb(e,t){for(let i=0;i<this.batch_width*this.batch_width;i++)this.__set_pixel_rgb(e.src,i,t,!0,!0,!0),e.dirty_count++}__flood_data_texture_rgba(e,t){for(let i=0;i<this.batch_width*this.batch_width;i++)this.__set_pixel_rgba(e.src,i,t,!0,!0,!0,!0),e.dirty_count++}__create_rgb_texture(e){let t=new Uint8Array(3*e*e);return new I(t,e,e,O)}__create_rgba_texture(e){let t=new Uint8Array(4*e*e);return new I(t,e,e,U)}__create_rgba_float_texture(e){let t=new Float32Array(4*e*e);return new I(t,e,e,U,N)}__get_data_texture(e){for(let t=0;t<this.data_textures.length;t++)if(this.data_textures[t].name===e)return this.data_textures[t];console.error("Data texture "+e+" does not exist")}__get_object_index(e){for(let t=0;t<this.object_names.length;t++)if(this.object_names[t]===e)return t;console.error("the name "+e+" is not contained in this batch")}__add_data_texture(e,t,i,r){return i.needsUpdate=!0,this.data_textures.push({name:e,src:t,dst:i,one_pixel:r,last_accessed_index:-1,dirty_count:0}),this.uniforms[e]={value:i},this.data_textures[this.data_textures.length-1]}dispose(){for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].src.dispose(),this.data_textures[e].dst.dispose(),this.data_textures[e].one_pixel.dispose()}}var gt=new class{init(){this.batches=[]}batch(t){let i=[],r=e.ceilPowerOfTwo(Math.sqrt(t.length));this.__init_uv_array(i,r);let s=0;for(let e=0;e<t.length;e++){let n=t[e].getAttribute("position").count,a=Math.floor(e/r),o=e-r*a;for(let e=0;e<n;e++)i[s]=o/r+.5/r,i[s+1]=a/r+.5/r,s+=2}let n=new k(new Float32Array(i),2),a=he.mergeBufferGeometries(t);return a.setAttribute("attr_accessor_uv",n),this.batches.push(new mt(a,r)),this.batches[this.batches.length-1]}upload_texture_data(e){for(let t=0;t<this.batches.length;t++)this.batches[t].upload_texture_data(e,1)}__init_uv_array(e,t){for(let i=0;i<t*t*2;i++)e.push(0)}};var vt=new class{init(){this.ui_elements=[],this._tmp_normalized_pos=new i,this.ss_scene=new v,this.ss_scene.autoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new v,this.ws_scene.autoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new P(-1,1,1,-1,-100,100)}delete_element(e){let t=this.ui_elements.indexOf(e);t>-1&&this.ui_elements.splice(t,1),this.ss_scene.remove(e),this.ws_scene.remove(e),e.dispose()}add_screen_space_element(e){this.ui_elements.push(e),this.ss_scene.add(e),e.set_screen_space_coordinate_system()}add_world_space_element(e){this.ui_elements.push(e),this.ws_scene.add(e),e.set_world_space_coordinate_system()}update(){this.ss_camera.updateProjectionMatrix(),this._tmp_normalized_pos.copy(dt.NDC);for(let e=0;e<this.ui_elements.length;e++)this.ui_elements[e].update_state(this._tmp_normalized_pos)}render(e){this.ss_scene.children.length>0&&ht.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&ht.render(this.ws_scene,qe.current)}clear(){this.current_clicked_element=void 0}};class ft{constructor(){}static linear_map(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}static between(e,t,i){return e>=t&&e<=i}static mod(e,t){return(e%t+t)%t}static rgb_to_hex(e){return e.r=Math.round(255*e.r).toString(16),e.g=Math.round(255*e.g).toString(16),e.b=Math.round(255*e.b).toString(16),1===e.r.length&&(e.r="0"+e.r),1===e.g.length&&(e.g="0"+e.g),1===e.b.length&&(e.b="0"+e.b),"#"+e.r+e.g+e.b}static project_points_on_plane(e,t){let i=new d,r=[];for(let s=0;s<e.length;s++)t.projectPoint(e[s],i),r.push(i.clone());return r}static matrix4_lerp(t,i,r,s){for(let n=0;n<16;n++)r.elements[n]=e.lerp(t.elements[n],i.elements[n],s)}static equals(e,t){return Math.abs(e-t)<1e-6}static perspective_divide(e){return e.x/=e.w,e.y/=e.w,e.z/=e.w,e}static points_average(e){let t=e[0].clone();for(let i=1;i<e.length;i++)t.add(e[i]);return t.multiplyScalar(1/e.length),t}static get_random_color(){let e=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"],t="#";return t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t}}var xt=new class{init(){this.tmp_mat=new E,this.tmp_vec=new d(0,0,1),this.tmp_vec2=new d(0,0,0),this.plane=new j,this.ray=new B,this.tmp_size=new d,this.tmp_unproj=new d}get_up_dir(e){return e=e||qe.current,this.tmp_vec.set(0,1,0),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}get_forward_dir(e){return e=e||qe.current,this.tmp_vec.set(0,0,-1),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}get_right_dir(e){return e=e||qe.current,this.tmp_vec.set(1,0,0),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}unproject_mouse_position(e,t){let i=(t=t||qe.current).fov/2*Math.PI/180,r=2*Math.atan(Math.tan(i)*t.aspect)/2,s=Math.tan(i)*t.far,n=Math.tan(r)*t.far;return this.tmp_vec.set(n*e.x,s*e.y,-t.far).normalize(),this.tmp_vec.applyQuaternion(t.quaternion)}get_plane_intersection(e,t,i,r){return r=r||qe.current,i=i||dt.NDC,this.plane.setFromNormalAndCoplanarPoint(t||this.get_forward_dir(r),e),r.isPerspectiveCamera?this.ray.set(r.position,this.unproject_mouse_position(i,r)):(this.tmp_unproj.set(i.x,i.y,1).unproject(r),this.ray.set(r.position,this.tmp_unproj)),this.ray.intersectPlane(this.plane,this.tmp_vec2),this.tmp_vec2}fit_points_on_camera(e,t=1){let i=(new V).setFromPoints(e).center,r=this.get_forward_dir(qe.current).clone(),s=(new j).setFromNormalAndCoplanarPoint(r,i),n=ft.project_points_on_plane(e,s),a=new d,o=(new z).setFromPoints(n);o.getCenter(a);let _=new d(0,1,0).applyQuaternion(qe.current.quaternion),l=_.clone().cross(r).normalize(),h=(new E).set(l.x,_.x,r.x,i.x,l.y,_.y,r.y,i.y,l.z,_.z,r.z,i.z,0,0,0,1),c=(new E).getInverse(h);for(let e=0;e<n.length;e++)n[e].applyMatrix4(c);let u=new d;o=(new z).setFromPoints(n),o.getSize(u),u.multiplyScalar(t);let p=new d;return o.getCenter(p),{position:a,zoom:this.get_zoom_to_fit_rect(u.x/2,u.y/2)}}get_zoom_to_fit_rect(e,t){let i=qe.current.fov/2*Math.PI/180,r=2*Math.atan(Math.tan(i)*qe.current.aspect)/2,s=t/Math.tan(i),n=e/Math.tan(r);return Math.max(Math.abs(n),Math.abs(s))}get_zoom_to_fit_box(e,t){if(t.isOrthographicCamera){e.getSize(this.tmp_size);let t=this.tmp_size.x,i=this.tmp_size.y,r=t/i;return it.aspect_ratio/r>1?it.height/i:it.width/t}{let t=new d;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){return e.getWorldPosition(this.tmp_vec),this.tmp_vec.project(t),this.tmp_vec.x=(.5*this.tmp_vec.x+.5)*it.width,this.tmp_vec.y=(1-(.5*this.tmp_vec.y+.5))*it.height,this.tmp_vec}world_pos_to_screen(e,t){return t=t||qe.current,this.tmp_vec.copy(e),this.tmp_vec.project(t),this.tmp_vec.x=(.5*this.tmp_vec.x+.5)*it.width,this.tmp_vec.y=(1-(.5*this.tmp_vec.y+.5))*it.height,this.tmp_vec}update_projection(e){e.left=-it.width/2,e.right=it.width/2,e.top=it.height/2,e.bottom=-it.height/2,e.aspect=it.aspect_ratio,e.updateProjectionMatrix(!0)}};var wt=new class{constructor(){}init(e,t,i){qe.init(),xt.init(),Ye.init(),He.init(),Ae.init(),gt.init(),dt.init(t),fe.init(),pt.init(),Ce.init(),Ke.init(),it.init(),Pe.init(),vt.init(),ht.init(e,i),nt.init()}dispose(e){ht.dispose(),dt.dispose(),Ke.dispose(),e.dispose()}};class bt extends we{constructor(e,t,i){super(e,t,i),this.loader=new G}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,JSON.parse(i)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}var yt="#define GLSLIFY 1\nvarying vec2 vUv;varying vec4 vRay;uniform mat4 _InverseProjMatrix;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vRay=_InverseProjMatrix*vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}";class Tt extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}",yt),this.uniforms._InverseProjMatrix={value:new E},this.uniforms._ProjectionMatrix={value:new E},this.uniforms._Bias={value:.0125},this.uniforms._Radius={value:.3},this.uniforms._FarPlane={value:100},this.uniforms._SampleKernel={value:this.__get_sample_kernel()},this.uniforms._RandomRotation={value:this.__get_rotation_kernel()}}__get_sample_kernel(){let t=[];for(let i=0;i<64;i++){let r=new d(2*Math.random()-1,2*Math.random()-1,Math.random());r.normalize();let s=i/64;s=e.lerp(.1,1,s*s),r.multiplyScalar(s),t.push(r)}return t}__get_rotation_kernel(){let e=new Uint8Array(48);for(let t=0;t<16;t++)e[3*t+1]=Math.floor(255*Math.random()),e[3*t+2]=Math.floor(255*Math.random()),e[3*t+3]=0;let t=new I(e,4,4,O);return t.wrapS=q,t.wrapT=q,t.needsUpdate=!0,t}}class St extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _AO;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){gl_FragColor.rgb=texture2D(_MainTex,vUv).rgb*(1.0-texture2D(_AO,vUv).r);gl_FragColor.a=1.0;}"),this.uniforms._AO={value:void 0}}}class Mt extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}",yt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new E}}}class Ft extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){vec4 sum=vec4(0.,0.,0.,0.);vec2 dir=(0.5/_Resolution)*_SampleDir;float _Distance=2.0;sum+=texture2D(_MainTex,vUv+dir*-4.*_Distance)*0.0525;sum+=texture2D(_MainTex,vUv+dir*-3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*-2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*-1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*0.*_Distance)*0.225;sum+=texture2D(_MainTex,vUv+dir*1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*4.*_Distance)*0.0525;gl_FragColor=vec4(sum);}"),this.uniforms._SampleDir={value:new i}}}class zt{constructor(e){this.RT1=new D(1,1),this.RT2=new D(1,1),this.box_blur_mat=new Ft}blur(e){e.width===this.RT1.width&&e.height===this.RT1.height||(this.RT1.setSize(e.width,e.height),this.RT2.setSize(e.width,e.height)),this.box_blur_mat.uniforms._SampleDir.value.set(1,0),ht.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),ht.blit(this.RT1,e,this.box_blur_mat)}}class Rt extends ke{constructor(){super(),this.ssao_mat=new Tt,this.ssao_compose_mat=new St,this.debug_normals=new Mt,this.ssaa=He.use_ssaa?2:1,this.main_RT=new D(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT=new D(it.width,it.height),this.blurrer=new zt,ht.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),ht.clear(this.main_RT,qe.current,!0,!1),ht.render(Ke.current,qe.current,this.main_RT),this.__update_uniforms(),ht.blit(ht.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),ht.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,ht.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(qe.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(qe.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=qe.current.far}__check_RT_size(){this.main_RT.width===it.width*this.ssaa&&this.main_RT.height===it.height*this.ssaa||(this.main_RT.setSize(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT.setSize(it.width,it.height))}}class At extends ke{constructor(){super()}render(){ht.clear(void 0,qe.current,!0,!0),Ke.current.on_pre_render&&Ke.current.on_pre_render(),Ke.current.render?Ke.current.render():ht.render(Ke.current,qe.current),Ke.current.on_post_render&&Ke.current.on_post_render()}}class Ct extends Ge{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};let t=[new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF")];this.uniforms.bloomTintColors={value:t}}set_RT_0(e){this.uniforms.blurTexture1.value=e}set_RT_1(e){this.uniforms.blurTexture2.value=e}set_RT_2(e){this.uniforms.blurTexture3.value=e}set_RT_3(e){this.uniforms.blurTexture4.value=e}set_RT_4(e){this.uniforms.blurTexture5.value=e}set_bloom_strength(e){this.uniforms.bloomStrength.value=e}set_bloom_radius(e){this.uniforms.bloomRadius.value=e}set_tint_color_0(e){this.uniforms.bloomTintColors.value[0].set(e)}set_tint_color_1(e){this.uniforms.bloomTintColors.value[1].set(e)}set_tint_color_2(e){this.uniforms.bloomTintColors.value[2].set(e)}set_tint_color_3(e){this.uniforms.bloomTintColors.value[3].set(e)}set_tint_color_4(e){this.uniforms.bloomTintColors.value[4].set(e)}}class Dt extends Ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}class Pt extends Ge{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new i(.5,.5)},this.uniforms.direction={value:new i(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class Lt extends Ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new s("#000000")},this.uniforms.defaultOpacity={value:0}}}class It{constructor(e=5){this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=e,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:Y,magFilter:Y,format:U},this.renderTargetBright=new D(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Lt}blur(e,t){this.resize_RT(e.width,e.height),t?ht.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):ht.blit(e,this.renderTargetBright);let i=this.renderTargetBright;for(let e=0;e<this.nMips;e++){let t=this.separableBlurMaterials[e];t.set_direction(1,0),ht.blit(i,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),ht.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),i=this.renderTargetsVertical[e]}}get_blurred_texture(){return this.renderTargetsHorizontal[0].texture}get_blurred_RT(){return this.renderTargetsHorizontal[0]}init_RT(){this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(let e=0;e<this.nMips;e++){let e=new D(1,1,this.rt_pars),t=new D(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e),this.renderTargetsVertical.push(t)}}resize_RT(e,t){if(this.current_width===e&&this.current_height===t)return;this.current_width=e,this.current_height=t;let i=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(i,r);for(let e=0;e<this.nMips;e++)this.renderTargetsVertical[e].setSize(i,r),this.renderTargetsHorizontal[e].setSize(i,r),this.separableBlurMaterials[e].set_size(i,r),i=Math.round(i/2),r=Math.round(r/2)}init_materials(e,t){this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new Pt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class Ot extends ke{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new Dt}on_enter(){this.blurrer=new It,this.main_RT=new D(it.render_width,it.render_height),this.blur_RT=new D(it.render_width,it.render_height),this.bloom_compose_mat=new Ct(5),this.blurrer=new It(5),this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture),this.bloom_compose_mat.set_bloom_strength(1),this.bloom_compose_mat.set_bloom_radius(1),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.bloom_compose_mat.set_bloom_radius(e)}set_tint_color_0(e){this.bloom_compose_mat.set_tint_color_0(e)}set_tint_color_1(e){this.bloom_compose_mat.set_tint_color_1(e)}set_tint_color_2(e){this.bloom_compose_mat.set_tint_color_2(e)}set_tint_color_3(e){this.bloom_compose_mat.set_tint_color_3(e)}set_tint_color_4(e){this.bloom_compose_mat.set_tint_color_4(e)}render(){this.__check_RT_size(),ht.clear(this.main_RT,qe.current,!0,!1),ht.render(Ke.current,qe.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),ht.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),ht.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===it.render_width&&this.main_RT.height===it.render_height||(this.main_RT.setSize(it.render_width,it.render_height),this.blur_RT.setSize(it.render_width,it.render_height))}}class Ut extends P{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.clear_color=new s("#000000"),this.clear_alpha=1}}var Nt={Arrow:tt,Cube:$e,HorizontalPlane:class extends f{constructor(e,t,i,r){e=e||1,t=t||1,i=i||"#FF0000",r=r||new w({color:i});let s=new M(e,t);s.rotateX(-1.57),super(s,r)}},Sphere:et,VerticalPlane:class extends f{constructor(e,t,i,r){e=e||1,t=t||1,i=i||"#FF0000",r=r||new w({color:i}),super(new M(e,t),r)}}};var kt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){for(let e of this.enabled_components)e.update(Oe.transition_handler.current_state_data)}register_component(e){this.components.push(e)}enable_component(e){this.enabled_components.add(e)}disable_component(e){this.enabled_components.delete(e)}get_component_by_name(e){console.warn("DEPRECATED. Use ViewComponentManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.components.length;t++)if(this.components[t].name===e)return this.components[t];console.error("[ViewComponentManager.get] no component found for: ",e)}};class Et{constructor(e,t){e=e||new Ne,this._frame_id=-1,this.target_application=e,this.graphics=t,this.is_running=!1,this.frames_passed=0}update(){this.is_running&&(Pe.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.target_application.update(),Oe.update(),kt.update(),this.target_application.on_pre_render(),this.graphics.update(),vt.update(),vt.render(this.graphics),this.target_application.on_post_render(),nt.render(this.graphics),dt.clear(),vt.clear(),nt.clear(),this._frame_id=requestAnimationFrame(this.update.bind(this)),this.frames_passed++)}start(){this.is_running||(this.graphics.check_for_resize(),0===this.frames_passed&&this.target_application.on_enter(),this.is_running=!0,this.update())}stop(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(),cancelAnimationFrame(this._frame_id))}set_state(e){this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this)}dispose(){this.stop(),this.frames_passed=0}}class jt extends we{constructor(e,t,i){super(e,t,i),this.loader=new W}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(()=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯"),t.__loading_ended()}))}}class Bt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ue.GLTFLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Vt extends we{constructor(e,t,i){super(e,t,i),this.loader=new de.ColladaLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Gt extends we{constructor(e,t,i){super(e,t,i),this.loader=new G}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class qt extends we{constructor(e,t,i){super(e,t,i),this.loader=new H,this.loader.setPath(t+"/"),this.urls=["px.png","nx.png","py.png","ny.png","pz.png","nz.png"]}on_preloaded_finished(e){let t=this;this.loader.load(this.urls,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class Yt{constructor(e,t=!0,i=1){this.buffer=e,this.loop=t,this.volume=i,this.audio=void 0}init(e){this.audio=new Q(e),this.audio.setBuffer(this.buffer),this.audio.setLoop(this.loop),this.audio.setVolume(this.volume)}play(){this.audio.play()}pause(){this.audio.pause()}stop(){this.audio.stop()}get is_playing(){return this.audio.isPlaying}}class Wt extends we{constructor(e,t,i=!0,r=1,s){super(e,t,s),this.loader=new X,this.loop=i,this.volume=r}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,new Yt(i,this.loop,this.volume)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Audio could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class Ht extends we{constructor(e,t,i){super(e,t,i),this.loader=new pe.OBJLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Qt extends we{constructor(e,t,i){super(e,t,i),this.loader=new J}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Xt extends we{constructor(e,t,i){super(e,t,i),this.loader=new me.RGBELoader,this.loader.setDataType(Z)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Jt extends we{constructor(e,t,i){super(e,t,i),this.loader=new G}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,t.parse_path(i)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}parse_path(e){let t=e.split("\n");""===t[t.length-1]&&t.pop();let i=[];for(let e=0;e<t.length;e+=3){let r=parseFloat(t[e+0]),s=parseFloat(t[e+1]),n=parseFloat(t[e+2]);i.push(new d(r,s,n))}return i}}class Zt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ge.HDRCubeTextureLoader,this.url_suffix=["/px.hdr","/nx.hdr","/py.hdr","/ny.hdr","/pz.hdr","/nz.hdr"]}on_preloaded_finished(e){let t=this;this.loader.setPath(this.url).setDataType(Z).load(this.url_suffix,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Kt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ue.GLTFLoader,this.draco_loader=new ve.DRACOLoader,this.draco_loader.setDecoderPath(window.draco_decoder_path),this.draco_loader.setDecoderConfig({type:"js"}),this.loader.setDRACOLoader(this.draco_loader)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class $t extends we{constructor(e,t,i){super(e,t,i),this.loader=new G}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class ei{constructor(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}add_texture(e,t,i){this.resource_loaders.push(new jt(e,t,i))}add_gltf(e,t,i){this.resource_loaders.push(new Bt(e,t,i))}add_basis(e,t,i,r,s){this.resource_loaders.push(new Ve(e,t,i,r,s))}add_gltf_draco(e,t,i){this.resource_loaders.push(new Kt(e,t,i))}add_dae(e,t,i){this.resource_loaders.push(new Vt(e,t,i))}add_obj(e,t,i){this.resource_loaders.push(new Ht(e,t,i))}add_file(e,t,i){this.resource_loaders.push(new $t(e,t,i))}add_text(e,t,i){this.resource_loaders.push(new Gt(e,t,i))}add_cubemap(e,t,i){this.resource_loaders.push(new qt(e,t,i))}add_audio(e,t,i,r,s){this.resource_loaders.push(new Wt(e,t,i,r,s))}add_json(e,t,i){this.resource_loaders.push(new bt(e,t,i))}add_point_array(e,t,i){this.resource_loaders.push(new Jt(e,t,i))}add_hdr(e,t,i){this.resource_loaders.push(new Xt(e,t,i))}add_hdr_cubemap(e,t,i){this.resource_loaders.push(new Zt(e,t,i))}add_font(e,t,i){this.resource_loaders.push(new Qt(e,t,i))}add_loader(e){this.resource_loaders.push(e)}load(e){for(let t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||Ce)}get loading_finished(){let e=!0;for(let t=0;t<this.resource_loaders.length;t++)e=e&&this.resource_loaders[t].has_finished;return e}get has_errors(){let e=!1;for(let t=0;t<this.resource_loaders.length;t++)e=e||this.resource_loaders[t].has_error;return e}print_errors(){console.error("Batch <"+this.batch_name+"> could not load successfully");for(let e=0;e<this.resource_loaders.length;e++)this.resource_loaders[e].has_error&&this.resource_loaders[e].print_error()}get_progress(){return this.get_loaded_bytes()/this.get_total_bytes()}get_loaded_bytes(){let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].loaded_bytes;return e}get_total_bytes(){let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].total_bytes;return e}}class ti extends We{constructor(){super(),this.text_margin=new i(2,0)}__draw(e,t,i,r){r.font=t.font;let s=this.get_text_size(e,t.font);i.width=Math.ceil(s.x+2*this.text_margin.x),i.height=Math.ceil(s.y+2*this.text_margin.y),r.clearRect(0,0,i.width,i.height),r.globalAlpha=0,r.fillStyle=t.font_color||"#000000",r.fillRect(0,0,i.width,i.height),r.globalAlpha=1,r.globalAlpha=1,r.font=t.font,r.fillStyle=t.font_color||"#000000",r.textBaseline="middle",r.textAlign=t.textAlign||"center","center"===r.textAlign?r.fillText(e,i.width/2,i.height/2):r.fillText(e,0,i.height/2)}}class ii{constructor({name:e,container:t}){this.name=e,this.container=t,kt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),kt.enable_component(this)}update(){}on_exit(){this.container.classList.add("hidden"),kt.disable_component(this)}set_opacity(e){this.container.style.opacity=e}}class ri{constructor(){}static merge_from_to(e,t){t.push.apply(t,e)}static expand_vec3_array(e,t){let i=t-e.length;for(let t=0;t<i;t++)e.push(e[t].clone())}static remove_elem(e,t){let i=e.indexOf(t);i>-1&&e.splice(i,1)}static get_closest_point(e,t){let i=e[0],r=i.distanceTo(t);for(let s=1;s<e.length;s++)e[s].distanceTo(t)<r&&(i=e[s],r=e[s].distanceTo(t));return i}static object_values_to_array(e){let t=Object.keys(e),i=[];for(let r=0;r<t.length;r++)i.push(e[t[r]]);return i}}class si{constructor(){this.sphere=new V}fit_points(e,t,i,r){this.sphere.setFromPoints(e);let s=Math.degToRad(i/2),n=2*Math.atan(Math.tan(s)*r)/2,a=this.get_up_plane_normal(t,s),o=this.get_down_plane_normal(t,s),_=this.get_left_plane_normal(t,n),l=this.get_right_plane_normal(t,n),h=new d(0,0,-1).applyQuaternion(t),c=this.sphere.center.clone(),u=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=c.clone().add(h.clone().multiplyScalar(-1*u)),m=(new j).setFromNormalAndCoplanarPoint(a,p),g=(new j).setFromNormalAndCoplanarPoint(o,p),v=(new j).setFromNormalAndCoplanarPoint(_,p),f=(new j).setFromNormalAndCoplanarPoint(l,p);this.apply_center_correction_to_pos(p,e,t,m,g,v,f),m.setFromNormalAndCoplanarPoint(a,p),g.setFromNormalAndCoplanarPoint(o,p),v.setFromNormalAndCoplanarPoint(_,p),f.setFromNormalAndCoplanarPoint(l,p);let x=1/0,w=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){let i=new K(e[t].clone(),e[t].clone().add(w)),r=new d,s=new d,n=new d,a=new d;m.intersectLine(i,r),g.intersectLine(i,s),v.intersectLine(i,n),f.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",t),s.length()<1e-4&&console.log("down intersection not found",t),n.length()<1e-4&&console.log("left intersection not found",t),a.length()<1e-4&&console.log("right intersection not found",t);let o=e[t].clone().sub(r).length(),_=e[t].clone().sub(s).length(),l=e[t].clone().sub(n).length(),h=e[t].clone().sub(a).length(),c=Math.min(o,_),u=Math.min(l,h),p=Math.min(c,u);p<x&&(x=p)}let b=h.clone().multiplyScalar(x);return p.clone().add(b)}apply_center_correction_to_pos(e,t,i,r,s,n,a){let o=this.get_vertical_correction(t,s,r,i),_=this.get_hozirontal_correction(t,n,a,i);e.add(o),e.add(_)}get_vertical_correction(e,t,i,r){let s,n,a=1/0,o=1/0,_=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let l=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(-5e6))),h=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(l,c),i.intersectLine(h,u);let p=c.distanceTo(e[r]),m=u.distanceTo(e[r]);u.length()<1e-4&&console.log("vertical up intersection not found",r),c.length()<1e-4&&console.log("vertical down intersection not found",r),p<o&&(o=p,n=e[r]),m<a&&(a=m,s=e[r])}console.log(s,n);let l=(a-o)/2;return _.clone().multiplyScalar(-l)}get_hozirontal_correction(e,t,i,r){let s,n,a=1/0,o=1/0,_=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let l=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(-5e6))),h=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(l,c),i.intersectLine(h,u);let p=c.distanceTo(e[r]),m=u.distanceTo(e[r]);c.length()<1e-4&&console.log("left intersection not found",r),u.length()<1e-4&&console.log("right intersection not found",r),p<o&&(o=p,n=e[r]),m<a&&(a=m,s=e[r])}let l=(a-o)/2;return console.log(s,n),_.clone().multiplyScalar(-l)}get_up_plane_normal(e,t){let i=new d(0,-1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),t)),i.applyQuaternion(e),i}get_down_plane_normal(e,t){let i=new d(0,1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),-t)),i.applyQuaternion(e),i}get_left_plane_normal(e,t){let i=new d(1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),t)),i.applyQuaternion(e),i}get_right_plane_normal(e,t){let i=new d(-1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),-t)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class ni{static convert_to_non_indexed_geometry(e){let t=e.index,i=e.getAttribute("position"),r=[];for(let e=0;e<t.count;e+=3)r.push(i.getX(t.array[e+0])),r.push(i.getY(t.array[e+0])),r.push(i.getZ(t.array[e+0])),r.push(i.getX(t.array[e+1])),r.push(i.getY(t.array[e+1])),r.push(i.getZ(t.array[e+1])),r.push(i.getX(t.array[e+2])),r.push(i.getY(t.array[e+2])),r.push(i.getZ(t.array[e+2]));let s=new m;return s.setAttribute("position",new k(new Float32Array(r),3)),ni.add_barycentric_attribute(s),s}static add_barycentric_attribute(e){let t=[],i=e.getAttribute("position");for(let e=0;e<i.count;e+=3)t.push(1),t.push(0),t.push(0),t.push(0),t.push(1),t.push(0),t.push(0),t.push(0),t.push(1);e.setAttribute("barycentric",new k(new Float32Array(t),3))}}class ai{constructor(){}static get_image_data(e){let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");return i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height)}static get_pixel(e,t,i){let r=4*(t+e.width*i),s=e.data;return new F(s[r+0],s[r+1],s[r+2],s[r+3])}}var oi=new class{constructor(){}sample(e,t){let i=[],r=99999999;for(let t=0;t<e.faces.length;t++){let s=this.get_face_area(e.faces[t],e.vertices);r=Math.min(s,r),i.push(s)}let s=this.get_uniform_face_distribution(i,r,e.faces),n=this.select_random_faces(s,t);return this.sample_data_from_faces(n,e.vertices)}sample_data_from_faces(e,t){let i=[],r=[];for(let s=0;s<e.length;s++){let n=e[s],a=Math.random(),o=Math.random();i.push(this.sample_point_in_face(a,o,t[n.a],t[n.b],t[n.c]).clone()),r&&n.normal&&r.push(n.normal.clone())}return{points:i,normals:r}}select_random_faces(e,t){let i=[];for(let r=0;r<t;r++){let t=e[parseInt(Math.random()*(e.length-1))];i.push(t)}return i}get_uniform_face_distribution(e,t,i){let r=[];for(let s=0;s<e.length;s++){e[s]/=t;let n=parseInt(Math.round(e[s]));for(let e=0;e<n;e++)r.push(i[s])}return r}get_face_area(e,t){let i=t[e.a].clone(),r=t[e.b].clone(),s=t[e.c].clone(),n=r.clone().sub(i),a=s.clone().sub(i);return n.cross(a).length()/2}sample_point_in_face(e,t,i,r,s){e+t>1&&(e=1-e,t=1-t);let n=1-(e+t);return i.clone().multiplyScalar(e).add(r.clone().multiplyScalar(t)).add(s.clone().multiplyScalar(n))}};var _i=new class{get_mesh(e,t){e.traverse((e=>{e instanceof f&&(e.geometry&&(e.geometry=(new m).fromGeometry(e.geometry)),t(e))}))}get_geometries(e){let t=[];return this.get_mesh(e,(e=>{t.push(e.geometry)})),t}assign_material(e,t,i){e.traverse((e=>{e instanceof f&&(void 0===i||e.name===i)&&(e.material=t)}))}clone_animated_gltf(e){const t={animations:e.animations,scene:e.scene.clone(!0)},i={};e.scene.traverse((e=>{e.isSkinnedMesh&&(i[e.name]=e)}));const r={},s={};t.scene.traverse((e=>{e.isBone&&(r[e.name]=e),e.isSkinnedMesh&&(s[e.name]=e)}));for(let e in i){const t=i[e].skeleton,n=s[e],a=[];for(let e=0;e<t.bones.length;++e){const i=r[t.bones[e].name];a.push(i)}n.bind(new ee(a,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,i){e.traverse((e=>{e instanceof f&&(e.castShadow=t,e.receiveShadow=i)}))}__find_object(e,t,i){e.traverse((e=>{e.name===t&&i(e)}))}get_object(e,t){let i;return e.traverse((e=>{e.name===t&&(i=e)})),i}get_object_by_type(e,t){let i;return e.traverse((e=>{e.constructor.name===t&&(i=e)})),i}};class li{constructor(){}static xml_to_json(e){let t={};if(1===e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(let i=0;i<e.attributes.length;i++){let r=e.attributes.item(i);t["@attributes"][r.nodeName]=r.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let i=0;i<e.childNodes.length;i++){let r=e.childNodes.item(i),s=r.nodeName;if(void 0===t[s])t[s]=this.xml_to_json(r);else{if(void 0===t[s].push){let e=t[s];t[s]=[],t[s].push(e)}t[s].push(this.xml_to_json(r))}}return t}}class hi{constructor(){}static capitalize(e){const t=e.split(" ");for(let e=0;e<t.length;e++)t[e]=t[e][0].toUpperCase()+t[e].substr(1);return t.join(" ")}static capitalize_first_letter(e){return e.charAt(0).toUpperCase()+e.slice(1)}static snake_to_camelcase(e){return e.replace(/([-_][a-z])/g,(e=>e.toUpperCase().replace("-","").replace("_","")))}}class ci{constructor(){}time_str_to_ms(e){e=e.split(":");let t=Number(e[0]);t=60*t*60*1e3;let i=Number(e[1]);i=60*i*1e3;let r=Number(e[2]);return r*=1e3,t+i+r}}class ui{constructor(){this.sphere=new V}fit_points(t,i,r,s){this.sphere.setFromPoints(t);let n=e.degToRad(r/2),a=2*Math.atan(Math.tan(n)*s)/2,o=this.get_up_plane_normal(i,n),_=this.get_down_plane_normal(i,n),l=this.get_left_plane_normal(i,a),h=this.get_right_plane_normal(i,a),c=new d(0,0,-1).applyQuaternion(i),u=this.sphere.center.clone(),p=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,r,s),m=u.clone().add(c.clone().multiplyScalar(-1*p)),g=(new j).setFromNormalAndCoplanarPoint(o,m),v=(new j).setFromNormalAndCoplanarPoint(_,m),f=(new j).setFromNormalAndCoplanarPoint(l,m),x=(new j).setFromNormalAndCoplanarPoint(h,m);this.apply_center_correction_to_pos(m,t,i,g,v,f,x),g.setFromNormalAndCoplanarPoint(o,m),v.setFromNormalAndCoplanarPoint(_,m),f.setFromNormalAndCoplanarPoint(l,m),x.setFromNormalAndCoplanarPoint(h,m);let w=1/0,b=c.clone().multiplyScalar(-2*p);for(let e=0;e<t.length;e++){let i=new K(t[e].clone(),t[e].clone().add(b)),r=new d,s=new d,n=new d,a=new d;g.intersectLine(i,r),v.intersectLine(i,s),f.intersectLine(i,n),x.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",e),s.length()<1e-4&&console.log("down intersection not found",e),n.length()<1e-4&&console.log("left intersection not found",e),a.length()<1e-4&&console.log("right intersection not found",e);let o=t[e].clone().sub(r).length(),_=t[e].clone().sub(s).length(),l=t[e].clone().sub(n).length(),h=t[e].clone().sub(a).length(),c=Math.min(o,_),u=Math.min(l,h),p=Math.min(c,u);p<w&&(w=p)}let y=c.clone().multiplyScalar(w);return m.clone().add(y)}apply_center_correction_to_pos(e,t,i,r,s,n,a){let o=this.get_vertical_correction(t,s,r,i),_=this.get_horizontal_correction(t,n,a,i);e.add(o),e.add(_)}get_vertical_correction(e,t,i,r){let s=1/0,n=1/0,a=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let o=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),_=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),l=new d,h=new d;t.intersectLine(o,l),i.intersectLine(_,h);let c=l.distanceTo(e[r]),u=h.distanceTo(e[r]);h.length()<1e-4&&console.log("vertical up intersection not found",r),l.length()<1e-4&&console.log("vertical down intersection not found",r),c<n&&(n=c),u<s&&(s=u)}let o=(s-n)/2;return a.clone().multiplyScalar(-o)}get_horizontal_correction(e,t,i,r){let s=1/0,n=1/0,a=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let o=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),_=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),l=new d,h=new d;t.intersectLine(o,l),i.intersectLine(_,h);let c=l.distanceTo(e[r]),u=h.distanceTo(e[r]);l.length()<1e-4&&console.log("left intersection not found",r),h.length()<1e-4&&console.log("right intersection not found",r),c<n&&(n=c),u<s&&(s=u)}let o=(s-n)/2;return a.clone().multiplyScalar(-o)}get_up_plane_normal(e,t){let i=new d(0,-1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),t)),i.applyQuaternion(e),i}get_down_plane_normal(e,t){let i=new d(0,1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),-t)),i.applyQuaternion(e),i}get_left_plane_normal(e,t){let i=new d(1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),t)),i.applyQuaternion(e),i}get_right_plane_normal(e,t){let i=new d(-1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),-t)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class di{constructor(){}fit_points(e,t,i,r){let s=t.clone().inverse(),n=[];for(let t=0;t<e.length;t++)n.push(e[t].clone().applyQuaternion(s));let a=(new z).setFromPoints(n),o=new d;a.getSize(o);let _=this.get_distance_to_fit_rect(o.x/2,o.y/2,i,r),l=new d;return a.getCenter(l),l.applyQuaternion(t),{center:l,distance_to_center:_}}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class pi extends f{constructor(){let e=new r({uniforms:{_Color:{value:new s("#919191")}},vertexShader:"#define GLSLIFY 1\nattribute vec3 barycentric;varying vec3 vBarycentric;void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=(modelMatrix*vec4(position,1.0)).xyz;gl_Position=VP*vec4(pos,1.0);vBarycentric=barycentric;}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 _Color;varying vec3 vBarycentric;float edgeFactor(vec3 baryc){vec3 d=fwidth(baryc);vec3 a3=smoothstep(vec3(0.0),d*1.5,baryc);return min(min(a3.x,a3.y),a3.z);}void main(){float alpha=edgeFactor(vBarycentric+vec3(1.,1.,0.));gl_FragColor.rgb=mix(_Color,vec3(0.),alpha);gl_FragColor.a=1.0-alpha;gl_FragColor.a*=0.2;}",extensions:{derivatives:!0},transparent:!0,depthWrite:!1}),t=new M(100,100,100,100);super(ni.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57}}class mi extends f{constructor(e){let t=new m;t.setAttribute("position",new k(new Float32Array([]),3)),t.setAttribute("next_position",new k(new Float32Array([]),3)),t.setAttribute("previous_position",new k(new Float32Array([]),3)),t.setAttribute("orientation",new k(new Float32Array([]),1)),t.setAttribute("coverage",new k(new Float32Array([]),1)),super(t,new r({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new s("#FF0000")}},vertexShader:"#define GLSLIFY 1\nuniform float _Thickness;attribute vec3 next_position;attribute vec3 previous_position;attribute float orientation;attribute float coverage;varying float line_coverage;varying float uv_u;vec3 w_space_normal(vec3 from,vec3 to){vec3 w_from=(modelMatrix*vec4(from,1.0)).xyz;vec3 w_to=(modelMatrix*vec4(to,1.0)).xyz;vec3 z=normalize(w_to-w_from);return normalize(cross(z,normalize(cameraPosition-w_from)));}void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=position;vec3 normal=w_space_normal(next_position,previous_position);pos=(modelMatrix*vec4(pos,1.0)).xyz;pos+=normal*(_Thickness*0.5)*orientation;gl_Position=VP*vec4(pos,1.0);line_coverage=coverage;uv_u=orientation*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nuniform float _Length;uniform float _ElapsedTime;uniform float _Thickness;uniform vec3 _Color;varying float line_coverage;varying float uv_u;float aastep(float threshold,float value){\n#ifdef GL_OES_standard_derivatives\nfloat afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757;return smoothstep(threshold-afwidth,threshold+afwidth,value);\n#else\nreturn step(threshold,value);\n#endif\n}void main(){float u=(1.0-abs(uv_u*2.0-1.0));float diffuse=dot(vec2(u,u),vec2(0.0,1.0))*0.5+0.5;gl_FragColor=vec4(_Color*diffuse,1.0);}",transparent:!0,depthWrite:!1,extensions:{derivatives:!0}})),e&&this.setup(e)}setup(e){let t=[],i=[],r=[],s=[],n=[],a=0;for(let o=0;o<e.length;o++){t.push(e[o].x),t.push(e[o].y),t.push(e[o].z),s.push(1),t.push(e[o].x),t.push(e[o].y),t.push(e[o].z),s.push(-1);let _=this.__get_next_position(e,o);i.push(_.x),i.push(_.y),i.push(_.z),i.push(_.x),i.push(_.y),i.push(_.z);let l=this.__get_previous_position(e,o);r.push(l.x),r.push(l.y),r.push(l.z),r.push(l.x),r.push(l.y),r.push(l.z),n.push(a),n.push(a),o<e.length-1&&(a+=e[o].distanceTo(_))}let o=new Float32Array(t),_=new Float32Array(i),l=new Float32Array(r),h=new Float32Array(s),c=new Float32Array(n),u=[];for(let e=0;e<(o.length/3-2)/2;e++){let t=2*e+1;u.push(t),u.push(t+1),u.push(t-1),u.push(t),u.push(t+2),u.push(t+1)}this.geometry.setIndex(u),this.geometry.getAttribute("position").copy(new k(o,3)),this.geometry.getAttribute("next_position").copy(new k(_,3)),this.geometry.getAttribute("previous_position").copy(new k(l,3)),this.geometry.getAttribute("orientation").copy(new k(h,1)),this.geometry.getAttribute("coverage").copy(new k(c,1)),this.geometry.getAttribute("position").needsUpdate=!0,this.geometry.getAttribute("next_position").needsUpdate=!0,this.geometry.getAttribute("previous_position").needsUpdate=!0,this.geometry.getAttribute("orientation").needsUpdate=!0,this.geometry.getAttribute("coverage").needsUpdate=!0,this.material.uniforms._Length.value=a,this._length=a}set thickness(e){this.material.uniforms._Thickness.value=e}get thickness(){return this.material.uniforms._Thickness.value}__get_previous_position(e,t){return 0===t?e[1].clone().sub(e[0]).multiplyScalar(-1).add(e[0]):e[t-1]}__get_next_position(e,t){return t===e.length-1?e[e.length-2].clone().sub(e[e.length-1]).multiplyScalar(-1).add(e[e.length-1]):e[t+1]}update(){}distance(){return this.accumulated_length}total_length(){return this.accumulated_length}dispose(){this.geometry.dispose(),this.material.dispose(),this.parent&&this.parent.remove(this)}set color(e){this.material.uniforms._Color.value.set(e)}get color(){return this.material.uniforms._Color.value}copy_color(e){this.material.uniforms._Color.value.copy(e)}}class gi extends f{constructor(e,t){t=t||new i(0,0);let s=new r({uniforms:{_MainTex:{value:e},_ScreenAligned:{value:0},_Scale:{value:1},_Opacity:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;uniform float _ScreenAligned;uniform float _Scale;void main(){vec3 pos=position;mat4 local_to_camera=modelViewMatrix;float scale=_Scale;local_to_camera[0]=mix(modelViewMatrix[0],vec4(1.0*scale,0.0,0.0,0.0),_ScreenAligned);local_to_camera[1]=mix(modelViewMatrix[1],vec4(0.0,1.0*scale,0.0,0.0),_ScreenAligned);local_to_camera[2]=mix(modelViewMatrix[2],vec4(0.0,0.0,1.0*scale,0.0),_ScreenAligned);gl_Position=projectionMatrix*local_to_camera*vec4(pos,1.0);vUv=uv;}",fragmentShader:"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;uniform float _Opacity;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor.a*=_Opacity;}",transparent:!0,depthWrite:!1,side:te}),n=new ie(1,1,1);n.translate(-t.x/2,-t.y/2,0);let a=e.image.width/e.image.height;n.scale(a,1,1),super(n,s),this.current_scale=a,this.geometry.computeBoundingBox(),this.tmp_bb_size=new d,this.geometry.boundingBox.getSize(this.tmp_bb_size)}update_texture(){this.material.uniforms._MainTex.value.needsUpdate=!0;let e=this.material.uniforms._MainTex.value.image;this.geometry.scale(1/this.current_scale,1,1),this.current_scale=e.width/e.height,this.geometry.scale(this.current_scale,1,1),this.geometry.computeBoundingBox(),this.geometry.boundingBox.getSize(this.tmp_bb_size)}get size(){return this.tmp_bb_size.clone().multiplyScalar(this.scale.x)}set size(e){this.scale.set(e,e,e),this.material.uniforms._Scale.value=e}set screen_aligned(e){this.material.uniforms._ScreenAligned.value=!0===e?1:0}get screen_aligned(){return 1===this.material.uniforms._ScreenAligned.value}set opacity(e){this.material.uniforms._Opacity.value=e}get opacity(){return this.material.uniforms._Opacity.value}dispose(){this.geometry.dispose(),this.parent.remove(this),this.material.uniforms._MainTex.value.dispose(),this.material.dispose()}}class vi extends gi{constructor(e,t,i,r,s){let n=new ti(s),a={font:t,font_color:i||"#000000"},o=n.draw_on_texture(e,a);o.minFilter=re,o.minFilter=Y,o.needsUpdate=!0,super(o,r),this.simple_text_drawer=n,this.canvas_texture=o,this.draw_settings=a}set text(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()}get text(){return"not implemented"}}class fi extends Be{constructor(e=1){super("#define GLSLIFY 1\nuniform vec2 _ScreenSize;uniform vec2 _TextureSize;uniform vec2 _PixelOffset;uniform vec3 _NDC;uniform vec2 _PivotPoint;uniform float _DepthOffset;varying vec2 vUv;vec2 add_pixel_offset(vec2 pos){pos=pos*0.5+0.5;pos*=_ScreenSize;pos=ceil(pos+_PixelOffset)+0.5;pos/=_ScreenSize;return pos*2.0-1.0;}void main(){vec4 projected_pos=projectionMatrix*viewMatrix*vec4(_NDC,1.0);projected_pos.zw+=_DepthOffset;projected_pos.xyz/=projected_pos.w;vec2 normalized_size=_TextureSize/_ScreenSize;vec2 dir=uv*2.0-1.0;dir-=_PivotPoint;vec2 pos=projected_pos.xy+dir*normalized_size;gl_Position=vec4(add_pixel_offset(pos),projected_pos.z,1.0);vUv=uv;}","#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _ScreenSize;uniform vec2 _TextureSize;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv+vec2(0.5,0.5)/_TextureSize);}",{_MainTex:{value:void 0},_ScreenSize:{value:new i(Screen.width,Screen.height)},_TextureSize:{value:new i},_PixelOffset:{value:new i(0,0)},_NDC:{value:new d},_PivotPoint:{value:new i},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class xi{constructor(){this.tmp_vec=new i}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class wi{constructor(){this.tmp_vec3=new d,this.tmp_vec2=new i}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(qe.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class bi{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class yi extends bi{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class Ti extends bi{constructor(){super()}on_enter(e){e.on_mouse_enter()}update(e,t){e.is_mouse_over(t)?e.set_state(e._on_hover_state):e.set_state(e._on_exit_state)}}class Si extends bi{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class Mi extends bi{constructor(){super()}on_enter(e){this.__trigger_on_hover(e)}update(e,t){e.is_mouse_over(t)?this.__trigger_on_hover(e):e.set_state(e._on_exit_state)}__trigger_on_hover(e){e.on_mouse_hover()}}class Fi extends f{constructor(e,t){super(new ie(1,1),new fi),this.is_clickable=!1,this.position_strategy=new wi,this.current_state=new yi,this._position=new d,this._on_idle_state=new yi,this._on_enter_state=new Ti,this._on_exit_state=new Si,this._on_hover_state=new Mi,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new i,this.cached_NDC_position=new i,this.screen_pos_tmp=new i,this.texture_size=new i(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new i}set_render_order(e){this.renderOrder=e}get pivot_point(){return this.material.uniforms._PivotPoint.value}set_pixel_offset(e){this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e)}set_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}get position(){return this._position}set use_depth(e){this.material.depthTest=e}get use_depth(){return this.material.depthTest}set depth_offset(e){this.material.uniforms._DepthOffset.value=e}get depth_offset(){return this.material.uniforms._DepthOffset.value}clear_state(){this.visible=!1}set_world_space_coordinate_system(){this.position_strategy=new wi}set_screen_space_coordinate_system(){this.position_strategy=new xi}set_texture(e){e.minFilter=c,e.magFilter=c,e.needsUpdate=!0,this.texture_size.set(e.image.width,e.image.height),this.material.uniforms._MainTex.value=e,this.get_size(this.material.uniforms._TextureSize.value),this.visible=!0}update_state(e){this.material.uniforms._ScreenSize.value.set(it.width,it.height),this.get_size(this.material.uniforms._TextureSize.value),this.cached_NDC_position.copy(this.position_strategy.get_pos_NDC(this.position)),this.material.uniforms._NDC.value.copy(this.position),this.current_state.update(this,e)}is_mouse_over(e){this.screen_pos_tmp.copy(this.cached_NDC_position),this.to_screen_position(this.screen_pos_tmp),this.screen_pos_tmp.x+=this.pixel_offset.x,this.screen_pos_tmp.y+=this.pixel_offset.y;let t=(new se).setFromCenterAndSize(this.screen_pos_tmp,this.get_size());return this.mouse_pos_tmp.copy(e),this.to_screen_position(this.mouse_pos_tmp),t.containsPoint(this.mouse_pos_tmp)}to_screen_position(e){e.x=(.5*e.x+.5)*it.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*it.height+this.pixel_offset.y}get_screen_space_position(){let e=this.cached_NDC_position.clone();return this.to_screen_position(e),e}set_screen_space_position(e){this.position.x=e.x/it.width*2-1,this.position.y=e.y/it.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),it.remove_screen_material(this.material),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/it.dpr):(new i).copy(this.texture_size).multiplyScalar(this.size/it.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class zi extends f{constructor(e,t){super(e,t);let i=this;this.onBeforeRender=()=>{i.material.update()}}}class Ri{constructor(e,t,r){let s=t.right-t.left,n=t.top-t.bottom;this.scale=new i(s,n),this.position=new i(e+t.left,t.bottom),this.atlas_bounds=new F(r.left,r.right,r.top,r.bottom)}}class Ai{constructor(e,t=""){this.glyph_layout=e,this.glyphs=[],this.glyph_is_dirty=!0,this.matrix_is_dirty=!0,this.color_is_dirty=!0,this.position=new d,this.quaternion=new $,this.scale=new d(1,1,1),this.matrix=new E,this.color=new s("#FFFFFF"),this.pivot_point=new i,this.__opacity=1,this.__text=t,this.__generate_glyphs(t)}set text(e){this.__text=e,this.__generate_glyphs(e),this.matrix_is_dirty=!0}get text(){return this.__text}update_matrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrix_is_dirty=!1,this.glyph_is_dirty=!0}clear_glyph_dirty(){this.glyph_is_dirty=!1}clear_color_dirty(){this.color_is_dirty=!1}set_rotation(e=0,t=0){let i=(new $).setFromAxisAngle(new d(0,1,0),e/360*Math.PI*2),r=(new $).setFromAxisAngle(new d(1,0,0),-t/360*Math.PI*2);this.quaternion.copy(i.multiply(r)),this.matrix_is_dirty=!0}set_position(e){this.position.copy(e),this.matrix_is_dirty=!0}set_size(e){this.scale.set(e,e,e),this.matrix_is_dirty=!0}set_color(e){this.color.set(e),this.color_is_dirty=!0}set_pivot(e){this.pivot_point.copy(e),this.update_glyphs()}set opacity(e){this.__opacity=e,this.color_is_dirty=!0}get opacity(){return this.__opacity}update_glyphs(){this.__generate_glyphs(this.text)}__generate_glyphs(e){let t=0;this.glyphs.length=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i),s=this.glyph_layout.find((e=>e.unicode===r));if(s){if(s.planeBounds){let e=new Ri(t,s.planeBounds,s.atlasBounds);this.glyphs.push(e)}t+=s.advance}}let r=new se,s=this.glyphs[0];r.setFromCenterAndSize(s.position.clone().add(new i(s.scale.x/2,s.scale.y/2)),s.scale);for(let e=1;e<this.glyphs.length;e++){let t=this.glyphs[e],s=(new se).setFromCenterAndSize(t.position.clone().add(new i(t.scale.x/2,t.scale.y/2)),t.scale);r.union(s)}let n=new i;r.getSize(n);for(let e=0;e<this.glyphs.length;e++)this.glyphs[e].position.x-=n.x/2,this.glyphs[e].position.y-=n.y/2,this.glyphs[e].position.x+=n.x/2*this.pivot_point.x,this.glyphs[e].position.y+=n.y/2*this.pivot_point.y;this.glyph_is_dirty=!0}}class Ci extends Be{constructor(e){super("#define GLSLIFY 1\nattribute vec4 transformsCol0;attribute vec4 transformsCol1;attribute vec4 transformsCol2;attribute vec4 transformsCol3;attribute vec4 glyph_bounds;attribute vec4 plane_bounds;attribute vec4 color;varying vec2 vUv;varying vec4 v_glyph_bounds;varying vec4 v_color;void main(){vec4 pos=vec4(position,1.0);pos.x*=plane_bounds.z;pos.y*=plane_bounds.w;pos.x+=plane_bounds.x;pos.y+=plane_bounds.y;mat4 offset_matrix=mat4(transformsCol0,transformsCol1,transformsCol2,transformsCol3);gl_Position=projectionMatrix*viewMatrix*offset_matrix*pos;vUv=uv;v_glyph_bounds=glyph_bounds;v_color=color;}","#define GLSLIFY 1\nuniform sampler2D _Texture;uniform float _Boldness;varying vec2 vUv;uniform vec2 _AtlasSize;varying vec4 v_glyph_bounds;varying vec4 v_color;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){float left=v_glyph_bounds.x/_AtlasSize.x;float right=v_glyph_bounds.y/_AtlasSize.x;float top=v_glyph_bounds.z/_AtlasSize.y;float bottom=v_glyph_bounds.w/_AtlasSize.y;float width=abs(right-left);float height=abs(top-bottom);vec2 coord=vec2(vUv.x*width+left,vUv.y*height+top-height);vec4 col=texture2D(_Texture,coord);float sig_dist=median(col.r,col.g,col.b);float _Cutoff=_Boldness;float dist=(_Cutoff-sig_dist);vec2 ddist=vec2(dFdx(dist),dFdy(dist));float pixelDist=dist/length(ddist);float opacity=clamp(0.5-pixelDist,0.0,1.0);gl_FragColor=vec4(v_color.rgb,opacity*v_color.a);}",{_Texture:{value:e},_Boldness:{value:.5},_AtlasSize:{value:new i(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=te,e.minFilter=Y,e.magFilter=Y,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(t){this.uniforms._Boldness.value=e.lerp(.5,.2,t)}}class Di extends f{constructor(e,t){let r=new ne;r.instanceCount=0;let s=new M(1,1);s.translate(.5,.5,0),r.setAttribute("position",new ae(s.getAttribute("position").array,3)),r.setAttribute("uv",new ae(s.getAttribute("uv").array,2)),r.index=s.index;let n=new oe(new Float32Array(8e3),4,!1),a=new oe(new Float32Array(8e3),4,!1),o=new oe(new Float32Array(8e3),4,!1),_=new oe(new Float32Array(8e3),4,!1),l=new oe(new Float32Array(8e3),4,!1),h=new oe(new Float32Array(8e3),4,!1),c=new oe(new Float32Array(8e3),4,!1);n.usage=_e,a.usage=_e,o.usage=_e,_.usage=_e,l.usage=_e,h.usage=_e,c.usage=_e,r.setAttribute("transformsCol0",n),r.setAttribute("transformsCol1",a),r.setAttribute("transformsCol2",o),r.setAttribute("transformsCol3",_),r.setAttribute("glyph_bounds",l),r.setAttribute("plane_bounds",h),r.setAttribute("color",c),super(r,new Ci(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new i(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){let t=new Ai(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){ri.remove_elem(this.text_elements,e),this.update(!0)}update(e){let t=this.geometry.getAttribute("glyph_bounds"),i=this.geometry.getAttribute("plane_bounds"),r=this.geometry.getAttribute("transformsCol0"),s=this.geometry.getAttribute("transformsCol1"),n=this.geometry.getAttribute("transformsCol2"),a=this.geometry.getAttribute("transformsCol3"),o=this.geometry.getAttribute("color"),_=!0===e,l=!0===e,h=!0===e,c=0;for(let e=0;e<this.text_elements.length;e++){let u=this.text_elements[e];u.matrix_is_dirty&&(_=!0,u.update_matrix()),u.glyph_is_dirty&&(l=!0,u.clear_glyph_dirty()),u.color_is_dirty&&(h=!0,u.clear_color_dirty());let d=u.matrix,p=u.color,m=u.opacity;for(let e=0;e<u.glyphs.length;e++){let _=u.glyphs[e],l=c;t.setXYZW(l,_.atlas_bounds.x,_.atlas_bounds.y,_.atlas_bounds.z,_.atlas_bounds.w),i.setXYZW(l,_.position.x,_.position.y,_.scale.x,_.scale.y),r.setXYZW(l,d.elements[0],d.elements[1],d.elements[2],d.elements[3]),s.setXYZW(l,d.elements[4],d.elements[5],d.elements[6],d.elements[7]),n.setXYZW(l,d.elements[8],d.elements[9],d.elements[10],d.elements[11]),a.setXYZW(l,d.elements[12],d.elements[13],d.elements[14],d.elements[15]),o.setXYZW(l,p.r,p.g,p.b,m),c++}}this.geometry.instanceCount=c,c>this.max_allocations&&console.error("SDFTextBatch exceeded maximum glyph allocations(max/current): ",this.max_allocations,c,this),_&&(r.needsUpdate=!0,s.needsUpdate=!0,n.needsUpdate=!0,a.needsUpdate=!0),l&&(t.needsUpdate=!0,i.needsUpdate=!0),h&&(o.needsUpdate=!0)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pi extends Te{constructor(e,t=0,i=1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=i}update(e,t){let i=this.from.clone();i.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(i)}}class Li extends Ge{constructor(){super('#define GLSLIFY 1\n/*3x3 MedianGLSL 1.0Morgan McGuire and Kyle Whitson,2006Williams Collegehttp:Copyright(c)Morgan McGuire and Williams College,2006All rights reserved.Redistribution and use in source and binary forms,with or withoutmodification,are permitted provided that the following conditions aremet:Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyrightnotice,this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING,BUT NOTLIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHTHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES(INCLUDING,BUT NOTLIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE,DATA,OR PROFITS;OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY,WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/uniform sampler2D _SourceTex;uniform vec2 _SourceTexSize;varying vec2 vUv;\n#define vec vec4\n#define toVec(x) x.rgba\n#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);\n#define t2(a, b) s2(v[a], v[b]);\n#define t24(a, b, c, d, e, f, g, h) t2(a, b); t2(c, d); t2(e, f); t2(g, h);\n#define t25(a, b, c, d, e, f, g, h, i, j) t24(a, b, c, d, e, f, g, h); t2(i, j);\n#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);\n#define mn3(a, b, c) s2(a, b); s2(a, c);\n#define mx3(a, b, c) s2(b, c); s2(a, c);\n#define mnmx3(a, b, c) mx3(a, b, c); s2(a, b);\n#define mnmx4(a, b, c, d) s2(a, b); s2(c, d); s2(a, c); s2(b, d);\n#define mnmx5(a, b, c, d, e) s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e);\n#define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f);\nvoid main(){vec2 inv_size=vec2(1.0/_SourceTexSize.x,1.0/_SourceTexSize.y);\n#ifdef kernel5x5\nvec v[25];for(int dX=-2;dX<=2;++dX){for(int dY=-2;dY<=2;++dY){vec2 offset=vec2(float(dX),float(dY));v[(dX+2)*5+(dY+2)]=toVec(texture2D(_SourceTex,vUv+offset*inv_size));}}vec temp;t25(0,1,3,4,2,4,2,3,6,7);t25(5,7,5,6,9,7,1,7,1,4);t25(12,13,11,13,11,12,15,16,14,16);t25(14,15,18,19,17,19,17,18,21,22);t25(20,22,20,21,23,24,2,5,3,6);t25(0,6,0,3,4,7,1,7,1,4);t25(11,14,8,14,8,11,12,15,9,15);t25(9,12,13,16,10,16,10,13,20,23);t25(17,23,17,20,21,24,18,24,18,21);t25(19,22,8,17,9,18,0,18,0,9);t25(10,19,1,19,1,10,11,20,2,20);t25(2,11,12,21,3,21,3,12,13,22);t25(4,22,4,13,14,23,5,23,5,14);t25(15,24,6,24,6,15,7,16,7,19);t25(3,11,5,17,11,17,9,17,4,10);t25(6,12,7,14,4,6,4,7,12,14);t25(10,14,6,7,10,12,6,10,6,17);t25(12,17,7,17,7,10,12,18,7,12);t24(10,18,12,20,10,20,10,12);gl_FragColor=v[12];\n#endif\n#ifdef kernel3x3\nvec v[9];for(int dX=-1;dX<=1;++dX){for(int dY=-1;dY<=1;++dY){vec2 offset=vec2(float(dX),float(dY));v[(dX+1)*3+(dY+1)]=toVec(texture2D(_SourceTex,vUv+offset*inv_size));}}vec temp;mnmx6(v[0],v[1],v[2],v[3],v[4],v[5]);mnmx5(v[1],v[2],v[3],v[4],v[6]);mnmx4(v[2],v[3],v[4],v[7]);mnmx3(v[3],v[4],v[8]);toVec(gl_FragColor)=v[4];\n#endif\n}',void 0,{kernel3x3:!0}),this.uniforms._SourceTex={value:void 0},this.uniforms._SourceTexSize={value:new i(1,1)}}set_texture(e){this.uniforms._SourceTex.value=e;let t=this.get_size(e);this.uniforms._SourceTexSize.value.copy(t)}get_size(e){return e.isVideoTexture?new i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class Ii{constructor(e){this.RT=new D(1,1,{type:N,format:U,minFilter:c,magFilter:c}),this.RT1=new D(1,1,{type:N,format:U,minFilter:c,magFilter:c}),this.median_filter_mat=new Li}filter(e){let t=this.get_size(e);t.x===this.RT.width&&t.y===this.RT.height||(this.RT.setSize(t.x,t.y),this.RT1.setSize(t.x,t.y)),this.median_filter_mat.set_texture(e),ht.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),ht.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),ht.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class Oi extends Ge{constructor(e){super(e?"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 upsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv+vec2(-halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,-halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,-halfpixel.y))*2.0;return sum/12.0;}void main(){vec2 half_pixel;half_pixel.x=0.5/_Resolution.x;half_pixel.y=0.5/_Resolution.y;gl_FragColor=upsample(vUv,half_pixel);}":"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 downsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv)*4.0;sum+=texture2D(_MainTex,uv-halfpixel);sum+=texture2D(_MainTex,uv+halfpixel);sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y));sum+=texture2D(_MainTex,uv-vec2(halfpixel.x,-halfpixel.y));return sum/8.0;}void main(){vec2 half_pixel=vec2(0.5/_Resolution.x,0.5/_Resolution.y);gl_FragColor=downsample(vUv,half_pixel);}")}}class Ui extends Ge{constructor(e,t){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;void main(){vec4 col=texture2D(_MainTex,vUv);gl_FragColor=col;gl_FragColor.a=col.a;}")}set offset(e){this.uniforms._Offset.value=e}get offset(){return this.uniforms._Offset.value}}class Ni{constructor(e){this.current_width=1,this.current_height=1,this.RT0=new D(1,1),this.RT1=new D(1,1),this.RT2=new D(1,1),this.RT3=new D(1,1),this.RT4=new D(1,1),this.upscale_blur_mat=new Oi(!0),this.downscale_blur_mat=new Oi(!1),this.alpha_filter_mat=new Ui}blur(e){this.check_RT_resize(e.width,e.height),ht.blit(e,this.RT1,this.alpha_filter_mat),ht.blit(this.RT1,this.RT2,this.downscale_blur_mat),ht.blit(this.RT2,this.RT3,this.downscale_blur_mat),ht.blit(this.RT3,this.RT4,this.downscale_blur_mat),ht.blit(this.RT4,this.RT3,this.upscale_blur_mat),ht.blit(this.RT3,this.RT2,this.upscale_blur_mat),ht.blit(this.RT2,e,this.upscale_blur_mat)}check_RT_resize(e,t){this.current_width===e&&this.current_height===t||(this.current_width=e,this.current_height=t,this.RT0.setSize(this.current_width/2,this.current_height/2),this.RT1.setSize(this.current_width/2,this.current_height/2),this.RT2.setSize(this.current_width/4,this.current_height/4),this.RT3.setSize(this.current_width/8,this.current_height/8),this.RT4.setSize(this.current_width/16,this.current_height/16))}}class ki extends u{constructor(){super(),this.attributes=[],this.particles=void 0}set_from_geometry(e,t,i){if(i&&void 0===e.getAttribute("storage_uv")){let t=this.build_uv_storage_attribute(e.getAttribute("position").count);e.setAttribute("storage_uv",t)}let r=new le(e,t);r.frustumCulled=!1,this.particles=r,this.add(r)}add_texture_attribute(e){}add_attribute(e,t){}build_uv_storage_attribute(e){let t=this.calculate_resolution(e),i=new Float32Array(2*e);for(let r=0,s=0;r<2*e;r+=2,s++)i[r]=s%t/t+.5/t,i[r+1]=Math.floor(s/t)/t+.5/t;return new k(i,2)}calculate_resolution(e){return Math.ceil(Math.sqrt(e))}update(){for(let e=0;e<this.attributes.length;e++)this.attributes[e].update()}set_attribute_update_material(e,t){for(let i=0;i<this.attributes.length;i++)this.attributes[i].name===e&&(this.attributes[i].update_material=t)}dispose(){this.particles.geometry.dispose(),this.particles.material.dispose()}}export{we as AbstractLoader,Fe as ActionEvent,Te as ActionInterpolator,be as ActionSequencer,Re as ActionSequencerBuilder,Ue as ApplicationView,ri as ArrayUtilities,Ne as BaseApplication,ke as BaseRender,Be as BaseShaderMaterial,Ve as BasisLoader,Ge as BlitMaterial,zt as Blurrer,Je as CSSAnimator,qe as CameraManager,xt as CameraUtilities,We as CanvasDrawer,Ye as Capabilities,He as Configuration,nt as Debug,ut as DebugNormalsRender,ze as DrawIOAnimationSheet,Oi as DualFilteringBlurMaterial,Ni as DualFilteringBlurrer,ye as EasingFunctions,Ae as EventManager,si as FrustumPointFitter,ki as GPUParticleSystem,It as GaussianBlurrer,ni as GeometryUtilities,ht as Graphics,pi as Grid,ai as ImageUtilities,wt as Initializer,dt as Input,bt as JSONLoader,mi as Line,ft as MathUtilities,Ii as MedianFilter,oi as MeshSampler,_i as ModelUtilities,Rt as NormalAORender,At as NormalRender,Se as NumberInterpolator,fe as OS,li as ObjectUtilities,Ut as OrthographicCamera,di as OrthographicFrustumPointFitter,st as PerspectiveCamera,ui as PerspectiveFrustumPointFitter,Nt as Primitives,Et as RenderLoop,ei as ResourceBatch,Ce as ResourceContainer,Di as SDFTextBatch,Ke as SceneManager,it as Screen,ti as SimpleTextDrawer,hi as StringUtilities,vi as Text2D,Pe as Time,ci as TimeUtilities,De as TransitionTable,vt as UI,Fi as UIElement,Ot as UnrealBloomRender,zi as UpdatableMaterialMesh,xe as Validation,Pi as VectorInterpolator,ii as ViewComponent,kt as ViewComponentManager,Me as ViewContext,Oe as ViewManager};
|
|
1
|
+
import{Math as e,Clock as t,Vector2 as i,ShaderMaterial as r,Color as s,sRGBEncoding as n,NoBlending as a,AlwaysDepth as o,CanvasTexture as _,UVMapping as l,ClampToEdgeWrapping as h,NearestFilter as c,Object3D as u,Vector3 as d,LineBasicMaterial as p,BufferGeometry as m,Line as g,Scene as v,Mesh as f,BoxGeometry as x,MeshBasicMaterial as w,SphereBufferGeometry as b,CylinderBufferGeometry as y,ConeBufferGeometry as T,PerspectiveCamera as S,PlaneBufferGeometry as M,Vector4 as F,Box3 as z,Box3Helper as R,CatmullRomCurve3 as A,SphereGeometry as C,WebGLRenderTarget as D,OrthographicCamera as P,WebGLRenderer as L,DataTexture as I,RGBFormat as O,RGBAFormat as U,FloatType as N,BufferAttribute as k,Matrix4 as E,Plane as j,Ray as B,Sphere as G,FileLoader as V,RepeatWrapping as q,LinearFilter as Y,TextureLoader as W,CubeTextureLoader as H,Audio as Q,AudioLoader as X,FontLoader as J,UnsignedByteType as Z,Line3 as K,Quaternion as $,Skeleton as ee,DoubleSide as te,PlaneGeometry as ie,LinearMipMapLinearFilter as re,Box2 as se,InstancedBufferGeometry as ne,Float32BufferAttribute as ae,InstancedBufferAttribute as oe,DynamicDrawUsage as _e,Points as le}from"three";import{BufferGeometryUtils as he}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{InputController as ce}from"pit-js";import*as ue from"three/examples/jsm/loaders/GLTFLoader.js";import*as de from"three/examples/jsm/loaders/ColladaLoader.js";import*as pe from"three/examples/jsm/loaders/OBJLoader.js";import*as me from"three/examples/jsm/loaders/RGBELoader.js";import*as ge from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import*as ve from"three/examples/jsm/loaders/DRACOLoader.js";var fe=new class{init(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"}}get_os(){let e=window.navigator.userAgent,t=window.navigator.platform,i=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?i=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?i=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?i=this.operating_systems.WINDOWS:/Android/.test(e)?i=this.operating_systems.ANDROID:!i&&/Linux/.test(t)&&(i=this.operating_systems.LINUX),i}get is_android(){return this.get_os()===this.operating_systems.ANDROID}get is_ios(){return navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad}get is_safari(){let e=navigator.userAgent.toLowerCase();return-1!==e.indexOf("safari")&&!(e.indexOf("chrome")>-1)}get is_ipad(){return navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2}get is_mobile(){return!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/)}get is_linux(){return this.get_os()===this.operating_systems.LINUX}get is_mac(){return this.get_os()===this.operating_systems.MAC}get is_windows(){return this.get_os()===this.operating_systems.WINDOWS}};class xe{constructor(){}static is_int(e){return Number(e)===e&&e%1==0}static is_float(e){return Number(e)===e&&e%1!=0}static is_number(e){return this.is_int(e)||this.is_float(e)}static is_json(e){try{JSON.parse(e)}catch(e){return!1}return!0}}class we{constructor(e,t,i=1){this.resource_id=e,this.url=t,this.loaded_bytes=0,this.total_bytes=i,this.has_finished=!1,this.has_error=!1,this.error_message="none"}__update_downloaded_bytes(e,t){e=xe.is_number(e)?e:1,t=xe.is_number(t)?t:1,this.loaded_bytes=e,t>0&&(this.total_bytes=t),this.loaded_bytes>this.total_bytes&&console.warn("Total bytes is smaller than loaded ones. Please set total bytes by hand to:",this.url)}__loading_ended(){this.has_finished=!0}__set_error(e){this.has_error=!0,this.error_message=e}print_error(){console.error("Error while loading "+this.resource_id+"\n\t path: "+this.url+"\n\t\t"+this.error_message)}load(e){const t=fe.is_safari?"no-cache":"default";fetch(this.url,{method:"GET",mode:"cors",cache:t,credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}async on_progress(e,t){const i=t.body.getReader();let r=+t.headers.get("Content-Length"),s=0;for(;;){const{done:e,value:t}=await i.read();if(e)break;s+=t.length,this.__update_downloaded_bytes(s,r)}this.on_preloaded_finished(e)}on_preloaded_finished(e){}__on_error(e){console.error(e)}}class be{constructor(e){this.elapsed_time=-1e-5,this.playing=!1,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};let t=Object.keys(e);for(let e=0;e<t.length;e++)this.channels[t[e]]=[];this.duration=0}play(){this.playing=!0}stop(){this.playing=!1}reset(){this.elapsed_time=-1e-5}skip(){this.elapsed_time=this.get_duration(),this.__play_clips(this.elapsed_time,this.elapsed_time+.01)}update(e){this.playing&&(this.__play_clips(this.elapsed_time,this.elapsed_time+e),this.elapsed_time=this.elapsed_time+e)}set_progress(t){this.elapsed_time=e.clamp(t,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)}set_normalized_progress(t){this.elapsed_time=e.clamp(t,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return e.clamp(this.elapsed_time/this.get_duration(),0,1)}is_finished(){return this.elapsed_time>this.get_duration()}add_action_event(e,t){this.action_events.push({trigger_time:e,action:t}),this.duration=Math.max(this.duration,e)}add_action_interpolator(e,t,i,r=!1){if(r){let e=this.channels[i.attribute_name];void 0===e&&console.error(`${i.attribute_name} missing in initial state data.`),0===e.length?i.from=this.initial_context[i.attribute_name]:i.from=e[e.length-1].interpolator.to}let s={from:e,to:t,interpolator:i};this.duration=Math.max(this.duration,t),this.channels[i.attribute_name].push(s)}get_property_target_value(e){let t=this.__get_nearest_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1)}get_duration(){return this.duration}__play_clips(e,t){for(let i=0;i<this.action_events.length;i++)this.action_events[i].trigger_time>=e&&this.action_events[i].trigger_time<t&&this.action_events[i].action.trigger();let i=Object.keys(this.initial_context);for(let t=0;t<i.length;t++){let r=i[t],s=this.__get_nearest_keyframe(r,e);this.context[r]=this.evaluate_keyframe(s,e)}}evaluate_keyframe(t,i){return this.tmp_t=this.__linear_map_01(i,t.from,t.to),t.interpolator.evaluate(e.clamp(this.tmp_t,0,1))}__linear_map_01(e,t,i){return(e-t)/(i-t)*1+0}__get_nearest_keyframe(e,t){let i,r=9999999,s=this.channels[e];for(let e=0;e<s.length;e++){let n=s[e],a=Math.min(Math.abs(n.from-t),Math.abs(n.to-t));a<r&&(r=a,i=n)}return i}}var ye=new class{constructor(){}linear(e){return e}triangular(e){return 1-Math.abs(2*e%2-1)}ease_in_sine(e){return 1-Math.cos(3.1415926*e/2)}ease_out_sine(e){return Math.sin(3.1415926*e/2)}ease_in_out_sine(e){return-(Math.cos(3.1415926*e)-1)/2}ease_in_cubic(e){return e*e*e}ease_out_cubic(e){return 1-Math.pow(1-e,3)}ease_in_out_cubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}ease_in_quad(e){return e*e}ease_out_quad(e){return 1-(1-e)*(1-e)}ease_in_out_quad(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}ease_in_quart(e){return e*e*e*e}ease_out_quart(e){return 1-Math.pow(1-e,4)}ease_in_out_quart(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2}ease_in_quint(e){return e*e*e*e*e}ease_out_quint(e){return 1-Math.pow(1-e,5)}ease_in_out_quint(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2}ease_in_expo(e){return 0===e?0:Math.pow(2,10*e-10)}ease_out_expo(e){return 1===e?1:1-Math.pow(2,-10*e)}ease_in_out_expo(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}ease_in_circ(e){return 1-Math.sqrt(1-Math.pow(e,2))}ease_out_circ(e){return Math.sqrt(1-Math.pow(e-1,2))}ease_in_out_circ(e){return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2}ease_in_back(e){return 2.7015*e*e*e-1.7015*e*e}ease_out_back(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)}ease_in_out_back(e){return e<.5?Math.pow(2*e,2)*(7.189819*e-2.5949095)/2:(Math.pow(2*e-2,2)*(3.5949095*(2*e-2)+2.5949095)+2)/2}ease_in_elastic(e){const t=2*Math.PI/3;return 0===e?0:1===e?1:-Math.pow(2,10*e-10)*Math.sin((10*e-10.75)*t)}ease_out_elastic(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1}ease_in_out_elastic(e){return 0===e?0:1===e?1:e<.5?-Math.pow(2,20*e-10)*Math.sin(1.3962633*(20*e-11.125))/2:Math.pow(2,-20*e+10)*Math.sin(1.3962633*(20*e-11.125))/2+1}ease_in_bounce(e){return 1-this.ease_out_bounce(1-e)}ease_out_bounce(e){const t=7.5625,i=2.75;return e<1/i?t*e*e:e<2/i?t*(e-=1.5/i)*e+.75:e<2.5/i?t*(e-=2.25/i)*e+.9375:t*(e-=2.625/i)*e+.984375}ease_in_out_bounce(e){return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2}heartbeat(e){return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8}};class Te{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?ye[e]:e}update(e,t){}}class Se extends Te{constructor(e,t=0,i=1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=i}update(t,i){t[this.attribute_name]=e.lerp(this.from,this.to,this.easing_function(i))}evaluate(t){return e.lerp(this.from,this.to,this.easing_function(t))}}var Me=new class{constructor(){this.app=void 0}set_app(e){this.app=e}};class Fe{constructor(e,t){this.name=e,this.method=t}trigger(){Me.app[this.name][this.method]()}}class ze{constructor(){}parse(e){let t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),i=[],r=[];for(let e=0;e<t.length;e++){let s=t[e],n=s.parentElement,a=n.getAttribute("value"),o=this.get_node_x_position(s)/100,_=parseFloat(s.getAttribute("width"))/100;if(n.getAttribute("style").includes("rhombus;")){let e=a.split("."),t=e[0],i=e[1];r.push({name:t,method:i,at_time:o+.5*_})}if(n.getAttribute("style").includes("rounded=0;")&&!n.getAttribute("style").includes("text;")&&""!==a&&!a.includes(" ")){let e=a.split("="),t=e[0],r=e[1].split("--"),s=parseFloat(r[0]),n=r[1];2!==e.length&&console.error("DrawIO data is malformed:",a),2!==r.length&&console.error("DrawIO data is malformed:",a),i.push({attribute_name:t,from_time:o,to_time:o+_,to_value:s,easing_function:n})}}return i.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:i,triggers:r}}get_node_x_position(e){let t=e.getAttribute("x");return null===t?0:parseFloat(t)}}class Re{constructor(e){this.initial_state_data=e}from_animation_sheet(e,t,i){i=i||this.initial_state_data;let r=e.animation_tracks,s=e.triggers,n=this.state_to_tracks(this.initial_state_data);for(let e=0;e<n.length;e++)void 0===r.find((t=>t.attribute_name===n[e].attribute_name))&&r.push(n[e]);let a=new be(t);for(let e=0;e<r.length;e++){let i=r[e],s=new Se(i.attribute_name,t[i.attribute_name],i.to_value,i.easing_function);a.add_action_interpolator(i.from_time,i.to_time,s,!0)}for(let e=0;e<s.length;e++){let t=s[e],i=new Fe(t.name,t.method);a.add_action_event(t.at_time,i)}return a}state_to_tracks(e){let t=[],i=Object.keys(e);for(let r=0;r<i.length;r++)t.push({attribute_name:i[r],from_time:0,to_time:1,to_value:e[i[r]],easing_function:"ease_in_out_cubic"});return t}from_draw_io(e,t){let i=(new ze).parse(e),r=i.animation_tracks,s=i.triggers,n=new be(t);for(let e=0;e<r.length;e++){let i=r[e],s=new Se(i.attribute_name,t[i.attribute_name],i.to_value,i.easing_function);n.add_action_interpolator(i.from_time,i.to_time,s,!0)}for(let e=0;e<s.length;e++){let t=s[e],i=new Fe(t.name,t.method);n.add_action_event(t.at_time,i)}return n}}var Ae=new class{init(){this.queue={},this.zoom_changed_evt="zoom_changed",this.store_clickd_evt="store_clicked",this.point_selected_evt="point_selected",this.config_changed="config_changed",this.path_substep_completed="path_substep_completed",this.path_completed="path_completed",this.go_to_store_requested_evt="go_to_store_requested",this.resource_loaded_evt="resource_loaded",this.service_clicked_evt="service_clicked",this.unit_pos_updated_evt="unit_position_updated",this.floor_changed_evt="floor_changed",this.on_enter_floor_navigation="on_enter_floor_navigation",this.on_exit_floor_navigation="on_exit_floor_navigation",this.on_enter_floor_selection="on_enter_floor_selection",this.on_exit_floor_selection="on_exit_floor_selection",this.on_enter_outside_navigation="on_enter_outside_navigation",this.on_exit_outside_navigation="on_exit_outside_navigation",this.step_selected_evt="step_selected"}fire(e,t){let i=this.queue[e];if(void 0===i)return;let r=i.length;for(;r--;)i[r](t)}on(e,t){void 0===this.queue[e]&&(this.queue[e]=[]),this.queue[e].push(t)}fire_zoom_changed(e){this.fire(this.zoom_changed_evt,e)}fire_store_selected(e){this.fire(this.store_clickd_evt,e)}fire_point_selected(e){this.fire(this.point_selected_evt,e)}fire_config_changed(){this.fire(this.config_changed)}fire_path_substep_completed(e){this.fire(this.path_substep_completed,e)}fire_path_completed(){this.fire(this.path_completed)}fire_step_selected(e){this.fire(this.step_selected_evt,e)}fire_go_to_store_requested(e){this.fire(this.go_to_store_requested_evt,e)}fire_resource_loaded(e){this.fire(this.resource_loaded_evt,e)}fire_service_clicked(e){this.fire(this.service_clicked_evt,e)}fire_unit_position_updated(e){this.fire(this.unit_pos_updated_evt,e)}fire_floor_switched(e){this.fire(this.floor_changed_evt,e)}fire_on_enter_floor_navigation(e){this.fire(this.on_enter_floor_navigation,e)}fire_on_exit_floor_navigation(e){this.fire(this.on_exit_floor_navigation,e)}fire_on_enter_floor_selection(e){this.fire(this.on_enter_floor_selection,e)}fire_on_exit_floor_selection(e){this.fire(this.on_exit_floor_selection,e)}fire_on_enter_outside_navigation(e){this.fire(this.on_enter_outside_navigation,e)}fire_on_exit_outside_navigation(e){this.fire(this.on_exit_outside_navigation,e)}};var Ce=new class{init(){this.resources={},this.resources_by_url={}}set_resource(e,t,i){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=i,this.resources_by_url[t]=i),Ae.fire_resource_loaded({name:e,value:i})}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}};class De{constructor(){this.transitions=[],this.initial_state_data={}}get(e,t){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].to===e){return new Re(this.initial_state_data).from_animation_sheet(this.transitions[i].data,t)}console.error("TransitionTable.get no data found for: ",e)}add_transitions(e){for(let t=0;t<e.length;t++)this.transitions.push(e[t])}set_transitions(e){this.transitions=e}set_initial_state_data(e){this.initial_state_data=e}}var Pe=new class{init(){this.___time=new t,this.__delta_time=0,this.__elapsed_time=0,this.__allocated_time=new i(0,0)}get delta_time(){return this.__delta_time<.4?this.__delta_time:.016}get elapsed_time(){return this.__elapsed_time}get shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_time}__update(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime()}};class Le{constructor(e){this.name=e}start(){}show(){}hide(){}before_enter(){}on_enter(){}update(){}update_enter_transition(e,t,i){this.update_transition(e,t,i)}update_exit_transition(e,t,i){}update_transition(e,t,i){}before_exit(){}on_exit(){}}class Ie{constructor(e){this.last_state=new Le,this.current_state=new Le,this.initial_state_data={},this.current_state_data={},this.transition_table=e,this.transitioning=!1}go_to_state(e,t=!1){this.last_state=this.current_state,this.current_state=e,this.last_state.before_exit(),this.current_state.show(),this.current_state.before_enter(),this.action_sequencer=this.transition_table.get(this.current_state.name,this.current_state_data),this.action_sequencer.play(),this.transitioning=!0,t&&(this.action_sequencer.skip(),this.update())}update(){this.transitioning?(this.action_sequencer.update(Pe.delta_time),this.last_state.update_exit_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.current_state.update_enter_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.action_sequencer.is_finished()&&(this.transitioning=!1,this.action_sequencer.update(Pe.delta_time),this.last_state.update_exit_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.current_state.update_enter_transition(this.current_state_data,this.action_sequencer.get_progress(),this.action_sequencer),this.last_state.name!==this.current_state.name&&this.last_state.hide(),this.last_state.on_exit(),this.current_state.on_enter())):this.current_state.update()}set_state(e){this.current_state=e}set_initial_state_data(e){Object.assign(this.initial_state_data,e),Object.assign(this.current_state_data,e)}}var Oe=new class{constructor(){this.views=[],this.transition_table=new De,this.transition_handler=new Ie(this.transition_table)}update(){this.transition_handler.update()}go_to_view(e,t=!0,i=!1){let r=this.get(e);this.transition_handler.go_to_state(r,i),t&&this.__change_browser_url(r.url)}register_view(e){this.views.push(e)}has_view(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1}add_transitions(e){this.transition_table.add_transitions(e)}set_transitions(e){this.transition_table.set_transitions(e)}set_view(e){let t=this.get(e);this.transition_handler.set_state(t)}get_current_view(){return this.transition_handler.current_state}get_view_by_name(e){console.warn("DEPRECATED. Use ViewManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return this.views[t];console.error("[ViewManager.get] no view found for: ",e)}get_view_by_url(e){console.warn("DEPRECATED. Use ViewManager.get_by_url instead"),this.get_by_url(e)}get_by_url(e){for(let t=0;t<this.views.length;t++)if(this.views[t].url===e)return this.views[t];console.error("[ViewManager.get_by_url] no view found for: ",e)}set_initial_state_data(e){this.transition_table.set_initial_state_data(e),this.transition_handler.set_initial_state_data(e)}__change_browser_url(e){window.history.pushState("","",e)}};class Ue extends Le{constructor({name:e,url:t,container:i}){super(e),this.container=i,this.url=t;let r=[{to:e,data:(new ze).parse(Ce.get(`${e}_data`))}];Oe.register_view(this),Oe.add_transitions(r)}show(){this.container.classList.add("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}on_enter(){this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}before_exit(){this.container.classList.add("before_exit"),this.container.classList.remove("before_enter"),this.container.classList.remove("hidden")}hide(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")}set_opacity(e){this.container.style.opacity=e}}class Ne{on_post_start(){}on_enter(){}on_exit(){}update(){}on_post_render(){}on_pre_render(){}}class ke{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}var Ee="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",je="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class Be extends r{constructor(e,t,i){super({vertexShader:e||Ee,fragmentShader:t||je,uniforms:i||{_Color:{value:new s("#FF0000")}}})}}class Ge extends we{constructor(e,t,i,r,s){super(e,t,s),this.loader=r,this.loader.setWorkerLimit(1),this.loader.setTranscoderPath("libs/basis/"),this.loader.detectSupport(i)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{i.encoding=n,e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ve extends r{constructor(e,t,r){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new i(0,0)},_TargetResolution:{value:new i(0,0)}},defines:r||{},vertexShader:t||"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}",fragmentShader:e||"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);}",depthWrite:!1,blending:a,depthTest:!1,depthFunc:o})}}var qe=new class{init(){this._current=void 0}set current(e){this._current=e}get current(){return this._current}};var Ye=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class We{constructor(e){this.uses_dynamic_font=e,this.__textHeight=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}getFontHeight(e="Arial"){if(null==this.__textHeight||this.uses_dynamic_font){let t=document.getElementsByTagName("body")[0],i=document.createElement("div"),r=document.createTextNode("MÉqgOLAKTAL");i.appendChild(r),i.setAttribute("style",`font:${e};position:absolute;top:0;left:0`),t.appendChild(i),this.__textHeight=i.offsetHeight,t.removeChild(i)}return this.__textHeight}get_text_size(e,t="24px Arial"){let r=new i;return this.ctx.font=t,r.x=Math.ceil(this.ctx.measureText(e).width),r.y=Math.ceil(this.getFontHeight(t)),r}draw_canvas(e,t={}){return t.font=t.font||"24px Arial",t.font_color=t.font_color||"#000000",this.__draw(e,t,this.canvas,this.ctx),this.canvas}draw_on_texture(e,t){let i=this.draw_canvas(e,t),r=new _(i,l,h,h,c,c);return r.generateMipMaps=!1,r.needsUpdate=!0,r}__draw(e,t){}roundRect(e,t,i,r,s,n,a,o){if(void 0===o&&(o=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{let e={tl:0,tr:0,br:0,bl:0};for(let t in e)n[t]=n[t]||e[t]}e.beginPath(),e.moveTo(t+n.tl,i),e.lineTo(t+r-n.tr,i),e.quadraticCurveTo(t+r,i,t+r,i+n.tr),e.lineTo(t+r,i+s-n.br),e.quadraticCurveTo(t+r,i+s,t+r-n.br,i+s),e.lineTo(t+n.bl,i+s),e.quadraticCurveTo(t,i+s,t,i+s-n.bl),e.lineTo(t,i+n.tl),e.quadraticCurveTo(t,i,t+n.tl,i),e.closePath(),a&&e.fill(),o&&e.stroke()}}var He=new class{init(e={}){this.dpr=1,this.app={}}from_json(e){}};class Qe{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Xe{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(t){this.t+=Pe.delta_time/t.duration,this.easing_function_t=t.easing_function(this.t),this.easing_function_t=e.clamp(this.easing_function_t,0,1),t.set_property_value(e.lerp(t.from,t.to,this.easing_function_t)),this.easing_function_t>=.9999&&(t.set_property_value(t.to),t.set_current_state(new Qe),t.finished_callback(t))}on_exit(e){}}class Je{constructor({element:e,css_property:t,from:i=0,to:r=1,duration:s=1,value_prefix:n="",value_suffix:a="",easing_function:o=ye.ease_in_out_cubic,finished_callback:_=(()=>{})}){this.element=e,this.css_property=t,this.from=i,this.to=r,this.value_prefix=n,this.value_suffix=a,this.duration=s,this.easing_function=o,this.finished_callback=_,this.current_state=new Qe}animate(){this.set_current_state(new Xe)}stop(){this.set_current_state(new Qe)}set_property_value(e){this.element.style[this.css_property]=`${this.value_prefix}${e}${this.value_suffix}`}update(){this.current_state.update(this)}get is_animating(){return this.current_state.is_animating}set_current_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}}class Ze extends u{constructor(e=1){super();const t=[];t.push(new d(0,0,0)),t.push(new d(0,0,1e3));const i=new p({color:4474111,depthFunc:o}),r=(new m).setFromPoints(t),s=new g(r,i);s.renderOrder=5e4;const n=[];n.push(new d(0,0,0)),n.push(new d(0,1e3,0));const a=new p({color:4521796,depthFunc:o}),_=(new m).setFromPoints(n),l=new g(_,a);l.renderOrder=5e4;const h=[];h.push(new d(0,0,0)),h.push(new d(1e3,0,0));const c=new p({color:16729156,depthFunc:o}),u=(new m).setFromPoints(h),v=new g(u,c);v.renderOrder=5e4,this.renderOrder=1e5,this.add(s),this.add(l),this.add(v),this.scale.set(e,e,e)}update(){}dispose(){}}var Ke=new class{init(){this._current=new v,this._current.name="default_scene"}add_scene(e){}get current(){return this._current}set current(e){this._current=e}dispose(){for(this.current.traverse((e=>{e.geometry&&(e.geometry.dispose(),e.material.dispose())}));this.current.children.length>0;)this.current.remove(this.current.children[0])}};class $e extends f{constructor(e,t,i){e=e||new d(1,1,1),t=t||new d(1,1,1),i=i||16711680,super(new x(e.x,e.y,e.z,t.x,t.y,t.z),new w({color:i}))}}class et extends f{constructor(e,t){t=t||"#FF0000",super(new b(e=e||1,64,64),new w({color:t}))}}class tt extends f{constructor(e,t,i){e=e||"#FF0000";let r=(t=t||1)-.4,s=new y(.01,.01,r,32);s.translate(0,r/2,0);let n=new T(.1,.4,32);n.translate(0,r+.2,0);let a=he.mergeBufferGeometries([s,n]);a.rotateX(1.57),super(a,new w({color:e})),i&&this.quaternion.setFromUnitVectors(new d(0,0,1),i),this._dir=i}set dir(e){this.quaternion.setFromUnitVectors(new d(0,0,1),e),this._dir=e}get dir(){return this._dir}set length(e){this.scale.z=e}get length(){return this.scale.z}}var it=new class{init(){this.width=1,this.height=1,this.position=new i,this.render_width=1,this.render_height=1,this.width_height=new i(this.width,this.height),this.dpr=1,this.pixel_size=new i(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update_size(e,t){this.width=e,this.height=t,this.pixel_size=new i(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=t,this.render_width=e*this.dpr,this.render_height=t*this.dpr}apply_pixel_density_v2(e){return e.multiplyScalar(1/this.dpr),e}apply_pixel_density(e){return e*(1/this.dpr)}get_pixel_size(){return this.pixel_size}get aspect_ratio(){return this.width/this.height}};class rt extends Be{constructor(e,t,r,s){super("\n uniform vec2 _ScreenSpacePosition;\n uniform vec2 _ScreenSize;\n uniform vec2 _TextureSize;\n varying vec2 vUv;\n void main()\n {\n vec2 pos = uv * vec2(_TextureSize.x / _ScreenSize.x, _TextureSize.y / _ScreenSize.y);\n pos += vec2(_ScreenSpacePosition.x / _ScreenSize.x, _ScreenSpacePosition.y / _ScreenSize.y);\n\n pos.x = pos.x * 2.0 - 1.0;\n pos.y = pos.y * 2.0 - 1.0;\n\n gl_Position = vec4(pos, 0.0, 1.0);\n vUv = uv;\n }\n ","\n uniform sampler2D _MainTex;\n varying vec2 vUv;\n\n void main()\n {\n gl_FragColor = texture2D(_MainTex, vUv);\n }\n ",{_MainTex:{value:void 0},_ScreenSpacePosition:{value:new i},_ScreenSize:{value:new i},_TextureSize:{value:new i}})}set_position(e,t){this.uniforms._ScreenSpacePosition.value.set(e,t)}set_texture(e,t,i){this.uniforms._MainTex.value=e,this.uniforms._TextureSize.value.set(e.image.width,e.image.height),void 0!==t&&(this.uniforms._TextureSize.value.x=t),void 0!==i&&(this.uniforms._TextureSize.value.y=i)}set_screen_size(e,t){this.uniforms._ScreenSize.value.set(e,t)}}class st extends S{constructor(e,t,i,r){super(e,t,i,r),this.clear_color=new s("#000000"),this.clear_alpha=1}}var nt=new class{init(){this.Vector3_one=new d(1,1,1),this.Vector3_zero=new d(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new v,this.camera=new st}draw_arrow(e,t,i=16711680){let r=new tt(i,t.length(),t.clone().normalize());return r.position.copy(e),Ke.current.add(r),r}draw_axis(){let e=new Ze;return Ke.current.add(e),e}set_debug_RT(e){this.rt_debug=e}draw_rectangle(e,t,i,r){t=t||100,i=i||100,this.ctx.fillStyle=r||"rgba(255, 0, 0, 1)",this.ctx.fillRect(e.x-t/2,this.ctx.canvas.height-e.y-i/2,t,i)}clear(){this.ctx&&this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}draw_line_2D(e,t,i){this.ctx.strokeStyle=i||"rgba(255, 0, 0, 1)",this.ctx.beginPath(),this.ctx.moveTo(e.x,e.y),this.ctx.lineTo(t.x,t.y),this.ctx.closePath(),this.ctx.stroke()}draw_line(e,t=16711680){let i=new p({color:t}),r=(new m).setFromPoints(e),s=new g(r,i);return s.frustumCulled=!1,Ke.current.add(s),s}draw_cube(e,t,i){t=t||1,i=i||16711680,e=e||new d;let r=new $e(new d(t,t,t),void 0,i);return r.position.copy(e),Ke.current.add(r),r}draw_oriented_cube(e,t,i=1,r="#FF0000",s=.1){let n=e.distanceTo(t),a=new $e(new d(s,i,n),void 0,r),o=t.clone().sub(e).multiplyScalar(.5),_=o.clone().normalize();return o.add(e),a.position.copy(o),a.quaternion.setFromUnitVectors(new d(0,0,-1),_),Ke.current.add(a),a}draw_plane(e,t,i){let s=new M(e,t),n=new r({uniforms:{_Color:{value:new F(0,1,0,.2)}},vertexShader:Ee,fragmentShader:je,transparent:!0,depthWrite:!1}),a=new f(s,n);return a.renderOrder=-1e4,Ke.current.add(a),a}draw_empty_cube(e,t,i){t=t||1,i=i||16711680;let r=(new z).setFromCenterAndSize(new d,new d(t,t,t)),s=new R(r,i);return s.position.copy(e||new d),s}draw_sphere(e,t,i){t=t||1,i=i||16711680,e=e||new d;let r=new et(t,i);return r.position.copy(e),Ke.current.add(r),r}draw_point_array(e,t=!1,i=16711680){let r=new A(e,t);r.updateArcLengths();let s=r.getSpacedPoints(200);return this.draw_line(s,65280)}draw_sphere_helper(e,t){t=t||16711680;let i=new C(e.radius,32,32),r=new w({color:t}),s=new f(i,r);return s.position.copy(e.center),Ke.current.add(s),s}draw_math_sphere(e){let t=new C(e.radius,32,32),i=new r({uniforms:{_Color:{value:new F(1,0,0,.2)}},vertexShader:Ee,fragmentShader:je,transparent:!0}),s=new f(t,i);s.position.copy(e.center),Ke.current.add(s)}draw_bounding_box(e){let t=new R(e,16776960);Ke.current.add(t)}draw_curve(e,t){let i=new d(0,0,0);t&&(i.y=t.offset||0);for(let t=0;t<e.length-1;t++)this.draw_line(e[t].clone().add(i),e[t+1].clone().add(i))}draw_texture(e,t,i){let r=new f(new M(1,1),new rt);return this.display_texture_meshes.push(r),this.scene.add(r),r.material.set_texture(e,t,i),r}render(e){for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(it.width,it.height);this.scene.children.length>0&&e.render(this.scene,this.camera)}};class at extends Ve{constructor(e,t){super("#define GLSLIFY 1\nuniform vec4 _DepthNormal;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(_DepthNormal.x),EncodeNormal(normalize(_DepthNormal.yzw)));}"),this.uniforms._DepthNormal={value:new F(e,t.x,t.y,t.z)}}}class ot extends r{constructor(){super({uniforms:{_FarPlane:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;v_normal=(modelViewMatrix*vec4(normal,0.0)).xyz;v_pos=(modelViewMatrix*vec4(pos,1.0)).xyz;gl_Position=MVP*vec4(pos,1.0);}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;uniform float _FarPlane;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(length(v_pos.z)/_FarPlane),EncodeNormal(normalize(v_normal)));}"})}set far_plane(e){this.uniforms._FarPlane.value=e}get far_plane(){return this.uniforms._FarPlane.value}}class _t{constructor(){this.RT=new D(it.width,it.height),this.clear_depth_normal_mat=new at(1,new d(0,0,1)),this.depth_normal_material=new ot}render(e){this.__resize_RT_if_necessary(),e.clear(this.RT,void 0,!0,!0),e.blit_clear_with_material(this.RT,this.clear_depth_normal_mat),this.depth_normal_material.far_plane=qe.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===it.width&&this.RT.height===it.height||this.RT.setSize(it.width,it.height)}get render_target(){return this.RT}}class lt{constructor(e){this.renderer=e,this._blit_scene=new v,this._blit_material=new Ve,this._blit_quad=new f(new M(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new P(-1,1,1,-1,-1e4,1e4)}blit(e,t){this._blit_quad.material=this._blit_material;let i=!0===e.isWebGLRenderTarget?e.texture:e,r=!0===e.isWebGLRenderTarget?e.width:e.image.width,s=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=i,this._blit_quad.material.uniforms._Resolution.value.set(r,s),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}material_pass(e,t){this._blit_quad.material=e,this.__render(t)}blit_with_material(e,t,i){let r=!0===e.isWebGLRenderTarget?e.texture:e,s=!0===e.isWebGLRenderTarget?e.width:e.image.width,n=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material=i,this._blit_quad.material.uniforms._MainTex.value=r,this._blit_quad.material.uniforms._Resolution.value.set(s,n),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}blit_clear_with_material(e,t){this._blit_quad.material=t,this.__render(e)}dispose(){this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose()}__render(e){e=void 0===e?null:e;let t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(void 0===e?null:e),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(t)}}var ht=new class{init(e,t){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.context_attributes=t||{alpha:!0,depth:!0,desynchronized:!1,stencil:!1,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1},t.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,console.log("Using WebGL "+(this.is_webgl2?2:1)),this._renderer=new L({canvas:e,context:this.canvas_context}),this._renderer.autoClear=!1,this._renderer.setPixelRatio(1),it.dpr=He.dpr,this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new lt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new ke,this.current_render_mode=this.no_render,Ye.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),Ye.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,Ye.fp_textures_available=this._renderer.capabilities.floatVertexTextures,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new _t}get dom_element(){return this._renderer.domElement}get depth_normals_RT(){return this.depth_and_normals_renderer.render_target}set_state(e){this.current_render_mode.on_exit(this,this._renderer),this.current_render_mode=e,this.current_render_mode.on_enter(this,this._renderer)}update(){this.check_for_resize(),this.generateDepthNormalTexture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),qe.current&&this.current_render_mode.render()}__update_current_camera(){qe.current&&(qe.current.aspect=it.aspect_ratio,qe.current.updateProjectionMatrix(),qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0))}render(e,t,i,r){this.__apply_override_material(e,r),this._renderer.setRenderTarget(void 0===i?null:i),this._renderer.render(e||Ke.current,t||qe.current),this.__apply_override_material(e,void 0)}render_scene(e){e.on_before_render&&e.on_before_render(),e.render&&e.render(),e.on_post_render&&e.on_post_render()}__apply_override_material(e,t){t=void 0===t?null:t,e?e.overrideMaterial=t:Ke.current.overrideMaterial=t}readback_RT(e,t){this._renderer.readRenderTargetPixels(e,0,0,e.width,e.height,t)}clear(e,t,i,r){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!i,!!r)}check_for_resize(){let e=this.canvas.clientWidth,t=this.canvas.clientHeight;if(e!==it.width||t!==it.height||He.dpr!==it.dpr){let i=this.canvas.getBoundingClientRect();it.dpr=He.dpr,it.update_position(i.x,i.y),it.update_size(e,t),this.canvas.width=it.render_width,this.canvas.height=it.render_height,this._renderer.setViewport(0,0,it.render_width,it.render_height),this.__update_current_camera()}}on_resize(){console.error("Graphics.on_resize call no longer needed.")}material_pass(e,t){this.blitter.material_pass(e,t)}blit(e,t,i){i?this.blitter.blit_with_material(e,t,i):this.blitter.blit(e,t)}blit_clear_with_material(e,t){this.blitter.blit_clear_with_material(e,t)}take_screenshot(e,t=it.width,i=it.height){let r=it.width,s=it.height,n=t,a=i,o=1024,_=1024,l=parseInt(Math.ceil(n/o)),h=parseInt(Math.ceil(a/_));it.update_size(o,_),this._renderer.setPixelRatio(1),this._renderer.setSize(o,_,!1);let c=document.createElement("canvas").getContext("2d");c.canvas.width=n,c.canvas.height=a,qe.current.aspect=it.aspect_ratio,qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)qe.current.setViewOffset(n,a,it.width*e,it.height*t,it.width,it.height),this.current_render_mode.render(),c.drawImage(this._renderer.domElement,it.width*e,it.height*t);c.canvas.toBlob(e,"image/png;base64;"),qe.current.clearViewOffset(),it.update_size(r,s),this._renderer.setPixelRatio(He.dpr),this._renderer.setSize(r,s,!1),qe.current.aspect=it.aspect_ratio,qe.current.updateMatrix(),qe.current.updateMatrixWorld(!0)}download_screenshot(e){let t=document.createElement("a");t.download="Snapshot.png",t.href=URL.createObjectURL(e),t.click(),t.onclick=function(){requestAnimationFrame((function(){URL.revokeObjectURL(t.href)})),t.removeAttribute("href")}}dispose(){this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose()}};class ct extends r{constructor(){super({uniforms:{},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);v_normal=(modelMatrix*vec4(normal,0.0)).xyz;}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_FragColor=vec4(v_normal*0.5+vec3(0.5),1.0);}"})}}class ut extends ke{constructor(){super()}render(){ht.clear(void 0,qe.current,!0,!0),ht.render(Ke.current,qe.current,void 0,new ct)}}var dt=new class extends ce{constructor(){super(),this.left_mouse_button_clicked=!1,this.captured_NDC={x:0,y:0}}clear(){super.clear(),this.left_mouse_button_clicked=!1}};var pt=new class{init(){this.target_geometry=void 0,this.target_position=new d}set_target_geometry(e){this.target_geometry=e}};class mt{constructor(e,t){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=t,this.data_textures=[],this.object_names=void 0,this.zero_offset=new i,this.write_offset=new i,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(e,t,i){this.material=new r({uniforms:this.uniforms,vertexShader:t,fragmentShader:i}),this.object_names=e}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){let i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(this.batch_width),s=this.__create_rgb_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){let i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(this.batch_width),s=this.__create_rgba_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){let i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(this.batch_width),s=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,i,r,s);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,i,r,s,n){let a=this.__get_object_index(e),o=this.__get_data_texture(t);this.__set_pixel_rgb(o.src,a,i,r,s,n),this.__set_pixel_rgb(o.one_pixel,0,i,r,s,n),o.last_accessed_index=a,o.dirty_count++}set_object_uniform_v4(e,t,i,r,s,n,a){let o=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,o,i,r,s,n,a),this.__set_pixel_rgba(_.one_pixel,0,i,r,s,n,a),_.last_accessed_index=o,_.dirty_count++}upload_texture_data(e,t){for(let i=0;i<this.data_textures.length;i++)t>0&&this.data_textures[i].dirty_count>0&&(1===this.data_textures[i].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[i]),this.data_textures[i].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[i]),this.data_textures[i].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){let i=t.last_accessed_index;-1!==i&&(this.write_offset.y=Math.floor(i/this.batch_width),this.write_offset.x=i-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new f(this.geometry,this.material)}__set_pixel_rgb(e,t,i,r,s,n){r&&(e.image.data[3*t+0]=i.x),s&&(e.image.data[3*t+1]=i.y),n&&(e.image.data[3*t+2]=i.z)}__set_pixel_rgba(e,t,i,r,s,n,a){r&&(e.image.data[4*t+0]=i.x),s&&(e.image.data[4*t+1]=i.y),n&&(e.image.data[4*t+2]=i.z),a&&(e.image.data[4*t+3]=i.w)}__flood_data_texture_rgb(e,t){for(let i=0;i<this.batch_width*this.batch_width;i++)this.__set_pixel_rgb(e.src,i,t,!0,!0,!0),e.dirty_count++}__flood_data_texture_rgba(e,t){for(let i=0;i<this.batch_width*this.batch_width;i++)this.__set_pixel_rgba(e.src,i,t,!0,!0,!0,!0),e.dirty_count++}__create_rgb_texture(e){let t=new Uint8Array(3*e*e);return new I(t,e,e,O)}__create_rgba_texture(e){let t=new Uint8Array(4*e*e);return new I(t,e,e,U)}__create_rgba_float_texture(e){let t=new Float32Array(4*e*e);return new I(t,e,e,U,N)}__get_data_texture(e){for(let t=0;t<this.data_textures.length;t++)if(this.data_textures[t].name===e)return this.data_textures[t];console.error("Data texture "+e+" does not exist")}__get_object_index(e){for(let t=0;t<this.object_names.length;t++)if(this.object_names[t]===e)return t;console.error("the name "+e+" is not contained in this batch")}__add_data_texture(e,t,i,r){return i.needsUpdate=!0,this.data_textures.push({name:e,src:t,dst:i,one_pixel:r,last_accessed_index:-1,dirty_count:0}),this.uniforms[e]={value:i},this.data_textures[this.data_textures.length-1]}dispose(){for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].src.dispose(),this.data_textures[e].dst.dispose(),this.data_textures[e].one_pixel.dispose()}}var gt=new class{init(){this.batches=[]}batch(t){let i=[],r=e.ceilPowerOfTwo(Math.sqrt(t.length));this.__init_uv_array(i,r);let s=0;for(let e=0;e<t.length;e++){let n=t[e].getAttribute("position").count,a=Math.floor(e/r),o=e-r*a;for(let e=0;e<n;e++)i[s]=o/r+.5/r,i[s+1]=a/r+.5/r,s+=2}let n=new k(new Float32Array(i),2),a=he.mergeBufferGeometries(t);return a.setAttribute("attr_accessor_uv",n),this.batches.push(new mt(a,r)),this.batches[this.batches.length-1]}upload_texture_data(e){for(let t=0;t<this.batches.length;t++)this.batches[t].upload_texture_data(e,1)}__init_uv_array(e,t){for(let i=0;i<t*t*2;i++)e.push(0)}};var vt=new class{init(){this.ui_elements=[],this._tmp_normalized_pos=new i,this.ss_scene=new v,this.ss_scene.autoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new v,this.ws_scene.autoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new P(-1,1,1,-1,-100,100)}delete_element(e){let t=this.ui_elements.indexOf(e);t>-1&&this.ui_elements.splice(t,1),this.ss_scene.remove(e),this.ws_scene.remove(e),e.dispose()}add_screen_space_element(e){this.ui_elements.push(e),this.ss_scene.add(e),e.set_screen_space_coordinate_system()}add_world_space_element(e){this.ui_elements.push(e),this.ws_scene.add(e),e.set_world_space_coordinate_system()}update(){this.ss_camera.updateProjectionMatrix(),this._tmp_normalized_pos.copy(dt.NDC);for(let e=0;e<this.ui_elements.length;e++)this.ui_elements[e].update_state(this._tmp_normalized_pos)}render(e){this.ss_scene.children.length>0&&ht.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&ht.render(this.ws_scene,qe.current)}clear(){this.current_clicked_element=void 0}};class ft{constructor(){}static linear_map(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}static between(e,t,i){return e>=t&&e<=i}static mod(e,t){return(e%t+t)%t}static rgb_to_hex(e){return e.r=Math.round(255*e.r).toString(16),e.g=Math.round(255*e.g).toString(16),e.b=Math.round(255*e.b).toString(16),1===e.r.length&&(e.r="0"+e.r),1===e.g.length&&(e.g="0"+e.g),1===e.b.length&&(e.b="0"+e.b),"#"+e.r+e.g+e.b}static project_points_on_plane(e,t){let i=new d,r=[];for(let s=0;s<e.length;s++)t.projectPoint(e[s],i),r.push(i.clone());return r}static matrix4_lerp(t,i,r,s){for(let n=0;n<16;n++)r.elements[n]=e.lerp(t.elements[n],i.elements[n],s)}static equals(e,t){return Math.abs(e-t)<1e-6}static perspective_divide(e){return e.x/=e.w,e.y/=e.w,e.z/=e.w,e}static points_average(e){let t=e[0].clone();for(let i=1;i<e.length;i++)t.add(e[i]);return t.multiplyScalar(1/e.length),t}static get_random_color(){let e=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"],t="#";return t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t+=e[Math.floor(16*Math.random())],t}}var xt=new class{init(){this.tmp_mat=new E,this.tmp_vec=new d(0,0,1),this.tmp_vec2=new d(0,0,0),this.plane=new j,this.ray=new B,this.tmp_size=new d,this.tmp_unproj=new d}get_up_dir(e){return e=e||qe.current,this.tmp_vec.set(0,1,0),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}get_forward_dir(e){return e=e||qe.current,this.tmp_vec.set(0,0,-1),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}get_right_dir(e){return e=e||qe.current,this.tmp_vec.set(1,0,0),this.tmp_vec.applyQuaternion(e.quaternion),this.tmp_vec}unproject_mouse_position(e,t){let i=(t=t||qe.current).fov/2*Math.PI/180,r=2*Math.atan(Math.tan(i)*t.aspect)/2,s=Math.tan(i)*t.far,n=Math.tan(r)*t.far;return this.tmp_vec.set(n*e.x,s*e.y,-t.far).normalize(),this.tmp_vec.applyQuaternion(t.quaternion)}get_plane_intersection(e,t,i,r){return r=r||qe.current,i=i||dt.NDC,this.plane.setFromNormalAndCoplanarPoint(t||this.get_forward_dir(r),e),r.isPerspectiveCamera?this.ray.set(r.position,this.unproject_mouse_position(i,r)):(this.tmp_unproj.set(i.x,i.y,1).unproject(r),this.ray.set(r.position,this.tmp_unproj)),this.ray.intersectPlane(this.plane,this.tmp_vec2),this.tmp_vec2}fit_points_on_camera(e,t=1){let i=(new G).setFromPoints(e).center,r=this.get_forward_dir(qe.current).clone(),s=(new j).setFromNormalAndCoplanarPoint(r,i),n=ft.project_points_on_plane(e,s),a=new d,o=(new z).setFromPoints(n);o.getCenter(a);let _=new d(0,1,0).applyQuaternion(qe.current.quaternion),l=_.clone().cross(r).normalize(),h=(new E).set(l.x,_.x,r.x,i.x,l.y,_.y,r.y,i.y,l.z,_.z,r.z,i.z,0,0,0,1),c=(new E).getInverse(h);for(let e=0;e<n.length;e++)n[e].applyMatrix4(c);let u=new d;o=(new z).setFromPoints(n),o.getSize(u),u.multiplyScalar(t);let p=new d;return o.getCenter(p),{position:a,zoom:this.get_zoom_to_fit_rect(u.x/2,u.y/2)}}get_zoom_to_fit_rect(e,t){let i=qe.current.fov/2*Math.PI/180,r=2*Math.atan(Math.tan(i)*qe.current.aspect)/2,s=t/Math.tan(i),n=e/Math.tan(r);return Math.max(Math.abs(n),Math.abs(s))}get_zoom_to_fit_box(e,t){if(t.isOrthographicCamera){e.getSize(this.tmp_size);let t=this.tmp_size.x,i=this.tmp_size.y,r=t/i;return it.aspect_ratio/r>1?it.height/i:it.width/t}{let t=new d;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){return e.getWorldPosition(this.tmp_vec),this.tmp_vec.project(t),this.tmp_vec.x=(.5*this.tmp_vec.x+.5)*it.width,this.tmp_vec.y=(1-(.5*this.tmp_vec.y+.5))*it.height,this.tmp_vec}world_pos_to_screen(e,t){return t=t||qe.current,this.tmp_vec.copy(e),this.tmp_vec.project(t),this.tmp_vec.x=(.5*this.tmp_vec.x+.5)*it.width,this.tmp_vec.y=(1-(.5*this.tmp_vec.y+.5))*it.height,this.tmp_vec}update_projection(e){e.left=-it.width/2,e.right=it.width/2,e.top=it.height/2,e.bottom=-it.height/2,e.aspect=it.aspect_ratio,e.updateProjectionMatrix(!0)}};var wt=new class{constructor(){}init(e,t,i){qe.init(),xt.init(),Ye.init(),He.init(),Ae.init(),gt.init(),dt.init(t),fe.init(),pt.init(),Ce.init(),Ke.init(),it.init(),Pe.init(),vt.init(),ht.init(e,i),nt.init()}dispose(e){ht.dispose(),dt.dispose(),Ke.dispose(),e.dispose()}};class bt extends we{constructor(e,t,i){super(e,t,i),this.loader=new V}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,JSON.parse(i)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}var yt="#define GLSLIFY 1\nvarying vec2 vUv;varying vec4 vRay;uniform mat4 _InverseProjMatrix;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vRay=_InverseProjMatrix*vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}";class Tt extends Ve{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}",yt),this.uniforms._InverseProjMatrix={value:new E},this.uniforms._ProjectionMatrix={value:new E},this.uniforms._Bias={value:.0125},this.uniforms._Radius={value:.3},this.uniforms._FarPlane={value:100},this.uniforms._SampleKernel={value:this.__get_sample_kernel()},this.uniforms._RandomRotation={value:this.__get_rotation_kernel()}}__get_sample_kernel(){let t=[];for(let i=0;i<64;i++){let r=new d(2*Math.random()-1,2*Math.random()-1,Math.random());r.normalize();let s=i/64;s=e.lerp(.1,1,s*s),r.multiplyScalar(s),t.push(r)}return t}__get_rotation_kernel(){let e=new Uint8Array(48);for(let t=0;t<16;t++)e[3*t+1]=Math.floor(255*Math.random()),e[3*t+2]=Math.floor(255*Math.random()),e[3*t+3]=0;let t=new I(e,4,4,O);return t.wrapS=q,t.wrapT=q,t.needsUpdate=!0,t}}class St extends Ve{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _AO;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){gl_FragColor.rgb=texture2D(_MainTex,vUv).rgb*(1.0-texture2D(_AO,vUv).r);gl_FragColor.a=1.0;}"),this.uniforms._AO={value:void 0}}}class Mt extends Ve{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}",yt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new E}}}class Ft extends Ve{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){vec4 sum=vec4(0.,0.,0.,0.);vec2 dir=(0.5/_Resolution)*_SampleDir;float _Distance=2.0;sum+=texture2D(_MainTex,vUv+dir*-4.*_Distance)*0.0525;sum+=texture2D(_MainTex,vUv+dir*-3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*-2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*-1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*0.*_Distance)*0.225;sum+=texture2D(_MainTex,vUv+dir*1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*4.*_Distance)*0.0525;gl_FragColor=vec4(sum);}"),this.uniforms._SampleDir={value:new i}}}class zt{constructor(e){this.RT1=new D(1,1),this.RT2=new D(1,1),this.box_blur_mat=new Ft}blur(e){e.width===this.RT1.width&&e.height===this.RT1.height||(this.RT1.setSize(e.width,e.height),this.RT2.setSize(e.width,e.height)),this.box_blur_mat.uniforms._SampleDir.value.set(1,0),ht.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),ht.blit(this.RT1,e,this.box_blur_mat)}}class Rt extends ke{constructor(){super(),this.ssao_mat=new Tt,this.ssao_compose_mat=new St,this.debug_normals=new Mt,this.ssaa=He.use_ssaa?2:1,this.main_RT=new D(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT=new D(it.width,it.height),this.blurrer=new zt,ht.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),ht.clear(this.main_RT,qe.current,!0,!1),ht.render(Ke.current,qe.current,this.main_RT),this.__update_uniforms(),ht.blit(ht.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),ht.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,ht.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(qe.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(qe.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=qe.current.far}__check_RT_size(){this.main_RT.width===it.width*this.ssaa&&this.main_RT.height===it.height*this.ssaa||(this.main_RT.setSize(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT.setSize(it.width,it.height))}}class At extends ke{constructor(){super()}render(){ht.clear(void 0,qe.current,!0,!0),Ke.current.on_pre_render&&Ke.current.on_pre_render(),Ke.current.render?Ke.current.render():ht.render(Ke.current,qe.current),Ke.current.on_post_render&&Ke.current.on_post_render()}}class Ct extends Ve{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};let t=[new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF"),new s("#FFFFFF")];this.uniforms.bloomTintColors={value:t}}set_RT_0(e){this.uniforms.blurTexture1.value=e}set_RT_1(e){this.uniforms.blurTexture2.value=e}set_RT_2(e){this.uniforms.blurTexture3.value=e}set_RT_3(e){this.uniforms.blurTexture4.value=e}set_RT_4(e){this.uniforms.blurTexture5.value=e}set_bloom_strength(e){this.uniforms.bloomStrength.value=e}set_bloom_radius(e){this.uniforms.bloomRadius.value=e}set_tint_color_0(e){this.uniforms.bloomTintColors.value[0].set(e)}set_tint_color_1(e){this.uniforms.bloomTintColors.value[1].set(e)}set_tint_color_2(e){this.uniforms.bloomTintColors.value[2].set(e)}set_tint_color_3(e){this.uniforms.bloomTintColors.value[3].set(e)}set_tint_color_4(e){this.uniforms.bloomTintColors.value[4].set(e)}}class Dt extends Ve{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}class Pt extends Ve{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new i(.5,.5)},this.uniforms.direction={value:new i(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class Lt extends Ve{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new s("#000000")},this.uniforms.defaultOpacity={value:0}}}class It{constructor(e=5){this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=e,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:Y,magFilter:Y,format:U},this.renderTargetBright=new D(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Lt}blur(e,t){this.resize_RT(e.width,e.height),t?ht.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):ht.blit(e,this.renderTargetBright);let i=this.renderTargetBright;for(let e=0;e<this.nMips;e++){let t=this.separableBlurMaterials[e];t.set_direction(1,0),ht.blit(i,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),ht.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),i=this.renderTargetsVertical[e]}}get_blurred_texture(){return this.renderTargetsHorizontal[0].texture}get_blurred_RT(){return this.renderTargetsHorizontal[0]}init_RT(){this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(let e=0;e<this.nMips;e++){let e=new D(1,1,this.rt_pars),t=new D(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e),this.renderTargetsVertical.push(t)}}resize_RT(e,t){if(this.current_width===e&&this.current_height===t)return;this.current_width=e,this.current_height=t;let i=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(i,r);for(let e=0;e<this.nMips;e++)this.renderTargetsVertical[e].setSize(i,r),this.renderTargetsHorizontal[e].setSize(i,r),this.separableBlurMaterials[e].set_size(i,r),i=Math.round(i/2),r=Math.round(r/2)}init_materials(e,t){this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new Pt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class Ot extends ke{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new Dt}on_enter(){this.blurrer=new It,this.main_RT=new D(it.render_width,it.render_height),this.blur_RT=new D(it.render_width,it.render_height),this.bloom_compose_mat=new Ct(5),this.blurrer=new It(5),this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture),this.bloom_compose_mat.set_bloom_strength(1),this.bloom_compose_mat.set_bloom_radius(1),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.bloom_compose_mat.set_bloom_radius(e)}set_tint_color_0(e){this.bloom_compose_mat.set_tint_color_0(e)}set_tint_color_1(e){this.bloom_compose_mat.set_tint_color_1(e)}set_tint_color_2(e){this.bloom_compose_mat.set_tint_color_2(e)}set_tint_color_3(e){this.bloom_compose_mat.set_tint_color_3(e)}set_tint_color_4(e){this.bloom_compose_mat.set_tint_color_4(e)}render(){this.__check_RT_size(),ht.clear(this.main_RT,qe.current,!0,!1),ht.render(Ke.current,qe.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),ht.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),ht.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===it.render_width&&this.main_RT.height===it.render_height||(this.main_RT.setSize(it.render_width,it.render_height),this.blur_RT.setSize(it.render_width,it.render_height))}}class Ut extends P{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.clear_color=new s("#000000"),this.clear_alpha=1}}var Nt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){for(let e of this.enabled_components)e.update(Oe.transition_handler.current_state_data)}register_component(e){this.components.push(e)}enable_component(e){this.enabled_components.add(e)}disable_component(e){this.enabled_components.delete(e)}get_component_by_name(e){console.warn("DEPRECATED. Use ViewComponentManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.components.length;t++)if(this.components[t].name===e)return this.components[t];console.error("[ViewComponentManager.get] no component found for: ",e)}};class kt{constructor(e,t){e=e||new Ne,this._frame_id=-1,this.target_application=e,this.graphics=t,this.is_running=!1,this.frames_passed=0}update(){this.is_running&&(Pe.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.target_application.update(),Oe.update(),Nt.update(),this.target_application.on_pre_render(),this.graphics.update(),vt.update(),vt.render(this.graphics),this.target_application.on_post_render(),nt.render(this.graphics),dt.clear(),vt.clear(),nt.clear(),this._frame_id=requestAnimationFrame(this.update.bind(this)),this.frames_passed++)}start(){this.is_running||(this.graphics.check_for_resize(),0===this.frames_passed&&this.target_application.on_enter(),this.is_running=!0,this.update())}stop(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(),cancelAnimationFrame(this._frame_id))}set_state(e){this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this)}dispose(){this.stop(),this.frames_passed=0}}class Et extends we{constructor(e,t,i){super(e,t,i),this.loader=new W}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(()=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯"),t.__loading_ended()}))}}class jt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ue.GLTFLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Bt extends we{constructor(e,t,i){super(e,t,i),this.loader=new de.ColladaLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Gt extends we{constructor(e,t,i){super(e,t,i),this.loader=new V}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class Vt extends we{constructor(e,t,i){super(e,t,i),this.loader=new H,this.loader.setPath(t+"/"),this.urls=["px.png","nx.png","py.png","ny.png","pz.png","nz.png"]}on_preloaded_finished(e){let t=this;this.loader.load(this.urls,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class qt{constructor(e,t=!0,i=1){this.buffer=e,this.loop=t,this.volume=i,this.audio=void 0}init(e){this.audio=new Q(e),this.audio.setBuffer(this.buffer),this.audio.setLoop(this.loop),this.audio.setVolume(this.volume)}play(){this.audio.play()}pause(){this.audio.pause()}stop(){this.audio.stop()}get is_playing(){return this.audio.isPlaying}}class Yt extends we{constructor(e,t,i=!0,r=1,s){super(e,t,s),this.loader=new X,this.loop=i,this.volume=r}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,new qt(i,this.loop,this.volume)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Audio could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class Wt extends we{constructor(e,t,i){super(e,t,i),this.loader=new pe.OBJLoader}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ht extends we{constructor(e,t,i){super(e,t,i),this.loader=new J}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Qt extends we{constructor(e,t,i){super(e,t,i),this.loader=new me.RGBELoader,this.loader.setDataType(Z)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Xt extends we{constructor(e,t,i){super(e,t,i),this.loader=new V}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,t.parse_path(i)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}parse_path(e){let t=e.split("\n");""===t[t.length-1]&&t.pop();let i=[];for(let e=0;e<t.length;e+=3){let r=parseFloat(t[e+0]),s=parseFloat(t[e+1]),n=parseFloat(t[e+2]);i.push(new d(r,s,n))}return i}}class Jt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ge.HDRCubeTextureLoader,this.url_suffix=["/px.hdr","/nx.hdr","/py.hdr","/ny.hdr","/pz.hdr","/nz.hdr"]}on_preloaded_finished(e){let t=this;this.loader.setPath(this.url).setDataType(Z).load(this.url_suffix,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Zt extends we{constructor(e,t,i){super(e,t,i),this.loader=new ue.GLTFLoader,this.draco_loader=new ve.DRACOLoader,this.draco_loader.setDecoderPath(window.draco_decoder_path),this.draco_loader.setDecoderConfig({type:"js"}),this.loader.setDRACOLoader(this.draco_loader)}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Kt extends we{constructor(e,t,i){super(e,t,i),this.loader=new V}on_preloaded_finished(e){let t=this;this.loader.load(this.url,(i=>{e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class $t{constructor(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}add_texture(e,t,i){this.resource_loaders.push(new Et(e,t,i))}add_gltf(e,t,i){this.resource_loaders.push(new jt(e,t,i))}add_basis(e,t,i,r,s){this.resource_loaders.push(new Ge(e,t,i,r,s))}add_gltf_draco(e,t,i){this.resource_loaders.push(new Zt(e,t,i))}add_dae(e,t,i){this.resource_loaders.push(new Bt(e,t,i))}add_obj(e,t,i){this.resource_loaders.push(new Wt(e,t,i))}add_file(e,t,i){this.resource_loaders.push(new Kt(e,t,i))}add_text(e,t,i){this.resource_loaders.push(new Gt(e,t,i))}add_cubemap(e,t,i){this.resource_loaders.push(new Vt(e,t,i))}add_audio(e,t,i,r,s){this.resource_loaders.push(new Yt(e,t,i,r,s))}add_json(e,t,i){this.resource_loaders.push(new bt(e,t,i))}add_point_array(e,t,i){this.resource_loaders.push(new Xt(e,t,i))}add_hdr(e,t,i){this.resource_loaders.push(new Qt(e,t,i))}add_hdr_cubemap(e,t,i){this.resource_loaders.push(new Jt(e,t,i))}add_font(e,t,i){this.resource_loaders.push(new Ht(e,t,i))}add_loader(e){this.resource_loaders.push(e)}load(e){for(let t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||Ce)}get loading_finished(){let e=!0;for(let t=0;t<this.resource_loaders.length;t++)e=e&&this.resource_loaders[t].has_finished;return e}get has_errors(){let e=!1;for(let t=0;t<this.resource_loaders.length;t++)e=e||this.resource_loaders[t].has_error;return e}print_errors(){console.error("Batch <"+this.batch_name+"> could not load successfully");for(let e=0;e<this.resource_loaders.length;e++)this.resource_loaders[e].has_error&&this.resource_loaders[e].print_error()}get_progress(){return this.get_loaded_bytes()/this.get_total_bytes()}get_loaded_bytes(){let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].loaded_bytes;return e}get_total_bytes(){let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].total_bytes;return e}}class ei extends We{constructor(){super(),this.text_margin=new i(2,0)}__draw(e,t,i,r){r.font=t.font;let s=this.get_text_size(e,t.font);i.width=Math.ceil(s.x+2*this.text_margin.x),i.height=Math.ceil(s.y+2*this.text_margin.y),r.clearRect(0,0,i.width,i.height),r.globalAlpha=0,r.fillStyle=t.font_color||"#000000",r.fillRect(0,0,i.width,i.height),r.globalAlpha=1,r.globalAlpha=1,r.font=t.font,r.fillStyle=t.font_color||"#000000",r.textBaseline="middle",r.textAlign=t.textAlign||"center","center"===r.textAlign?r.fillText(e,i.width/2,i.height/2):r.fillText(e,0,i.height/2)}}class ti{constructor({name:e,container:t}){this.name=e,this.container=t,Nt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),Nt.enable_component(this)}update(){}on_exit(){this.container.classList.add("hidden"),Nt.disable_component(this)}set_opacity(e){this.container.style.opacity=e}}class ii extends f{constructor(e,t,i,r){e=e||1,t=t||1,i=i||"#FF0000",r=r||new w({color:i});let s=new M(e,t);s.rotateX(-1.57),super(s,r)}}class ri extends f{constructor(e,t,i,r){e=e||1,t=t||1,i=i||"#FF0000",r=r||new w({color:i}),super(new M(e,t),r)}}class si{constructor(){}static merge_from_to(e,t){t.push.apply(t,e)}static expand_vec3_array(e,t){let i=t-e.length;for(let t=0;t<i;t++)e.push(e[t].clone())}static remove_elem(e,t){let i=e.indexOf(t);i>-1&&e.splice(i,1)}static get_closest_point(e,t){let i=e[0],r=i.distanceTo(t);for(let s=1;s<e.length;s++)e[s].distanceTo(t)<r&&(i=e[s],r=e[s].distanceTo(t));return i}static object_values_to_array(e){let t=Object.keys(e),i=[];for(let r=0;r<t.length;r++)i.push(e[t[r]]);return i}}class ni{constructor(){this.sphere=new G}fit_points(e,t,i,r){this.sphere.setFromPoints(e);let s=Math.degToRad(i/2),n=2*Math.atan(Math.tan(s)*r)/2,a=this.get_up_plane_normal(t,s),o=this.get_down_plane_normal(t,s),_=this.get_left_plane_normal(t,n),l=this.get_right_plane_normal(t,n),h=new d(0,0,-1).applyQuaternion(t),c=this.sphere.center.clone(),u=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=c.clone().add(h.clone().multiplyScalar(-1*u)),m=(new j).setFromNormalAndCoplanarPoint(a,p),g=(new j).setFromNormalAndCoplanarPoint(o,p),v=(new j).setFromNormalAndCoplanarPoint(_,p),f=(new j).setFromNormalAndCoplanarPoint(l,p);this.apply_center_correction_to_pos(p,e,t,m,g,v,f),m.setFromNormalAndCoplanarPoint(a,p),g.setFromNormalAndCoplanarPoint(o,p),v.setFromNormalAndCoplanarPoint(_,p),f.setFromNormalAndCoplanarPoint(l,p);let x=1/0,w=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){let i=new K(e[t].clone(),e[t].clone().add(w)),r=new d,s=new d,n=new d,a=new d;m.intersectLine(i,r),g.intersectLine(i,s),v.intersectLine(i,n),f.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",t),s.length()<1e-4&&console.log("down intersection not found",t),n.length()<1e-4&&console.log("left intersection not found",t),a.length()<1e-4&&console.log("right intersection not found",t);let o=e[t].clone().sub(r).length(),_=e[t].clone().sub(s).length(),l=e[t].clone().sub(n).length(),h=e[t].clone().sub(a).length(),c=Math.min(o,_),u=Math.min(l,h),p=Math.min(c,u);p<x&&(x=p)}let b=h.clone().multiplyScalar(x);return p.clone().add(b)}apply_center_correction_to_pos(e,t,i,r,s,n,a){let o=this.get_vertical_correction(t,s,r,i),_=this.get_hozirontal_correction(t,n,a,i);e.add(o),e.add(_)}get_vertical_correction(e,t,i,r){let s,n,a=1/0,o=1/0,_=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let l=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(-5e6))),h=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(l,c),i.intersectLine(h,u);let p=c.distanceTo(e[r]),m=u.distanceTo(e[r]);u.length()<1e-4&&console.log("vertical up intersection not found",r),c.length()<1e-4&&console.log("vertical down intersection not found",r),p<o&&(o=p,n=e[r]),m<a&&(a=m,s=e[r])}console.log(s,n);let l=(a-o)/2;return _.clone().multiplyScalar(-l)}get_hozirontal_correction(e,t,i,r){let s,n,a=1/0,o=1/0,_=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let l=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(-5e6))),h=new K(e[r].clone(),e[r].clone().add(_.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(l,c),i.intersectLine(h,u);let p=c.distanceTo(e[r]),m=u.distanceTo(e[r]);c.length()<1e-4&&console.log("left intersection not found",r),u.length()<1e-4&&console.log("right intersection not found",r),p<o&&(o=p,n=e[r]),m<a&&(a=m,s=e[r])}let l=(a-o)/2;return console.log(s,n),_.clone().multiplyScalar(-l)}get_up_plane_normal(e,t){let i=new d(0,-1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),t)),i.applyQuaternion(e),i}get_down_plane_normal(e,t){let i=new d(0,1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),-t)),i.applyQuaternion(e),i}get_left_plane_normal(e,t){let i=new d(1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),t)),i.applyQuaternion(e),i}get_right_plane_normal(e,t){let i=new d(-1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),-t)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class ai{static convert_to_non_indexed_geometry(e){let t=e.index,i=e.getAttribute("position"),r=[];for(let e=0;e<t.count;e+=3)r.push(i.getX(t.array[e+0])),r.push(i.getY(t.array[e+0])),r.push(i.getZ(t.array[e+0])),r.push(i.getX(t.array[e+1])),r.push(i.getY(t.array[e+1])),r.push(i.getZ(t.array[e+1])),r.push(i.getX(t.array[e+2])),r.push(i.getY(t.array[e+2])),r.push(i.getZ(t.array[e+2]));let s=new m;return s.setAttribute("position",new k(new Float32Array(r),3)),ai.add_barycentric_attribute(s),s}static add_barycentric_attribute(e){let t=[],i=e.getAttribute("position");for(let e=0;e<i.count;e+=3)t.push(1),t.push(0),t.push(0),t.push(0),t.push(1),t.push(0),t.push(0),t.push(0),t.push(1);e.setAttribute("barycentric",new k(new Float32Array(t),3))}}class oi{constructor(){}static get_image_data(e){let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");return i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height)}static get_pixel(e,t,i){let r=4*(t+e.width*i),s=e.data;return new F(s[r+0],s[r+1],s[r+2],s[r+3])}}var _i=new class{constructor(){}sample(e,t){let i=[],r=99999999;for(let t=0;t<e.faces.length;t++){let s=this.get_face_area(e.faces[t],e.vertices);r=Math.min(s,r),i.push(s)}let s=this.get_uniform_face_distribution(i,r,e.faces),n=this.select_random_faces(s,t);return this.sample_data_from_faces(n,e.vertices)}sample_data_from_faces(e,t){let i=[],r=[];for(let s=0;s<e.length;s++){let n=e[s],a=Math.random(),o=Math.random();i.push(this.sample_point_in_face(a,o,t[n.a],t[n.b],t[n.c]).clone()),r&&n.normal&&r.push(n.normal.clone())}return{points:i,normals:r}}select_random_faces(e,t){let i=[];for(let r=0;r<t;r++){let t=e[parseInt(Math.random()*(e.length-1))];i.push(t)}return i}get_uniform_face_distribution(e,t,i){let r=[];for(let s=0;s<e.length;s++){e[s]/=t;let n=parseInt(Math.round(e[s]));for(let e=0;e<n;e++)r.push(i[s])}return r}get_face_area(e,t){let i=t[e.a].clone(),r=t[e.b].clone(),s=t[e.c].clone(),n=r.clone().sub(i),a=s.clone().sub(i);return n.cross(a).length()/2}sample_point_in_face(e,t,i,r,s){e+t>1&&(e=1-e,t=1-t);let n=1-(e+t);return i.clone().multiplyScalar(e).add(r.clone().multiplyScalar(t)).add(s.clone().multiplyScalar(n))}};var li=new class{get_mesh(e,t){e.traverse((e=>{e instanceof f&&(e.geometry&&(e.geometry=(new m).fromGeometry(e.geometry)),t(e))}))}get_geometries(e){let t=[];return this.get_mesh(e,(e=>{t.push(e.geometry)})),t}assign_material(e,t,i){e.traverse((e=>{e instanceof f&&(void 0===i||e.name===i)&&(e.material=t)}))}clone_animated_gltf(e){const t={animations:e.animations,scene:e.scene.clone(!0)},i={};e.scene.traverse((e=>{e.isSkinnedMesh&&(i[e.name]=e)}));const r={},s={};t.scene.traverse((e=>{e.isBone&&(r[e.name]=e),e.isSkinnedMesh&&(s[e.name]=e)}));for(let e in i){const t=i[e].skeleton,n=s[e],a=[];for(let e=0;e<t.bones.length;++e){const i=r[t.bones[e].name];a.push(i)}n.bind(new ee(a,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,i){e.traverse((e=>{e instanceof f&&(e.castShadow=t,e.receiveShadow=i)}))}__find_object(e,t,i){e.traverse((e=>{e.name===t&&i(e)}))}get_object(e,t){let i;return e.traverse((e=>{e.name===t&&(i=e)})),i}get_object_by_type(e,t){let i;return e.traverse((e=>{e.constructor.name===t&&(i=e)})),i}};class hi{constructor(){}static xml_to_json(e){let t={};if(1===e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(let i=0;i<e.attributes.length;i++){let r=e.attributes.item(i);t["@attributes"][r.nodeName]=r.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let i=0;i<e.childNodes.length;i++){let r=e.childNodes.item(i),s=r.nodeName;if(void 0===t[s])t[s]=this.xml_to_json(r);else{if(void 0===t[s].push){let e=t[s];t[s]=[],t[s].push(e)}t[s].push(this.xml_to_json(r))}}return t}}class ci{constructor(){}static capitalize(e){const t=e.split(" ");for(let e=0;e<t.length;e++)t[e]=t[e][0].toUpperCase()+t[e].substr(1);return t.join(" ")}static capitalize_first_letter(e){return e.charAt(0).toUpperCase()+e.slice(1)}static snake_to_camelcase(e){return e.replace(/([-_][a-z])/g,(e=>e.toUpperCase().replace("-","").replace("_","")))}}class ui{constructor(){}time_str_to_ms(e){e=e.split(":");let t=Number(e[0]);t=60*t*60*1e3;let i=Number(e[1]);i=60*i*1e3;let r=Number(e[2]);return r*=1e3,t+i+r}}class di{constructor(){this.sphere=new G}fit_points(t,i,r,s){this.sphere.setFromPoints(t);let n=e.degToRad(r/2),a=2*Math.atan(Math.tan(n)*s)/2,o=this.get_up_plane_normal(i,n),_=this.get_down_plane_normal(i,n),l=this.get_left_plane_normal(i,a),h=this.get_right_plane_normal(i,a),c=new d(0,0,-1).applyQuaternion(i),u=this.sphere.center.clone(),p=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,r,s),m=u.clone().add(c.clone().multiplyScalar(-1*p)),g=(new j).setFromNormalAndCoplanarPoint(o,m),v=(new j).setFromNormalAndCoplanarPoint(_,m),f=(new j).setFromNormalAndCoplanarPoint(l,m),x=(new j).setFromNormalAndCoplanarPoint(h,m);this.apply_center_correction_to_pos(m,t,i,g,v,f,x),g.setFromNormalAndCoplanarPoint(o,m),v.setFromNormalAndCoplanarPoint(_,m),f.setFromNormalAndCoplanarPoint(l,m),x.setFromNormalAndCoplanarPoint(h,m);let w=1/0,b=c.clone().multiplyScalar(-2*p);for(let e=0;e<t.length;e++){let i=new K(t[e].clone(),t[e].clone().add(b)),r=new d,s=new d,n=new d,a=new d;g.intersectLine(i,r),v.intersectLine(i,s),f.intersectLine(i,n),x.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",e),s.length()<1e-4&&console.log("down intersection not found",e),n.length()<1e-4&&console.log("left intersection not found",e),a.length()<1e-4&&console.log("right intersection not found",e);let o=t[e].clone().sub(r).length(),_=t[e].clone().sub(s).length(),l=t[e].clone().sub(n).length(),h=t[e].clone().sub(a).length(),c=Math.min(o,_),u=Math.min(l,h),p=Math.min(c,u);p<w&&(w=p)}let y=c.clone().multiplyScalar(w);return m.clone().add(y)}apply_center_correction_to_pos(e,t,i,r,s,n,a){let o=this.get_vertical_correction(t,s,r,i),_=this.get_horizontal_correction(t,n,a,i);e.add(o),e.add(_)}get_vertical_correction(e,t,i,r){let s=1/0,n=1/0,a=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let o=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),_=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),l=new d,h=new d;t.intersectLine(o,l),i.intersectLine(_,h);let c=l.distanceTo(e[r]),u=h.distanceTo(e[r]);h.length()<1e-4&&console.log("vertical up intersection not found",r),l.length()<1e-4&&console.log("vertical down intersection not found",r),c<n&&(n=c),u<s&&(s=u)}let o=(s-n)/2;return a.clone().multiplyScalar(-o)}get_horizontal_correction(e,t,i,r){let s=1/0,n=1/0,a=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){let o=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),_=new K(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),l=new d,h=new d;t.intersectLine(o,l),i.intersectLine(_,h);let c=l.distanceTo(e[r]),u=h.distanceTo(e[r]);l.length()<1e-4&&console.log("left intersection not found",r),h.length()<1e-4&&console.log("right intersection not found",r),c<n&&(n=c),u<s&&(s=u)}let o=(s-n)/2;return a.clone().multiplyScalar(-o)}get_up_plane_normal(e,t){let i=new d(0,-1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),t)),i.applyQuaternion(e),i}get_down_plane_normal(e,t){let i=new d(0,1,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(1,0,0),-t)),i.applyQuaternion(e),i}get_left_plane_normal(e,t){let i=new d(1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),t)),i.applyQuaternion(e),i}get_right_plane_normal(e,t){let i=new d(-1,0,0);return i.applyQuaternion((new $).setFromAxisAngle(new d(0,1,0),-t)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class pi{constructor(){}fit_points(e,t,i,r){let s=t.clone().inverse(),n=[];for(let t=0;t<e.length;t++)n.push(e[t].clone().applyQuaternion(s));let a=(new z).setFromPoints(n),o=new d;a.getSize(o);let _=this.get_distance_to_fit_rect(o.x/2,o.y/2,i,r),l=new d;return a.getCenter(l),l.applyQuaternion(t),{center:l,distance_to_center:_}}get_distance_to_fit_rect(e,t,i,r){let s=i/2*Math.PI/180,n=2*Math.atan(Math.tan(s)*r)/2,a=t/Math.tan(s),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(a))}}class mi extends f{constructor(){let e=new r({uniforms:{_Color:{value:new s("#919191")}},vertexShader:"#define GLSLIFY 1\nattribute vec3 barycentric;varying vec3 vBarycentric;void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=(modelMatrix*vec4(position,1.0)).xyz;gl_Position=VP*vec4(pos,1.0);vBarycentric=barycentric;}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 _Color;varying vec3 vBarycentric;float edgeFactor(vec3 baryc){vec3 d=fwidth(baryc);vec3 a3=smoothstep(vec3(0.0),d*1.5,baryc);return min(min(a3.x,a3.y),a3.z);}void main(){float alpha=edgeFactor(vBarycentric+vec3(1.,1.,0.));gl_FragColor.rgb=mix(_Color,vec3(0.),alpha);gl_FragColor.a=1.0-alpha;gl_FragColor.a*=0.2;}",extensions:{derivatives:!0},transparent:!0,depthWrite:!1}),t=new M(100,100,100,100);super(ai.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57}}class gi extends f{constructor(e){let t=new m;t.setAttribute("position",new k(new Float32Array([]),3)),t.setAttribute("next_position",new k(new Float32Array([]),3)),t.setAttribute("previous_position",new k(new Float32Array([]),3)),t.setAttribute("orientation",new k(new Float32Array([]),1)),t.setAttribute("coverage",new k(new Float32Array([]),1)),super(t,new r({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new s("#FF0000")}},vertexShader:"#define GLSLIFY 1\nuniform float _Thickness;attribute vec3 next_position;attribute vec3 previous_position;attribute float orientation;attribute float coverage;varying float line_coverage;varying float uv_u;vec3 w_space_normal(vec3 from,vec3 to){vec3 w_from=(modelMatrix*vec4(from,1.0)).xyz;vec3 w_to=(modelMatrix*vec4(to,1.0)).xyz;vec3 z=normalize(w_to-w_from);return normalize(cross(z,normalize(cameraPosition-w_from)));}void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=position;vec3 normal=w_space_normal(next_position,previous_position);pos=(modelMatrix*vec4(pos,1.0)).xyz;pos+=normal*(_Thickness*0.5)*orientation;gl_Position=VP*vec4(pos,1.0);line_coverage=coverage;uv_u=orientation*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nuniform float _Length;uniform float _ElapsedTime;uniform float _Thickness;uniform vec3 _Color;varying float line_coverage;varying float uv_u;float aastep(float threshold,float value){\n#ifdef GL_OES_standard_derivatives\nfloat afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757;return smoothstep(threshold-afwidth,threshold+afwidth,value);\n#else\nreturn step(threshold,value);\n#endif\n}void main(){float u=(1.0-abs(uv_u*2.0-1.0));float diffuse=dot(vec2(u,u),vec2(0.0,1.0))*0.5+0.5;gl_FragColor=vec4(_Color*diffuse,1.0);}",transparent:!0,depthWrite:!1,extensions:{derivatives:!0}})),e&&this.setup(e)}setup(e){let t=[],i=[],r=[],s=[],n=[],a=0;for(let o=0;o<e.length;o++){t.push(e[o].x),t.push(e[o].y),t.push(e[o].z),s.push(1),t.push(e[o].x),t.push(e[o].y),t.push(e[o].z),s.push(-1);let _=this.__get_next_position(e,o);i.push(_.x),i.push(_.y),i.push(_.z),i.push(_.x),i.push(_.y),i.push(_.z);let l=this.__get_previous_position(e,o);r.push(l.x),r.push(l.y),r.push(l.z),r.push(l.x),r.push(l.y),r.push(l.z),n.push(a),n.push(a),o<e.length-1&&(a+=e[o].distanceTo(_))}let o=new Float32Array(t),_=new Float32Array(i),l=new Float32Array(r),h=new Float32Array(s),c=new Float32Array(n),u=[];for(let e=0;e<(o.length/3-2)/2;e++){let t=2*e+1;u.push(t),u.push(t+1),u.push(t-1),u.push(t),u.push(t+2),u.push(t+1)}this.geometry.setIndex(u),this.geometry.getAttribute("position").copy(new k(o,3)),this.geometry.getAttribute("next_position").copy(new k(_,3)),this.geometry.getAttribute("previous_position").copy(new k(l,3)),this.geometry.getAttribute("orientation").copy(new k(h,1)),this.geometry.getAttribute("coverage").copy(new k(c,1)),this.geometry.getAttribute("position").needsUpdate=!0,this.geometry.getAttribute("next_position").needsUpdate=!0,this.geometry.getAttribute("previous_position").needsUpdate=!0,this.geometry.getAttribute("orientation").needsUpdate=!0,this.geometry.getAttribute("coverage").needsUpdate=!0,this.material.uniforms._Length.value=a,this._length=a}set thickness(e){this.material.uniforms._Thickness.value=e}get thickness(){return this.material.uniforms._Thickness.value}__get_previous_position(e,t){return 0===t?e[1].clone().sub(e[0]).multiplyScalar(-1).add(e[0]):e[t-1]}__get_next_position(e,t){return t===e.length-1?e[e.length-2].clone().sub(e[e.length-1]).multiplyScalar(-1).add(e[e.length-1]):e[t+1]}update(){}distance(){return this.accumulated_length}total_length(){return this.accumulated_length}dispose(){this.geometry.dispose(),this.material.dispose(),this.parent&&this.parent.remove(this)}set color(e){this.material.uniforms._Color.value.set(e)}get color(){return this.material.uniforms._Color.value}copy_color(e){this.material.uniforms._Color.value.copy(e)}}class vi extends f{constructor(e,t){t=t||new i(0,0);let s=new r({uniforms:{_MainTex:{value:e},_ScreenAligned:{value:0},_Scale:{value:1},_Opacity:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;uniform float _ScreenAligned;uniform float _Scale;void main(){vec3 pos=position;mat4 local_to_camera=modelViewMatrix;float scale=_Scale;local_to_camera[0]=mix(modelViewMatrix[0],vec4(1.0*scale,0.0,0.0,0.0),_ScreenAligned);local_to_camera[1]=mix(modelViewMatrix[1],vec4(0.0,1.0*scale,0.0,0.0),_ScreenAligned);local_to_camera[2]=mix(modelViewMatrix[2],vec4(0.0,0.0,1.0*scale,0.0),_ScreenAligned);gl_Position=projectionMatrix*local_to_camera*vec4(pos,1.0);vUv=uv;}",fragmentShader:"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;uniform float _Opacity;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor.a*=_Opacity;}",transparent:!0,depthWrite:!1,side:te}),n=new ie(1,1,1);n.translate(-t.x/2,-t.y/2,0);let a=e.image.width/e.image.height;n.scale(a,1,1),super(n,s),this.current_scale=a,this.geometry.computeBoundingBox(),this.tmp_bb_size=new d,this.geometry.boundingBox.getSize(this.tmp_bb_size)}update_texture(){this.material.uniforms._MainTex.value.needsUpdate=!0;let e=this.material.uniforms._MainTex.value.image;this.geometry.scale(1/this.current_scale,1,1),this.current_scale=e.width/e.height,this.geometry.scale(this.current_scale,1,1),this.geometry.computeBoundingBox(),this.geometry.boundingBox.getSize(this.tmp_bb_size)}get size(){return this.tmp_bb_size.clone().multiplyScalar(this.scale.x)}set size(e){this.scale.set(e,e,e),this.material.uniforms._Scale.value=e}set screen_aligned(e){this.material.uniforms._ScreenAligned.value=!0===e?1:0}get screen_aligned(){return 1===this.material.uniforms._ScreenAligned.value}set opacity(e){this.material.uniforms._Opacity.value=e}get opacity(){return this.material.uniforms._Opacity.value}dispose(){this.geometry.dispose(),this.parent.remove(this),this.material.uniforms._MainTex.value.dispose(),this.material.dispose()}}class fi extends vi{constructor(e,t,i,r,s){let n=new ei(s),a={font:t,font_color:i||"#000000"},o=n.draw_on_texture(e,a);o.minFilter=re,o.minFilter=Y,o.needsUpdate=!0,super(o,r),this.simple_text_drawer=n,this.canvas_texture=o,this.draw_settings=a}set text(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()}get text(){return"not implemented"}}class xi extends Be{constructor(e=1){super("#define GLSLIFY 1\nuniform vec2 _ScreenSize;uniform vec2 _TextureSize;uniform vec2 _PixelOffset;uniform vec3 _NDC;uniform vec2 _PivotPoint;uniform float _DepthOffset;varying vec2 vUv;vec2 add_pixel_offset(vec2 pos){pos=pos*0.5+0.5;pos*=_ScreenSize;pos=ceil(pos+_PixelOffset)+0.5;pos/=_ScreenSize;return pos*2.0-1.0;}void main(){vec4 projected_pos=projectionMatrix*viewMatrix*vec4(_NDC,1.0);projected_pos.zw+=_DepthOffset;projected_pos.xyz/=projected_pos.w;vec2 normalized_size=_TextureSize/_ScreenSize;vec2 dir=uv*2.0-1.0;dir-=_PivotPoint;vec2 pos=projected_pos.xy+dir*normalized_size;gl_Position=vec4(add_pixel_offset(pos),projected_pos.z,1.0);vUv=uv;}","#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _ScreenSize;uniform vec2 _TextureSize;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv+vec2(0.5,0.5)/_TextureSize);}",{_MainTex:{value:void 0},_ScreenSize:{value:new i(Screen.width,Screen.height)},_TextureSize:{value:new i},_PixelOffset:{value:new i(0,0)},_NDC:{value:new d},_PivotPoint:{value:new i},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class wi{constructor(){this.tmp_vec=new i}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class bi{constructor(){this.tmp_vec3=new d,this.tmp_vec2=new i}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(qe.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class yi{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class Ti extends yi{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class Si extends yi{constructor(){super()}on_enter(e){e.on_mouse_enter()}update(e,t){e.is_mouse_over(t)?e.set_state(e._on_hover_state):e.set_state(e._on_exit_state)}}class Mi extends yi{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class Fi extends yi{constructor(){super()}on_enter(e){this.__trigger_on_hover(e)}update(e,t){e.is_mouse_over(t)?this.__trigger_on_hover(e):e.set_state(e._on_exit_state)}__trigger_on_hover(e){e.on_mouse_hover()}}class zi extends f{constructor(e,t){super(new ie(1,1),new xi),this.is_clickable=!1,this.position_strategy=new bi,this.current_state=new Ti,this._position=new d,this._on_idle_state=new Ti,this._on_enter_state=new Si,this._on_exit_state=new Mi,this._on_hover_state=new Fi,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new i,this.cached_NDC_position=new i,this.screen_pos_tmp=new i,this.texture_size=new i(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new i}set_render_order(e){this.renderOrder=e}get pivot_point(){return this.material.uniforms._PivotPoint.value}set_pixel_offset(e){this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e)}set_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}get position(){return this._position}set use_depth(e){this.material.depthTest=e}get use_depth(){return this.material.depthTest}set depth_offset(e){this.material.uniforms._DepthOffset.value=e}get depth_offset(){return this.material.uniforms._DepthOffset.value}clear_state(){this.visible=!1}set_world_space_coordinate_system(){this.position_strategy=new bi}set_screen_space_coordinate_system(){this.position_strategy=new wi}set_texture(e){e.minFilter=c,e.magFilter=c,e.needsUpdate=!0,this.texture_size.set(e.image.width,e.image.height),this.material.uniforms._MainTex.value=e,this.get_size(this.material.uniforms._TextureSize.value),this.visible=!0}update_state(e){this.material.uniforms._ScreenSize.value.set(it.width,it.height),this.get_size(this.material.uniforms._TextureSize.value),this.cached_NDC_position.copy(this.position_strategy.get_pos_NDC(this.position)),this.material.uniforms._NDC.value.copy(this.position),this.current_state.update(this,e)}is_mouse_over(e){this.screen_pos_tmp.copy(this.cached_NDC_position),this.to_screen_position(this.screen_pos_tmp),this.screen_pos_tmp.x+=this.pixel_offset.x,this.screen_pos_tmp.y+=this.pixel_offset.y;let t=(new se).setFromCenterAndSize(this.screen_pos_tmp,this.get_size());return this.mouse_pos_tmp.copy(e),this.to_screen_position(this.mouse_pos_tmp),t.containsPoint(this.mouse_pos_tmp)}to_screen_position(e){e.x=(.5*e.x+.5)*it.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*it.height+this.pixel_offset.y}get_screen_space_position(){let e=this.cached_NDC_position.clone();return this.to_screen_position(e),e}set_screen_space_position(e){this.position.x=e.x/it.width*2-1,this.position.y=e.y/it.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),it.remove_screen_material(this.material),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/it.dpr):(new i).copy(this.texture_size).multiplyScalar(this.size/it.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class Ri extends f{constructor(e,t){super(e,t);let i=this;this.onBeforeRender=()=>{i.material.update()}}}class Ai{constructor(e,t,r){let s=t.right-t.left,n=t.top-t.bottom;this.scale=new i(s,n),this.position=new i(e+t.left,t.bottom),this.atlas_bounds=new F(r.left,r.right,r.top,r.bottom)}}class Ci{constructor(e,t=""){this.glyph_layout=e,this.glyphs=[],this.glyph_is_dirty=!0,this.matrix_is_dirty=!0,this.color_is_dirty=!0,this.position=new d,this.quaternion=new $,this.scale=new d(1,1,1),this.matrix=new E,this.color=new s("#FFFFFF"),this.pivot_point=new i,this.__opacity=1,this.__text=t,this.__generate_glyphs(t)}set text(e){this.__text=e,this.__generate_glyphs(e),this.matrix_is_dirty=!0}get text(){return this.__text}update_matrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrix_is_dirty=!1,this.glyph_is_dirty=!0}clear_glyph_dirty(){this.glyph_is_dirty=!1}clear_color_dirty(){this.color_is_dirty=!1}set_rotation(e=0,t=0){let i=(new $).setFromAxisAngle(new d(0,1,0),e/360*Math.PI*2),r=(new $).setFromAxisAngle(new d(1,0,0),-t/360*Math.PI*2);this.quaternion.copy(i.multiply(r)),this.matrix_is_dirty=!0}set_position(e){this.position.copy(e),this.matrix_is_dirty=!0}set_size(e){this.scale.set(e,e,e),this.matrix_is_dirty=!0}set_color(e){this.color.set(e),this.color_is_dirty=!0}set_pivot(e){this.pivot_point.copy(e),this.update_glyphs()}set opacity(e){this.__opacity=e,this.color_is_dirty=!0}get opacity(){return this.__opacity}update_glyphs(){this.__generate_glyphs(this.text)}__generate_glyphs(e){let t=0;this.glyphs.length=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i),s=this.glyph_layout.find((e=>e.unicode===r));if(s){if(s.planeBounds){let e=new Ai(t,s.planeBounds,s.atlasBounds);this.glyphs.push(e)}t+=s.advance}}let r=new se,s=this.glyphs[0];r.setFromCenterAndSize(s.position.clone().add(new i(s.scale.x/2,s.scale.y/2)),s.scale);for(let e=1;e<this.glyphs.length;e++){let t=this.glyphs[e],s=(new se).setFromCenterAndSize(t.position.clone().add(new i(t.scale.x/2,t.scale.y/2)),t.scale);r.union(s)}let n=new i;r.getSize(n);for(let e=0;e<this.glyphs.length;e++)this.glyphs[e].position.x-=n.x/2,this.glyphs[e].position.y-=n.y/2,this.glyphs[e].position.x+=n.x/2*this.pivot_point.x,this.glyphs[e].position.y+=n.y/2*this.pivot_point.y;this.glyph_is_dirty=!0}}class Di extends Be{constructor(e){super("#define GLSLIFY 1\nattribute vec4 transformsCol0;attribute vec4 transformsCol1;attribute vec4 transformsCol2;attribute vec4 transformsCol3;attribute vec4 glyph_bounds;attribute vec4 plane_bounds;attribute vec4 color;varying vec2 vUv;varying vec4 v_glyph_bounds;varying vec4 v_color;void main(){vec4 pos=vec4(position,1.0);pos.x*=plane_bounds.z;pos.y*=plane_bounds.w;pos.x+=plane_bounds.x;pos.y+=plane_bounds.y;mat4 offset_matrix=mat4(transformsCol0,transformsCol1,transformsCol2,transformsCol3);gl_Position=projectionMatrix*viewMatrix*offset_matrix*pos;vUv=uv;v_glyph_bounds=glyph_bounds;v_color=color;}","#define GLSLIFY 1\nuniform sampler2D _Texture;uniform float _Boldness;varying vec2 vUv;uniform vec2 _AtlasSize;varying vec4 v_glyph_bounds;varying vec4 v_color;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){float left=v_glyph_bounds.x/_AtlasSize.x;float right=v_glyph_bounds.y/_AtlasSize.x;float top=v_glyph_bounds.z/_AtlasSize.y;float bottom=v_glyph_bounds.w/_AtlasSize.y;float width=abs(right-left);float height=abs(top-bottom);vec2 coord=vec2(vUv.x*width+left,vUv.y*height+top-height);vec4 col=texture2D(_Texture,coord);float sig_dist=median(col.r,col.g,col.b);float _Cutoff=_Boldness;float dist=(_Cutoff-sig_dist);vec2 ddist=vec2(dFdx(dist),dFdy(dist));float pixelDist=dist/length(ddist);float opacity=clamp(0.5-pixelDist,0.0,1.0);gl_FragColor=vec4(v_color.rgb,opacity*v_color.a);}",{_Texture:{value:e},_Boldness:{value:.5},_AtlasSize:{value:new i(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=te,e.minFilter=Y,e.magFilter=Y,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(t){this.uniforms._Boldness.value=e.lerp(.5,.2,t)}}class Pi extends f{constructor(e,t){let r=new ne;r.instanceCount=0;let s=new M(1,1);s.translate(.5,.5,0),r.setAttribute("position",new ae(s.getAttribute("position").array,3)),r.setAttribute("uv",new ae(s.getAttribute("uv").array,2)),r.index=s.index;let n=new oe(new Float32Array(8e3),4,!1),a=new oe(new Float32Array(8e3),4,!1),o=new oe(new Float32Array(8e3),4,!1),_=new oe(new Float32Array(8e3),4,!1),l=new oe(new Float32Array(8e3),4,!1),h=new oe(new Float32Array(8e3),4,!1),c=new oe(new Float32Array(8e3),4,!1);n.usage=_e,a.usage=_e,o.usage=_e,_.usage=_e,l.usage=_e,h.usage=_e,c.usage=_e,r.setAttribute("transformsCol0",n),r.setAttribute("transformsCol1",a),r.setAttribute("transformsCol2",o),r.setAttribute("transformsCol3",_),r.setAttribute("glyph_bounds",l),r.setAttribute("plane_bounds",h),r.setAttribute("color",c),super(r,new Di(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new i(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){let t=new Ci(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){si.remove_elem(this.text_elements,e),this.update(!0)}update(e){let t=this.geometry.getAttribute("glyph_bounds"),i=this.geometry.getAttribute("plane_bounds"),r=this.geometry.getAttribute("transformsCol0"),s=this.geometry.getAttribute("transformsCol1"),n=this.geometry.getAttribute("transformsCol2"),a=this.geometry.getAttribute("transformsCol3"),o=this.geometry.getAttribute("color"),_=!0===e,l=!0===e,h=!0===e,c=0;for(let e=0;e<this.text_elements.length;e++){let u=this.text_elements[e];u.matrix_is_dirty&&(_=!0,u.update_matrix()),u.glyph_is_dirty&&(l=!0,u.clear_glyph_dirty()),u.color_is_dirty&&(h=!0,u.clear_color_dirty());let d=u.matrix,p=u.color,m=u.opacity;for(let e=0;e<u.glyphs.length;e++){let _=u.glyphs[e],l=c;t.setXYZW(l,_.atlas_bounds.x,_.atlas_bounds.y,_.atlas_bounds.z,_.atlas_bounds.w),i.setXYZW(l,_.position.x,_.position.y,_.scale.x,_.scale.y),r.setXYZW(l,d.elements[0],d.elements[1],d.elements[2],d.elements[3]),s.setXYZW(l,d.elements[4],d.elements[5],d.elements[6],d.elements[7]),n.setXYZW(l,d.elements[8],d.elements[9],d.elements[10],d.elements[11]),a.setXYZW(l,d.elements[12],d.elements[13],d.elements[14],d.elements[15]),o.setXYZW(l,p.r,p.g,p.b,m),c++}}this.geometry.instanceCount=c,c>this.max_allocations&&console.error("SDFTextBatch exceeded maximum glyph allocations(max/current): ",this.max_allocations,c,this),_&&(r.needsUpdate=!0,s.needsUpdate=!0,n.needsUpdate=!0,a.needsUpdate=!0),l&&(t.needsUpdate=!0,i.needsUpdate=!0),h&&(o.needsUpdate=!0)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Li extends Te{constructor(e,t=0,i=1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=i}update(e,t){let i=this.from.clone();i.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(i)}}class Ii extends Ve{constructor(){super('#define GLSLIFY 1\n/*3x3 MedianGLSL 1.0Morgan McGuire and Kyle Whitson,2006Williams Collegehttp:Copyright(c)Morgan McGuire and Williams College,2006All rights reserved.Redistribution and use in source and binary forms,with or withoutmodification,are permitted provided that the following conditions aremet:Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyrightnotice,this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING,BUT NOTLIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHTHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES(INCLUDING,BUT NOTLIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE,DATA,OR PROFITS;OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY,WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/uniform sampler2D _SourceTex;uniform vec2 _SourceTexSize;varying vec2 vUv;\n#define vec vec4\n#define toVec(x) x.rgba\n#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);\n#define t2(a, b) s2(v[a], v[b]);\n#define t24(a, b, c, d, e, f, g, h) t2(a, b); t2(c, d); t2(e, f); t2(g, h);\n#define t25(a, b, c, d, e, f, g, h, i, j) t24(a, b, c, d, e, f, g, h); t2(i, j);\n#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);\n#define mn3(a, b, c) s2(a, b); s2(a, c);\n#define mx3(a, b, c) s2(b, c); s2(a, c);\n#define mnmx3(a, b, c) mx3(a, b, c); s2(a, b);\n#define mnmx4(a, b, c, d) s2(a, b); s2(c, d); s2(a, c); s2(b, d);\n#define mnmx5(a, b, c, d, e) s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e);\n#define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f);\nvoid main(){vec2 inv_size=vec2(1.0/_SourceTexSize.x,1.0/_SourceTexSize.y);\n#ifdef kernel5x5\nvec v[25];for(int dX=-2;dX<=2;++dX){for(int dY=-2;dY<=2;++dY){vec2 offset=vec2(float(dX),float(dY));v[(dX+2)*5+(dY+2)]=toVec(texture2D(_SourceTex,vUv+offset*inv_size));}}vec temp;t25(0,1,3,4,2,4,2,3,6,7);t25(5,7,5,6,9,7,1,7,1,4);t25(12,13,11,13,11,12,15,16,14,16);t25(14,15,18,19,17,19,17,18,21,22);t25(20,22,20,21,23,24,2,5,3,6);t25(0,6,0,3,4,7,1,7,1,4);t25(11,14,8,14,8,11,12,15,9,15);t25(9,12,13,16,10,16,10,13,20,23);t25(17,23,17,20,21,24,18,24,18,21);t25(19,22,8,17,9,18,0,18,0,9);t25(10,19,1,19,1,10,11,20,2,20);t25(2,11,12,21,3,21,3,12,13,22);t25(4,22,4,13,14,23,5,23,5,14);t25(15,24,6,24,6,15,7,16,7,19);t25(3,11,5,17,11,17,9,17,4,10);t25(6,12,7,14,4,6,4,7,12,14);t25(10,14,6,7,10,12,6,10,6,17);t25(12,17,7,17,7,10,12,18,7,12);t24(10,18,12,20,10,20,10,12);gl_FragColor=v[12];\n#endif\n#ifdef kernel3x3\nvec v[9];for(int dX=-1;dX<=1;++dX){for(int dY=-1;dY<=1;++dY){vec2 offset=vec2(float(dX),float(dY));v[(dX+1)*3+(dY+1)]=toVec(texture2D(_SourceTex,vUv+offset*inv_size));}}vec temp;mnmx6(v[0],v[1],v[2],v[3],v[4],v[5]);mnmx5(v[1],v[2],v[3],v[4],v[6]);mnmx4(v[2],v[3],v[4],v[7]);mnmx3(v[3],v[4],v[8]);toVec(gl_FragColor)=v[4];\n#endif\n}',void 0,{kernel3x3:!0}),this.uniforms._SourceTex={value:void 0},this.uniforms._SourceTexSize={value:new i(1,1)}}set_texture(e){this.uniforms._SourceTex.value=e;let t=this.get_size(e);this.uniforms._SourceTexSize.value.copy(t)}get_size(e){return e.isVideoTexture?new i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class Oi{constructor(e){this.RT=new D(1,1,{type:N,format:U,minFilter:c,magFilter:c}),this.RT1=new D(1,1,{type:N,format:U,minFilter:c,magFilter:c}),this.median_filter_mat=new Ii}filter(e){let t=this.get_size(e);t.x===this.RT.width&&t.y===this.RT.height||(this.RT.setSize(t.x,t.y),this.RT1.setSize(t.x,t.y)),this.median_filter_mat.set_texture(e),ht.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),ht.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),ht.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class Ui extends Ve{constructor(e){super(e?"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 upsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv+vec2(-halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,-halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,-halfpixel.y))*2.0;return sum/12.0;}void main(){vec2 half_pixel;half_pixel.x=0.5/_Resolution.x;half_pixel.y=0.5/_Resolution.y;gl_FragColor=upsample(vUv,half_pixel);}":"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 downsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv)*4.0;sum+=texture2D(_MainTex,uv-halfpixel);sum+=texture2D(_MainTex,uv+halfpixel);sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y));sum+=texture2D(_MainTex,uv-vec2(halfpixel.x,-halfpixel.y));return sum/8.0;}void main(){vec2 half_pixel=vec2(0.5/_Resolution.x,0.5/_Resolution.y);gl_FragColor=downsample(vUv,half_pixel);}")}}class Ni extends Ve{constructor(e,t){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;void main(){vec4 col=texture2D(_MainTex,vUv);gl_FragColor=col;gl_FragColor.a=col.a;}")}set offset(e){this.uniforms._Offset.value=e}get offset(){return this.uniforms._Offset.value}}class ki{constructor(e){this.current_width=1,this.current_height=1,this.RT0=new D(1,1),this.RT1=new D(1,1),this.RT2=new D(1,1),this.RT3=new D(1,1),this.RT4=new D(1,1),this.upscale_blur_mat=new Ui(!0),this.downscale_blur_mat=new Ui(!1),this.alpha_filter_mat=new Ni}blur(e){this.check_RT_resize(e.width,e.height),ht.blit(e,this.RT1,this.alpha_filter_mat),ht.blit(this.RT1,this.RT2,this.downscale_blur_mat),ht.blit(this.RT2,this.RT3,this.downscale_blur_mat),ht.blit(this.RT3,this.RT4,this.downscale_blur_mat),ht.blit(this.RT4,this.RT3,this.upscale_blur_mat),ht.blit(this.RT3,this.RT2,this.upscale_blur_mat),ht.blit(this.RT2,e,this.upscale_blur_mat)}check_RT_resize(e,t){this.current_width===e&&this.current_height===t||(this.current_width=e,this.current_height=t,this.RT0.setSize(this.current_width/2,this.current_height/2),this.RT1.setSize(this.current_width/2,this.current_height/2),this.RT2.setSize(this.current_width/4,this.current_height/4),this.RT3.setSize(this.current_width/8,this.current_height/8),this.RT4.setSize(this.current_width/16,this.current_height/16))}}class Ei extends u{constructor(){super(),this.attributes=[],this.particles=void 0}set_from_geometry(e,t,i){if(i&&void 0===e.getAttribute("storage_uv")){let t=this.build_uv_storage_attribute(e.getAttribute("position").count);e.setAttribute("storage_uv",t)}let r=new le(e,t);r.frustumCulled=!1,this.particles=r,this.add(r)}add_texture_attribute(e){}add_attribute(e,t){}build_uv_storage_attribute(e){let t=this.calculate_resolution(e),i=new Float32Array(2*e);for(let r=0,s=0;r<2*e;r+=2,s++)i[r]=s%t/t+.5/t,i[r+1]=Math.floor(s/t)/t+.5/t;return new k(i,2)}calculate_resolution(e){return Math.ceil(Math.sqrt(e))}update(){for(let e=0;e<this.attributes.length;e++)this.attributes[e].update()}set_attribute_update_material(e,t){for(let i=0;i<this.attributes.length;i++)this.attributes[i].name===e&&(this.attributes[i].update_material=t)}dispose(){this.particles.geometry.dispose(),this.particles.material.dispose()}}export{we as AbstractLoader,Fe as ActionEvent,Te as ActionInterpolator,be as ActionSequencer,Re as ActionSequencerBuilder,Ue as ApplicationView,si as ArrayUtilities,tt as Arrow,Ne as BaseApplication,ke as BaseRender,Be as BaseShaderMaterial,Ge as BasisLoader,Ve as BlitMaterial,zt as Blurrer,Je as CSSAnimator,qe as CameraManager,xt as CameraUtilities,We as CanvasDrawer,Ye as Capabilities,He as Configuration,$e as Cube,nt as Debug,ut as DebugNormalsRender,ze as DrawIOAnimationSheet,Ui as DualFilteringBlurMaterial,ki as DualFilteringBlurrer,ye as EasingFunctions,Ae as EventManager,ni as FrustumPointFitter,Ei as GPUParticleSystem,It as GaussianBlurrer,ai as GeometryUtilities,ht as Graphics,mi as Grid,ii as HorizontalPlane,oi as ImageUtilities,wt as Initializer,dt as Input,bt as JSONLoader,gi as Line,ft as MathUtilities,Oi as MedianFilter,_i as MeshSampler,li as ModelUtilities,Rt as NormalAORender,At as NormalRender,Se as NumberInterpolator,fe as OS,hi as ObjectUtilities,Ut as OrthographicCamera,pi as OrthographicFrustumPointFitter,st as PerspectiveCamera,di as PerspectiveFrustumPointFitter,kt as RenderLoop,$t as ResourceBatch,Ce as ResourceContainer,Pi as SDFTextBatch,Ke as SceneManager,it as Screen,ei as SimpleTextDrawer,et as Sphere,ci as StringUtilities,fi as Text2D,Pe as Time,ui as TimeUtilities,De as TransitionTable,vt as UI,zi as UIElement,Ot as UnrealBloomRender,Ri as UpdatableMaterialMesh,xe as Validation,Li as VectorInterpolator,ri as VerticalPlane,ti as ViewComponent,Nt as ViewComponentManager,Me as ViewContext,Oe as ViewManager};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|