ohzi-core 13.0.0 → 13.0.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.
Files changed (132) hide show
  1. package/build/index.mjs +1 -1
  2. package/build/index.mjs.map +1 -1
  3. package/build/index.module.js +2 -0
  4. package/build/index.module.js.map +1 -0
  5. package/package.json +4 -4
  6. package/src/CameraManager.ts +0 -2
  7. package/src/CustomBezierCurve.ts +0 -11
  8. package/src/Debug.ts +1 -2
  9. package/src/OS.ts +2 -0
  10. package/src/ResourceContainer.ts +4 -6
  11. package/src/SceneManager.ts +0 -1
  12. package/src/action_sequencer/ActionSequencer.ts +0 -1
  13. package/src/components/Input.ts +11 -11
  14. package/src/utilities/OMath.ts +1 -7
  15. package/types/BaseApplication.d.ts +1 -7
  16. package/types/CameraManager.d.ts +7 -5
  17. package/types/CustomBezierCurve.d.ts +0 -11
  18. package/types/Debug.d.ts +11 -167
  19. package/types/Graphics.d.ts +20 -94
  20. package/types/Initializer.d.ts +2 -4
  21. package/types/KeyboardInput.d.ts +1 -37
  22. package/types/OScreen.d.ts +7 -18
  23. package/types/OrthographicCamera.d.ts +5 -15
  24. package/types/PerspectiveCamera.d.ts +3 -12
  25. package/types/RenderLoop.d.ts +6 -120
  26. package/types/ResourceContainer.d.ts +10 -26
  27. package/types/SceneManager.d.ts +10 -10
  28. package/types/Screen.d.ts +4 -16
  29. package/types/Time.d.ts +3 -5
  30. package/types/action_sequencer/ActionEvent.d.ts +0 -5
  31. package/types/action_sequencer/ActionInterpolator.d.ts +5 -11
  32. package/types/action_sequencer/ActionSequencer.d.ts +4 -63
  33. package/types/action_sequencer/NumberInterpolator.d.ts +4 -12
  34. package/types/action_sequencer/VectorInterpolator.d.ts +5 -9
  35. package/types/canvas_drawer/CanvasDrawer.d.ts +3 -33
  36. package/types/canvas_drawer/MultiLineTextDrawer.d.ts +8 -13
  37. package/types/canvas_drawer/SimpleTextDrawer.d.ts +4 -8
  38. package/types/components/AxisHelper.d.ts +2 -2
  39. package/types/components/BaseObject.d.ts +9 -12
  40. package/types/components/EdgeMesh.d.ts +16 -42
  41. package/types/components/GeometryEdgeVisualizer.d.ts +8 -12
  42. package/types/components/Grid.d.ts +2 -2
  43. package/types/components/Input.d.ts +11 -11
  44. package/types/components/Line.d.ts +7 -28
  45. package/types/components/MultiLinePath.d.ts +8 -10
  46. package/types/components/MultiLineText2D.d.ts +12 -22
  47. package/types/components/ObjectAxis.d.ts +5 -8
  48. package/types/components/ObjectOrientedBoundingBox.d.ts +20 -45
  49. package/types/components/PlaneHelper.d.ts +7 -6
  50. package/types/components/Shape2D.d.ts +7 -14
  51. package/types/components/Shape3D.d.ts +6 -10
  52. package/types/components/Text2D.d.ts +6 -11
  53. package/types/components/UpdatableMaterialMesh.d.ts +5 -8
  54. package/types/components/WorldImage.d.ts +4 -10
  55. package/types/components/mouse_interactors/ObjectRotator.d.ts +17 -12
  56. package/types/components/sdf_text/SDFText.d.ts +1 -5
  57. package/types/components/sdf_text/SDFTextBatch.d.ts +4 -3
  58. package/types/data_textures/CustomDataTexture.d.ts +11 -9
  59. package/types/data_textures/RGBADataTexture.d.ts +4 -3
  60. package/types/data_textures/RGBAFloatDataTexture.d.ts +4 -3
  61. package/types/data_textures/RGBDataTexture.d.ts +4 -3
  62. package/types/data_textures/RGBFloatDataTexture.d.ts +4 -3
  63. package/types/gpu_particles/GPUParticleSystem.d.ts +9 -12
  64. package/types/gpu_particles/ParticleAttribute.d.ts +5 -4
  65. package/types/html_utilities/CSSAnimator.d.ts +3 -2
  66. package/types/loaders/AsyncAbstractLoader.d.ts +4 -22
  67. package/types/loaders/assets_loader/AssetLoader.d.ts +6 -4
  68. package/types/loaders/assets_loader/AsyncAssetsLoaderWorker.d.ts +1 -1
  69. package/types/loaders/assets_loader/ResourceBatch.d.ts +16 -14
  70. package/types/loaders/assets_loader/ResourceLoaderChecker.d.ts +9 -8
  71. package/types/materials/BaseShaderMaterial.d.ts +1 -1
  72. package/types/materials/BlitMaterial.d.ts +1 -1
  73. package/types/materials/BloomComposeMaterial.d.ts +5 -4
  74. package/types/materials/DeferredRendererComposeMaterial.d.ts +10 -7
  75. package/types/materials/DepthNormalMaterial.d.ts +1 -1
  76. package/types/materials/FXAAMaterial.d.ts +5 -3
  77. package/types/materials/MedianFilterMaterial.d.ts +3 -2
  78. package/types/materials/SDFScreenTextMaterial.d.ts +8 -7
  79. package/types/materials/SSAOMaterial.d.ts +2 -3
  80. package/types/materials/ScreenSpaceTextureMaterial.d.ts +9 -7
  81. package/types/materials/UnrealBlurMaterial.d.ts +5 -4
  82. package/types/materials/UnrealComposeMaterial.d.ts +5 -4
  83. package/types/materials/ViewPositionMaterial.d.ts +5 -4
  84. package/types/materials/deferred/DeferredPointLightMaterial.d.ts +10 -9
  85. package/types/materials/gpu_particles/AttributeUpdateMaterial.d.ts +8 -7
  86. package/types/materials/gpu_particles/BasicParticleMaterial.d.ts +5 -4
  87. package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +5 -3
  88. package/types/primitives/Arrow.d.ts +5 -8
  89. package/types/primitives/Cube.d.ts +3 -8
  90. package/types/primitives/HorizontalPlane.d.ts +3 -9
  91. package/types/primitives/Sphere.d.ts +5 -7
  92. package/types/primitives/VerticalPlane.d.ts +3 -9
  93. package/types/raycast/GroupRaycaster.d.ts +20 -15
  94. package/types/raycast/PlaneDragResolver.d.ts +21 -16
  95. package/types/raycast/PlaneRaycastResolver.d.ts +8 -5
  96. package/types/raycast/PlaneRaycaster.d.ts +10 -9
  97. package/types/raycast/RaycastResolver.d.ts +8 -5
  98. package/types/raycast/SurfaceDragResolver.d.ts +19 -15
  99. package/types/raycast/states/BaseState.d.ts +7 -5
  100. package/types/raycast/states/IdleState.d.ts +7 -3
  101. package/types/raycast/states/OnRaycastEnter.d.ts +7 -3
  102. package/types/raycast/states/OnRaycastExit.d.ts +7 -3
  103. package/types/raycast/states/OnRaycastHover.d.ts +8 -3
  104. package/types/render_mode/BloomRender.d.ts +15 -12
  105. package/types/render_mode/DeferredRender.d.ts +15 -13
  106. package/types/render_mode/NormalAORender.d.ts +9 -8
  107. package/types/render_mode/UnrealBloomRender.d.ts +8 -7
  108. package/types/render_utilities/Blitter.d.ts +5 -6
  109. package/types/render_utilities/Blurrer.d.ts +5 -4
  110. package/types/render_utilities/DepthAndNormalsRenderer.d.ts +6 -5
  111. package/types/render_utilities/DualFilteringBlurrer.d.ts +8 -9
  112. package/types/render_utilities/GaussianBlurrer.d.ts +5 -3
  113. package/types/render_utilities/MedianFilter.d.ts +7 -6
  114. package/types/render_utilities/ViewPositionRenderer.d.ts +12 -10
  115. package/types/resource_loader/CubemapLoader.d.ts +2 -2
  116. package/types/resource_loader/DDSLoader.d.ts +9 -7
  117. package/types/resource_loader/FileLoader.d.ts +2 -2
  118. package/types/resource_loader/PointArrayLoader.d.ts +2 -3
  119. package/types/resource_loader/SVGLoader.d.ts +9 -7
  120. package/types/resource_loader/TextLoader.d.ts +2 -2
  121. package/types/scenes/AbstractScene.d.ts +5 -4
  122. package/types/shaders/grid/grid.tsl.d.ts +5 -2
  123. package/types/utilities/CameraUtilities.d.ts +2 -4
  124. package/types/utilities/FrustumPointFitter.d.ts +1 -2
  125. package/types/utilities/GeometryUtilities.d.ts +2 -2
  126. package/types/utilities/ImageUtilities.d.ts +1 -1
  127. package/types/utilities/OrthographicFrustumPointFitter.d.ts +1 -1
  128. package/types/utilities/PerspectiveFrustumPointFitter.d.ts +1 -2
  129. package/types/view_components/ApplicationView.d.ts +1 -1
  130. package/types/view_components/TransitionManager.d.ts +6 -4
  131. package/types/view_components/ViewManager.d.ts +5 -2
  132. package/types/view_components/transition/TransitionTable.d.ts +4 -1
package/build/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{Vector2 as e,NoBlending as t,AlwaysDepth as r,Texture as n,ShaderMaterial as i,Color as o,Scene as a,Mesh as s,PlaneGeometry as u,OrthographicCamera as l,Vector4 as _,RenderTarget as c,Vector3 as h,PositionalAudio as p,Audio as d,AudioContext as f,SRGBColorSpace as m,NoColorSpace as v,CubeTextureLoader as g,CanvasTexture as y,UVMapping as b,ClampToEdgeWrapping as w,NearestFilter as x,LineBasicMaterial as T,BufferGeometry as S,Line as M,Object3D as F,PerspectiveCamera as z,CylinderGeometry as A,ConeGeometry as R,MeshBasicMaterial as P,BoxGeometry as C,SphereGeometry as k,Box3 as O,Box3Helper as L,CatmullRomCurve3 as D,Plane as j,Line3 as U,Quaternion as I,Sphere as N,Matrix4 as E,Ray as q,DataTexture as V,RGBAFormat as B,RepeatWrapping as Y,LinearFilter as G,HalfFloatType as W,UnsignedByteType as X,LinearSRGBColorSpace as Q,BufferAttribute as H,Skeleton as Z,DoubleSide as J,LinearMipMapLinearFilter as K,Box2 as $,InstancedBufferGeometry as ee,Float32BufferAttribute as te,InstancedBufferAttribute as re,DynamicDrawUsage as ne,FloatType as ie,Points as oe,FileLoader as ae}from"three";import{WebGPURenderer as se,MeshBasicNodeMaterial as ue}from"three/webgpu";import{GLTFLoader as le}from"three/examples/jsm/loaders/GLTFLoader.js";import{HDRCubeTextureLoader as _e}from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import{HDRLoader as ce}from"three/examples/jsm/loaders/HDRLoader";import*as he from"three/examples/jsm/utils/BufferGeometryUtils.js";export{he as BufferGeometryUtils};import{uniform as pe,attribute as de,vec3 as fe,mix as me,fwidth as ve,smoothstep as ge,min as ye}from"three/tsl";import{ColladaLoader as be}from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as we}from"three/examples/jsm/loaders/FontLoader.js";import{OBJLoader as xe}from"three/examples/jsm/loaders/OBJLoader.js";var Te=function(){function e(){}return e.prototype.on_post_start=function(){},e.prototype.on_enter=function(e){},e.prototype.on_exit=function(e){},e.prototype.before_update=function(){},e.prototype.update=function(){},e.prototype.fixed_update=function(){},e.prototype.on_post_render=function(){},e.prototype.on_pre_render=function(){},e.prototype.on_frame_end=function(){},e}(),Se=function(e,t){return Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Se(e,t)};function Me(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Se(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Fe(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))}function ze(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}"function"==typeof SuppressedError&&SuppressedError;var Ae=function(i){function o(o,a,s){var u=i.call(this,{uniforms:{_MainTex:{value:null},_Resolution:{value:new e(0,0)},_TargetResolution:{value:new e(0,0)}},defines:s||{},vertexShader:a||"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}",fragmentShader:o||"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);}",depthWrite:!1,blending:t,depthTest:!1,depthFunc:r})||this;return u.uniforms={_MainTex:{value:n},_Resolution:{value:e},_TargetResolution:{value:e}},u}return Me(o,i),o}(i),Re=function(e){function t(t){void 0===t&&(t=!1);var r=e.call(this,"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec4 col0=sampleTex(_MainTex,vUv);vec4 col1=sampleTex(_SecondTex,vUv);gl_FragColor=col0+col1;gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));}")||this;return r.defines.USE_LINEAR_COLOR_SPACE=t,r.uniforms._SecondTex={value:void 0},r}return Me(t,e),t.prototype.set_add_texture=function(e){this.uniforms._SecondTex.value=e},t}(Ae),Pe="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}",Ce="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",ke=function(e){function t(t,r,n){return e.call(this,{vertexShader:t||Ce,fragmentShader:r||Pe,uniforms:null!=n?n:{_Color:{value:new o("#FF0000")}}})||this}return Me(t,e),t}(i),Oe=function(e){function t(t,r){void 0===r&&(r=!1);var n=e.call(this,"#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);}vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*sampleTex(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*sampleTex(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*sampleTex(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*sampleTex(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*sampleTex(blurTexture5,vUv));\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}",void 0,{NUM_MIPS:t})||this;n.uniforms._MainTex={value:void 0},n.uniforms._BlurredTex={value:void 0},n.uniforms._BloomStrength={value:1},n.uniforms.blurTexture1={value:null},n.uniforms.blurTexture2={value:null},n.uniforms.blurTexture3={value:null},n.uniforms.blurTexture4={value:null},n.uniforms.blurTexture5={value:null},n.uniforms.bloomStrength={value:1},n.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},n.uniforms.bloomRadius={value:1},n.defines.USE_LINEAR_COLOR_SPACE=r;var i=[new o("#FFFFFF"),new o("#FFFFFF"),new o("#FFFFFF"),new o("#FFFFFF"),new o("#FFFFFF")];return n.uniforms.bloomTintColors={value:i},n}return Me(t,e),t.prototype.set_blur_texture_0=function(e){this.uniforms.blurTexture1.value=e},t.prototype.set_blur_texture_1=function(e){this.uniforms.blurTexture2.value=e},t.prototype.set_blur_texture_2=function(e){this.uniforms.blurTexture3.value=e},t.prototype.set_blur_texture_3=function(e){this.uniforms.blurTexture4.value=e},t.prototype.set_blur_texture_4=function(e){this.uniforms.blurTexture5.value=e},t.prototype.set_bloom_strength=function(e){this.uniforms.bloomStrength.value=e},t.prototype.set_bloom_radius=function(e){this.uniforms.bloomRadius.value=e},t.prototype.set_tint_color_0=function(e){this.uniforms.bloomTintColors.value[0].set(e)},t.prototype.set_tint_color_1=function(e){this.uniforms.bloomTintColors.value[1].set(e)},t.prototype.set_tint_color_2=function(e){this.uniforms.bloomTintColors.value[2].set(e)},t.prototype.set_tint_color_3=function(e){this.uniforms.bloomTintColors.value[3].set(e)},t.prototype.set_tint_color_4=function(e){this.uniforms.bloomTintColors.value[4].set(e)},t}(Ae),Le=function(){function e(){}return e.prototype.render=function(e){},e.prototype.on_enter=function(e,t){},e.prototype.on_exit=function(e,t){},e.prototype.resize=function(){},e.prototype.dispose=function(){},e}(),De=function(){function e(e,t,r){void 0===r&&(r=1),this.resource_id=e,this.url=t,this.loaded_bytes=0,this.total_bytes=r,this.has_finished=!1,this.has_error=!1,this.error_message="none"}return e.prototype.__update_downloaded_bytes=function(e,t){e=this.is_number(e)?e:1,t=this.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)},e.prototype.__loading_ended=function(){this.has_finished=!0},e.prototype.__set_error=function(e){this.has_error=!0,this.error_message=e},e.prototype.print_error=function(){console.error("Error while loading "+this.resource_id+"\n\t path: "+this.url+"\n\t\t"+this.error_message)},e.prototype.load=function(e){if(void 0===e.resources_by_url[this.url]){fetch(this.url,{method:"GET",mode:"cors",cache:"default",credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()},e.prototype.on_progress=function(e,t){return Fe(this,void 0,void 0,(function(){var r,n,i,o,a,s,u;return ze(this,(function(l){switch(l.label){case 0:r=t.clone(),n=t.body.getReader(),i=+t.headers.get("Content-Length"),o=0,l.label=1;case 1:return[4,n.read()];case 2:return a=l.sent(),s=a.done,u=a.value,s?[3,3]:(o+=u.length,this.__update_downloaded_bytes(o,i),[3,1]);case 3:return t.ok?this.on_preloaded_finished(e,r):(this.__set_error("".concat(t.status,": ").concat(t.statusText)),this.__loading_ended()),[2]}}))}))},e.prototype.on_preloaded_finished=function(e,t){},e.prototype.__on_error=function(e){console.error(e)},e.prototype.is_int=function(e){return Number(e)===e&&e%1==0},e.prototype.is_float=function(e){return Number(e)===e&&e%1!=0},e.prototype.is_number=function(e){return this.is_int(e)||this.is_float(e)},e}(),je=new(function(){function e(){}return e.prototype.init=function(){this._current=void 0,this._spectator=void 0},Object.defineProperty(e.prototype,"current",{get:function(){return this._current},set:function(e){this._current=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spectator",{get:function(){return this._spectator},set:function(e){this._spectator=e},enumerable:!1,configurable:!0}),e}()),Ue=new(function(){function t(){}return t.prototype.init=function(){this.width=1,this.height=1,this.position=new e,this.render_width=1,this.render_height=1,this.width_height=new e(this.width,this.height),this.dpr=1,this.pixel_size=new e(1/this.width,1/this.height)},t.prototype.update_position=function(e,t){this.position.set(e,t)},t.prototype.update=function(){this.size_changed=!1},t.prototype.update_size=function(t,r){this.width=t,this.height=r,this.pixel_size=new e(1/this.width,1/this.height),this.width_height.x=t,this.width_height.y=r,this.render_width=t*this.dpr,this.render_height=r*this.dpr,this.size_changed=!0},t.prototype.apply_pixel_density_v2=function(e){return e.multiplyScalar(1/this.dpr),e},t.prototype.apply_pixel_density=function(e){return e*(1/this.dpr)},t.prototype.get_pixel_size=function(){return this.pixel_size},Object.defineProperty(t.prototype,"aspect_ratio",{get:function(){return this.width/this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"portrait",{get:function(){return this.width<this.height},enumerable:!1,configurable:!0}),t}()),Ie=new(function(){function e(){}return e.prototype.init=function(){this._current=new _t({name:"default_scene",compilators:{}}),this._current.name="default_scene"},e.prototype.add_scene=function(e){},Object.defineProperty(e.prototype,"current",{get:function(){return this._current},set:function(e){this._current=e},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){for(this.current.traverse((function(e){if(e.geometry){e.geometry.dispose();var t=e.material;Array.isArray(t)?t.forEach((function(e){return e.dispose()})):t.dispose()}}));this.current.children.length>0;)this.current.remove(this.current.children[0])},e}()),Ne=function(){function e(e){this.renderer=e,this._blit_scene=new a,this._blit_material=new Ae,this._blit_quad=new s(new u(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new l(-1,1,1,-1,-1e4,1e4)}return e.prototype.blit=function(e,t){this._blit_quad.material=this._blit_material;var r=!0===e.isRenderTarget?e.texture:e,n=!0===e.isRenderTarget?e.width:e.image.width,i=!0===e.isRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=r,this._blit_quad.material.uniforms._Resolution.value.set(n,i),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)},e.prototype.material_pass=function(e,t){this._blit_quad.material=e,this.__render(t)},e.prototype.blit_with_material=function(e,t,r){var n=!0===e.isRenderTarget?e.texture:e,i=!0===e.isRenderTarget?e.width:e.image.width,o=!0===e.isRenderTarget?e.height:e.image.height;this._blit_quad.material=r,this._blit_quad.material.uniforms._MainTex.value=n,this._blit_quad.material.uniforms._Resolution.value.set(i,o),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)},e.prototype.blit_clear_with_material=function(e,t){this._blit_quad.material=t,this.__render(e)},e.prototype.dispose=function(){this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose()},e.prototype.__render=function(e){var t=void 0===e?null:e,r=this.renderer.getRenderTarget();this.renderer.setRenderTarget(t),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(r)},e}(),Ee=function(e){function t(t,r){var n=e.call(this,"#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;return n.uniforms._DepthNormal={value:new _(t,r.x,r.y,r.z)},n}return Me(t,e),t}(Ae),qe=function(e){function t(){return e.call(this,{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)));}"})||this}return Me(t,e),Object.defineProperty(t.prototype,"far_plane",{get:function(){return this.uniforms._FarPlane.value},set:function(e){this.uniforms._FarPlane.value=e},enumerable:!1,configurable:!0}),t}(i),Ve=function(){function e(){this.RT=new c(Ue.width,Ue.height),this.clear_depth_normal_mat=new Ee(1,new h(0,0,1)),this.depth_normal_material=new qe}return e.prototype.render=function(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=je.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)},e.prototype.__resize_RT_if_necessary=function(){this.RT.width===Ue.width&&this.RT.height===Ue.height||this.RT.setSize(Ue.width,Ue.height)},Object.defineProperty(e.prototype,"render_target",{get:function(){return this.RT},enumerable:!1,configurable:!0}),e}(),Be=new(function(){function e(){}return e.prototype.init=function(e){var t=e.core_attributes,r=e.renderer_attributes,n=e.dpr;this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generate_depth_normal_texture=!1,this.depth_and_normals_renderer=void 0,this.core_attributes={xr_enabled:!1},Object.assign(this.core_attributes,t),this._renderer=new se(r),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,Ue.dpr=n,this._renderer.setPixelRatio(1),this.blitter=new Ne(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new Le,this.current_render_mode=this.no_render,this.generate_depth_normal_texture=!1,this.depth_and_normals_renderer=new Ve},Object.defineProperty(e.prototype,"dom_element",{get:function(){return this._renderer.domElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth_normals_RT",{get:function(){return this.depth_and_normals_renderer.render_target},enumerable:!1,configurable:!0}),e.prototype.set_state=function(e){this.current_render_mode.on_exit(this,this._renderer),this.current_render_mode=e,this.current_render_mode.on_enter(this,this._renderer)},e.prototype.update=function(){this.generate_depth_normal_texture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),je.current&&this.current_render_mode.render(),Ue.update()},e.prototype.__update_current_camera=function(){je.current&&(je.current.aspect=Ue.aspect_ratio,je.current.updateProjectionMatrix(),je.current.updateMatrix(),je.current.updateMatrixWorld(!0))},e.prototype.render=function(e,t,r,n){this.__apply_override_material(e,n),this._renderer.setRenderTarget(void 0===r?null:r),this._renderer.render(e||Ie.current,t||je.current),this.__apply_override_material(e,void 0)},e.prototype.compile=function(e,t,r,n){return Fe(this,void 0,void 0,(function(){return ze(this,(function(i){switch(i.label){case 0:return this.__apply_override_material(e,n),this._renderer.setRenderTarget(void 0===r?null:r),[4,this._renderer.compile(e||Ie.current,t||je.current)];case 1:return i.sent(),this.__apply_override_material(e,void 0),[2]}}))}))},e.prototype.compile_async=function(e,t,r,n,i){return Fe(this,void 0,void 0,(function(){var o;return ze(this,(function(a){return this.__apply_override_material(e,n),this._renderer.setRenderTarget(void 0===r?null:r),o=this._renderer.compileAsync(e||Ie.current,t||je.current,i),this.__apply_override_material(e,void 0),[2,o]}))}))},e.prototype.render_scene=function(e){"on_pre_render"in e&&e.on_pre_render(),"render"in e?e.render():this.render(e,void 0),"on_post_render"in e&&e.on_post_render()},e.prototype.__apply_override_material=function(e,t){t=void 0===t?null:t,e?e.overrideMaterial=t:Ie.current.overrideMaterial=t},e.prototype.readback_RT=function(e){return Fe(this,void 0,void 0,(function(){return ze(this,(function(t){return[2,this._renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height)]}))}))},e.prototype.clear=function(e,t,r,n){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!r,!!n)},e.prototype.on_resize=function(e,t){for(var r=0,n=e;r<n.length;r++){var i=n[r];Ue.dpr=t,Ue.update_position(i.contentRect.x,i.contentRect.y),Ue.update_size(i.contentRect.width,i.contentRect.height),this.canvas.width=Ue.render_width,this.canvas.height=Ue.render_height,this._renderer.setViewport(0,0,Ue.render_width,Ue.render_height),this._renderer.setSize(window.innerWidth,window.innerHeight),this.__update_current_camera()}},e.prototype.material_pass=function(e,t){this.blitter.material_pass(e,t)},e.prototype.blit=function(e,t,r){r?this.blitter.blit_with_material(e,t,r):this.blitter.blit(e,t)},e.prototype.blit_clear_with_material=function(e,t){this.blitter.blit_clear_with_material(e,t)},e.prototype.take_screenshot=function(e,t,r){void 0===t&&(t=Ue.width),void 0===r&&(r=Ue.height);var n=Ue.width,i=Ue.height,o=t,a=r,s=1024,u=1024,l=Math.ceil(o/s),_=Math.ceil(a/u);Ue.update_size(s,u);var c=this._renderer.getPixelRatio();this._renderer.setPixelRatio(1),this._renderer.setSize(s,u,!1);var h=document.createElement("canvas").getContext("2d");h.canvas.width=o,h.canvas.height=a,je.current.aspect=Ue.aspect_ratio,je.current.updateMatrix(),je.current.updateMatrixWorld(!0);for(var p=0;p<l;p++)for(var d=0;d<_;d++)je.current.setViewOffset(o,a,Ue.width*p,Ue.height*d,Ue.width,Ue.height),this.current_render_mode.render(),h.drawImage(this._renderer.domElement,Ue.width*p,Ue.height*d);h.canvas.toBlob(e,"image/png;base64;"),je.current.clearViewOffset(),Ue.update_size(n,i),this._renderer.setPixelRatio(c),this._renderer.setSize(n,i,!1),je.current.aspect=Ue.aspect_ratio,je.current.updateMatrix(),je.current.updateMatrixWorld(!0)},e.prototype.download_screenshot=function(e){var 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")}},e.prototype.dispose=function(){this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose()},e}()),Ye=function(){function e(e,t,r,n){void 0===t&&(t=!0),void 0===r&&(r=1),void 0===n&&(n=!1),this.buffer=e,this.loop=t,this.volume=r,this.positional=n,this.audio=void 0}return e.prototype.init=function(e){this.positional?this.audio=new p(e):this.audio=new d(e),this.audio.setBuffer(this.buffer),this.audio.setLoop(this.loop),this.audio.gain.gain.value=0,this.audio.setVolume(this.loop?0:this.volume)},e.prototype.play=function(){this.audio.play()},e.prototype.pause=function(){this.audio.pause()},e.prototype.stop=function(){this.audio.stop()},Object.defineProperty(e.prototype,"is_playing",{get:function(){return this.audio.isPlaying},enumerable:!1,configurable:!0}),e}(),Ge=function(e){function t(t,r,n,i,o,a){void 0===n&&(n=!0),void 0===i&&(i=0),void 0===a&&(a=!1);var s=e.call(this,t,r,o)||this;return s.loop=n,s.volume=i,s.positional=a,s}return Me(t,e),t.prototype.on_preloaded_finished=function(e){void 0===e.resources_by_url[this.url]?this.instantiate_audio(e):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t.prototype.instantiate_audio=function(e){var t=this,r=f.getContext(),n=r.createBuffer(2,22050,44100);fetch(this.url).then((function(e){return e.blob()})).then((function(i){i.arrayBuffer?i.arrayBuffer().then((function(n){r.decodeAudioData(n,(function(r){e.set_resource(t.resource_id,t.url,new Ye(r,t.loop,t.volume,t.positional)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}))})):(e.set_resource(t.resource_id,t.url,new Ye(n,t.loop,t.volume,t.positional)),t.__update_downloaded_bytes(1,1),t.__loading_ended())}))},t}(De),We=function(){function e(){}return e.prototype.init=function(){this.resources={},this.resources_by_url={}},e.prototype.set_resource=function(e,t,r){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=r,this.resources_by_url[t]=r)},e.prototype.get_resource=function(e){return this.resources[e]},e.prototype.get=function(e){return this.resources[e]},e}(),Xe=new We,Qe=function(){function e(e,t,r){this.resource_container=Xe,this.assets=t,this.name=e,this.worker=r,this.bound_on_message=this.on_message.bind(this),this.__setup_worker(),this.assets_loaders=this.__setup_loaders()}return e.prototype.load=function(){this.worker.postMessage({type:"load",loader_name:this.name})},e.prototype.is_loaded=function(){for(var e=0;e<this.assets_loaders.length;e++){var t=this.assets_loaders[e];if(!t.has_finished)return!1;t.has_error&&(t.url=t.original_url,t.print_error())}return!0},e.prototype.get_progress=function(){return this.__get_loaded_bytes()/this.__get_total_bytes()},e.prototype.__get_loaded_bytes=function(){for(var e=1,t=0;t<this.assets_loaders.length;t++)e+=this.assets_loaders[t].loaded_bytes;return e},e.prototype.__get_total_bytes=function(){for(var e=1,t=0;t<this.assets_loaders.length;t++)e+=this.assets_loaders[t].total_bytes;return e},e.prototype.get_assets_names=function(){for(var e=[],t=0;t<this.assets.length;t++){var r=this.assets[t];e.push(r.name)}return e},e.create_worker=function(){return new Worker(new URL("./assets_loader/AsyncAssetsLoaderWorker.ts",import.meta.url),{name:"OHZI - AssetLoader",type:"module"})},e.prototype.__setup_worker=function(){this.worker.addEventListener("message",this.bound_on_message),this.worker.postMessage({type:"assets",loader_name:this.name,data:this.assets})},e.prototype.on_message=function(e){var t=e.data;if(t.type==="asset_loaded_".concat(this.name))this.__on_assets_loaded(t.data)},e.prototype.__on_assets_loaded=function(e){this.worker.removeEventListener("message",this.bound_on_message);for(var t=0;t<this.assets_loaders.length;t++){var r=this.assets_loaders[t];r.original_url=r.url,r.url=e[r.resource_id],r.on_preloaded_finished(this.resource_container)}},e.prototype.__setup_loaders=function(){return console.warn("Not implemented"),[]},e}(),He=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.__setup_loaders=function(){for(var e=[],t=0;t<this.assets.length;t++){var r=this.assets[t];e.push(new Ge(r.name,r.url,r.loop,r.volume,r.size,r.positional))}return e},t}(Qe),Ze=function(e){function t(t,r,n,i){var o=e.call(this,t,r,i)||this;return o.loader=new le,o.loader.setDRACOLoader(n),o}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Je=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new le,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Ke=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.__setup_loaders=function(){for(var e=[],t=0;t<this.assets.length;t++){var r=this.assets[t];if(r.draco){var n=Xe.get("draco_loader");e.push(new Ze(r.name,r.url,n,r.size))}else e.push(new Je(r.name,r.url,r.size))}return e},t}(Qe),$e=new(function(){function e(){}return e.prototype.init=function(){return Fe(this,void 0,void 0,(function(){var e,t;return ze(this,(function(r){switch(r.label){case 0:return this.browser_name="",this.agent=window.navigator.userAgent.toLowerCase(),this.has_web_xr_support="xr"in navigator,e=this,(t=this.has_web_xr_support)?[4,navigator.xr.isSessionSupported("immersive-vr")]:[3,2];case 1:t=r.sent(),r.label=2;case 2:switch(e.is_vr=t,!0){case this.agent.indexOf("edge")>-1:this.browser_name="edge_ie";break;case this.agent.indexOf("edg")>-1:this.browser_name="edge_chromium";break;case this.agent.indexOf("opr")>-1&&!!window.opr:this.browser_name="opera";break;case this.agent.indexOf("chrome")>-1&&!!window.chrome:this.browser_name="chrome";break;case this.agent.indexOf("trident")>-1:this.browser_name="iexplorer";break;case this.agent.indexOf("firefox")>-1:this.browser_name="firefox";break;case this.agent.indexOf("safari")>-1:this.browser_name="safari";break;default:this.browser_name="other"}return this.version=this.get_version(),[2]}}))}))},Object.defineProperty(e.prototype,"name",{get:function(){return this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is_safari",{get:function(){return"safari"===this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is_chrome",{get:function(){return"chrome"===this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is_firefox",{get:function(){return"firefox"===this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is_edge",{get:function(){return"edge_ie"===this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is_edge_chromium",{get:function(){return"edge_chromium"===this.browser_name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"has_webm",{get:function(){return!!(this.is_chrome||this.is_firefox||this.is_edge_chromium)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"has_hvec",{get:function(){return this.is_safari},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"preferred_video_extension",{get:function(){return this.has_webm?"webm":this.has_hvec?"hvec.mp4":"mp4"},enumerable:!1,configurable:!0}),e.prototype.get_version=function(){var e=navigator.userAgent,t=[],r="0",n=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])&&(r="IE "+((t=/\brv[ :]+(\d+)/g.exec(e)||[])[1]||"")),"Chrome"===n[1]&&null!=(t=e.match(/\b(OPR|Edge)\/(\d+)/))&&(r=t.slice(1).join(" ").replace("OPR","Opera")),n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+(\.\d+)?)/i))&&n.splice(1,1,t[1]),r=n.join(" "),Number(r.split(" ")[1])},e}()),et=function(e){function t(t,r,n,i,o,a){void 0===i&&(i=!0),void 0===o&&(o=!1),void 0===a&&(a=!0);var s=e.call(this,t,r,n)||this;return s.original_url="",s.colorSpaceConversion=a,s.premultiplyAlpha=o,s.flipY=i,s}return Me(t,e),t.prototype.on_preloaded_finished=function(e){$e.is_safari?this.load_with_old_method(e):this.load_with_new_method(e)},t.prototype.load_with_old_method=function(e){var t=this;if(void 0===e.resources_by_url[this.url]){var r=new n,i=new Image;i.src=this.url,i.onload=function(){r.image=i,r.flipY=t.flipY,r.premultiplyAlpha=t.premultiplyAlpha,r.colorSpace=t.colorSpaceConversion?m:v,r.needsUpdate=!0,e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()},i.onerror=function(){console.error("The source image could not be decoded.",t.original_url)}}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()},t.prototype.load_with_new_method=function(e){var t=this;if(void 0===e.resources_by_url[this.url]){var r={credentials:"same-origin"};fetch(this.url,r).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,{colorSpaceConversion:t.colorSpaceConversion?"default":"none",imageOrientation:t.flipY?"flipY":"from-image",premultiplyAlpha:t.premultiplyAlpha?"premultiply":"none"})})).then((function(r){var i=new n(r);i.flipY=t.flipY,i.premultiplyAlpha=t.premultiplyAlpha,i.colorSpace=t.colorSpaceConversion?m:v,i.needsUpdate=!0,e.set_resource(t.resource_id,t.url,i),t.__update_downloaded_bytes(1,1),t.__loading_ended()})).catch((function(e){console.error(e,t.original_url)}))}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()},t}(De),tt=function(e){function t(t,r,n,i){var o=e.call(this,t,r,i)||this;return o.loader=n,o}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(e){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),rt=function(e){function t(t,r,n,i){var o=e.call(this,t,r,i)||this;return o.loader=new g,o.loader.setPath(r+"/"),o.urls=["px.".concat(n),"nx.".concat(n),"py.".concat(n),"ny.".concat(n),"pz.".concat(n),"nz.".concat(n)],o}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(e){t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯"+e),t.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),nt=function(e){function t(t,r,n,i){var o=e.call(this,t,r,i)||this;return o.loader=new _e,o.loader.setPath(r+"/"),o.urls=["px.".concat(n),"nx.".concat(n),"py.".concat(n),"ny.".concat(n),"pz.".concat(n),"nz.".concat(n)],o}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),it=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new ce,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),ot=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.__setup_loaders=function(){for(var e=[],t=0;t<this.assets.length;t++){var r=this.assets[t];switch(r.kind){case"regular":e.push(new et(r.name,r.url,r.size,r.flipY,r.premultiplyAlpha,r.colorSpaceConversion));break;case"basis":e.push(new tt(r.name,r.url,Xe.get("basis_loader"),r.size));break;case"hdr":e.push(new it(r.name,r.url,r.size));break;case"cubemap":e.push(new rt(r.name,r.url,r.extension,r.size));break;case"cubemap_hdr":e.push(new nt(r.name,r.url,r.extension,r.size))}}return e},t}(Qe),at=function(){function e(e){this.compilators=e,this.first_update=!0,this.index=0}return e.prototype.update=function(){this.is_finished()||(this.compilators[this.index].finished?(this.index++,this.first_update=!0):this.first_update?(this.compilators[this.index].start(),this.first_update=!1):this.compilators[this.index].update())},e.prototype.is_finished=function(){return this.index===this.compilators.length},e}(),st=function(){function e(e,t){var r=t.SceneCompilator,n=t.TexturesCompilator,i=t.AudiosCompilator;this.scene=e,this.SceneCompilator=r,this.TexturesCompilator=n,this.AudiosCompilator=i,this.loaders=[],this.compilators=[],this.callback_called=!1}return e.prototype.set_assets=function(e,t,r,n,i,o){void 0===n&&(n=[]),void 0===i&&(i=[]),void 0===o&&(o=[]),this.scene_objects=e,this.scene_textures=t,this.scene_sounds=r,this.custom_loaders=n,this.custom_compilators=i,this.custom_data=o},Object.defineProperty(e.prototype,"loading_progress",{get:function(){for(var e=0,t=0;t<this.loaders.length;t++){e+=this.loaders[t].get_progress()}return e/this.loaders.length},enumerable:!1,configurable:!0}),e.prototype.load=function(){this.setup_loader(),this.loaders[0].load()},e.prototype.on_enter=function(){},e.prototype.on_exit=function(){},e.prototype.update=function(){},e.prototype.setup_loader=function(){var e=[],t=Xe.get("assets_worker");t.postMessage({type:"reset",loader_name:this.scene.name});var r=new Ke(this.scene.name,this.scene_objects,t);this.loaders.push(r),e.push(new this.SceneCompilator(this.scene));var n=new ot(this.scene.name,this.scene_textures,t);this.loaders.push(n),e.push(new this.TexturesCompilator(n.get_assets_names()));var i=new He(this.scene.name,this.scene_sounds,t);this.loaders.push(i),e.push(new this.AudiosCompilator(i.get_assets_names()));for(var o=0;o<this.custom_loaders.length;o++){var a=new this.custom_loaders[o](this.scene.name,this.custom_data[o],t);this.loaders.push(a),e.push(new this.custom_compilators[o](a.get_assets_names()))}this.compilator_manager=new at(e)},e.prototype.is_loaded=function(){for(var e=!0,t=0;t<this.loaders.length;t++){var r=this.loaders[t];e=e&&r.is_loaded()}return e},e.prototype.is_compiled=function(){return this.compilator_manager.update(),this.compilator_manager.is_finished()},e}(),ut=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Me(t,e),t.prototype.on_enter=function(){e.prototype.on_enter.call(this)},t.prototype.on_exit=function(){e.prototype.on_exit.call(this)},t.prototype.update=function(){e.prototype.update.call(this),this.is_loaded()&&this.scene.on_high_quality_assets_ready()},t}(st),lt=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.on_assets_ready_called=!1,n}return Me(t,e),t.prototype.on_enter=function(){e.prototype.on_enter.call(this)},t.prototype.on_exit=function(){e.prototype.on_exit.call(this)},t.prototype.update=function(){e.prototype.update.call(this),this.is_loaded()&&(this.on_assets_ready_called||(this.scene.on_assets_ready(),this.on_assets_ready_called=!0),this.is_compiled()&&this.scene.on_assets_compiled())},t}(st),_t=function(e){function t(t){var r=t.name,n=t.compilators,i=e.call(this)||this;return i.name=r,i.initialized=!1,i.is_loaded=!1,i.is_high_loaded=!1,i.loading_states={regular:new lt(i,n),high:new ut(i,n)},i.current_loading_state=new st(i,n),i}return Me(t,e),Object.defineProperty(t.prototype,"loading_progress",{get:function(){return this.current_loading_state.loading_progress},enumerable:!1,configurable:!0}),t.prototype.init=function(){this.initialized=!0},t.prototype.load=function(){this.initialized||this.init(),this.set_loading_state(this.loading_states.regular),this.current_loading_state.load()},t.prototype.get_objects=function(){var e=[];return this.traverse((function(t){t instanceof s&&t.geometry&&e.push(t)})),e},t.prototype.dispose_cpu=function(){this.traverse((function(e){if(e instanceof s&&e.geometry&&(e.geometry.attributes.position.array=new Float32Array(3),e.geometry.attributes.normal&&(e.geometry.attributes.normal.array=new Float32Array(3)),e.geometry.attributes.uv&&(e.geometry.attributes.uv.array=new Float32Array(2)),e.material.map))for(var t=0;t<e.material.map.mipmaps.length;t++)e.material.map.mipmaps[t]=new Uint8Array(4)})),this.initialized=!1},t.prototype.dispose=function(){this.traverse((function(e){e instanceof s&&e.material&&(e.material.map&&e.material.map.dispose(),e.material.dispose(),e.geometry.dispose())})),this.initialized=!1},t.prototype.set_assets=function(e,t,r,n,i,o){this.loading_states.regular.set_assets(e,t,r,n,i,o)},t.prototype.set_high_assets=function(e,t,r,n,i,o){this.loading_states.high.set_assets(e,t,r,n,i,o)},t.prototype.set_loading_state=function(e){this.current_loading_state.on_exit(),this.current_loading_state=e,this.current_loading_state.on_enter()},t.prototype.update_loading_state=function(){this.is_high_loaded||this.current_loading_state.update()},t.prototype.update=function(){this.update_loading_state()},t.prototype.on_assets_ready=function(){},t.prototype.on_assets_compiled=function(){this.is_loaded=!0,this.set_loading_state(this.loading_states.high),this.current_loading_state.load()},t.prototype.on_high_quality_assets_ready=function(){this.is_high_loaded=!0},t.prototype.on_pre_render=function(){},t.prototype.render=function(){Be.render(this,je.current)},t.prototype.on_post_render=function(){},t}(a),ct=function(){function e(e,t,r){this.name=e,this.method=t,this.args=r}return e.prototype.trigger=function(){var e;(e=ViewApi.application[this.name])[this.method].apply(e,this.args.split(","))},e}(),ht=function(){function e(){}return e.linear_map=function(e,t,r,n,i){return(e-t)/(r-t)*(i-n)+n},e.between=function(e,t,r){return e>=t&&e<=r},e.mod=function(e,t){return(e%t+t)%t},e.rgb_to_hex=function(e){return e.r=Math.round(255*parseFloat(e.r)).toString(16),e.g=Math.round(255*parseFloat(e.g)).toString(16),e.b=Math.round(255*parseFloat(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},e.project_points_on_plane=function(e,t){var r=e[0].clone();r.set(0,0,0);for(var n=[],i=0;i<e.length;i++)t.projectPoint(e[i],r),n.push(r.clone());return n},e.matrix4_lerp=function(e,t,r,n){for(var i=0;i<16;i++)r.elements[i]=this.lerp(e.elements[i],t.elements[i],n)},e.equals=function(e,t){return Math.abs(e-t)<1e-6},e.lerp=function(e,t,r){return(1-r)*e+r*t},e.clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},e.euclideanModulo=function(e,t){return(e%t+t)%t},e.pingpong=function(t,r){return void 0===r&&(r=1),r-Math.abs(e.euclideanModulo(t,2*r)-r)},e.degToRad=function(e){return e*(Math.PI/180)},e.radToDeg=function(e){return e*(180/Math.PI)},e.deg_to_rad=function(e){return e*(Math.PI/180)},e.rad_to_deg=function(e){return e*(180/Math.PI)},e.perspective_divide=function(e){return e.x/=e.w,e.y/=e.w,e.z/=e.w,e},e.points_average=function(e){for(var t=e[0].clone(),r=1;r<e.length;r++)t.add(e[r]);return t.multiplyScalar(1/e.length),t},e.get_random_color=function(){var 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())]},e.saturate=function(t){return e.clamp(t,0,1)},e.generate_uuid=function(){var e=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&r]+e[r>>8&255]+"-"+e[r>>16&15|64]+e[r>>24&255]+"-"+e[63&n|128]+e[n>>8&255]+"-"+e[n>>16&255]+e[n>>24&255]+e[255&i]+e[i>>8&255]+e[i>>16&255]+e[i>>24&255]).toLowerCase()},e}(),pt=function(){function e(e){void 0===e&&(e={}),this.previous_elapsed_time=-1e-5,this.elapsed_time=-1e-5,this.playback_speed=this.__get_playback_speed(),this.playing=!0,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};for(var t=Object.keys(e),r=0;r<t.length;r++)this.channels[t[r]]=[];this.duration=0}return e.prototype.play=function(){this.playing=!0},e.prototype.stop=function(){this.playing=!1},e.prototype.reset=function(){this.elapsed_time=-1e-5},e.prototype.skip=function(){var e=this.get_duration();this.__play_clips(this.elapsed_time,e+1e-4),this.elapsed_time=e},e.prototype.update=function(e){this.playing&&(this.previous_elapsed_time=this.elapsed_time,this.elapsed_time+=e*this.playback_speed,this.__play_clips(this.previous_elapsed_time,this.elapsed_time))},e.prototype.set_progress=function(e){this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=ht.clamp(e,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)},e.prototype.set_normalized_progress=function(e){this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=ht.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)},e.prototype.get_progress=function(){return ht.clamp(this.elapsed_time/this.get_duration(),0,1)},e.prototype.is_finished=function(){return this.elapsed_time>this.get_duration()},e.prototype.add_action_event=function(e,t){this.action_events.push({trigger_time:e,action:t}),this.duration=Math.max(this.duration,e)},e.prototype.add_action_interpolator=function(e,t,r,n){if(void 0===n&&(n=!1),n){var i=this.channels[r.attribute_name];void 0===i&&console.error("".concat(r.attribute_name," missing in initial state data.")),0===i.length?r.from=this.initial_context[r.attribute_name]:r.from=i[i.length-1].interpolator.to}var o={from:e,to:t,interpolator:r};this.duration=Math.max(this.duration,t),this.channels[r.attribute_name].push(o)},e.prototype.get_current_target_value=function(e){var t=this.__get_current_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1)},e.prototype.get_current_starting_value=function(e){return this.__get_current_keyframe(e,this.elapsed_time).interpolator.evaluate(0)},e.prototype.get_current_progress=function(e){var t=this.__get_current_keyframe(e,this.elapsed_time),r=this.__linear_map_01(this.elapsed_time,t.from,t.to);return t.interpolator.easing_function(r)},e.prototype.get_duration=function(){return this.duration},e.prototype.__play_clips=function(e,t){this.elapsed_time>this.previous_elapsed_time&&this.__play_events(this.previous_elapsed_time,this.elapsed_time);for(var r=Object.keys(this.initial_context),n=0;n<r.length;n++){var i=r[n],o=this.__get_current_keyframe(i,e);this.context[i]=this.evaluate_keyframe(o,e)}},e.prototype.__play_events=function(e,t){for(var r=0;r<this.action_events.length;r++){var n=this.action_events[r].trigger_time;ht.between(n,e,t)&&this.action_events[r].action.trigger()}},e.prototype.evaluate_keyframe=function(e,t){return this.tmp_t=this.__linear_map_01(t,e.from,e.to),e.interpolator.evaluate(ht.clamp(this.tmp_t,0,1))},e.prototype.get_keyframes=function(e){return this.channels[e]},e.prototype.is_channel_redefined=function(e){for(var t=0;t<this.channels[e].length;t++){if(this.channels[e][t].interpolator.initial)return!1}return!0},e.prototype.__linear_map_01=function(e,t,r){return ht.saturate((e-t)/(r-t)*1+0)},e.prototype.__get_current_keyframe=function(e,t){for(var r=void 0,n=this.channels[e],i=0;i<n.length;i++){if(t>=(a=n[i]).from&&t<=a.to)return r=a}var o=1/0;for(i=0;i<n.length;i++){var a=n[i],s=Math.abs(a.to-t);s<o&&(r=a,o=s)}return r},e.prototype.__get_playback_speed=function(){var e=new URLSearchParams(window.location.search).get("transitions_velocity");return e?Number(e):1},e.prototype.set_initial_value_on_channel=function(e,t){this.get_keyframes(e)[0].interpolator.from=t},e.prototype.set_final_value_on_channel=function(e,t){var r=this.get_keyframes(e);r[r.length-1].interpolator.to=t},e}(),dt=function(){function e(){}return e.linear=function(e){return e},e.triangular=function(e){return 1-Math.abs(2*e%2-1)},e.ease_in_sine=function(e){return 1-Math.cos(3.1415926*e/2)},e.ease_out_sine=function(e){return Math.sin(3.1415926*e/2)},e.ease_in_out_sine=function(e){return-(Math.cos(3.1415926*e)-1)/2},e.ease_in_cubic=function(e){return e*e*e},e.ease_out_cubic=function(e){return 1-Math.pow(1-e,3)},e.ease_in_out_cubic=function(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},e.ease_in_quad=function(e){return e*e},e.ease_out_quad=function(e){return 1-(1-e)*(1-e)},e.ease_in_out_quad=function(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},e.ease_in_quart=function(e){return e*e*e*e},e.ease_out_quart=function(e){return 1-Math.pow(1-e,4)},e.ease_in_out_quart=function(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2},e.ease_in_quint=function(e){return e*e*e*e*e},e.ease_out_quint=function(e){return 1-Math.pow(1-e,5)},e.ease_in_out_quint=function(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2},e.ease_in_expo=function(e){return 0===e?0:Math.pow(2,10*e-10)},e.ease_out_expo=function(e){return 1===e?1:1-Math.pow(2,-10*e)},e.ease_in_out_expo=function(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},e.ease_in_circ=function(e){return 1-Math.sqrt(1-Math.pow(e,2))},e.ease_out_circ=function(e){return Math.sqrt(1-Math.pow(e-1,2))},e.ease_in_out_circ=function(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},e.ease_in_back=function(e){return 2.7015*e*e*e-1.7015*e*e},e.ease_out_back=function(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)},e.ease_in_out_back=function(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},e.ease_in_elastic=function(e){var 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)},e.ease_out_elastic=function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1},e.ease_in_out_elastic=function(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},e.ease_in_bounce=function(e){return 1-this.ease_out_bounce(1-e)},e.ease_out_bounce=function(e){var t=7.5625,r=2.75;return e<1/r?t*e*e:e<2/r?t*(e-=1.5/r)*e+.75:e<2.5/r?t*(e-=2.25/r)*e+.9375:t*(e-=2.625/r)*e+.984375},e.ease_in_out_bounce=function(e){return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2},e.heartbeat=function(e){return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8},e}(),ft=function(){function e(e){void 0===e&&(e="linear"),this.easing_function=void 0,this.easing_function="string"==typeof e?dt[e]:e,this.attribute_name="",this.from=0,this.to=1}return e.prototype.update=function(e,t){},e}(),mt=function(e){function t(t,r,n,i,o){void 0===r&&(r=0),void 0===n&&(n=1),void 0===i&&(i=!1),void 0===o&&(o="linear");var a=e.call(this,o)||this;return a.attribute_name=t,a.from=r,a.to=n,a.initial=i,a}return Me(t,e),t.prototype.update=function(e,t){e[this.attribute_name]=ht.lerp(this.from,this.to,this.easing_function(t))},t.prototype.evaluate=function(e){return ht.lerp(this.from,this.to,this.easing_function(e))},t}(ft),vt=function(){function e(){}return e.prototype.parse=function(e){for(var t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),r=[],n=[],i=0;i<t.length;i++){var o=t[i],a=o.parentElement,s=a.getAttribute("value"),u=this.get_node_x_position(o)/100,l=parseFloat(o.getAttribute("width"))/100;if(a.getAttribute("style").includes("rhombus;")){var _=(h=s.split("."))[0],c=h[1];n.push({name:_,method:c,at_time:u+.5*l})}if(a.getAttribute("style").includes("rounded=0;")&&!a.getAttribute("style").includes("text;")&&""!==s&&!s.includes(" ")){var h,p=(h=s.split("="))[0],d=h[1].split("--"),f=parseFloat(d[0]),m=d[1];2!==h.length&&console.error("DrawIO data is malformed:",s),2!==d.length&&console.error("DrawIO data is malformed:",s),r.push({attribute_name:p,from_time:u,to_time:u+l,to_value:f,easing_function:m})}}return r.sort((function(e,t){return e.from_time-t.from_time})),{animation_tracks:r,triggers:n}},e.prototype.get_node_x_position=function(e){var t=e.getAttribute("x");return null===t?0:parseFloat(t)},e}(),gt=function(){function e(e){this.default_state_data=e}return e.prototype.from_animation_sheet=function(e,t,r){r=r||this.default_state_data;for(var n=e.animation_tracks,i=e.triggers,o=this.state_to_tracks(this.default_state_data,this.get_longest_time(e.animation_tracks)),a=function(e){void 0===n.find((function(t){return t.attribute_name===o[e].attribute_name}))&&n.push(o[e])},s=0;s<o.length;s++)a(s);var u=new pt(t);for(s=0;s<n.length;s++){var l=n[s],_=new mt(l.attribute_name,t[l.attribute_name],l.to_value,l.initial,l.easing_function);u.add_action_interpolator(l.from_time,l.to_time,_,!0)}for(s=0;s<i.length;s++){l=i[s];var c=new ct(l.name,l.method,l.args);u.add_action_event(l.at_time,c)}return u},e.prototype.state_to_tracks=function(e,t){for(var r=[],n=Object.keys(e),i=0;i<n.length;i++)r.push({attribute_name:n[i],from_time:0,to_time:t<1?t:1,to_value:e[n[i]],initial:!0,easing_function:"ease_in_out_cubic"});return r},e.prototype.from_draw_io=function(e,t){for(var r=(new vt).parse(e),n=r.animation_tracks,i=r.triggers,o=new pt(t),a=0;a<n.length;a++){var s=n[a],u=new mt(s.attribute_name,t[s.attribute_name],s.to_value,!1,s.easing_function);o.add_action_interpolator(s.from_time,s.to_time,u,!0)}for(a=0;a<i.length;a++){s=i[a];var l=new ct(s.name,s.method);o.add_action_event(s.at_time,l)}return o},e.prototype.get_longest_time=function(e){for(var t=-1,r=0;r<e.length;r++){var n=e[r].to_time;t=n>t?n:t}return t},e}(),yt=function(){function e(){this.transitions=[],this.default_state_data={}}return e.prototype.get=function(e,t,r){for(var n=0;n<this.transitions.length;n++){if(this.transitions[n].from===e&&this.transitions[n].to===t)return new gt(this.default_state_data).from_animation_sheet(this.transitions[n].data,r)}for(n=0;n<this.transitions.length;n++){if(this.transitions[n].to===t&&void 0===this.transitions[n].from)return new gt(this.default_state_data).from_animation_sheet(this.transitions[n].data,r)}console.error("TransitionTable.get no data found for: ",e,t)},e.prototype.add_transitions=function(e){for(var t=0;t<e.length;t++)this.transitions.push(e[t])},e.prototype.set_transitions=function(e){this.transitions=e},e.prototype.set_default_state_data=function(e){this.default_state_data=e},e}(),bt=new(function(){function e(){this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016]}return e.prototype.init=function(){this.__previous_elapsed_time=-1,this.__delta_time=0,this.__smooth_delta_time=0,this.__elapsed_time=0,this.__frame_interpolation_t=0,this.fixed_delta_time=1/30},Object.defineProperty(e.prototype,"elapsed_time",{get:function(){return this.__elapsed_time},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"delta_time",{get:function(){return this.__delta_time},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"smooth_delta_time",{get:function(){return this.__smooth_delta_time},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frame_interpolation",{get:function(){return this.__frame_interpolation_t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fdt",{get:function(){return this.fixed_delta_time},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dt",{get:function(){return this.delta_time},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sdt",{get:function(){return this.smooth_delta_time},enumerable:!1,configurable:!0}),e.prototype.__set_frame_interpolation=function(e){this.__frame_interpolation_t=e},e.prototype.__update=function(e){this.__previous_elapsed_time<0&&(this.__previous_elapsed_time=e),this.__delta_time=(e-this.__previous_elapsed_time)/1e3,this.__elapsed_time=e/1e3,this.__delta_buffer.shift(),this.__delta_buffer.push(this.delta_time<.32?this.delta_time:.032),this.__calculate_smooth_delta_time(),this.__previous_elapsed_time=e},e.prototype.__calculate_smooth_delta_time=function(){this.__smooth_delta_time=0;for(var e=0;e<this.__delta_buffer.length;e++)this.__smooth_delta_time+=this.__delta_buffer[e];this.__smooth_delta_time=this.__smooth_delta_time/this.__delta_buffer.length},e}()),wt=function(){function e(e){this.name=e}return e.prototype.start=function(){},e.prototype.before_enter=function(){},e.prototype.on_enter=function(){},e.prototype.before_exit=function(){},e.prototype.on_exit=function(){},e.prototype.before_update=function(){},e.prototype.update=function(){},e.prototype.fixed_update=function(){},e.prototype.update_enter_transition=function(e,t,r){},e.prototype.update_exit_transition=function(e,t,r){},e}(),xt=function(){function e(e){this.last_state=new wt("last_initial"),this.current_state=new wt("current_initial"),this.default_state_data={},this.current_state_data={},this.transition_table=e,this.transitioning=!1}return e.prototype.go_to_state=function(e,t){void 0===t&&(t=!1),this.transitioning&&this.__exit_last_state(),this.last_state=this.current_state,this.current_state=e,this.last_state.before_exit(),this.current_state.before_enter(),this.action_sequencer=this.transition_table.get(this.last_state.name,this.current_state.name,this.current_state_data),this.action_sequencer.play(),this.transitioning=!0,t&&(this.action_sequencer.skip(),this.update())},e.prototype.update=function(){this.transitioning?(this.__update_transitions(),this.action_sequencer.is_finished()&&(this.transitioning=!1,this.__update_transitions(),this.__exit_last_state(),this.current_state.on_enter())):this.current_state.update()},e.prototype.before_update=function(){this.current_state.before_update()},e.prototype.fixed_update=function(){this.current_state.fixed_update()},e.prototype.set_state=function(e){this.current_state=e},e.prototype.set_default_state_data=function(e){Object.assign(this.default_state_data,e),Object.assign(this.current_state_data,e)},e.prototype.__update_transitions=function(){this.action_sequencer.update(bt.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)},e.prototype.__exit_last_state=function(){this.last_state.on_exit()},e}(),Tt=new(function(){function e(){this.transition_table=new yt,this.transition_handler=new xt(this.transition_table)}return Object.defineProperty(e.prototype,"action_sequencer",{get:function(){return this.transition_handler.action_sequencer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"current_state_data",{get:function(){return this.transition_handler.current_state_data},enumerable:!1,configurable:!0}),e.prototype.get_current_state=function(){return this.transition_handler.current_state},e.prototype.go_to_state=function(e,t){void 0===t&&(t=!1),this.transition_handler.go_to_state(e,t)},e.prototype.before_update=function(){this.transition_handler.before_update()},e.prototype.update=function(){this.transition_handler.update()},e.prototype.fixed_update=function(){this.transition_handler.fixed_update()},e.prototype.add_transitions=function(e){this.transition_table.add_transitions(e)},e.prototype.set_transitions=function(e){this.transition_table.set_transitions(e)},e.prototype.set_state=function(e){this.transition_handler.set_state(e)},e.prototype.set_default_state_data=function(e){this.transition_table.set_default_state_data(e),this.transition_handler.set_default_state_data(e)},e}()),St=new(function(){function e(){this.views=[],this.browser_title_suffix=""}return e.prototype.update=function(){this.__set_views_opacities()},e.prototype.go_to_view=function(e,t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var n=this.get(e);t&&(this.__change_browser_url(n.url),this.__change_browser_title(n.url)),Tt.go_to_state(n,r)},e.prototype.go_to_scene=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=this.get(e),i=this.get("transition");i.set_next_view(n),this.go_to_view(i.name,t,r)},e.prototype.register_view=function(e){this.views.push(e)},e.prototype.has_view=function(e){for(var t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1},e.prototype.set_view=function(e){var t=this.get(e);Tt.set_state(t)},e.prototype.set_browser_title_suffix=function(e){this.browser_title_suffix=e},e.prototype.get_current_view=function(){return Tt.get_current_state()},e.prototype.get_view_by_name=function(e){console.warn("DEPRECATED. Use ViewManager.get instead"),this.get(e)},e.prototype.get=function(e){for(var 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)},e.prototype.get_by_url=function(e){for(var 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)},e.prototype.__change_browser_url=function(e){window.history.pushState("","",e)},e.prototype.__change_browser_title=function(e){var t=this.__capitalize(e);document.title=t?"".concat(t," | ").concat(this.browser_title_suffix):this.browser_title_suffix},e.prototype.__set_views_opacities=function(){for(var e=0;e<this.views.length;e++)this.views[e].set_opacity(Tt.current_state_data)},e.prototype.__capitalize=function(e){var t=e.toUpperCase().replace("/","");return t=this.__snake_to_whitespace(t)},e.prototype.__snake_to_whitespace=function(e){return e.replace(/([-_][A-Z])/g,(function(e){return e.replace("-"," ").replace("_"," ")}))},e}()),Mt=function(e){function t(t){var r=t.name,n=t.url,i=t.container,o=t.transition_data,a=e.call(this,r)||this;a.container=i,a.url=n,a.current_opacity=0;var s=[{to:r,data:o=o||{animation_tracks:[],triggers:[]}}];return St.register_view(a),Tt.add_transitions(s),a}return Me(t,e),t.prototype.before_enter=function(){this.container.classList.add("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")},t.prototype.on_enter=function(){this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")},t.prototype.before_exit=function(){this.container.classList.add("before_exit"),this.container.classList.remove("before_enter"),this.container.classList.remove("hidden")},t.prototype.on_exit=function(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")},t.prototype.set_opacity=function(e){var t=e["".concat(this.name,"_opacity")];(this.current_opacity>t||this.current_opacity<t)&&(this.current_opacity=t,this.container.style.opacity=this.current_opacity)},t}(wt),Ft=function(){function t(e){this.uses_dynamic_font=!!e,this.__textHeight=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}return t.prototype.getFontHeight=function(e){if(void 0===e&&(e="Arial"),null==this.__textHeight||this.uses_dynamic_font){var t=document.getElementsByTagName("body")[0],r=document.createElement("div"),n=document.createTextNode("MÉqgOLAKTAL");r.appendChild(n),r.setAttribute("style","font:".concat(e,";position:absolute;top:0;left:0")),t.appendChild(r),this.__textHeight=r.offsetHeight,t.removeChild(r)}return this.__textHeight},t.prototype.get_text_size=function(t,r){void 0===r&&(r="24px Arial");var n=new e;return this.ctx.font=r,n.x=Math.ceil(this.ctx.measureText(t).width),n.y=Math.ceil(this.getFontHeight(r)),n},t.prototype.draw_canvas=function(e,t){return void 0===t&&(t={}),t.font=t.font||"24px Arial",t.font_color=t.font_color||"#000000",this.__draw(e,t,this.canvas,this.ctx),this.canvas},t.prototype.draw_on_texture=function(e,t){var r=this.draw_canvas(e,t),n=new y(r,b,w,w,x,x);return n.generateMipmaps=!1,n.needsUpdate=!0,n},t.prototype.__draw=function(e,t,r,n){},t.prototype.roundRect=function(e,t,r,n,i,o,a,s){if(void 0===s&&(s=!0),void 0===o&&(o=5),"number"==typeof o)o={tl:o,tr:o,br:o,bl:o};else{var u={tl:0,tr:0,br:0,bl:0};for(var l in u){var _=l;o[_]=o[_]||u[_]}}e.beginPath(),e.moveTo(t+o.tl,r),e.lineTo(t+n-o.tr,r),e.quadraticCurveTo(t+n,r,t+n,r+o.tr),e.lineTo(t+n,r+i-o.br),e.quadraticCurveTo(t+n,r+i,t+n-o.br,r+i),e.lineTo(t+o.bl,r+i),e.quadraticCurveTo(t,r+i,t,r+i-o.bl),e.lineTo(t,r+o.tl),e.quadraticCurveTo(t,r,t+o.tl,r),e.closePath(),a&&e.fill(),s&&e.stroke()},t}(),zt=function(t){function r(){var r=t.call(this)||this;return r.text_margin=new e(2,0),r}return Me(r,t),r.prototype.__draw=function(e,t,r,n){n.font=t.font;var i=this.get_text_size(e,t.font);r.width=Math.ceil(i.x+2*this.text_margin.x),r.height=Math.ceil(i.y+2*this.text_margin.y),n.clearRect(0,0,r.width,r.height),n.globalAlpha=0,n.fillStyle=t.font_color||"#000000",n.fillRect(0,0,r.width,r.height),n.globalAlpha=1,n.globalAlpha=1,n.font=t.font,n.fillStyle=t.font_color||"#000000",n.textBaseline="middle",n.textAlign=t.textAlign||"center","center"===n.textAlign?n.fillText(e,r.width/2,r.height/2):n.fillText(e,0,r.height/2)},r}(Ft),At=new(function(){function e(){}return e.prototype.init=function(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1},e}()),Rt=function(e){function t(t){void 0===t&&(t=1);var n=e.call(this)||this,i=[];i.push(new h(0,0,0)),i.push(new h(0,0,1e3));var o=new T({color:4474111,depthFunc:r}),a=(new S).setFromPoints(i),s=new M(a,o);s.renderOrder=5e4;var u=[];u.push(new h(0,0,0)),u.push(new h(0,1e3,0));var l=new T({color:4521796,depthFunc:r}),_=(new S).setFromPoints(u),c=new M(_,l);c.renderOrder=5e4;var p=[];p.push(new h(0,0,0)),p.push(new h(1e3,0,0));var d=new T({color:16729156,depthFunc:r}),f=(new S).setFromPoints(p),m=new M(f,d);return m.renderOrder=5e4,n.renderOrder=1e5,n.add(s),n.add(c),n.add(m),n.scale.set(t,t,t),n}return Me(t,e),t.prototype.update=function(){},t.prototype.dispose=function(){},t}(F),Pt=function(t){function r(){return t.call(this,"\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 e},_ScreenSize:{value:new e},_TextureSize:{value:new e}})||this}return Me(r,t),r.prototype.set_position=function(e,t){this.uniforms._ScreenSpacePosition.value.set(e,t)},r.prototype.set_texture=function(e,t,r){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!==r&&(this.uniforms._TextureSize.value.y=r)},r.prototype.set_screen_size=function(e,t){this.uniforms._ScreenSize.value.set(e,t)},r}(ke),Ct=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n,i)||this;return a.clear_color=new o("#000000"),a.clear_alpha=1,a}return Me(t,e),t.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.clear_color.copy(t.clear_color),this.clear_alpha=t.clear_alpha,this},t}(z),kt=function(e){function t(t,r,n){var i=this;t=t||"#FF0000";var o=(r=r||1)-.4,a=new A(.01,.01,o,32);a.translate(0,o/2,0);var s=new R(.1,.4,32);s.translate(0,o+.2,0);var u=he.mergeGeometries([a,s]);u.rotateX(1.57);var l=new P({color:t});return i=e.call(this,u,l)||this,n&&i.quaternion.setFromUnitVectors(new h(0,0,1),n),i._dir=n,i}return Me(t,e),Object.defineProperty(t.prototype,"dir",{get:function(){return this._dir},set:function(e){this.quaternion.setFromUnitVectors(new h(0,0,1),e),this._dir=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.scale.z},set:function(e){this.scale.z=e},enumerable:!1,configurable:!0}),t}(s),Ot=function(e){function t(t,r,n){t=t||new h(1,1,1),r=r||new h(1,1,1),n=n||16711680;var i=new C(t.x,t.y,t.z,r.x,r.y,r.z),o=new P({color:n});return e.call(this,i,o)||this}return Me(t,e),t}(s),Lt=function(e){function t(t,r){var n=this;r=r||"#FF0000";var i=new k(t=t||1,64,64),o=new P({color:r});return(n=e.call(this,i,o)||this).radius=t,n.color=r,n.center=n.position,n}return Me(t,e),t}(s),Dt=function(){function e(){}return e.prototype.init=function(){this.Vector3_one=new h(1,1,1),this.Vector3_zero=new h(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new a,this.camera=new Ct(60,Ue.aspect_ratio,.1,1e3),this.camera.clear_alpha=0},e.prototype.draw_arrow=function(e,t,r){void 0===r&&(r=16711680);var n=new kt(r,t.length(),t.clone().normalize());return n.position.copy(e),this.scene.add(n),n},e.prototype.draw_axis=function(){var e=new Rt;return this.scene.add(e),e},e.prototype.set_debug_RT=function(e){this.rt_debug=e},e.prototype.draw_rectangle=function(e,t,r,n){t=t||100,r=r||100,this.ctx.fillStyle=n||"rgba(255, 0, 0, 1)",this.ctx.fillRect(e.x-t/2,this.ctx.canvas.height-e.y-r/2,t,r)},e.prototype.clear=function(){this.ctx&&this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)},e.prototype.draw_line_2D=function(e,t,r){this.ctx.strokeStyle=r||"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()},e.prototype.draw_line=function(e,t){void 0===t&&(t=16711680);var r=new T({color:t}),n=(new S).setFromPoints(e),i=new M(n,r);return i.frustumCulled=!1,this.scene.add(i),i},e.prototype.draw_cube=function(e,t,r){t=t||1,r=r||16711680,e=e||new h;var n=new Ot(new h(t,t,t),void 0,r);return n.position.copy(e),this.scene.add(n),n},e.prototype.draw_oriented_cube=function(e,t,r,n,i){void 0===r&&(r=1),void 0===n&&(n="#FF0000"),void 0===i&&(i=.1);var o=e.distanceTo(t),a=new Ot(new h(i,r,o),void 0,n),s=t.clone().sub(e).multiplyScalar(.5),u=s.clone().normalize();return s.add(e),a.position.copy(s),a.quaternion.setFromUnitVectors(new h(0,0,-1),u),this.scene.add(a),a},e.prototype.draw_plane=function(e,t,r){var n=new u(e,t),o=new i({uniforms:{_Color:{value:new _(0,1,0,.2)}},vertexShader:Ce,fragmentShader:Pe,transparent:!0,depthWrite:!1}),a=new s(n,o);return a.renderOrder=-1e4,this.scene.add(a),a},e.prototype.draw_empty_cube=function(e,t,r){t=t||1,r=r||16711680;var n=(new O).setFromCenterAndSize(new h,new h(t,t,t)),i=new L(n,r);return i.position.copy(e||new h),i},e.prototype.draw_sphere=function(e,t,r){t=t||1,r=r||16711680,e=e||new h;var n=new Lt(t,r);return n.position.copy(e),this.scene.add(n),n},e.prototype.draw_point_array=function(e,t,r){void 0===t&&(t=!1);var n=new D(e,t);n.updateArcLengths();var i=n.getSpacedPoints(200);return this.draw_line(i,65280)},e.prototype.draw_sphere_helper=function(e,t){t=t||16711680;var r=new k(e.radius,32,32),n=new P({color:t}),i=new s(r,n);return i.position.copy(e.center),Ie.current.add(i),i},e.prototype.draw_math_sphere=function(e){var t=new k(e.radius,32,32),r=new i({uniforms:{_Color:{value:new _(1,0,0,.2)}},vertexShader:Ce,fragmentShader:Pe,transparent:!0}),n=new s(t,r);n.position.copy(e.center),Ie.current.add(n)},e.prototype.draw_bounding_box=function(e){var t=new L(e,16776960);Ie.current.add(t)},e.prototype.draw_curve=function(e,t){var r=new h(0,0,0);t&&(r.y=t.offset||0);for(var n=0;n<e.length-1;n++)this.draw_line([e[n].clone().add(r),e[n+1].clone().add(r)])},e.prototype.draw_texture=function(e,t,r){var n=new s(new u(1,1),new Pt);return this.display_texture_meshes.push(n),this.scene.add(n),n.material.set_texture(e,t,r),n},e.prototype.render=function(e){for(var t=0;t<this.display_texture_meshes.length;t++)this.display_texture_meshes[t].material.set_screen_size(Ue.width,Ue.height);this.scene.children.length>0&&e.render(this.scene,je.current)},e}(),jt=new Dt,Ut=function(){function e(){}return Object.defineProperty(e.prototype,"is_animating",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.on_enter=function(e){},e.prototype.update=function(e){},e.prototype.on_exit=function(e){},e}(),It=function(){function e(){this.t=0,this.easing_function_t=0}return Object.defineProperty(e.prototype,"is_animating",{get:function(){return!0},enumerable:!1,configurable:!0}),e.prototype.on_enter=function(e){},e.prototype.update=function(e){this.t+=bt.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=ht.clamp(this.easing_function_t,0,1),e.set_property_value(ht.lerp(e.from,e.to,this.easing_function_t)),this.easing_function_t>=.9999&&(e.set_property_value(e.to),e.set_current_state(new Ut),e.finished_callback(e))},e.prototype.on_exit=function(e){},e}(),Nt=function(){function e(e){var t=e.element,r=e.css_property,n=e.from,i=void 0===n?0:n,o=e.to,a=void 0===o?1:o,s=e.duration,u=void 0===s?1:s,l=e.value_prefix,_=void 0===l?"":l,c=e.value_suffix,h=void 0===c?"":c,p=e.easing_function,d=void 0===p?dt.ease_in_out_cubic:p,f=e.finished_callback,m=void 0===f?function(){}:f;this.element=t,this.css_property=r,this.from=i,this.to=a,this.value_prefix=_,this.value_suffix=h,this.duration=u,this.easing_function=d,this.finished_callback=m,this.current_state=new Ut}return e.prototype.animate=function(){this.set_current_state(new It)},e.prototype.stop=function(){this.set_current_state(new Ut)},e.prototype.set_property_value=function(e){this.element.style[this.css_property]="".concat(this.value_prefix).concat(e).concat(this.value_suffix)},e.prototype.update=function(){this.current_state.update(this)},Object.defineProperty(e.prototype,"is_animating",{get:function(){return this.current_state.is_animating},enumerable:!1,configurable:!0}),e.prototype.set_current_state=function(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)},e}(),Et=function(){function e(){}return e.prototype.init=function(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"},this.is_mobile=!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/),this.is_ipad=!!(navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2),this.is_ios=!!navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad,this.is_android=this.get_os()===this.operating_systems.ANDROID,this.is_linux=this.get_os()===this.operating_systems.LINUX,this.is_mac=this.get_os()===this.operating_systems.MAC,this.is_windows=this.get_os()===this.operating_systems.WINDOWS},e.prototype.get_os=function(){var e=window.navigator.userAgent,t=window.navigator.platform,r=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?r=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?r=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?r=this.operating_systems.WINDOWS:/Android/.test(e)?r=this.operating_systems.ANDROID:!r&&/Linux/.test(t)&&(r=this.operating_systems.LINUX),r},e}(),qt=new Et,Vt=new(function(){function e(){}return e.prototype.init=function(){this.target_geometry=void 0,this.target_position=new h},e.prototype.set_target_geometry=function(e){this.target_geometry=e},e}()),Bt=function(){function e(){}return e.prototype.fit_points=function(e,t,r,n){for(var i=t.clone().inverse(),o=[],a=0;a<e.length;a++)o.push(e[a].clone().applyQuaternion(i));var s=(new O).setFromPoints(o),u=new h;s.getSize(u);var l=this.get_distance_to_fit_rect(u.x/2,u.y/2,r,n),_=new h;return s.getCenter(_),_.applyQuaternion(t),{center:_,distance_to_center:l}},e.prototype.get_distance_to_fit_rect=function(e,t,r,n){var i=r/2*Math.PI/180,o=2*Math.atan(Math.tan(i)*n)/2,a=t/Math.tan(i),s=e/Math.tan(o);return Math.max(Math.abs(s),Math.abs(a))},e}(),Yt=function(){function e(){this.sphere=new N}return e.prototype.fit_points=function(e,t,r,n){this.sphere.setFromPoints(e);var i=ht.degToRad(r/2),o=2*Math.atan(Math.tan(i)*n)/2,a=this.get_up_plane_normal(t,i),s=this.get_down_plane_normal(t,i),u=this.get_left_plane_normal(t,o),l=this.get_right_plane_normal(t,o),_=new h(0,0,-1).applyQuaternion(t),c=this.sphere.center.clone(),p=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,r,n),d=c.clone().add(_.clone().multiplyScalar(-1*p)),f=(new j).setFromNormalAndCoplanarPoint(a,d),m=(new j).setFromNormalAndCoplanarPoint(s,d),v=(new j).setFromNormalAndCoplanarPoint(u,d),g=(new j).setFromNormalAndCoplanarPoint(l,d);this.apply_center_correction_to_pos(d,e,t,f,m,v,g),f.setFromNormalAndCoplanarPoint(a,d),m.setFromNormalAndCoplanarPoint(s,d),v.setFromNormalAndCoplanarPoint(u,d),g.setFromNormalAndCoplanarPoint(l,d);for(var y=1/0,b=_.clone().multiplyScalar(-2*p),w=0;w<e.length;w++){var x=new U(e[w].clone(),e[w].clone().add(b)),T=new h,S=new h,M=new h,F=new h;f.intersectLine(x,T),m.intersectLine(x,S),v.intersectLine(x,M),g.intersectLine(x,F),T.length()<1e-4&&console.log("up intersection not found",w),S.length()<1e-4&&console.log("down intersection not found",w),M.length()<1e-4&&console.log("left intersection not found",w),F.length()<1e-4&&console.log("right intersection not found",w);var z=e[w].clone().sub(T).length(),A=e[w].clone().sub(S).length(),R=e[w].clone().sub(M).length(),P=e[w].clone().sub(F).length(),C=Math.min(z,A),k=Math.min(R,P),O=Math.min(C,k);O<y&&(y=O)}var L=_.clone().multiplyScalar(y);return d.clone().add(L)},e.prototype.apply_center_correction_to_pos=function(e,t,r,n,i,o,a){var s=this.get_vertical_correction(t,i,n,r),u=this.get_horizontal_correction(t,o,a,r);e.add(s),e.add(u)},e.prototype.get_vertical_correction=function(e,t,r,n){for(var i=1/0,o=1/0,a=new h(0,1,0).applyQuaternion(n),s=0;s<e.length;s++){var u=new U(e[s].clone(),e[s].clone().add(a.clone().multiplyScalar(-5e6))),l=new U(e[s].clone(),e[s].clone().add(a.clone().multiplyScalar(5e6))),_=new h,c=new h;t.intersectLine(u,_),r.intersectLine(l,c);var p=_.distanceTo(e[s]),d=c.distanceTo(e[s]);c.length()<1e-4&&console.log("vertical up intersection not found",s),_.length()<1e-4&&console.log("vertical down intersection not found",s),p<o&&(o=p),d<i&&(i=d)}var f=(i-o)/2;return a.clone().multiplyScalar(-f)},e.prototype.get_horizontal_correction=function(e,t,r,n){for(var i=1/0,o=1/0,a=new h(1,0,0).applyQuaternion(n),s=0;s<e.length;s++){var u=new U(e[s].clone(),e[s].clone().add(a.clone().multiplyScalar(-5e6))),l=new U(e[s].clone(),e[s].clone().add(a.clone().multiplyScalar(5e6))),_=new h,c=new h;t.intersectLine(u,_),r.intersectLine(l,c);var p=_.distanceTo(e[s]),d=c.distanceTo(e[s]);_.length()<1e-4&&console.log("left intersection not found",s),c.length()<1e-4&&console.log("right intersection not found",s),p<o&&(o=p),d<i&&(i=d)}var f=(i-o)/2;return a.clone().multiplyScalar(-f)},e.prototype.get_up_plane_normal=function(e,t){var r=new h(0,-1,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(1,0,0),t)),r.applyQuaternion(e),r},e.prototype.get_down_plane_normal=function(e,t){var r=new h(0,1,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(1,0,0),-t)),r.applyQuaternion(e),r},e.prototype.get_left_plane_normal=function(e,t){var r=new h(1,0,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(0,1,0),t)),r.applyQuaternion(e),r},e.prototype.get_right_plane_normal=function(e,t){var r=new h(-1,0,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(0,1,0),-t)),r.applyQuaternion(e),r},e.prototype.get_distance_to_fit_rect=function(e,t,r,n){var i=r/2*Math.PI/180,o=2*Math.atan(Math.tan(i)*n)/2,a=t/Math.tan(i),s=e/Math.tan(o);return Math.max(Math.abs(s),Math.abs(a))},e}(),Gt=new(function(){function e(){}return e.prototype.init=function(e){this.tmp_mat=new E,this.plane=new j,this.ray=new q,this.tmp_size=new h,this.tmp_unproj=new h,this.input=e},e.prototype.get_up_dir=function(e){e=e||je.current;var t=new h;return t.set(0,1,0),t.applyQuaternion(e.quaternion),t},e.prototype.get_forward_dir=function(e){e=e||je.current;var t=new h;return t.set(0,0,-1),t.applyQuaternion(e.quaternion),t},e.prototype.get_right_dir=function(e){e=e||je.current;var t=new h;return t.set(1,0,0),t.applyQuaternion(e.quaternion),t},e.prototype.unproject_mouse_position=function(e,t){t=t||je.current;var r=new h,n=t.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(n)*t.aspect)/2,o=Math.tan(n)*t.far,a=Math.tan(i)*t.far;return r.set(a*e.x,o*e.y,-t.far).normalize(),r.applyQuaternion(t.quaternion)},e.prototype.get_plane_intersection=function(e,t,r,n){n=n||je.current,r=r||this.input.NDC;var i=new h;if(this.plane.setFromNormalAndCoplanarPoint(t||this.get_forward_dir(n),e),n.isPerspectiveCamera)this.ray.set(n.position,this.unproject_mouse_position(r,n));else{var o=new h(r.x*n.right,r.y*n.top,0);o.applyQuaternion(n.quaternion),o.add(n.position);var a=new h(0,0,-1).applyQuaternion(n.quaternion);this.ray.set(o,a)}return this.ray.intersectPlane(this.plane,i),i},e.prototype.fit_points_on_camera=function(e,t){void 0===t&&(t=1);var r=(new N).setFromPoints(e).center,n=this.get_forward_dir(je.current).clone(),i=(new j).setFromNormalAndCoplanarPoint(n,r),o=ht.project_points_on_plane(e,i),a=new h,s=(new O).setFromPoints(o);s.getCenter(a);for(var u=new h(0,1,0).applyQuaternion(je.current.quaternion),l=u.clone().cross(n).normalize(),_=(new E).set(l.x,u.x,n.x,r.x,l.y,u.y,n.y,r.y,l.z,u.z,n.z,r.z,0,0,0,1).invert(),c=0;c<o.length;c++)o[c].applyMatrix4(_);var p=new h;(s=(new O).setFromPoints(o)).getSize(p),p.multiplyScalar(t);var d=new h;return s.getCenter(d),{position:a,zoom:this.get_zoom_to_fit_rect(p.x/2,p.y/2)}},e.prototype.get_zoom_to_fit_rect=function(e,t){var r=je.current.fov/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*je.current.aspect)/2,i=t/Math.tan(r),o=e/Math.tan(n);return Math.max(Math.abs(o),Math.abs(i))},e.prototype.get_zoom_to_fit_box=function(e,t){if(t.isOrthographicCamera){e.getSize(this.tmp_size);var r=this.tmp_size.x,n=this.tmp_size.y,i=r/n;return Ue.aspect_ratio/i>1?Ue.height/n:Ue.width/r}var o=new h;return e.getSize(o),this.get_zoom_to_fit_rect(o.x,o.y)},e.prototype.get_html_screen_pos=function(e,t){t=t||je.current;var r=new h;return e.getWorldPosition(r),r.project(t),r.x=(.5*r.x+.5)*Ue.width,r.y=(1-(.5*r.y+.5))*Ue.height,r},e.prototype.world_pos_to_screen=function(e,t){t=t||je.current;var r=new h;return r.copy(e),r.project(t),r.x=(.5*r.x+.5)*Ue.width,r.y=(1-(.5*r.y+.5))*Ue.height,r},e.prototype.update_projection=function(e){e.left=-Ue.width/2,e.right=Ue.width/2,e.top=Ue.height/2,e.bottom=-Ue.height/2,e.aspect=Ue.aspect_ratio,e.updateProjectionMatrix(!0)},e.prototype.fit_bounding_box_points=function(e,t,r){void 0===r&&(r=1);var n=new h;n.copy(t.max).sub(t.min);var i=t.min.clone(),o=i.clone().add(new h(n.x,0,0)),a=i.clone().add(new h(0,n.y,0)),s=i.clone().add(new h(0,0,n.z)),u=i.clone().add(new h(n.x,0,n.z)),l=i.clone().add(new h(0,n.y,n.z)),_=t.max.clone(),c=i.clone().add(new h(n.x,n.y,0));return this.fit_points(e,[i,o,a,s,u,l,_,c],r)},e.prototype.fit_points=function(e,t,r){if(void 0===r&&(r=1),e.isPerspectiveCamera){var n=new h(0,0,-1).applyQuaternion(e.quaternion),i=n.clone().multiplyScalar(-1),o=new Yt,a=Ue.aspect_ratio,s=o.fit_points(t,e.quaternion,e.fov*r,a),u=(new O).setFromPoints(t),l=new h;u.getCenter(l);var _=(new j).setFromNormalAndCoplanarPoint(i,l),c=new q(s,n),p=new h;return c.intersectPlane(_,p),{zoom:s.distanceTo(p),reference_position:p,camera_position:s}}var d=(o=new Bt).fit_points(t,this.reference_rotation,e.fov*r,Ue.aspect_ratio);this.reference_position.copy(d.center),this.reference_zoom=d.distance_to_center;var f=new h(0,0,1).applyQuaternion(e.quaternion);return{zoom:d.distance_to_center,reference_position:d.center,camera_position:f.multiplyScalar(d.distance_to_center)}},e}()),Wt=new(function(){function e(){}return e.prototype.init=function(e){je.init(),Gt.init(e),At.init(),qt.init(),$e.init(),Vt.init(),Xe.init(),Ie.init(),Ue.init(),bt.init(),jt.init()},e.prototype.dispose=function(e){Be.dispose(),Ie.dispose(),e.dispose()},e}()),Xt=function(){function e(){}return e.prototype.init=function(e){this.ctrlz_pressed=!1,this.ctrlz_fired=!1,this.keys={},this.keys_keys=[],this.container=e,this.container.addEventListener("keydown",this.on_key_down.bind(this),!1),this.container.addEventListener("keyup",this.on_key_up.bind(this),!1)},e.prototype.on_key_down=function(e){90===e.keyCode&&e.ctrlKey&&!this.ctrlz_fired&&(this.ctrlz_pressed=!0,this.ctrlz_fired=!0),e.code&&this.press_key(e.code)},e.prototype.on_key_up=function(e){this.release_key(e.code)},e.prototype.clear=function(){this.ctrlz_pressed=!1;for(var e=0;e<this.keys_keys.length;e++)this.keys[this.keys_keys[e]].pressed=!1,this.keys[this.keys_keys[e]].released=!1},e.prototype.release_key=function(e){var t=this.keys[e];t&&(t.fired=!1,t.down=!1,t.released=!0)},e.prototype.release_keys=function(){this.ctrlz_fired=!1;for(var e=0;e<this.keys_keys.length;e++)this.keys[this.keys_keys[e]].fired=!1,this.keys[this.keys_keys[e]].down=!1},e.prototype.press_key=function(e){var t=this.keys[e];t&&(!1===t.down&&(t.pressed=!0),t.down=!0,t.fired=!0)},e.prototype.is_key_pressed=function(e){var t=this.keys[e];return!!t&&t.pressed},e.prototype.is_key_down=function(e){var t=this.keys[e];return!!t&&t.down},e.prototype.is_key_released=function(e){var t=this.keys[e];return!!t&&t.released},e.prototype.register_key=function(e){this.keys[e]={key_name:e,pressed:!1,down:!1,fired:!1,released:!1},this.keys_keys=Object.keys(this.keys)},e.prototype.unregister_key=function(e){delete this.keys[e]},e.prototype.dispose=function(){this.container.removeEventListener("keydown",this.on_key_down.bind(this),!1),this.container.removeEventListener("keyup",this.on_key_up.bind(this),!1)},e}(),Qt=function(e){function t(t,r,n,i,a,s){var u=e.call(this,t,r,n,i,a,s)||this;return u.clear_color=new o("#000000"),u.clear_alpha=1,u}return Me(t,e),t.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.clear_color.copy(t.clear_color),this.clear_alpha=t.clear_alpha,this},t}(l),Ht=function(e){function t(){return e.call(this,{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);}"})||this}return Me(t,e),t}(i),Zt=function(e){function t(){return e.call(this)||this}return Me(t,e),t.prototype.render=function(){Be.clear(void 0,je.current,!0,!0),Be.render(Ie.current,je.current,void 0,new Ht)},t}(Le),Jt="#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;}",Kt=function(e){function t(){var t=e.call(this,"#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);}",Jt)||this;return t.uniforms._FarPlane={value:1},t.uniforms._InverseProjMatrix={value:new E},t}return Me(t,e),t}(Ae),$t=function(e){function t(){var t=e.call(this,"#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;return t.uniforms._AO={value:void 0},t}return Me(t,e),t}(Ae),er=function(e){function t(){var t=e.call(this,"#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;}",Jt)||this;return t.uniforms._InverseProjMatrix={value:new E},t.uniforms._ProjectionMatrix={value:new E},t.uniforms._Bias={value:.0125},t.uniforms._Radius={value:.3},t.uniforms._FarPlane={value:100},t.uniforms._SampleKernel={value:t.__get_sample_kernel()},t.uniforms._RandomRotation={value:t.__get_rotation_kernel()},t}return Me(t,e),t.prototype.__get_sample_kernel=function(){for(var e=[],t=0;t<64;t++){var r=new h(2*Math.random()-1,2*Math.random()-1,Math.random());r.normalize();var n=t/64;n=ht.lerp(.1,1,n*n),r.multiplyScalar(n),e.push(r)}return e},t.prototype.__get_rotation_kernel=function(){for(var e=new Uint8Array(48),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;var r=new V(e,4,4,B);return r.wrapS=Y,r.wrapT=Y,r.needsUpdate=!0,r},t}(Ae),tr=function(t){function r(){var r=t.call(this,"#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;return r.uniforms._SampleDir={value:new e},r}return Me(r,t),r}(Ae),rr=function(){function e(){this.RT1=new c(1,1),this.RT2=new c(1,1),this.box_blur_mat=new tr}return e.prototype.blur=function(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),Be.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),Be.blit(this.RT1,e,this.box_blur_mat)},e}(),nr=function(e){function t(t){void 0===t&&(t=!1);var r=e.call(this)||this;return r.ssao_mat=new er,r.ssao_compose_mat=new $t,r.debug_normals=new Kt,r.ssaa=t?2:1,r.main_RT=new c(Ue.width*r.ssaa,Ue.height*r.ssaa),r.SSAO_RT=new c(Ue.width,Ue.height),r.blurrer=new rr,Be.generate_depth_normal_texture=!0,r}return Me(t,e),t.prototype.render=function(){this.__check_RT_size(),Be.clear(this.main_RT,je.current,!0,!1),Be.render(Ie.current,je.current,this.main_RT),this.__update_uniforms(),Be.blit(Be.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),Be.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,Be.blit(this.main_RT,void 0,this.ssao_compose_mat)},t.prototype.__update_uniforms=function(){this.ssao_mat.uniforms._InverseProjMatrix.value=je.current.projectionMatrix.clone().invert(),this.ssao_mat.uniforms._ProjectionMatrix.value=je.current.projectionMatrix.clone(),this.ssao_mat.uniforms._FarPlane.value=je.current.far},t.prototype.__check_RT_size=function(){this.main_RT.width===Ue.width*this.ssaa&&this.main_RT.height===Ue.height*this.ssaa||(this.main_RT.setSize(Ue.width*this.ssaa,Ue.height*this.ssaa),this.SSAO_RT.setSize(Ue.width,Ue.height))},t}(Le),ir=function(e){function t(){return e.call(this)||this}return Me(t,e),t.prototype.render=function(){Be.clear(void 0,je.current,!0,!0),Ie.current.on_pre_render(),Ie.current.render(),Ie.current.on_post_render()},t}(Le),or=function(t){function r(r){var n=t.call(this,"#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;uniform float radius;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=sampleTex(_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*radius;vec4 sample1=sampleTex(_MainTex,vUv+uvOffset);vec4 sample2=sampleTex(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}",void 0,{KERNEL_RADIUS:r,SIGMA:r})||this;return n.uniforms.texSize={value:new e(.5,.5)},n.uniforms.direction={value:new e(.5,.5)},n.uniforms.radius={value:1},n.defines.USE_LINEAR_COLOR_SPACE=!0,n}return Me(r,t),r.prototype.set_size=function(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t},r.prototype.set_direction=function(e,t){this.uniforms.direction.value.set(e,t)},r.prototype.set_radius=function(e){void 0===e&&(e=1),this.uniforms.radius.value=e},r}(Ae),ar=function(e){function t(){var t=e.call(this,"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec4 texel=sampleTex(_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);\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}")||this;return t.uniforms.luminosityThreshold={value:.23},t.uniforms.smoothWidth={value:.01},t.uniforms.defaultColor={value:new o("#000000")},t.uniforms.defaultOpacity={value:0},t.defines.USE_LINEAR_COLOR_SPACE=!0,t}return Me(t,e),t.prototype.set_threshold=function(e){this.uniforms.luminosityThreshold.value=e},t}(Ae),sr=function(){function e(e){void 0===e&&(e=!1),this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.use_half_float=e,this.nMips=5,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:G,magFilter:G,format:B,type:e?W:X,colorSpace:e?Q:m},this.renderTargetBright=new c(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new ar}return e.prototype.blur=function(e,t){this.resize_RT(e.width,e.height);var r=e;t&&(Be.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat),r=this.renderTargetBright);for(var n=0;n<this.nMips;n++){var i=this.separableBlurMaterials[n];i.set_direction(1,0),Be.blit(r,this.renderTargetsHorizontal[n],i),i.set_direction(0,1),Be.blit(this.renderTargetsHorizontal[n],this.renderTargetsVertical[n],i),r=this.renderTargetsVertical[n]}},e.prototype.get_blurred_texture=function(){return this.renderTargetsHorizontal[0].texture},e.prototype.get_blurred_RT=function(){return this.renderTargetsHorizontal[0]},e.prototype.init_RT=function(){this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(var e=0;e<this.nMips;e++){var t=new c(1,1,this.rt_pars),r=new c(1,1,this.rt_pars);t.texture.generateMipmaps=!1,r.texture.generateMipmaps=!1,t.texture.colorSpace=this.rt_pars.colorSpace,r.texture.colorSpace=this.rt_pars.colorSpace,this.renderTargetsHorizontal.push(t),this.renderTargetsVertical.push(r)}},e.prototype.resize_RT=function(e,t){if(this.current_width!==e||this.current_height!==t){this.current_width=e,this.current_height=t;var r=Math.round(e/2),n=Math.round(t/2);this.renderTargetBright.setSize(r,n);for(var i=0;i<this.nMips;i++)this.renderTargetsVertical[i].setSize(r,n),this.renderTargetsHorizontal[i].setSize(r,n),this.separableBlurMaterials[i].set_size(r,n),r=Math.round(r/2),n=Math.round(n/2)}},e.prototype.init_materials=function(){this.dispose_materials();for(var e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new or(this.kernelSizeArray[e]))},e.prototype.set_radius=function(e){for(var t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].set_radius(e)},e.prototype.set_luminosity_threshold=function(e){this.luminosity_high_pass_mat.set_threshold(e)},e.prototype.dispose_materials=function(){for(var e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0},e.prototype.dispose_RT=function(){for(var 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},e}(),ur=function(e){function t(t,r,n,i){void 0===i&&(i=!1);var o=e.call(this)||this;o.add_mat=new Re(r);var a={samples:t?8:1,type:r?W:X,format:B,colorSpace:Q,minFilter:x,magFilter:x};return o.use_rendering_size=i,o.main_RT=new c(1,1,a),o.main_RT.texture.colorSpace=Q,o.main_RT.texture.minFilter=x,o.main_RT.texture.magFilter=x,o.bloom_compose_mat=new Oe(5,r),o.blurrer=new sr(r),o.use_hight_luminosity_pass=n,o.luminosity_threshold=.5,o}return Me(t,e),t.prototype.on_enter=function(){this.bloom_compose_mat.set_blur_texture_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_blur_texture_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_blur_texture_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_blur_texture_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_blur_texture_4(this.blurrer.renderTargetsVertical[4].texture),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)},t.prototype.render=function(){this.__check_RT_size(),Be.clear(this.main_RT,je.current,!0,!1),Be.render(Ie.current,je.current,this.main_RT),this.blurrer.blur(this.main_RT,this.use_hight_luminosity_pass),Be.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),Be.blit(this.main_RT,void 0,this.add_mat)},t.prototype.set_bloom_strength=function(e){this.bloom_compose_mat.set_bloom_strength(e)},t.prototype.set_bloom_radius=function(e){this.blurrer.set_radius(e)},t.prototype.set_luminosity_threshold=function(e){this.blurrer.set_luminosity_threshold(e)},t.prototype.set_tint_color_0=function(e){this.bloom_compose_mat.set_tint_color_0(e)},t.prototype.set_tint_color_1=function(e){this.bloom_compose_mat.set_tint_color_1(e)},t.prototype.set_tint_color_2=function(e){this.bloom_compose_mat.set_tint_color_2(e)},t.prototype.set_tint_color_3=function(e){this.bloom_compose_mat.set_tint_color_3(e)},t.prototype.set_tint_color_4=function(e){this.bloom_compose_mat.set_tint_color_4(e)},t.prototype.__check_RT_size=function(){var e=this.use_rendering_size?Ue.render_width:Ue.width,t=this.use_rendering_size?Ue.render_height:Ue.height;this.main_RT.width===e&&this.main_RT.height===t||this.main_RT.setSize(e,t)},t}(Le),lr=function(e){function t(){return e.call(this)||this}return Me(t,e),t.prototype.render=function(){Ie.current.on_pre_render&&Ie.current.on_pre_render(),Ie.current.render?Ie.current.render():Be.render(Ie.current,je.current,Be._renderer.getRenderTarget()),this.render_spectator_camera(),Ie.current.on_post_render&&Ie.current.on_post_render()},t.prototype.render_spectator_camera=function(){var e=je.spectator;if(e&&Be._renderer.xr.isPresenting){var t=Be._renderer.xr.getCamera();e.projectionMatrix.copy(je.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);var r=Be._renderer.getRenderTarget();Be._renderer.xr.isPresenting=!1,Be._renderer.setRenderTarget(null),Be._renderer.render(Ie.current,e),Be._renderer.setRenderTarget(r),Be._renderer.xr.isPresenting=!0}},t}(Le),_r=new(function(){function e(){this.components=[],this.enabled_components=new Set}return e.prototype.update=function(){this.__set_components_opacities();for(var e=0,t=this.enabled_components;e<t.length;e++){t[e].update(Tt.current_state_data)}},e.prototype.register_component=function(e){this.components.push(e)},e.prototype.enable_component=function(e){this.enabled_components.add(e)},e.prototype.disable_component=function(e){this.enabled_components.delete(e)},e.prototype.get_component_by_name=function(e){console.warn("DEPRECATED. Use ViewComponentManager.get instead"),this.get(e)},e.prototype.get=function(e){for(var 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)},e.prototype.__set_components_opacities=function(){for(var e=0;e<this.components.length;e++)this.components[e].set_opacity(Tt.current_state_data)},e}()),cr=function(){function e(e,t,r){e=e||new Te,this.target_application=e,this.graphics=t,this.input=r,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0}return e.prototype.update=function(e){if(this.is_running){for(bt.__update(e),1===this.frames_passed&&this.target_application.on_post_start(),this.input.update(),this.time_accumulator+=bt.delta_time,this.target_application.before_update(),Tt.before_update();this.time_accumulator>bt.fixed_delta_time;)this.target_application.fixed_update(),Tt.fixed_update(),this.time_accumulator-=bt.fixed_delta_time;bt.__set_frame_interpolation(this.time_accumulator/bt.fixed_delta_time),this.target_application.update(),Tt.update(),St.update(),_r.update(),this.target_application.on_pre_render(),this.graphics.update(),this.target_application.on_post_render(),jt.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,this.input.clear(),jt.clear()}},e.prototype.start=function(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(this),this.is_running=!0,this.graphics._renderer.setAnimationLoop(this.update.bind(this)))},e.prototype.stop=function(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(this),this.graphics._renderer.setAnimationLoop(null))},e.prototype.set_state=function(e){this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this)},e.prototype.dispose=function(){this.stop(),this.frames_passed=0},e}(),hr=new(function(){function e(){}return e.prototype.init=function(){console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.init()},e.prototype.update_position=function(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.update_position(e,t)},e.prototype.update=function(){console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.update()},e.prototype.update_size=function(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.update_size(e,t)},e.prototype.apply_pixel_density_v2=function(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.apply_pixel_density_v2(e)},e.prototype.apply_pixel_density=function(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.apply_pixel_density(e)},e.prototype.get_pixel_size=function(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.get_pixel_size()},Object.defineProperty(e.prototype,"aspect_ratio",{get:function(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Ue.aspect_ratio},enumerable:!1,configurable:!0}),e}()),pr=function(){function e(e){var t=e.name,r=e.container;this.name=t,this.container=r,this.hidden=!0,_r.register_component(this)}return e.prototype.start=function(){},e.prototype.on_enter=function(){this.container.classList.remove("hidden"),_r.enable_component(this),this.hidden=!1},e.prototype.update=function(){},e.prototype.on_exit=function(){this.container.classList.add("hidden"),_r.disable_component(this),this.hidden=!0},e.prototype.set_opacity=function(e){this.container.style.opacity=e["".concat(this.name,"_opacity")],this.toggle_hidden()},e.prototype.toggle_hidden=function(){this.container.style.opacity>.001?this.hidden&&this.on_enter():this.hidden||this.on_exit()},e}(),dr=function(e){function t(t,r,n,i){t=t||1,r=r||1,n=n||"#FF0000",i=i||new P({color:n});var o=new u(t,r);return o.rotateX(-1.57),e.call(this,o,i)||this}return Me(t,e),t}(s),fr=function(e){function t(t,r,n,i){t=t||1,r=r||1,n=n||"#FF0000",i=i||new P({color:n});var o=new u(t,r);return e.call(this,o,i)||this}return Me(t,e),t}(s),mr=function(){function e(){}return e.merge_from_to=function(e,t){t.push.apply(t,e)},e.expand_vec3_array=function(e,t){for(var r=t-e.length,n=0;n<r;n++)e.push(e[n].clone())},e.remove_elem=function(e,t){var r=e.indexOf(t);r>-1&&e.splice(r,1)},e.get_closest_point=function(e,t){for(var r=e[0],n=r.distanceTo(t),i=1;i<e.length;i++)e[i].distanceTo(t)<n&&(r=e[i],n=e[i].distanceTo(t));return r},e.object_values_to_array=function(e){for(var t=Object.keys(e),r=[],n=0;n<t.length;n++)r.push(e[t[n]]);return r},e}(),vr=function(){function e(){this.sphere=new N}return e.prototype.fit_points=function(e,t,r,n){this.sphere.setFromPoints(e);var i=ht.degToRad(r/2),o=2*Math.atan(Math.tan(i)*n)/2,a=this.get_up_plane_normal(t,i),s=this.get_down_plane_normal(t,i),u=this.get_left_plane_normal(t,o),l=this.get_right_plane_normal(t,o),_=new h(0,0,-1).applyQuaternion(t),c=this.sphere.center.clone(),p=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,r,n),d=c.clone().add(_.clone().multiplyScalar(-1*p)),f=(new j).setFromNormalAndCoplanarPoint(a,d),m=(new j).setFromNormalAndCoplanarPoint(s,d),v=(new j).setFromNormalAndCoplanarPoint(u,d),g=(new j).setFromNormalAndCoplanarPoint(l,d);this.apply_center_correction_to_pos(d,e,t,f,m,v,g),f.setFromNormalAndCoplanarPoint(a,d),m.setFromNormalAndCoplanarPoint(s,d),v.setFromNormalAndCoplanarPoint(u,d),g.setFromNormalAndCoplanarPoint(l,d);for(var y=1/0,b=_.clone().multiplyScalar(-2*p),w=0;w<e.length;w++){var x=new U(e[w].clone(),e[w].clone().add(b)),T=new h,S=new h,M=new h,F=new h;f.intersectLine(x,T),m.intersectLine(x,S),v.intersectLine(x,M),g.intersectLine(x,F),T.length()<1e-4&&console.log("up intersection not found",w),S.length()<1e-4&&console.log("down intersection not found",w),M.length()<1e-4&&console.log("left intersection not found",w),F.length()<1e-4&&console.log("right intersection not found",w);var z=e[w].clone().sub(T).length(),A=e[w].clone().sub(S).length(),R=e[w].clone().sub(M).length(),P=e[w].clone().sub(F).length(),C=Math.min(z,A),k=Math.min(R,P),O=Math.min(C,k);O<y&&(y=O)}var L=_.clone().multiplyScalar(y);return d.clone().add(L)},e.prototype.apply_center_correction_to_pos=function(e,t,r,n,i,o,a){var s=this.get_vertical_correction(t,i,n,r),u=this.get_hozirontal_correction(t,o,a,r);e.add(s),e.add(u)},e.prototype.get_vertical_correction=function(e,t,r,n){for(var i=1/0,o=1/0,a=void 0,s=void 0,u=new h(0,1,0).applyQuaternion(n),l=0;l<e.length;l++){var _=new U(e[l].clone(),e[l].clone().add(u.clone().multiplyScalar(-5e6))),c=new U(e[l].clone(),e[l].clone().add(u.clone().multiplyScalar(5e6))),p=new h,d=new h;t.intersectLine(_,p),r.intersectLine(c,d);var f=p.distanceTo(e[l]),m=d.distanceTo(e[l]);d.length()<1e-4&&console.log("vertical up intersection not found",l),p.length()<1e-4&&console.log("vertical down intersection not found",l),f<o&&(o=f,s=e[l]),m<i&&(i=m,a=e[l])}console.log(a,s);var v=(i-o)/2;return u.clone().multiplyScalar(-v)},e.prototype.get_hozirontal_correction=function(e,t,r,n){for(var i=1/0,o=1/0,a=void 0,s=void 0,u=new h(1,0,0).applyQuaternion(n),l=0;l<e.length;l++){var _=new U(e[l].clone(),e[l].clone().add(u.clone().multiplyScalar(-5e6))),c=new U(e[l].clone(),e[l].clone().add(u.clone().multiplyScalar(5e6))),p=new h,d=new h;t.intersectLine(_,p),r.intersectLine(c,d);var f=p.distanceTo(e[l]),m=d.distanceTo(e[l]);p.length()<1e-4&&console.log("left intersection not found",l),d.length()<1e-4&&console.log("right intersection not found",l),f<o&&(o=f,s=e[l]),m<i&&(i=m,a=e[l])}var v=(i-o)/2;return console.log(a,s),u.clone().multiplyScalar(-v)},e.prototype.get_up_plane_normal=function(e,t){var r=new h(0,-1,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(1,0,0),t)),r.applyQuaternion(e),r},e.prototype.get_down_plane_normal=function(e,t){var r=new h(0,1,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(1,0,0),-t)),r.applyQuaternion(e),r},e.prototype.get_left_plane_normal=function(e,t){var r=new h(1,0,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(0,1,0),t)),r.applyQuaternion(e),r},e.prototype.get_right_plane_normal=function(e,t){var r=new h(-1,0,0);return r.applyQuaternion((new I).setFromAxisAngle(new h(0,1,0),-t)),r.applyQuaternion(e),r},e.prototype.get_distance_to_fit_rect=function(e,t,r,n){var i=r/2*Math.PI/180,o=2*Math.atan(Math.tan(i)*n)/2,a=t/Math.tan(i),s=e/Math.tan(o);return Math.max(Math.abs(s),Math.abs(a))},e}(),gr=function(){function e(){}return e.convert_to_non_indexed_geometry=function(t){for(var r=t.index,n=t.getAttribute("position"),i=[],o=0;o<r.count;o+=3)i.push(n.getX(r.array[o+0])),i.push(n.getY(r.array[o+0])),i.push(n.getZ(r.array[o+0])),i.push(n.getX(r.array[o+1])),i.push(n.getY(r.array[o+1])),i.push(n.getZ(r.array[o+1])),i.push(n.getX(r.array[o+2])),i.push(n.getY(r.array[o+2])),i.push(n.getZ(r.array[o+2]));var a=new S;return a.setAttribute("position",new H(new Float32Array(i),3)),e.add_barycentric_attribute(a),a},e.add_barycentric_attribute=function(e){for(var t=[],r=e.getAttribute("position"),n=0;n<r.count;n+=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 H(new Float32Array(t),3))},e}(),yr=function(){function e(){}return e.load_images=function(e){for(var t=e.querySelectorAll("img"),r=0;r<t.length;r++){var n=t[r];n.dataset.src&&(n.src=n.dataset.src)}var i=e.querySelectorAll("object");for(r=0;r<i.length;r++){var o=i[r];o.dataset.src&&(o.data=o.dataset.src)}},e.load_videos=function(e){for(var t=e.querySelectorAll("video"),r=0;r<t.length;r++){var n=t[r];n.dataset.src&&(n.src=n.dataset.src)}},e.load_iframes=function(e){for(var t=e.querySelectorAll("iframe"),r=0;r<t.length;r++){var n=t[r];n.dataset.src&&(n.src=n.dataset.src)}},e.load_elements=function(e,t){for(var r=e.querySelectorAll(t),n=0;n<r.length;n++){var i=r[n];i.dataset.src&&(i.src=i.dataset.src)}},e}(),br=function(){function e(){}return e.get_image_data=function(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height)},e.get_pixel=function(e,t,r){var n=4*(t+e.width*r),i=e.data;return new _(i[n+0],i[n+1],i[n+2],i[n+3])},e}(),wr=new(function(){function t(){}return t.prototype.sample=function(t,r){for(var n=[],i=99999999,o=t.getAttribute("position"),a=t.getAttribute("normal"),s=t.getAttribute("tangent"),u=t.getAttribute("uv"),l=t.index,_=[],c=0;c<l.count;c+=3){var p=l.array[c+0],d=l.array[c+1],f=l.array[c+2],m=new h;m.x=o.getX(p),m.y=o.getY(p),m.z=o.getZ(p);var v=new h;v.x=o.getX(d),v.y=o.getY(d),v.z=o.getZ(d);var g=new h;g.x=o.getX(f),g.y=o.getY(f),g.z=o.getZ(f);var y={a:m,b:v,c:g,normal:void 0,tangent:void 0,uv_a:void 0,uv_b:void 0,uv_c:void 0};if(a){(w=new h).x=a.getX(p),w.y=a.getY(p),w.z=a.getZ(p),(x=new h).x=a.getX(d),x.y=a.getY(d),x.z=a.getZ(d),(T=new h).x=a.getX(f),T.y=a.getY(f),T.z=a.getZ(f);var b=w.clone().add(x).add(T).normalize();y.normal=b}if(s){var w,x,T;(w=new h).x=s.getX(p),w.y=s.getY(p),w.z=s.getZ(p),(x=new h).x=s.getX(d),x.y=s.getY(d),x.z=s.getZ(d),(T=new h).x=s.getX(f),T.y=s.getY(f),T.z=s.getZ(f);var S=w.clone().add(x).add(T).normalize();y.tangent=S}if(u){var M=new e;M.x=u.getX(p),M.y=u.getY(p);var F=new e;F.x=u.getX(d),F.y=u.getY(d);var z=new e;z.x=u.getX(f),z.y=u.getY(f),y.uv_a=M,y.uv_b=F,y.uv_c=z}_.push(y);var A=this.get_face_area(y);i=Math.min(A,i),n.push(A)}var R=this.get_uniform_face_distribution(n,i,_),P=this.select_random_faces(R,r);return this.sample_data_from_faces(P)},t.prototype.sample_data_from_faces=function(e){for(var t=[],r=[],n=[],i=[],o=0;o<e.length;o++){var a=e[o],s=Math.random(),u=Math.random();t.push(this.sample_point_in_face(s,u,a.a,a.b,a.c).clone()),a.normal&&r.push(a.normal.clone()),a.tangent&&n.push(a.tangent.clone()),a.uv_a&&i.push(this.sample_point_in_face(s,u,a.uv_a,a.uv_b,a.uv_c).clone())}return{points:t,normals:r,tangents:n,uvs:i}},t.prototype.select_random_faces=function(e,t){for(var r=[],n=0;n<t;n++){var i=e[Math.floor(Math.random()*e.length)];r.push(i)}return r},t.prototype.get_uniform_face_distribution=function(e,t,r){for(var n=[],i=0;i<e.length;i++){e[i]/=t;for(var o=Math.floor(Math.round(e[i])),a=0;a<o;a++)n.push(r[i])}return n},t.prototype.get_face_area=function(e){var t=e.b.clone().sub(e.a),r=e.c.clone().sub(e.a);return t.cross(r).length()/2},t.prototype.sample_point_in_face=function(e,t,r,n,i){e+t>1&&(e=1-e,t=1-t);var o=1-(e+t);return r.clone().multiplyScalar(e).add(n.clone().multiplyScalar(t)).add(i.clone().multiplyScalar(o))},t}()),xr=new(function(){function e(){}return e.prototype.get_mesh=function(e,t){e.traverse((function(e){e instanceof s&&(e.geometry&&(e.geometry=e.geometry.clone()),t(e))}))},e.prototype.get_geometries=function(e){var t=[];return this.get_mesh(e,(function(e){t.push(e.geometry)})),t},e.prototype.assign_material=function(e,t,r){e.traverse((function(e){e instanceof s&&(void 0===r||e.name===r)&&(e.material=t)}))},e.prototype.clone_animated_gltf=function(e){var t={animations:e.animations,scene:e.scene.clone(!0)},r={};e.scene.traverse((function(e){e.isSkinnedMesh&&(r[e.name]=e)}));var n={},i={};for(var o in t.scene.traverse((function(e){e.isBone&&(n[e.name]=e),e.isSkinnedMesh&&(i[e.name]=e)})),r){for(var a=r[o].skeleton,s=i[o],u=[],l=0;l<a.bones.length;++l){var _=n[a.bones[l].name];u.push(_)}s.bind(new Z(u,a.boneInverses),s.matrixWorld)}return t},e.prototype.set_shadow_config=function(e,t,r){e.traverse((function(e){e instanceof s&&(e.castShadow=t,e.receiveShadow=r)}))},e.prototype.__find_object=function(e,t,r){e.traverse((function(e){e.name===t&&r(e)}))},e.prototype.get_object=function(e,t){var r=void 0;return e.traverse((function(e){e.name===t&&(r=e)})),r},e.prototype.get_object_by_type=function(e,t){var r=void 0;return e.traverse((function(e){e.constructor.name===t&&(r=e)})),r},e}()),Tr=function(){function e(){}return e.is_object=function(e){return e&&"object"==typeof e&&!Array.isArray(e)},e.merge_deep=function(t){for(var r,n,i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];if(!i.length)return t;var a=i.shift();if(e.is_object(t)&&e.is_object(a))for(var s in a)e.is_object(a[s])?(t[s]||Object.assign(t,((r={})[s]={},r)),e.merge_deep(t[s],a[s])):Object.assign(t,((n={})[s]=a[s],n));return e.merge_deep.apply(e,function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([t],i,!1))},e.xml_to_json=function(e){var t={};if(1===e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var r=0;r<e.attributes.length;r++){var n=e.attributes.item(r);t["@attributes"][n.nodeName]=n.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var i=0;i<e.childNodes.length;i++){var o=e.childNodes.item(i),a=o.nodeName;if(void 0===t[a])t[a]=this.xml_to_json(o);else{if(void 0===t[a].push){var s=t[a];t[a]=[],t[a].push(s)}t[a].push(this.xml_to_json(o))}}return t},e}(),Sr=function(){function e(){}return e.get_random_color=function(){for(var e=[0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"],t="#",r=0;r<6;r++){t+=e[Math.floor(Math.random()*e.length)]}return t},e.capitalize=function(e){for(var t=e.split(" "),r=0;r<t.length;r++)t[r]=t[r][0].toUpperCase()+t[r].substr(1);return t.join(" ")},e.capitalize_first_letter=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},e.snake_to_camelcase=function(e){return e.toLowerCase().replace(/[-_][a-z0-9]/g,(function(e){return e.slice(-1).toUpperCase()}))},e}(),Mr=function(){function e(){}return e.prototype.time_str_to_ms=function(e){var t=e.split(":"),r=Number(t[0]);r=60*r*60*1e3;var n=Number(t[1]);n=60*n*1e3;var i=Number(t[2]);return r+n+(i*=1e3)},e}(),Fr=function(){function e(){}return e.is_int=function(e){return Number(e)===e&&e%1==0},e.is_float=function(e){return Number(e)===e&&e%1!=0},e.is_number=function(e){return this.is_int(e)||this.is_float(e)},e.is_json=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},e}();var zr=function(e){function t(){var t=this,r=function(e){void 0===e&&(e="#4a4a4a");var t,r,n,i=pe(new o(e)),a=de("barycentric","vec3").add(fe(1,1,0)),s=(r=ve(t=a),n=ge(fe(0),r.mul(1.5),t),ye(ye(n.x,n.y),n.z));return{colorNode:me(i,fe(0),s),opacityNode:s.oneMinus().mul(.2)}}("#4a4a4a"),n=r.colorNode,i=r.opacityNode,a=new ue({transparent:!0,depthWrite:!1});a.colorNode=n,a.opacityNode=i;var s=new u(100,100,100,100),l=gr.convert_to_non_indexed_geometry(s);return(t=e.call(this,l,a)||this).rotation.x=-1.57,t}return Me(t,e),t}(s),Ar=function(e){function t(t){var r=this,n=new S;n.setAttribute("position",new H(new Float32Array([]),3)),n.setAttribute("next_position",new H(new Float32Array([]),3)),n.setAttribute("previous_position",new H(new Float32Array([]),3)),n.setAttribute("orientation",new H(new Float32Array([]),1)),n.setAttribute("coverage",new H(new Float32Array([]),1));var a=new i({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new o("#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});return(r=e.call(this,n,a)||this).material=a,t&&r.setup(t),r}return Me(t,e),t.prototype.setup=function(e){for(var t=[],r=[],n=[],i=[],o=[],a=0,s=0;s<e.length;s++){t.push(e[s].x),t.push(e[s].y),t.push(e[s].z),i.push(1),t.push(e[s].x),t.push(e[s].y),t.push(e[s].z),i.push(-1);var u=this.__get_next_position(e,s);r.push(u.x),r.push(u.y),r.push(u.z),r.push(u.x),r.push(u.y),r.push(u.z);var l=this.__get_previous_position(e,s);n.push(l.x),n.push(l.y),n.push(l.z),n.push(l.x),n.push(l.y),n.push(l.z),o.push(a),o.push(a),s<e.length-1&&(a+=e[s].distanceTo(u))}var _=new Float32Array(t),c=new Float32Array(r),h=new Float32Array(n),p=new Float32Array(i),d=new Float32Array(o),f=[];for(s=0;s<(_.length/3-2)/2;s++){var m=2*s+1;f.push(m),f.push(m+1),f.push(m-1),f.push(m),f.push(m+2),f.push(m+1)}this.geometry.setIndex(f),this.geometry.getAttribute("position").copy(new H(_,3)),this.geometry.getAttribute("next_position").copy(new H(c,3)),this.geometry.getAttribute("previous_position").copy(new H(h,3)),this.geometry.getAttribute("orientation").copy(new H(p,1)),this.geometry.getAttribute("coverage").copy(new H(d,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,this.accumulated_length=a},Object.defineProperty(t.prototype,"thickness",{get:function(){return this.material.uniforms._Thickness.value},set:function(e){this.material.uniforms._Thickness.value=e},enumerable:!1,configurable:!0}),t.prototype.__get_previous_position=function(e,t){return 0===t?e[1].clone().sub(e[0]).multiplyScalar(-1).add(e[0]):e[t-1]},t.prototype.__get_next_position=function(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]},t.prototype.update=function(){},t.prototype.distance=function(){return this.accumulated_length},t.prototype.total_length=function(){return this.accumulated_length},t.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.parent&&this.parent.remove(this)},Object.defineProperty(t.prototype,"color",{get:function(){return this.material.uniforms._Color.value},set:function(e){this.material.uniforms._Color.value.set(e)},enumerable:!1,configurable:!0}),t.prototype.copy_color=function(e){this.material.uniforms._Color.value.copy(e)},t}(s),Rr=function(t){function r(r,n){var o=this;n=n||new e(0,0);var a=new i({uniforms:{_MainTex:{value:r},_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:J}),s=new u(1,1,1);s.translate(-n.x/2,-n.y/2,0);var l=r.image.width/r.image.height;return s.scale(l,1,1),(o=t.call(this,s,a)||this).current_scale=l,o.geometry.computeBoundingBox(),o.tmp_bb_size=new h,o.geometry.boundingBox.getSize(o.tmp_bb_size),o.material=a,o}return Me(r,t),r.prototype.update_texture=function(){this.material.uniforms._MainTex.value.needsUpdate=!0;var 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)},Object.defineProperty(r.prototype,"size",{get:function(){return this.tmp_bb_size.clone().multiplyScalar(this.scale.x)},set:function(e){this.scale.copy(e),this.material.uniforms._Scale.value=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"screen_aligned",{get:function(){return 1===this.material.uniforms._ScreenAligned.value},set:function(e){this.material.uniforms._ScreenAligned.value=!0===e?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"opacity",{get:function(){return this.material.uniforms._Opacity.value},set:function(e){this.material.uniforms._Opacity.value=e},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.geometry.dispose(),this.parent.remove(this),this.material.uniforms._MainTex.value.dispose(),this.material.dispose()},r}(s),Pr=function(e){function t(t,r,n,i){var o=this,a=new zt,s={font:r,font_color:n||"#000000"},u=a.draw_on_texture(t,s);return u.minFilter=K,u.minFilter=G,u.needsUpdate=!0,(o=e.call(this,u,i)||this).simple_text_drawer=a,o.canvas_texture=u,o.draw_settings=s,o}return Me(t,e),Object.defineProperty(t.prototype,"text",{get:function(){return"not implemented"},set:function(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()},enumerable:!1,configurable:!0}),t}(Rr),Cr=function(e){function t(t,r){var n=e.call(this,t,r)||this;n.material=r;var i=n;return n.onBeforeRender=function(){"update"in i.material&&"function"==typeof i.material.update&&i.material.update()},n}return Me(t,e),t}(s),kr=function(t){function r(r){var n=t.call(this,"#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:r},_Boldness:{value:.5},_AtlasSize:{value:new e(1,1)}})||this;return n.transparent=!0,n.depthWrite=!1,n.side=J,r.minFilter=G,r.magFilter=G,r.generateMipmaps=!1,n}return Me(r,t),r.prototype.set_atlas_size=function(e){this.uniforms._AtlasSize.value.copy(e)},r.prototype.set_boldness=function(e){this.uniforms._Boldness.value=ht.lerp(.5,.2,e)},r}(ke),Or=function(t,r,n){var i=r.right-r.left,o=r.top-r.bottom;this.scale=new e(i,o),this.position=new e(t+r.left,r.bottom),this.atlas_bounds=new _(n.left,n.right,n.top,n.bottom)},Lr=function(){function t(t,r){void 0===r&&(r=""),this.glyph_layout=t,this.glyphs=[],this.glyph_is_dirty=!0,this.matrix_is_dirty=!0,this.color_is_dirty=!0,this.position=new h,this.quaternion=new I,this.scale=new h(1,1,1),this.matrix=new E,this.color=new o("#FFFFFF"),this.pivot_point=new e,this.__opacity=1,this.__text=r,this.__generate_glyphs(r)}return Object.defineProperty(t.prototype,"text",{get:function(){return this.__text},set:function(e){this.__text=e,this.__generate_glyphs(e),this.matrix_is_dirty=!0},enumerable:!1,configurable:!0}),t.prototype.update_matrix=function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrix_is_dirty=!1,this.glyph_is_dirty=!0},t.prototype.clear_glyph_dirty=function(){this.glyph_is_dirty=!1},t.prototype.clear_color_dirty=function(){this.color_is_dirty=!1},t.prototype.set_rotation=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var r=(new I).setFromAxisAngle(new h(0,1,0),e/360*Math.PI*2),n=(new I).setFromAxisAngle(new h(1,0,0),-t/360*Math.PI*2);this.quaternion.copy(r.multiply(n)),this.matrix_is_dirty=!0},t.prototype.set_position=function(e){this.position.copy(e),this.matrix_is_dirty=!0},t.prototype.set_size=function(e){this.scale.set(e,e,e),this.matrix_is_dirty=!0},t.prototype.set_color=function(e){this.color.set(e),this.color_is_dirty=!0},t.prototype.set_pivot=function(e){this.pivot_point.copy(e),this.update_glyphs()},Object.defineProperty(t.prototype,"opacity",{get:function(){return this.__opacity},set:function(e){this.__opacity=e,this.color_is_dirty=!0},enumerable:!1,configurable:!0}),t.prototype.update_glyphs=function(){this.__generate_glyphs(this.text)},t.prototype.__generate_glyphs=function(t){var r=0;this.glyphs.length=0;for(var n=function(e){var n=t.charCodeAt(e),o=i.glyph_layout.find((function(e){return e.unicode===n}));if(o){if(o.planeBounds){var a=new Or(r,o.planeBounds,o.atlasBounds);i.glyphs.push(a)}r+=o.advance}},i=this,o=0;o<t.length;o++)n(o);var a=new $,s=this.glyphs[0];a.setFromCenterAndSize(s.position.clone().add(new e(s.scale.x/2,s.scale.y/2)),s.scale);for(o=1;o<this.glyphs.length;o++){var u=this.glyphs[o],l=(new $).setFromCenterAndSize(u.position.clone().add(new e(u.scale.x/2,u.scale.y/2)),u.scale);a.union(l)}var _=new e;a.getSize(_);for(o=0;o<this.glyphs.length;o++)this.glyphs[o].position.x-=_.x/2,this.glyphs[o].position.y-=_.y/2,this.glyphs[o].position.x+=_.x/2*this.pivot_point.x,this.glyphs[o].position.y+=_.y/2*this.pivot_point.y;this.glyph_is_dirty=!0},t}(),Dr=function(t){function r(r,n){var i=this,o=new ee;o.instanceCount=0;var a=new u(1,1);a.translate(.5,.5,0),o.setAttribute("position",new te(a.getAttribute("position").array,3)),o.setAttribute("uv",new te(a.getAttribute("uv").array,2)),o.index=a.index;var s=new re(new Float32Array(8e3),4,!1),l=new re(new Float32Array(8e3),4,!1),_=new re(new Float32Array(8e3),4,!1),c=new re(new Float32Array(8e3),4,!1),h=new re(new Float32Array(8e3),4,!1),p=new re(new Float32Array(8e3),4,!1),d=new re(new Float32Array(8e3),4,!1);return s.usage=ne,l.usage=ne,_.usage=ne,c.usage=ne,h.usage=ne,p.usage=ne,d.usage=ne,o.setAttribute("transformsCol0",s),o.setAttribute("transformsCol1",l),o.setAttribute("transformsCol2",_),o.setAttribute("transformsCol3",c),o.setAttribute("glyph_bounds",h),o.setAttribute("plane_bounds",p),o.setAttribute("color",d),(i=t.call(this,o,new kr(n))||this).text_elements=[],i.font_layout=r,i.material.set_atlas_size(new e(r.atlas.width,r.atlas.height)),i.frustumCulled=!1,i}return Me(r,t),r.prototype.set_boldness=function(e){this.material.set_boldness(e)},r.prototype.add_text=function(e){var t=new Lr(this.font_layout.glyphs,e);return this.text_elements.push(t),t},r.prototype.remove_text=function(e){mr.remove_elem(this.text_elements,e),this.update(!0)},r.prototype.update=function(e){for(var t=this.geometry.getAttribute("glyph_bounds"),r=this.geometry.getAttribute("plane_bounds"),n=this.geometry.getAttribute("transformsCol0"),i=this.geometry.getAttribute("transformsCol1"),o=this.geometry.getAttribute("transformsCol2"),a=this.geometry.getAttribute("transformsCol3"),s=this.geometry.getAttribute("color"),u=!0===e,l=!0===e,_=!0===e,c=0,h=0;h<this.text_elements.length;h++){var p=this.text_elements[h];p.matrix_is_dirty&&(u=!0,p.update_matrix()),p.glyph_is_dirty&&(l=!0,p.clear_glyph_dirty()),p.color_is_dirty&&(_=!0,p.clear_color_dirty());for(var d=p.matrix,f=p.color,m=p.opacity,v=0;v<p.glyphs.length;v++){var g=p.glyphs[v],y=c;t.setXYZW(y,g.atlas_bounds.x,g.atlas_bounds.y,g.atlas_bounds.z,g.atlas_bounds.w),r.setXYZW(y,g.position.x,g.position.y,g.scale.x,g.scale.y),n.setXYZW(y,d.elements[0],d.elements[1],d.elements[2],d.elements[3]),i.setXYZW(y,d.elements[4],d.elements[5],d.elements[6],d.elements[7]),o.setXYZW(y,d.elements[8],d.elements[9],d.elements[10],d.elements[11]),a.setXYZW(y,d.elements[12],d.elements[13],d.elements[14],d.elements[15]),s.setXYZW(y,f.r,f.g,f.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),u&&(n.needsUpdate=!0,i.needsUpdate=!0,o.needsUpdate=!0,a.needsUpdate=!0),l&&(t.needsUpdate=!0,r.needsUpdate=!0),_&&(s.needsUpdate=!0)},r.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},r}(s),jr=function(e){function t(t,r,n,i){void 0===r&&(r=new h),void 0===n&&(n=new h(1,1,1)),void 0===i&&(i="linear");var o=e.call(this,i)||this;return o.attribute_name=t,o.from=r,o.to=n,o}return Me(t,e),t.prototype.update=function(e,t){var r=this.from.clone();r.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(r)},t}(ft),Ur=function(e){function t(){return e.call(this,"#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;}")||this}return Me(t,e),Object.defineProperty(t.prototype,"offset",{get:function(){return this.uniforms._Offset.value},set:function(e){this.uniforms._Offset.value=e},enumerable:!1,configurable:!0}),t}(Ae),Ir=function(e){function t(t){return e.call(this,t?"#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);}")||this}return Me(t,e),t}(Ae),Nr=function(){function e(){this.current_width=1,this.current_height=1,this.RT0=new c(1,1),this.RT1=new c(1,1),this.RT2=new c(1,1),this.RT3=new c(1,1),this.RT4=new c(1,1),this.upscale_blur_mat=new Ir(!0),this.downscale_blur_mat=new Ir(!1),this.alpha_filter_mat=new Ur}return e.prototype.blur=function(e){this.check_RT_resize(e.width,e.height),Be.blit(e,this.RT1,this.alpha_filter_mat),Be.blit(this.RT1,this.RT2,this.downscale_blur_mat),Be.blit(this.RT2,this.RT3,this.downscale_blur_mat),Be.blit(this.RT3,this.RT4,this.downscale_blur_mat),Be.blit(this.RT4,this.RT3,this.upscale_blur_mat),Be.blit(this.RT3,this.RT2,this.upscale_blur_mat),Be.blit(this.RT2,e,this.upscale_blur_mat)},e.prototype.check_RT_resize=function(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))},e}(),Er=function(t){function r(){var r=t.call(this,"#define GLSLIFY 1\nuniform 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;return r.uniforms._SourceTex={value:void 0},r.uniforms._SourceTexSize={value:new e(1,1)},r}return Me(r,t),r.prototype.set_texture=function(e){this.uniforms._SourceTex.value=e;var t=this.get_size(e);this.uniforms._SourceTexSize.value.copy(t)},r.prototype.get_size=function(t){return t.isVideoTexture?new e(Math.max(1,t.image.videoWidth),Math.max(1,t.image.videoHeight)):t.isWebGLRenderTarget?new e(t.width,t.height):t.isTexture?new e(t.image.width,t.image.height):new e(1,1)},r}(Ae),qr=function(){function t(){this.RT=new c(1,1,{type:ie,format:B,minFilter:x,magFilter:x}),this.RT1=new c(1,1,{type:ie,format:B,minFilter:x,magFilter:x}),this.median_filter_mat=new Er}return t.prototype.filter=function(e){var 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),Be.material_pass(this.median_filter_mat,this.RT);for(var r=0;r<0;r++)this.median_filter_mat.set_texture(this.RT.texture),Be.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),Be.material_pass(this.median_filter_mat,this.RT);return this.RT},t.prototype.get_size=function(t){return t.isVideoTexture?new e(Math.max(1,t.image.videoWidth),Math.max(1,t.image.videoHeight)):t.isRenderTarget?new e(t.width,t.height):t.isTexture?new e(t.image.width,t.image.height):new e(1,1)},t}(),Vr=function(){function e(e,t){this.read=void 0,this.write=void 0,this.name=e,this.update_material=t}return e.prototype.init_from_geometry=function(e){},e.prototype.init_from_attribute=function(e){},e.prototype.build_RT=function(t){var r=e.calculate_resolution(t),n={minFilter:x,magFilter:x,format:B,colorScape:v,type:At.fp_textures_available?ie:W,stencilBuffer:!1,depthBuffer:!1};return new c(r.width,r.height,n)},e.calculate_resolution=function(e){var t=Math.min(e,512);return{width:t,height:Math.max(1,Math.ceil(e/t))}},e.prototype.swap_RT=function(){var e=this.read;this.read=this.write,this.write=e},e.prototype.update=function(e){this.update_material&&(this.update_material.update(),e.children[0]instanceof s&&(e.children[0].material=this.update_material),this.update_material.uniforms._MainTex.value=this.read.texture,Be.render(e,void 0,this.write),e.children[0]instanceof s&&(e.children[0].material=void 0),this.swap_RT())},e.prototype.store_geometry_attribute_in_RT=function(e,t,r,n){n.children[0]instanceof s&&(n.children[0].geometry.setAttribute("data",e),n.children[0].material=r),Be.render(n,void 0,t),n.children[0]instanceof s&&(n.children[0].geometry.deleteAttribute("data"),n.children[0].material=void 0)},e.prototype.get_texture=function(){return this.read.texture},e}(),Br=function(e){function t(t,r){var n=e.call(this)||this;return n.attributes=[],n.mesh=n.build_point_mesh(t,r),n.add(n.mesh),n.attribute_writter_mesh=n.build_attribute_writter_mesh(t),n.attribute_writter_scene=new a,n.attribute_writter_scene.add(n.attribute_writter_mesh),n}return Me(t,e),t.prototype.add_texture_attribute=function(e){this.attributes.push(e)},t.prototype.add_update_attribute_array=function(e,t,r){this.attribute_writter_mesh.geometry.setAttribute(e,new H(t,r,!1))},t.prototype.add_attribute_array=function(e,t,r){this.mesh.geometry.setAttribute(e,new re(t,r,!1))},t.prototype.update=function(){var e=this.mesh.material;Array.isArray(e)?e.forEach((function(e){return e.dispose()})):e.dispose();for(var t=0;t<this.attributes.length;t++)this.attributes[t].update(this.attribute_writter_scene)},t.prototype.dispose=function(){this.mesh.geometry.dispose();var e=this.mesh.material;Array.isArray(e)?e.forEach((function(e){return e.dispose()})):e.dispose()},t.prototype.build_point_mesh=function(e,t){void 0===e&&(e=1);var r=new u,n=new ee;n.setAttribute("position",r.getAttribute("position")),n.index=r.index,n.setAttribute("storage_uv",this.build_uv_storage_attribute(e)),n.instanceCount=e;var i=new s(n,t);return i.frustumCulled=!1,i},t.prototype.build_attribute_writter_mesh=function(e){for(var t=Vr.calculate_resolution(e),r=t.width,n=t.height,i=new Float32Array(3*e),o=0;o<e;o++){var a=o%r,s=Math.floor(o/r);i[3*o+0]=(a+.5)/r,i[3*o+1]=(s+.5)/n,i[3*o+2]=o}var u=new S;u.setAttribute("position",new H(i,3,!1));var l=new oe(u);return l.frustumCulled=!1,l},t.prototype.build_uv_storage_attribute=function(e){for(var t=Vr.calculate_resolution(e),r=t.width,n=t.height,i=new Float32Array(2*e),o=0;o<e;o++){var a=o%r,s=Math.floor(o/r);i[2*o+0]=(a+.5)/r,i[2*o+1]=(s+.5)/n}return new re(i,2,!1)},t}(F),Yr=function(e){function n(n){return n=n||"\n varying vec4 value;\n attribute vec4 data;\n\n void main()\n {\n gl_Position = vec4(position.xy * 2.0 - 1.0, 1.0,1.0);\n gl_PointSize = 1.0;\n\n value = data;\n }\n ",e.call(this,{uniforms:{},vertexShader:n,fragmentShader:"#define GLSLIFY 1\nvarying vec4 value;void main(){gl_FragColor=value;}",depthWrite:!1,blending:t,depthTest:!1,depthFunc:r})||this}return Me(n,e),n}(i),Gr=function(e){function t(t){return e.call(this,"_Position",t)||this}return Me(t,e),t.prototype.store_geometry=function(e,t){var r=e.getAttribute("position");this.read=this.build_RT(r.count),this.write=this.build_RT(r.count);var n=new Yr;this.store_geometry_attribute_in_RT(e.getAttribute("position"),this.read,n,t)},t.prototype.store_positions=function(e,t){this.read=this.build_RT(e.length),this.write=this.build_RT(e.length);for(var r=new Float32Array(4*e.length),n=0;n<e.length;n++)r[4*n+0]=e[n].x,r[4*n+1]=e[n].y,r[4*n+2]=e[n].z,r[4*n+3]=10*(2*Math.random()-1);var i=new Yr;this.store_geometry_attribute_in_RT(new H(r,4),this.read,i,t)},t}(Vr),Wr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new be,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Xr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new ae,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(e){t.__set_error(e),t.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Qr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new we,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Hr=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?fetch(this.url).then((function(r){r.json().then((function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}))})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Zr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new xe,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(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()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),Jr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new ae,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,t.parse_path(r)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(e){t.__set_error(e),t.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t.prototype.parse_path=function(e){var t=e.split("\n");""===t[t.length-1]&&t.pop();for(var r=[],n=0;n<t.length;n+=3){var i=parseFloat(t[n+0]),o=parseFloat(t[n+1]),a=parseFloat(t[n+2]);r.push(new h(i,o,a))}return r},t}(De),Kr=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.loader=new ae,i}return Me(t,e),t.prototype.on_preloaded_finished=function(e){var t=this;void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(function(r){e.set_resource(t.resource_id,t.url,r),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(function(){}),(function(e){t.__set_error(e),t.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),$r=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.on_preloaded_finished=function(e,t){var r=this;void 0===e.resources_by_url[this.url]?t.blob().then((function(t){var i=new n,o=URL.createObjectURL(t),a=new Image;a.src=o,a.onload=function(){i.image=a,i.needsUpdate=!0,e.set_resource(r.resource_id,r.url,i),r.__update_downloaded_bytes(1,1),r.__loading_ended()},a.onerror=function(){console.error("Error loading texture. Maybe the resource is not an image?",r.url)}})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),en=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return Me(t,e),t.prototype.on_preloaded_finished=function(e,t){var r=this;void 0===e.resources_by_url[this.url]?t.blob().then((function(t){e.set_resource(r.resource_id,r.url,URL.createObjectURL(t)),r.__update_downloaded_bytes(1,1),r.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())},t}(De),tn=function(){function e(e){this.name=e,this.resources={},this.resources_by_url={}}return e.prototype.set_resource=function(e,t,r){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=r,this.resources_by_url[t]=r)},e.prototype.get_resource=function(e){return this.resources[e]},e.prototype.get=function(e){return this.resources[e]},e}(),rn=function(){function e(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}return e.prototype.add_loader=function(e){this.resource_loaders.push(e)},e.prototype.load=function(e){for(var t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||tn)},Object.defineProperty(e.prototype,"loading_finished",{get:function(){for(var e=!0,t=0;t<this.resource_loaders.length;t++)e=e&&this.resource_loaders[t].has_finished;return e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"has_errors",{get:function(){for(var e=!1,t=0;t<this.resource_loaders.length;t++)e=e||this.resource_loaders[t].has_error;return e},enumerable:!1,configurable:!0}),e.prototype.print_errors=function(){console.error("Batch <"+this.batch_name+"> could not load successfully");for(var e=0;e<this.resource_loaders.length;e++)this.resource_loaders[e].has_error&&this.resource_loaders[e].print_error()},e.prototype.get_progress=function(){return this.get_loaded_bytes()/this.get_total_bytes()},e.prototype.get_loaded_bytes=function(){for(var e=1,t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].loaded_bytes;return e},e.prototype.get_total_bytes=function(){for(var e=1,t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].total_bytes;return e},e}(),nn=function(){function e(){}return e.prototype.start=function(){this.finished=!1},e.prototype.update=function(){this.finished=!0},e}();export{De as AbstractLoader,_t as AbstractScene,ct as ActionEvent,ft as ActionInterpolator,pt as ActionSequencer,gt as ActionSequencerBuilder,Re as AddMaterial,Mt as ApplicationView,mr as ArrayUtilities,kt as Arrow,Qe as AsyncAbstractLoader,He as AsyncAudiosLoader,Ke as AsyncObjectsLoader,et as AsyncTextureLoader,ot as AsyncTexturesLoader,Ge as AudioLoader,Te as BaseApplication,Le as BaseRender,ke as BaseShaderMaterial,tt as BasisLoader,Ae as BlitMaterial,rr as Blurrer,$e as Browser,Nt as CSSAnimator,je as CameraManager,Gt as CameraUtilities,Ft as CanvasDrawer,At as Capabilities,nn as Compilator,Ot as Cube,rt as CubemapLoader,Wr as DAELoader,jt as Debug,Zt as DebugNormalsRender,vt as DrawIOAnimationSheet,Ir as DualFilteringBlurMaterial,Nr as DualFilteringBlurrer,dt as EasingFunctions,Xr as FileLoader,Qr as FontLoader,vr as FrustumPointFitter,Ze as GLTFDRACOLoader,Je as GLTFLoader,Br as GPUParticleSystem,sr as GaussianBlurrer,gr as GeometryUtilities,Be as Graphics,zr as Grid,nt as HDRCubeTextureLoader,it as HDRTextureLoader,yr as HTMLUtilities,ut as HighQualityLoadingState,dr as HorizontalPlane,br as ImageUtilities,Wt as Initializer,Hr as JSONLoader,Xt as KeyboardInput,Ar as Line,st as LoadingState,qr as MedianFilter,wr as MeshSampler,xr as ModelUtilities,nr as NormalAORender,ir as NormalRender,mt as NumberInterpolator,Zr as OBJLoader,ht as OMath,qt as OS,Ue as OScreen,Tr as ObjectUtilities,Qt as OrthographicCamera,Bt as OrthographicFrustumPointFitter,Vr as ParticleAttribute,Gr as ParticlePositionAttribute,Ct as PerspectiveCamera,Yt as PerspectiveFrustumPointFitter,Jr as PointArrayLoader,lt as RegularLoadingState,cr as RenderLoop,rn as ResourceBatch,Xe as ResourceContainer,Dr as SDFTextBatch,Ie as SceneManager,hr as Screen,zt as SimpleTextDrawer,Lt as Sphere,Sr as StringUtilities,Pr as Text2D,Kr as TextLoader,$r as TextureLoader,bt as Time,Mr as TimeUtilities,Tt as TransitionManager,yt as TransitionTable,Oe as UnrealBloomComposeMaterial,ur as UnrealBloomRender,Cr as UpdatableMaterialMesh,lr as VRRender,Fr as Validation,jr as VectorInterpolator,fr as VerticalPlane,en as VideoLoader,pr as ViewComponent,_r as ViewComponentManager,St as ViewManager,Rr as WorldImage};
1
+ import{ShaderMaterial as e,Vector2 as t,NoBlending as s,AlwaysDepth as r,Texture as i,Color as n,Scene as o,Mesh as a,PlaneGeometry as l,OrthographicCamera as _,Vector4 as h,RenderTarget as c,Vector3 as d,PositionalAudio as u,Audio as p,AudioContext as m,SRGBColorSpace as g,NoColorSpace as f,CubeTextureLoader as v,CanvasTexture as w,UVMapping as b,ClampToEdgeWrapping as y,NearestFilter as x,Object3D as T,LineBasicMaterial as S,BufferGeometry as M,Line as F,PerspectiveCamera as z,CylinderGeometry as A,ConeGeometry as R,MeshBasicMaterial as C,BoxGeometry as k,SphereGeometry as P,Box3 as L,Box3Helper as D,CatmullRomCurve3 as U,Sphere as O,Plane as I,Line3 as N,Quaternion as E,Matrix4 as j,Ray as q,DataTexture as V,RGBAFormat as B,RepeatWrapping as Y,LinearFilter as G,HalfFloatType as W,UnsignedByteType as X,LinearSRGBColorSpace as Q,BufferAttribute as H,Skeleton as $,DoubleSide as Z,LinearMipMapLinearFilter as J,Box2 as K,InstancedBufferGeometry as ee,Float32BufferAttribute as te,InstancedBufferAttribute as se,DynamicDrawUsage as re,FloatType as ie,Points as ne,FileLoader as oe}from"three";import{WebGPURenderer as ae,MeshBasicNodeMaterial as le}from"three/webgpu";import{GLTFLoader as _e}from"three/examples/jsm/loaders/GLTFLoader.js";import{HDRCubeTextureLoader as he}from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import{HDRLoader as ce}from"three/examples/jsm/loaders/HDRLoader";import*as de from"three/examples/jsm/utils/BufferGeometryUtils.js";export{de as BufferGeometryUtils};import{uniform as ue,attribute as pe,vec3 as me,mix as ge,fwidth as fe,smoothstep as ve,min as we}from"three/tsl";import{ColladaLoader as be}from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as ye}from"three/examples/jsm/loaders/FontLoader.js";import{OBJLoader as xe}from"three/examples/jsm/loaders/OBJLoader.js";class Te{on_post_start(){}on_enter(e){}on_exit(e){}before_update(){}update(){}fixed_update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}}class Se extends e{constructor(e,n,o){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new t(0,0)},_TargetResolution:{value:new t(0,0)}},defines:o||{},vertexShader:n||"#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:s,depthTest:!1,depthFunc:r}),this.uniforms={_MainTex:{value:i},_Resolution:{value:t},_TargetResolution:{value:t}}}}class Me extends Se{constructor(e=!1){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec4 col0=sampleTex(_MainTex,vUv);vec4 col1=sampleTex(_SecondTex,vUv);gl_FragColor=col0+col1;gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));}"),this.defines.USE_LINEAR_COLOR_SPACE=e,this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}var Fe="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}",ze="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}";class Ae extends e{constructor(e,t,s){super({vertexShader:e||ze,fragmentShader:t||Fe,uniforms:s??{_Color:{value:new n("#FF0000")}}})}}class Re extends Se{constructor(e,t=!1){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);}vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*sampleTex(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*sampleTex(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*sampleTex(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*sampleTex(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*sampleTex(blurTexture5,vUv));\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}",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:1},this.defines.USE_LINEAR_COLOR_SPACE=t;const s=[new n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF")];this.uniforms.bloomTintColors={value:s}}set_blur_texture_0(e){this.uniforms.blurTexture1.value=e}set_blur_texture_1(e){this.uniforms.blurTexture2.value=e}set_blur_texture_2(e){this.uniforms.blurTexture3.value=e}set_blur_texture_3(e){this.uniforms.blurTexture4.value=e}set_blur_texture_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 Ce{constructor(){}render(e){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}class ke{constructor(e,t,s=1){this.resource_id=e,this.url=t,this.loaded_bytes=0,this.total_bytes=s,this.has_finished=!1,this.has_error=!1,this.error_message="none"}__update_downloaded_bytes(e,t){e=this.is_number(e)?e:1,t=this.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){if(void 0===e.resources_by_url[this.url]){const t="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))}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()}async on_progress(e,t){const s=t.clone(),r=t.body.getReader(),i=+t.headers.get("Content-Length");let n=0;for(;;){const{done:e,value:t}=await r.read();if(e)break;n+=t.length,this.__update_downloaded_bytes(n,i)}t.ok?this.on_preloaded_finished(e,s):(this.__set_error(`${t.status}: ${t.statusText}`),this.__loading_ended())}on_preloaded_finished(e,t){}__on_error(e){console.error(e)}is_int(e){return Number(e)===e&&e%1==0}is_float(e){return Number(e)===e&&e%1!=0}is_number(e){return this.is_int(e)||this.is_float(e)}}const Pe=new class{init(){this._current=void 0,this._spectator=void 0}set current(e){this._current=e}get current(){return this._current}set spectator(e){this._spectator=e}get spectator(){return this._spectator}};const Le=new class{init(){this.width=1,this.height=1,this.position=new t,this.render_width=1,this.render_height=1,this.width_height=new t(this.width,this.height),this.dpr=1,this.pixel_size=new t(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update(){this.size_changed=!1}update_size(e,s){this.width=e,this.height=s,this.pixel_size=new t(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=s,this.render_width=e*this.dpr,this.render_height=s*this.dpr,this.size_changed=!0}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}get portrait(){return this.width<this.height}};const De=new class{init(){this._current=new nt({name:"default_scene",compilators:{}}),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=>{if(e.geometry){e.geometry.dispose();const t=e.material;Array.isArray(t)?t.forEach((e=>e.dispose())):t.dispose()}}));this.current.children.length>0;)this.current.remove(this.current.children[0])}};class Ue{constructor(e){this.renderer=e,this._blit_scene=new o,this._blit_material=new Se,this._blit_quad=new a(new l(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new _(-1,1,1,-1,-1e4,1e4)}blit(e,t){this._blit_quad.material=this._blit_material;const s=!0===e.isRenderTarget?e.texture:e,r=!0===e.isRenderTarget?e.width:e.image.width,i=!0===e.isRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=s,this._blit_quad.material.uniforms._Resolution.value.set(r,i),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,s){const r=!0===e.isRenderTarget?e.texture:e,i=!0===e.isRenderTarget?e.width:e.image.width,n=!0===e.isRenderTarget?e.height:e.image.height;this._blit_quad.material=s,this._blit_quad.material.uniforms._MainTex.value=r,this._blit_quad.material.uniforms._Resolution.value.set(i,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){const t=void 0===e?null:e,s=this.renderer.getRenderTarget();this.renderer.setRenderTarget(t),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(s)}}class Oe extends Se{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 h(e,t.x,t.y,t.z)}}}class Ie extends e{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 Ne{constructor(){this.RT=new c(Le.width,Le.height),this.clear_depth_normal_mat=new Oe(1,new d(0,0,1)),this.depth_normal_material=new Ie}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=Pe.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===Le.width&&this.RT.height===Le.height||this.RT.setSize(Le.width,Le.height)}get render_target(){return this.RT}}const Ee=new class{init({core_attributes:e,renderer_attributes:t,dpr:s}){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generate_depth_normal_texture=!1,this.depth_and_normals_renderer=void 0,this.core_attributes={xr_enabled:!1},Object.assign(this.core_attributes,e),this._renderer=new ae(t),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,Le.dpr=s,this._renderer.setPixelRatio(1),this.blitter=new Ue(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new Ce,this.current_render_mode=this.no_render,this.generate_depth_normal_texture=!1,this.depth_and_normals_renderer=new Ne}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.generate_depth_normal_texture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),Pe.current&&this.current_render_mode.render(),Le.update()}__update_current_camera(){Pe.current&&(Pe.current.aspect=Le.aspect_ratio,Pe.current.updateProjectionMatrix(),Pe.current.updateMatrix(),Pe.current.updateMatrixWorld(!0))}render(e,t,s,r){this.__apply_override_material(e,r),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.render(e||De.current,t||Pe.current),this.__apply_override_material(e,void 0)}async compile(e,t,s,r){this.__apply_override_material(e,r),this._renderer.setRenderTarget(void 0===s?null:s),await this._renderer.compile(e||De.current,t||Pe.current),this.__apply_override_material(e,void 0)}async compile_async(e,t,s,r,i){this.__apply_override_material(e,r),this._renderer.setRenderTarget(void 0===s?null:s);const n=this._renderer.compileAsync(e||De.current,t||Pe.current,i);return this.__apply_override_material(e,void 0),n}render_scene(e){"on_pre_render"in e&&e.on_pre_render(),"render"in e?e.render():this.render(e,void 0),"on_post_render"in e&&e.on_post_render()}__apply_override_material(e,t){t=void 0===t?null:t,e?e.overrideMaterial=t:De.current.overrideMaterial=t}async readback_RT(e){return this._renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height)}clear(e,t,s,r){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!s,!!r)}on_resize(e,t){for(const s of e)Le.dpr=t,Le.update_position(s.contentRect.x,s.contentRect.y),Le.update_size(s.contentRect.width,s.contentRect.height),this.canvas.width=Le.render_width,this.canvas.height=Le.render_height,this._renderer.setViewport(0,0,Le.render_width,Le.render_height),this._renderer.setSize(window.innerWidth,window.innerHeight),this.__update_current_camera()}material_pass(e,t){this.blitter.material_pass(e,t)}blit(e,t,s){s?this.blitter.blit_with_material(e,t,s):this.blitter.blit(e,t)}blit_clear_with_material(e,t){this.blitter.blit_clear_with_material(e,t)}take_screenshot(e,t=Le.width,s=Le.height){const r=Le.width,i=Le.height,n=t,o=s,a=1024,l=1024,_=Math.ceil(n/a),h=Math.ceil(o/l);Le.update_size(a,l);const c=this._renderer.getPixelRatio();this._renderer.setPixelRatio(1),this._renderer.setSize(a,l,!1);const d=document.createElement("canvas").getContext("2d");d.canvas.width=n,d.canvas.height=o,Pe.current.aspect=Le.aspect_ratio,Pe.current.updateMatrix(),Pe.current.updateMatrixWorld(!0);for(let e=0;e<_;e++)for(let t=0;t<h;t++)Pe.current.setViewOffset(n,o,Le.width*e,Le.height*t,Le.width,Le.height),this.current_render_mode.render(),d.drawImage(this._renderer.domElement,Le.width*e,Le.height*t);d.canvas.toBlob(e,"image/png;base64;"),Pe.current.clearViewOffset(),Le.update_size(r,i),this._renderer.setPixelRatio(c),this._renderer.setSize(r,i,!1),Pe.current.aspect=Le.aspect_ratio,Pe.current.updateMatrix(),Pe.current.updateMatrixWorld(!0)}download_screenshot(e){const 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 je{constructor(e,t=!0,s=1,r=!1){this.buffer=e,this.loop=t,this.volume=s,this.positional=r,this.audio=void 0}init(e){this.positional?this.audio=new u(e):this.audio=new p(e),this.audio.setBuffer(this.buffer),this.audio.setLoop(this.loop),this.audio.gain.gain.value=0,this.audio.setVolume(this.loop?0:this.volume)}play(){this.audio.play()}pause(){this.audio.pause()}stop(){this.audio.stop()}get is_playing(){return this.audio.isPlaying}}class qe extends ke{constructor(e,t,s=!0,r=0,i,n=!1){super(e,t,i),this.loop=s,this.volume=r,this.positional=n}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.instantiate_audio(e):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}instantiate_audio(e){const t=m.getContext(),s=t.createBuffer(2,22050,44100);fetch(this.url).then((e=>e.blob())).then((r=>{r.arrayBuffer?r.arrayBuffer().then((s=>{t.decodeAudioData(s,(t=>{e.set_resource(this.resource_id,this.url,new je(t,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))})):(e.set_resource(this.resource_id,this.url,new je(s,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended())}))}}const Ve=new class{init(){this.resources={},this.resources_by_url={}}set_resource(e,t,s){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=s,this.resources_by_url[t]=s)}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}};class Be{constructor(e,t,s){this.resource_container=Ve,this.assets=t,this.name=e,this.worker=s,this.bound_on_message=this.on_message.bind(this),this.__setup_worker(),this.assets_loaders=this.__setup_loaders()}load(){this.worker.postMessage({type:"load",loader_name:this.name})}is_loaded(){for(let e=0;e<this.assets_loaders.length;e++){const t=this.assets_loaders[e];if(!t.has_finished)return!1;t.has_error&&(t.url=t.original_url,t.print_error())}return!0}get_progress(){return this.__get_loaded_bytes()/this.__get_total_bytes()}__get_loaded_bytes(){let e=1;for(let t=0;t<this.assets_loaders.length;t++)e+=this.assets_loaders[t].loaded_bytes;return e}__get_total_bytes(){let e=1;for(let t=0;t<this.assets_loaders.length;t++)e+=this.assets_loaders[t].total_bytes;return e}get_assets_names(){const e=[];for(let t=0;t<this.assets.length;t++){const s=this.assets[t];e.push(s.name)}return e}static create_worker(){return new Worker(new URL("./assets_loader/AsyncAssetsLoaderWorker.ts",import.meta.url),{name:"OHZI - AssetLoader",type:"module"})}__setup_worker(){this.worker.addEventListener("message",this.bound_on_message),this.worker.postMessage({type:"assets",loader_name:this.name,data:this.assets})}on_message(e){const t=e.data;if(t.type===`asset_loaded_${this.name}`)this.__on_assets_loaded(t.data)}__on_assets_loaded(e){this.worker.removeEventListener("message",this.bound_on_message);for(let t=0;t<this.assets_loaders.length;t++){const s=this.assets_loaders[t];s.original_url=s.url,s.url=e[s.resource_id],s.on_preloaded_finished(this.resource_container)}}__setup_loaders(){return console.warn("Not implemented"),[]}}class Ye extends Be{constructor(e,t,s){super(e,t,s)}__setup_loaders(){const e=[];for(let t=0;t<this.assets.length;t++){const s=this.assets[t];e.push(new qe(s.name,s.url,s.loop,s.volume,s.size,s.positional))}return e}}class Ge extends ke{constructor(e,t,s,r){super(e,t,r),this.loader=new _e,this.loader.setDRACOLoader(s)}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class We extends ke{constructor(e,t,s){super(e,t,s),this.loader=new _e}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Xe extends Be{constructor(e,t,s){super(e,t,s)}__setup_loaders(){const e=[];for(let t=0;t<this.assets.length;t++){const s=this.assets[t];if(s.draco){const t=Ve.get("draco_loader");e.push(new Ge(s.name,s.url,t,s.size))}else e.push(new We(s.name,s.url,s.size))}return e}}const Qe=new class{async init(){switch(this.browser_name="",this.agent=window.navigator.userAgent.toLowerCase(),this.has_web_xr_support="xr"in navigator,this.is_vr=this.has_web_xr_support&&await navigator.xr.isSessionSupported("immersive-vr"),!0){case this.agent.indexOf("edge")>-1:this.browser_name="edge_ie";break;case this.agent.indexOf("edg")>-1:this.browser_name="edge_chromium";break;case this.agent.indexOf("opr")>-1&&!!window.opr:this.browser_name="opera";break;case this.agent.indexOf("chrome")>-1&&!!window.chrome:this.browser_name="chrome";break;case this.agent.indexOf("trident")>-1:this.browser_name="iexplorer";break;case this.agent.indexOf("firefox")>-1:this.browser_name="firefox";break;case this.agent.indexOf("safari")>-1:this.browser_name="safari";break;default:this.browser_name="other"}this.version=this.get_version()}get name(){return this.browser_name}get is_safari(){return"safari"===this.browser_name}get is_chrome(){return"chrome"===this.browser_name}get is_firefox(){return"firefox"===this.browser_name}get is_edge(){return"edge_ie"===this.browser_name}get is_edge_chromium(){return"edge_chromium"===this.browser_name}get has_webm(){return!!(this.is_chrome||this.is_firefox||this.is_edge_chromium)}get has_hvec(){return this.is_safari}get preferred_video_extension(){return this.has_webm?"webm":this.has_hvec?"hvec.mp4":"mp4"}get_version(){const e=navigator.userAgent;let t=[],s="0",r=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(r[1])&&(t=/\brv[ :]+(\d+)/g.exec(e)||[],s="IE "+(t[1]||"")),"Chrome"===r[1]&&(t=e.match(/\b(OPR|Edge)\/(\d+)/),null!=t&&(s=t.slice(1).join(" ").replace("OPR","Opera"))),r=r[2]?[r[1],r[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+(\.\d+)?)/i))&&r.splice(1,1,t[1]),s=r.join(" "),Number(s.split(" ")[1])}};class He extends ke{constructor(e,t,s,r=!0,i=!1,n=!0){super(e,t,s),this.original_url="",this.colorSpaceConversion=n,this.premultiplyAlpha=i,this.flipY=r}on_preloaded_finished(e){Qe.is_safari?this.load_with_old_method(e):this.load_with_new_method(e)}load_with_old_method(e){if(void 0===e.resources_by_url[this.url]){const t=new i,s=new Image;s.src=this.url,s.onload=()=>{t.image=s,t.flipY=this.flipY,t.premultiplyAlpha=this.premultiplyAlpha,t.colorSpace=this.colorSpaceConversion?g:f,t.needsUpdate=!0,e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()},s.onerror=()=>{console.error("The source image could not be decoded.",this.original_url)}}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()}load_with_new_method(e){if(void 0===e.resources_by_url[this.url]){const t={credentials:"same-origin"};fetch(this.url,t).then((e=>e.blob())).then((e=>createImageBitmap(e,{colorSpaceConversion:this.colorSpaceConversion?"default":"none",imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:this.premultiplyAlpha?"premultiply":"none"}))).then((t=>{const s=new i(t);s.flipY=this.flipY,s.premultiplyAlpha=this.premultiplyAlpha,s.colorSpace=this.colorSpaceConversion?g:f,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended()})).catch((e=>{console.error(e,this.original_url)}))}else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended()}}class $e extends ke{constructor(e,t,s,r){super(e,t,r),this.loader=s}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(e=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Ze extends ke{constructor(e,t,s,r){super(e,t,r),this.loader=new v,this.loader.setPath(t+"/"),this.urls=[`px.${s}`,`nx.${s}`,`py.${s}`,`ny.${s}`,`pz.${s}`,`nz.${s}`]}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯"+e),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Je extends ke{constructor(e,t,s,r){super(e,t,r),this.loader=new he,this.loader.setPath(t+"/"),this.urls=[`px.${s}`,`nx.${s}`,`py.${s}`,`ny.${s}`,`pz.${s}`,`nz.${s}`]}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Ke extends ke{constructor(e,t,s){super(e,t,s),this.loader=new ce}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class et extends Be{constructor(e,t,s){super(e,t,s)}__setup_loaders(){const e=[];for(let t=0;t<this.assets.length;t++){const s=this.assets[t];switch(s.kind){case"regular":e.push(new He(s.name,s.url,s.size,s.flipY,s.premultiplyAlpha,s.colorSpaceConversion));break;case"basis":e.push(new $e(s.name,s.url,Ve.get("basis_loader"),s.size));break;case"hdr":e.push(new Ke(s.name,s.url,s.size));break;case"cubemap":e.push(new Ze(s.name,s.url,s.extension,s.size));break;case"cubemap_hdr":e.push(new Je(s.name,s.url,s.extension,s.size))}}return e}}class tt{constructor(e){this.compilators=e,this.first_update=!0,this.index=0}update(){this.is_finished()||(this.compilators[this.index].finished?(this.index++,this.first_update=!0):this.first_update?(this.compilators[this.index].start(),this.first_update=!1):this.compilators[this.index].update())}is_finished(){return this.index===this.compilators.length}}class st{constructor(e,{SceneCompilator:t,TexturesCompilator:s,AudiosCompilator:r}){this.scene=e,this.SceneCompilator=t,this.TexturesCompilator=s,this.AudiosCompilator=r,this.loaders=[],this.compilators=[],this.callback_called=!1}set_assets(e,t,s,r=[],i=[],n=[]){this.scene_objects=e,this.scene_textures=t,this.scene_sounds=s,this.custom_loaders=r,this.custom_compilators=i,this.custom_data=n}get loading_progress(){let e=0;for(let t=0;t<this.loaders.length;t++){e+=this.loaders[t].get_progress()}return e/this.loaders.length}load(){this.setup_loader(),this.loaders[0].load()}on_enter(){}on_exit(){}update(){}setup_loader(){const e=[],t=Ve.get("assets_worker");t.postMessage({type:"reset",loader_name:this.scene.name});const s=new Xe(this.scene.name,this.scene_objects,t);this.loaders.push(s),e.push(new this.SceneCompilator(this.scene));const r=new et(this.scene.name,this.scene_textures,t);this.loaders.push(r),e.push(new this.TexturesCompilator(r.get_assets_names()));const i=new Ye(this.scene.name,this.scene_sounds,t);this.loaders.push(i),e.push(new this.AudiosCompilator(i.get_assets_names()));for(let s=0;s<this.custom_loaders.length;s++){const r=new this.custom_loaders[s](this.scene.name,this.custom_data[s],t);this.loaders.push(r),e.push(new this.custom_compilators[s](r.get_assets_names()))}this.compilator_manager=new tt(e)}is_loaded(){let e=!0;for(let t=0;t<this.loaders.length;t++){const s=this.loaders[t];e=e&&s.is_loaded()}return e}is_compiled(){return this.compilator_manager.update(),this.compilator_manager.is_finished()}}class rt extends st{on_enter(){super.on_enter()}on_exit(){super.on_exit()}update(){super.update(),this.is_loaded()&&this.scene.on_high_quality_assets_ready()}}class it extends st{constructor(e,t){super(e,t),this.on_assets_ready_called=!1}on_enter(){super.on_enter()}on_exit(){super.on_exit()}update(){super.update(),this.is_loaded()&&(this.on_assets_ready_called||(this.scene.on_assets_ready(),this.on_assets_ready_called=!0),this.is_compiled()&&this.scene.on_assets_compiled())}}class nt extends o{constructor({name:e,compilators:t}){super(),this.name=e,this.initialized=!1,this.is_loaded=!1,this.is_high_loaded=!1,this.loading_states={regular:new it(this,t),high:new rt(this,t)},this.current_loading_state=new st(this,t)}get loading_progress(){return this.current_loading_state.loading_progress}init(){this.initialized=!0}load(){this.initialized||this.init(),this.set_loading_state(this.loading_states.regular),this.current_loading_state.load()}get_objects(){const e=[];return this.traverse((t=>{t instanceof a&&t.geometry&&e.push(t)})),e}dispose_cpu(){this.traverse((e=>{if(e instanceof a&&e.geometry&&(e.geometry.attributes.position.array=new Float32Array(3),e.geometry.attributes.normal&&(e.geometry.attributes.normal.array=new Float32Array(3)),e.geometry.attributes.uv&&(e.geometry.attributes.uv.array=new Float32Array(2)),e.material.map))for(let t=0;t<e.material.map.mipmaps.length;t++)e.material.map.mipmaps[t]=new Uint8Array(4)})),this.initialized=!1}dispose(){this.traverse((e=>{e instanceof a&&e.material&&(e.material.map&&e.material.map.dispose(),e.material.dispose(),e.geometry.dispose())})),this.initialized=!1}set_assets(e,t,s,r,i,n){this.loading_states.regular.set_assets(e,t,s,r,i,n)}set_high_assets(e,t,s,r,i,n){this.loading_states.high.set_assets(e,t,s,r,i,n)}set_loading_state(e){this.current_loading_state.on_exit(),this.current_loading_state=e,this.current_loading_state.on_enter()}update_loading_state(){this.is_high_loaded||this.current_loading_state.update()}update(){this.update_loading_state()}on_assets_ready(){}on_assets_compiled(){this.is_loaded=!0,this.set_loading_state(this.loading_states.high),this.current_loading_state.load()}on_high_quality_assets_ready(){this.is_high_loaded=!0}on_pre_render(){}render(){Ee.render(this,Pe.current)}on_post_render(){}}class ot{constructor(e,t,s){this.name=e,this.method=t,this.args=s}trigger(){ViewApi.application[this.name][this.method](...this.args.split(","))}}class at{constructor(){}static linear_map(e,t,s,r,i){return(e-t)/(s-t)*(i-r)+r}static between(e,t,s){return e>=t&&e<=s}static mod(e,t){return(e%t+t)%t}static rgb_to_hex(e){return e.r=Math.round(255*parseFloat(e.r)).toString(16),e.g=Math.round(255*parseFloat(e.g)).toString(16),e.b=Math.round(255*parseFloat(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){const s=e[0].clone();s.set(0,0,0);const r=[];for(let i=0;i<e.length;i++)t.projectPoint(e[i],s),r.push(s.clone());return r}static matrix4_lerp(e,t,s,r){for(let i=0;i<16;i++)s.elements[i]=this.lerp(e.elements[i],t.elements[i],r)}static equals(e,t){return Math.abs(e-t)<1e-6}static lerp(e,t,s){return(1-s)*e+s*t}static clamp(e,t,s){return Math.max(t,Math.min(s,e))}static euclideanModulo(e,t){return(e%t+t)%t}static pingpong(e,t=1){return t-Math.abs(at.euclideanModulo(e,2*t)-t)}static degToRad(e){return e*(Math.PI/180)}static radToDeg(e){return e*(180/Math.PI)}static deg_to_rad(e){return e*(Math.PI/180)}static rad_to_deg(e){return e*(180/Math.PI)}static perspective_divide(e){return e.x/=e.w,e.y/=e.w,e.z/=e.w,e}static points_average(e){const t=e[0].clone();for(let s=1;s<e.length;s++)t.add(e[s]);return t.multiplyScalar(1/e.length),t}static get_random_color(){const e=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"];let 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}static saturate(e){return at.clamp(e,0,1)}static generate_uuid(){const e=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],t=4294967295*Math.random()|0,s=4294967295*Math.random()|0,r=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&s]+e[s>>8&255]+"-"+e[s>>16&15|64]+e[s>>24&255]+"-"+e[63&r|128]+e[r>>8&255]+"-"+e[r>>16&255]+e[r>>24&255]+e[255&i]+e[i>>8&255]+e[i>>16&255]+e[i>>24&255]).toLowerCase()}}class lt{constructor(e={}){this.previous_elapsed_time=-1e-5,this.elapsed_time=-1e-5,this.playback_speed=this.__get_playback_speed(),this.playing=!0,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};const 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(){const e=this.get_duration();this.__play_clips(this.elapsed_time,e+1e-4),this.elapsed_time=e}update(e){this.playing&&(this.previous_elapsed_time=this.elapsed_time,this.elapsed_time+=e*this.playback_speed,this.__play_clips(this.previous_elapsed_time,this.elapsed_time))}set_progress(e){this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=at.clamp(e,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)}set_normalized_progress(e){this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=at.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return at.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,s,r=!1){if(r){const e=this.channels[s.attribute_name];void 0===e&&console.error(`${s.attribute_name} missing in initial state data.`),0===e.length?s.from=this.initial_context[s.attribute_name]:s.from=e[e.length-1].interpolator.to}const i={from:e,to:t,interpolator:s};this.duration=Math.max(this.duration,t),this.channels[s.attribute_name].push(i)}get_current_target_value(e){const t=this.__get_current_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1)}get_current_starting_value(e){return this.__get_current_keyframe(e,this.elapsed_time).interpolator.evaluate(0)}get_current_progress(e){const t=this.__get_current_keyframe(e,this.elapsed_time),s=this.__linear_map_01(this.elapsed_time,t.from,t.to);return t.interpolator.easing_function(s)}get_duration(){return this.duration}__play_clips(e,t){this.elapsed_time>this.previous_elapsed_time&&this.__play_events(this.previous_elapsed_time,this.elapsed_time);const s=Object.keys(this.initial_context);for(let t=0;t<s.length;t++){const r=s[t],i=this.__get_current_keyframe(r,e);this.context[r]=this.evaluate_keyframe(i,e)}}__play_events(e,t){for(let s=0;s<this.action_events.length;s++){const r=this.action_events[s].trigger_time;at.between(r,e,t)&&this.action_events[s].action.trigger()}}evaluate_keyframe(e,t){return this.tmp_t=this.__linear_map_01(t,e.from,e.to),e.interpolator.evaluate(at.clamp(this.tmp_t,0,1))}get_keyframes(e){return this.channels[e]}is_channel_redefined(e){for(let t=0;t<this.channels[e].length;t++){if(this.channels[e][t].interpolator.initial)return!1}return!0}__linear_map_01(e,t,s){return at.saturate((e-t)/(s-t)*1+0)}__get_current_keyframe(e,t){let s;const r=this.channels[e];for(let e=0;e<r.length;e++){const i=r[e];if(t>=i.from&&t<=i.to)return s=i,s}let i=1/0;for(let e=0;e<r.length;e++){const n=r[e],o=Math.abs(n.to-t);o<i&&(s=n,i=o)}return s}__get_playback_speed(){const e=new URLSearchParams(window.location.search).get("transitions_velocity");return e?Number(e):1}set_initial_value_on_channel(e,t){this.get_keyframes(e)[0].interpolator.from=t}set_final_value_on_channel(e,t){const s=this.get_keyframes(e);s[s.length-1].interpolator.to=t}}class _t{constructor(){}static linear(e){return e}static triangular(e){return 1-Math.abs(2*e%2-1)}static ease_in_sine(e){return 1-Math.cos(3.1415926*e/2)}static ease_out_sine(e){return Math.sin(3.1415926*e/2)}static ease_in_out_sine(e){return-(Math.cos(3.1415926*e)-1)/2}static ease_in_cubic(e){return e*e*e}static ease_out_cubic(e){return 1-Math.pow(1-e,3)}static ease_in_out_cubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}static ease_in_quad(e){return e*e}static ease_out_quad(e){return 1-(1-e)*(1-e)}static ease_in_out_quad(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}static ease_in_quart(e){return e*e*e*e}static ease_out_quart(e){return 1-Math.pow(1-e,4)}static ease_in_out_quart(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2}static ease_in_quint(e){return e*e*e*e*e}static ease_out_quint(e){return 1-Math.pow(1-e,5)}static ease_in_out_quint(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2}static ease_in_expo(e){return 0===e?0:Math.pow(2,10*e-10)}static ease_out_expo(e){return 1===e?1:1-Math.pow(2,-10*e)}static 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}static ease_in_circ(e){return 1-Math.sqrt(1-Math.pow(e,2))}static ease_out_circ(e){return Math.sqrt(1-Math.pow(e-1,2))}static 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}static ease_in_back(e){return 2.7015*e*e*e-1.7015*e*e}static ease_out_back(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)}static 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}static 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)}static ease_out_elastic(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1}static 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}static ease_in_bounce(e){return 1-this.ease_out_bounce(1-e)}static ease_out_bounce(e){const t=7.5625,s=2.75;return e<1/s?t*e*e:e<2/s?t*(e-=1.5/s)*e+.75:e<2.5/s?t*(e-=2.25/s)*e+.9375:t*(e-=2.625/s)*e+.984375}static 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}static 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 ht{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?_t[e]:e,this.attribute_name="",this.from=0,this.to=1}update(e,t){}}class ct extends ht{constructor(e,t=0,s=1,r=!1,i="linear"){super(i),this.attribute_name=e,this.from=t,this.to=s,this.initial=r}update(e,t){e[this.attribute_name]=at.lerp(this.from,this.to,this.easing_function(t))}evaluate(e){return at.lerp(this.from,this.to,this.easing_function(e))}}class dt{constructor(){}parse(e){const t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),s=[],r=[];for(let e=0;e<t.length;e++){const i=t[e],n=i.parentElement,o=n.getAttribute("value"),a=this.get_node_x_position(i)/100,l=parseFloat(i.getAttribute("width"))/100;if(n.getAttribute("style").includes("rhombus;")){const e=o.split("."),t=e[0],s=e[1];r.push({name:t,method:s,at_time:a+.5*l})}if(n.getAttribute("style").includes("rounded=0;")&&!n.getAttribute("style").includes("text;")&&""!==o&&!o.includes(" ")){const e=o.split("="),t=e[0],r=e[1].split("--"),i=parseFloat(r[0]),n=r[1];2!==e.length&&console.error("DrawIO data is malformed:",o),2!==r.length&&console.error("DrawIO data is malformed:",o),s.push({attribute_name:t,from_time:a,to_time:a+l,to_value:i,easing_function:n})}}return s.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:s,triggers:r}}get_node_x_position(e){const t=e.getAttribute("x");return null===t?0:parseFloat(t)}}class ut{constructor(e){this.default_state_data=e}from_animation_sheet(e,t,s){s=s||this.default_state_data;const r=e.animation_tracks,i=e.triggers,n=this.state_to_tracks(this.default_state_data,this.get_longest_time(e.animation_tracks));for(let e=0;e<n.length;e++)void 0===r.find((t=>t.attribute_name===n[e].attribute_name))&&r.push(n[e]);const o=new lt(t);for(let e=0;e<r.length;e++){const s=r[e],i=new ct(s.attribute_name,t[s.attribute_name],s.to_value,s.initial,s.easing_function);o.add_action_interpolator(s.from_time,s.to_time,i,!0)}for(let e=0;e<i.length;e++){const t=i[e],s=new ot(t.name,t.method,t.args);o.add_action_event(t.at_time,s)}return o}state_to_tracks(e,t){const s=[],r=Object.keys(e);for(let i=0;i<r.length;i++)s.push({attribute_name:r[i],from_time:0,to_time:t<1?t:1,to_value:e[r[i]],initial:!0,easing_function:"ease_in_out_cubic"});return s}from_draw_io(e,t){const s=(new dt).parse(e),r=s.animation_tracks,i=s.triggers,n=new lt(t);for(let e=0;e<r.length;e++){const s=r[e],i=new ct(s.attribute_name,t[s.attribute_name],s.to_value,!1,s.easing_function);n.add_action_interpolator(s.from_time,s.to_time,i,!0)}for(let e=0;e<i.length;e++){const t=i[e],s=new ot(t.name,t.method);n.add_action_event(t.at_time,s)}return n}get_longest_time(e){let t=-1;for(let s=0;s<e.length;s++){const r=e[s].to_time;t=r>t?r:t}return t}}class pt{constructor(){this.transitions=[],this.default_state_data={}}get(e,t,s){for(let r=0;r<this.transitions.length;r++)if(this.transitions[r].from===e&&this.transitions[r].to===t){return new ut(this.default_state_data).from_animation_sheet(this.transitions[r].data,s)}for(let e=0;e<this.transitions.length;e++)if(this.transitions[e].to===t&&void 0===this.transitions[e].from){return new ut(this.default_state_data).from_animation_sheet(this.transitions[e].data,s)}console.error("TransitionTable.get no data found for: ",e,t)}add_transitions(e){for(let t=0;t<e.length;t++)this.transitions.push(e[t])}set_transitions(e){this.transitions=e}set_default_state_data(e){this.default_state_data=e}}const mt=new class{constructor(){this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016]}init(){this.__previous_elapsed_time=-1,this.__delta_time=0,this.__smooth_delta_time=0,this.__elapsed_time=0,this.__frame_interpolation_t=0,this.fixed_delta_time=1/30}get elapsed_time(){return this.__elapsed_time}get delta_time(){return this.__delta_time}get smooth_delta_time(){return this.__smooth_delta_time}get frame_interpolation(){return this.__frame_interpolation_t}get fdt(){return this.fixed_delta_time}get dt(){return this.delta_time}get sdt(){return this.smooth_delta_time}__set_frame_interpolation(e){this.__frame_interpolation_t=e}__update(e){this.__previous_elapsed_time<0&&(this.__previous_elapsed_time=e),this.__delta_time=(e-this.__previous_elapsed_time)/1e3,this.__elapsed_time=e/1e3,this.__delta_buffer.shift(),this.__delta_buffer.push(this.delta_time<.32?this.delta_time:.032),this.__calculate_smooth_delta_time(),this.__previous_elapsed_time=e}__calculate_smooth_delta_time(){this.__smooth_delta_time=0;for(let e=0;e<this.__delta_buffer.length;e++)this.__smooth_delta_time+=this.__delta_buffer[e];this.__smooth_delta_time=this.__smooth_delta_time/this.__delta_buffer.length}};class gt{constructor(e){this.name=e}start(){}before_enter(){}on_enter(){}before_exit(){}on_exit(){}before_update(){}update(){}fixed_update(){}update_enter_transition(e,t,s){}update_exit_transition(e,t,s){}}class ft{constructor(e){this.last_state=new gt("last_initial"),this.current_state=new gt("current_initial"),this.default_state_data={},this.current_state_data={},this.transition_table=e,this.transitioning=!1}go_to_state(e,t=!1){this.transitioning&&this.__exit_last_state(),this.last_state=this.current_state,this.current_state=e,this.last_state.before_exit(),this.current_state.before_enter(),this.action_sequencer=this.transition_table.get(this.last_state.name,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.__update_transitions(),this.action_sequencer.is_finished()&&(this.transitioning=!1,this.__update_transitions(),this.__exit_last_state(),this.current_state.on_enter())):this.current_state.update()}before_update(){this.current_state.before_update()}fixed_update(){this.current_state.fixed_update()}set_state(e){this.current_state=e}set_default_state_data(e){Object.assign(this.default_state_data,e),Object.assign(this.current_state_data,e)}__update_transitions(){this.action_sequencer.update(mt.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)}__exit_last_state(){this.last_state.on_exit()}}const vt=new class{constructor(){this.transition_table=new pt,this.transition_handler=new ft(this.transition_table)}get action_sequencer(){return this.transition_handler.action_sequencer}get current_state_data(){return this.transition_handler.current_state_data}get_current_state(){return this.transition_handler.current_state}go_to_state(e,t=!1){this.transition_handler.go_to_state(e,t)}before_update(){this.transition_handler.before_update()}update(){this.transition_handler.update()}fixed_update(){this.transition_handler.fixed_update()}add_transitions(e){this.transition_table.add_transitions(e)}set_transitions(e){this.transition_table.set_transitions(e)}set_state(e){this.transition_handler.set_state(e)}set_default_state_data(e){this.transition_table.set_default_state_data(e),this.transition_handler.set_default_state_data(e)}};const wt=new class{constructor(){this.views=[],this.browser_title_suffix=""}update(){this.__set_views_opacities()}go_to_view(e,t=!0,s=!1){const r=this.get(e);t&&(this.__change_browser_url(r.url),this.__change_browser_title(r.url)),vt.go_to_state(r,s)}go_to_scene(e,t=!1,s=!1){const r=this.get(e),i=this.get("transition");i.set_next_view(r),this.go_to_view(i.name,t,s)}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}set_view(e){const t=this.get(e);vt.set_state(t)}set_browser_title_suffix(e){this.browser_title_suffix=e}get_current_view(){return vt.get_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_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)}__change_browser_url(e){window.history.pushState("","",e)}__change_browser_title(e){const t=this.__capitalize(e);document.title=t?`${t} | ${this.browser_title_suffix}`:this.browser_title_suffix}__set_views_opacities(){for(let e=0;e<this.views.length;e++)this.views[e].set_opacity(vt.current_state_data)}__capitalize(e){let t=e.toUpperCase().replace("/","");return t=this.__snake_to_whitespace(t),t}__snake_to_whitespace(e){return e.replace(/([-_][A-Z])/g,(e=>e.replace("-"," ").replace("_"," ")))}};class bt extends gt{constructor({name:e,url:t,container:s,transition_data:r}){super(e),this.container=s,this.url=t,this.current_opacity=0;const i=[{to:e,data:r=r||{animation_tracks:[],triggers:[]}}];wt.register_view(this),vt.add_transitions(i)}before_enter(){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")}on_exit(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")}set_opacity(e){const t=e[`${this.name}_opacity`];(this.current_opacity>t||this.current_opacity<t)&&(this.current_opacity=t,this.container.style.opacity=this.current_opacity)}}class yt{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){const t=document.getElementsByTagName("body")[0],s=document.createElement("div"),r=document.createTextNode("MÉqgOLAKTAL");s.appendChild(r),s.setAttribute("style",`font:${e};position:absolute;top:0;left:0`),t.appendChild(s),this.__textHeight=s.offsetHeight,t.removeChild(s)}return this.__textHeight}get_text_size(e,s="24px Arial"){const r=new t;return this.ctx.font=s,r.x=Math.ceil(this.ctx.measureText(e).width),r.y=Math.ceil(this.getFontHeight(s)),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){const s=this.draw_canvas(e,t),r=new w(s,b,y,y,x,x);return r.generateMipmaps=!1,r.needsUpdate=!0,r}__draw(e,t,s,r){}roundRect(e,t,s,r,i,n,o,a){if(void 0===a&&(a=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{const e={tl:0,tr:0,br:0,bl:0};for(const t in e){const s=t;n[s]=n[s]||e[s]}}e.beginPath(),e.moveTo(t+n.tl,s),e.lineTo(t+r-n.tr,s),e.quadraticCurveTo(t+r,s,t+r,s+n.tr),e.lineTo(t+r,s+i-n.br),e.quadraticCurveTo(t+r,s+i,t+r-n.br,s+i),e.lineTo(t+n.bl,s+i),e.quadraticCurveTo(t,s+i,t,s+i-n.bl),e.lineTo(t,s+n.tl),e.quadraticCurveTo(t,s,t+n.tl,s),e.closePath(),o&&e.fill(),a&&e.stroke()}}class xt extends yt{constructor(){super(),this.text_margin=new t(2,0)}__draw(e,t,s,r){r.font=t.font;const i=this.get_text_size(e,t.font);s.width=Math.ceil(i.x+2*this.text_margin.x),s.height=Math.ceil(i.y+2*this.text_margin.y),r.clearRect(0,0,s.width,s.height),r.globalAlpha=0,r.fillStyle=t.font_color||"#000000",r.fillRect(0,0,s.width,s.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,s.width/2,s.height/2):r.fillText(e,0,s.height/2)}}const Tt=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class St extends T{constructor(e=1){super();const t=[];t.push(new d(0,0,0)),t.push(new d(0,0,1e3));const s=new S({color:4474111,depthFunc:r}),i=(new M).setFromPoints(t),n=new F(i,s);n.renderOrder=5e4;const o=[];o.push(new d(0,0,0)),o.push(new d(0,1e3,0));const a=new S({color:4521796,depthFunc:r}),l=(new M).setFromPoints(o),_=new F(l,a);_.renderOrder=5e4;const h=[];h.push(new d(0,0,0)),h.push(new d(1e3,0,0));const c=new S({color:16729156,depthFunc:r}),u=(new M).setFromPoints(h),p=new F(u,c);p.renderOrder=5e4,this.renderOrder=1e5,this.add(n),this.add(_),this.add(p),this.scale.set(e,e,e)}update(){}dispose(){}}class Mt extends Ae{constructor(){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 t},_ScreenSize:{value:new t},_TextureSize:{value:new t}})}set_position(e,t){this.uniforms._ScreenSpacePosition.value.set(e,t)}set_texture(e,t,s){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!==s&&(this.uniforms._TextureSize.value.y=s)}set_screen_size(e,t){this.uniforms._ScreenSize.value.set(e,t)}}class Ft extends z{constructor(e,t,s,r){super(e,t,s,r),this.clear_color=new n("#000000"),this.clear_alpha=1}copy(e){return super.copy(e),this.clear_color.copy(e.clear_color),this.clear_alpha=e.clear_alpha,this}}class zt extends a{constructor(e,t,s){e=e||"#FF0000";const r=(t=t||1)-.4,i=new A(.01,.01,r,32);i.translate(0,r/2,0);const n=new R(.1,.4,32);n.translate(0,r+.2,0);const o=de.mergeGeometries([i,n]);o.rotateX(1.57);super(o,new C({color:e})),s&&this.quaternion.setFromUnitVectors(new d(0,0,1),s),this._dir=s}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}}class At extends a{constructor(e,t,s){e=e||new d(1,1,1),t=t||new d(1,1,1),s=s||16711680;super(new k(e.x,e.y,e.z,t.x,t.y,t.z),new C({color:s}))}}class Rt extends a{constructor(e,t){t=t||"#FF0000";super(new P(e=e||1,64,64),new C({color:t})),this.radius=e,this.color=t,this.center=this.position}}const Ct=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 o,this.camera=new Ft(60,Le.aspect_ratio,.1,1e3),this.camera.clear_alpha=0}draw_arrow(e,t,s=16711680){const r=new zt(s,t.length(),t.clone().normalize());return r.position.copy(e),this.scene.add(r),r}draw_axis(){const e=new St;return this.scene.add(e),e}set_debug_RT(e){this.rt_debug=e}draw_rectangle(e,t,s,r){t=t||100,s=s||100,this.ctx.fillStyle=r||"rgba(255, 0, 0, 1)",this.ctx.fillRect(e.x-t/2,this.ctx.canvas.height-e.y-s/2,t,s)}clear(){this.ctx&&this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}draw_line_2D(e,t,s){this.ctx.strokeStyle=s||"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){const s=new S({color:t}),r=(new M).setFromPoints(e),i=new F(r,s);return i.frustumCulled=!1,this.scene.add(i),i}draw_cube(e,t,s){t=t||1,s=s||16711680,e=e||new d;const r=new At(new d(t,t,t),void 0,s);return r.position.copy(e),this.scene.add(r),r}draw_oriented_cube(e,t,s=1,r="#FF0000",i=.1){const n=e.distanceTo(t),o=new At(new d(i,s,n),void 0,r),a=t.clone().sub(e).multiplyScalar(.5),l=a.clone().normalize();return a.add(e),o.position.copy(a),o.quaternion.setFromUnitVectors(new d(0,0,-1),l),this.scene.add(o),o}draw_plane(t,s,r){const i=new l(t,s),n=new e({uniforms:{_Color:{value:new h(0,1,0,.2)}},vertexShader:ze,fragmentShader:Fe,transparent:!0,depthWrite:!1}),o=new a(i,n);return o.renderOrder=-1e4,this.scene.add(o),o}draw_empty_cube(e,t,s){t=t||1,s=s||16711680;const r=(new L).setFromCenterAndSize(new d,new d(t,t,t)),i=new D(r,s);return i.position.copy(e||new d),i}draw_sphere(e,t,s){t=t||1,s=s||16711680,e=e||new d;const r=new Rt(t,s);return r.position.copy(e),this.scene.add(r),r}draw_point_array(e,t=!1,s=16711680){const r=new U(e,t);r.updateArcLengths();const i=r.getSpacedPoints(200);return this.draw_line(i,65280)}draw_sphere_helper(e,t){t=t||16711680;const s=new P(e.radius,32,32),r=new C({color:t}),i=new a(s,r);return i.position.copy(e.center),De.current.add(i),i}draw_math_sphere(t){const s=new P(t.radius,32,32),r=new e({uniforms:{_Color:{value:new h(1,0,0,.2)}},vertexShader:ze,fragmentShader:Fe,transparent:!0}),i=new a(s,r);i.position.copy(t.center),De.current.add(i)}draw_bounding_box(e){const t=new D(e,16776960);De.current.add(t)}draw_curve(e,t){const s=new d(0,0,0);t&&(s.y=t.offset||0);for(let t=0;t<e.length-1;t++)this.draw_line([e[t].clone().add(s),e[t+1].clone().add(s)])}draw_texture(e,t,s){const r=new a(new l(1,1),new Mt);return this.display_texture_meshes.push(r),this.scene.add(r),r.material.set_texture(e,t,s),r}render(e){for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(Le.width,Le.height);this.scene.children.length>0&&e.render(this.scene,Pe.current)}};class kt{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Pt{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(e){this.t+=mt.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=at.clamp(this.easing_function_t,0,1),e.set_property_value(at.lerp(e.from,e.to,this.easing_function_t)),this.easing_function_t>=.9999&&(e.set_property_value(e.to),e.set_current_state(new kt),e.finished_callback(e))}on_exit(e){}}class Lt{constructor({element:e,css_property:t,from:s=0,to:r=1,duration:i=1,value_prefix:n="",value_suffix:o="",easing_function:a=_t.ease_in_out_cubic,finished_callback:l=(()=>{})}){this.element=e,this.css_property=t,this.from=s,this.to=r,this.value_prefix=n,this.value_suffix=o,this.duration=i,this.easing_function=a,this.finished_callback=l,this.current_state=new kt}animate(){this.set_current_state(new Pt)}stop(){this.set_current_state(new kt)}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)}}const Dt=new class{init(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"},this.is_mobile=!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/),this.is_ipad=!!(navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2),this.is_ios=!!navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad,this.is_android=this.get_os()===this.operating_systems.ANDROID,this.is_linux=this.get_os()===this.operating_systems.LINUX,this.is_mac=this.get_os()===this.operating_systems.MAC,this.is_windows=this.get_os()===this.operating_systems.WINDOWS}get_os(){const e=window.navigator.userAgent,t=window.navigator.platform;let s=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?s=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?s=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?s=this.operating_systems.WINDOWS:/Android/.test(e)?s=this.operating_systems.ANDROID:!s&&/Linux/.test(t)&&(s=this.operating_systems.LINUX),s}};const Ut=new class{init(){this.target_geometry=void 0,this.target_position=new d}set_target_geometry(e){this.target_geometry=e}};class Ot{constructor(){}fit_points(e,t,s,r){const i=t.clone().inverse(),n=[];for(let t=0;t<e.length;t++)n.push(e[t].clone().applyQuaternion(i));const o=(new L).setFromPoints(n),a=new d;o.getSize(a);const l=this.get_distance_to_fit_rect(a.x/2,a.y/2,s,r),_=new d;return o.getCenter(_),_.applyQuaternion(t),{center:_,distance_to_center:l}}get_distance_to_fit_rect(e,t,s,r){const i=s/2*Math.PI/180,n=2*Math.atan(Math.tan(i)*r)/2,o=t/Math.tan(i),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class It{constructor(){this.sphere=new O}fit_points(e,t,s,r){this.sphere.setFromPoints(e);const i=at.degToRad(s/2),n=2*Math.atan(Math.tan(i)*r)/2,o=this.get_up_plane_normal(t,i),a=this.get_down_plane_normal(t,i),l=this.get_left_plane_normal(t,n),_=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,s,r),p=c.clone().add(h.clone().multiplyScalar(-1*u)),m=(new I).setFromNormalAndCoplanarPoint(o,p),g=(new I).setFromNormalAndCoplanarPoint(a,p),f=(new I).setFromNormalAndCoplanarPoint(l,p),v=(new I).setFromNormalAndCoplanarPoint(_,p);this.apply_center_correction_to_pos(p,e,t,m,g,f,v),m.setFromNormalAndCoplanarPoint(o,p),g.setFromNormalAndCoplanarPoint(a,p),f.setFromNormalAndCoplanarPoint(l,p),v.setFromNormalAndCoplanarPoint(_,p);let w=1/0;const b=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){const s=new N(e[t].clone(),e[t].clone().add(b)),r=new d,i=new d,n=new d,o=new d;m.intersectLine(s,r),g.intersectLine(s,i),f.intersectLine(s,n),v.intersectLine(s,o),r.length()<1e-4&&console.log("up intersection not found",t),i.length()<1e-4&&console.log("down intersection not found",t),n.length()<1e-4&&console.log("left intersection not found",t),o.length()<1e-4&&console.log("right intersection not found",t);const a=e[t].clone().sub(r).length(),l=e[t].clone().sub(i).length(),_=e[t].clone().sub(n).length(),h=e[t].clone().sub(o).length(),c=Math.min(a,l),u=Math.min(_,h),p=Math.min(c,u);p<w&&(w=p)}const y=h.clone().multiplyScalar(w);return p.clone().add(y)}apply_center_correction_to_pos(e,t,s,r,i,n,o){const a=this.get_vertical_correction(t,i,r,s),l=this.get_horizontal_correction(t,n,o,s);e.add(a),e.add(l)}get_vertical_correction(e,t,s,r){let i=1/0,n=1/0;const o=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const a=new N(e[r].clone(),e[r].clone().add(o.clone().multiplyScalar(-5e6))),l=new N(e[r].clone(),e[r].clone().add(o.clone().multiplyScalar(5e6))),_=new d,h=new d;t.intersectLine(a,_),s.intersectLine(l,h);const c=_.distanceTo(e[r]),u=h.distanceTo(e[r]);h.length()<1e-4&&console.log("vertical up intersection not found",r),_.length()<1e-4&&console.log("vertical down intersection not found",r),c<n&&(n=c),u<i&&(i=u)}const a=(i-n)/2;return o.clone().multiplyScalar(-a)}get_horizontal_correction(e,t,s,r){let i=1/0,n=1/0;const o=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const a=new N(e[r].clone(),e[r].clone().add(o.clone().multiplyScalar(-5e6))),l=new N(e[r].clone(),e[r].clone().add(o.clone().multiplyScalar(5e6))),_=new d,h=new d;t.intersectLine(a,_),s.intersectLine(l,h);const c=_.distanceTo(e[r]),u=h.distanceTo(e[r]);_.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<i&&(i=u)}const a=(i-n)/2;return o.clone().multiplyScalar(-a)}get_up_plane_normal(e,t){const s=new d(0,-1,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new d(0,1,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new d(1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new d(-1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(0,1,0),-t)),s.applyQuaternion(e),s}get_distance_to_fit_rect(e,t,s,r){const i=s/2*Math.PI/180,n=2*Math.atan(Math.tan(i)*r)/2,o=t/Math.tan(i),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}const Nt=new class{init(e){this.tmp_mat=new j,this.plane=new I,this.ray=new q,this.tmp_size=new d,this.tmp_unproj=new d,this.input=e}get_up_dir(e){e=e||Pe.current;const t=new d;return t.set(0,1,0),t.applyQuaternion(e.quaternion),t}get_forward_dir(e){e=e||Pe.current;const t=new d;return t.set(0,0,-1),t.applyQuaternion(e.quaternion),t}get_right_dir(e){e=e||Pe.current;const t=new d;return t.set(1,0,0),t.applyQuaternion(e.quaternion),t}unproject_mouse_position(e,t){t=t||Pe.current;const s=new d,r=t.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(r)*t.aspect)/2,n=Math.tan(r)*t.far,o=Math.tan(i)*t.far;return s.set(o*e.x,n*e.y,-t.far).normalize(),s.applyQuaternion(t.quaternion)}get_plane_intersection(e,t,s,r){r=r||Pe.current,s=s||this.input.NDC;const i=new d;if(this.plane.setFromNormalAndCoplanarPoint(t||this.get_forward_dir(r),e),r.isPerspectiveCamera)this.ray.set(r.position,this.unproject_mouse_position(s,r));else{const e=new d(s.x*r.right,s.y*r.top,0);e.applyQuaternion(r.quaternion),e.add(r.position);const t=new d(0,0,-1).applyQuaternion(r.quaternion);this.ray.set(e,t)}return this.ray.intersectPlane(this.plane,i),i}fit_points_on_camera(e,t=1){const s=(new O).setFromPoints(e).center,r=this.get_forward_dir(Pe.current).clone(),i=(new I).setFromNormalAndCoplanarPoint(r,s),n=at.project_points_on_plane(e,i),o=new d;let a=(new L).setFromPoints(n);a.getCenter(o);const l=new d(0,1,0).applyQuaternion(Pe.current.quaternion),_=l.clone().cross(r).normalize(),h=(new j).set(_.x,l.x,r.x,s.x,_.y,l.y,r.y,s.y,_.z,l.z,r.z,s.z,0,0,0,1).invert();for(let e=0;e<n.length;e++)n[e].applyMatrix4(h);const c=new d;a=(new L).setFromPoints(n),a.getSize(c),c.multiplyScalar(t);const u=new d;return a.getCenter(u),{position:o,zoom:this.get_zoom_to_fit_rect(c.x/2,c.y/2)}}get_zoom_to_fit_rect(e,t){const s=Pe.current.fov/2*Math.PI/180,r=2*Math.atan(Math.tan(s)*Pe.current.aspect)/2,i=t/Math.tan(s),n=e/Math.tan(r);return Math.max(Math.abs(n),Math.abs(i))}get_zoom_to_fit_box(e,t){if(t.isOrthographicCamera){e.getSize(this.tmp_size);const t=this.tmp_size.x,s=this.tmp_size.y,r=t/s;return Le.aspect_ratio/r>1?Le.height/s:Le.width/t}{const t=new d;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){t=t||Pe.current;const s=new d;return e.getWorldPosition(s),s.project(t),s.x=(.5*s.x+.5)*Le.width,s.y=(1-(.5*s.y+.5))*Le.height,s}world_pos_to_screen(e,t){t=t||Pe.current;const s=new d;return s.copy(e),s.project(t),s.x=(.5*s.x+.5)*Le.width,s.y=(1-(.5*s.y+.5))*Le.height,s}update_projection(e){e.left=-Le.width/2,e.right=Le.width/2,e.top=Le.height/2,e.bottom=-Le.height/2,e.aspect=Le.aspect_ratio,e.updateProjectionMatrix(!0)}fit_bounding_box_points(e,t,s=1){const r=new d;r.copy(t.max).sub(t.min);const i=t.min.clone(),n=i.clone().add(new d(r.x,0,0)),o=i.clone().add(new d(0,r.y,0)),a=i.clone().add(new d(0,0,r.z)),l=i.clone().add(new d(r.x,0,r.z)),_=i.clone().add(new d(0,r.y,r.z)),h=t.max.clone(),c=i.clone().add(new d(r.x,r.y,0));return this.fit_points(e,[i,n,o,a,l,_,h,c],s)}fit_points(e,t,s=1){if(e.isPerspectiveCamera){const r=new d(0,0,-1).applyQuaternion(e.quaternion),i=r.clone().multiplyScalar(-1),n=new It,o=Le.aspect_ratio,a=n.fit_points(t,e.quaternion,e.fov*s,o),l=(new L).setFromPoints(t),_=new d;l.getCenter(_);const h=(new I).setFromNormalAndCoplanarPoint(i,_),c=new q(a,r),u=new d;c.intersectPlane(h,u);return{zoom:a.distanceTo(u),reference_position:u,camera_position:a}}{const r=(new Ot).fit_points(t,this.reference_rotation,e.fov*s,Le.aspect_ratio);this.reference_position.copy(r.center),this.reference_zoom=r.distance_to_center;const i=new d(0,0,1).applyQuaternion(e.quaternion);return{zoom:r.distance_to_center,reference_position:r.center,camera_position:i.multiplyScalar(r.distance_to_center)}}}};const Et=new class{constructor(){}init(e){Pe.init(),Nt.init(e),Tt.init(),Dt.init(),Qe.init(),Ut.init(),Ve.init(),De.init(),Le.init(),mt.init(),Ct.init()}dispose(e){Ee.dispose(),De.dispose(),e.dispose()}};class jt{init(e){this.ctrlz_pressed=!1,this.ctrlz_fired=!1,this.keys={},this.keys_keys=[],this.container=e,this.container.addEventListener("keydown",this.on_key_down.bind(this),!1),this.container.addEventListener("keyup",this.on_key_up.bind(this),!1)}on_key_down(e){90===e.keyCode&&e.ctrlKey&&!this.ctrlz_fired&&(this.ctrlz_pressed=!0,this.ctrlz_fired=!0),e.code&&this.press_key(e.code)}on_key_up(e){this.release_key(e.code)}clear(){this.ctrlz_pressed=!1;for(let e=0;e<this.keys_keys.length;e++)this.keys[this.keys_keys[e]].pressed=!1,this.keys[this.keys_keys[e]].released=!1}release_key(e){const t=this.keys[e];t&&(t.fired=!1,t.down=!1,t.released=!0)}release_keys(){this.ctrlz_fired=!1;for(let e=0;e<this.keys_keys.length;e++)this.keys[this.keys_keys[e]].fired=!1,this.keys[this.keys_keys[e]].down=!1}press_key(e){const t=this.keys[e];t&&(!1===t.down&&(t.pressed=!0),t.down=!0,t.fired=!0)}is_key_pressed(e){const t=this.keys[e];return!!t&&t.pressed}is_key_down(e){const t=this.keys[e];return!!t&&t.down}is_key_released(e){const t=this.keys[e];return!!t&&t.released}register_key(e){this.keys[e]={key_name:e,pressed:!1,down:!1,fired:!1,released:!1},this.keys_keys=Object.keys(this.keys)}unregister_key(e){delete this.keys[e]}dispose(){this.container.removeEventListener("keydown",this.on_key_down.bind(this),!1),this.container.removeEventListener("keyup",this.on_key_up.bind(this),!1)}}class qt extends _{constructor(e,t,s,r,i,o){super(e,t,s,r,i,o),this.clear_color=new n("#000000"),this.clear_alpha=1}copy(e){return super.copy(e),this.clear_color.copy(e.clear_color),this.clear_alpha=e.clear_alpha,this}}class Vt extends e{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 Bt extends Ce{constructor(){super()}render(){Ee.clear(void 0,Pe.current,!0,!0),Ee.render(De.current,Pe.current,void 0,new Vt)}}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 Gt extends Se{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 j}}}class Wt extends Se{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 Xt extends Se{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 j},this.uniforms._ProjectionMatrix={value:new j},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(){const e=[];for(let t=0;t<64;t++){const s=new d(2*Math.random()-1,2*Math.random()-1,Math.random());s.normalize();let r=t/64;r=at.lerp(.1,1,r*r),s.multiplyScalar(r),e.push(s)}return e}__get_rotation_kernel(){const 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;const t=new V(e,4,4,B);return t.wrapS=Y,t.wrapT=Y,t.needsUpdate=!0,t}}class Qt extends Se{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 t}}}class Ht{constructor(){this.RT1=new c(1,1),this.RT2=new c(1,1),this.box_blur_mat=new Qt}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),Ee.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),Ee.blit(this.RT1,e,this.box_blur_mat)}}class $t extends Ce{constructor(e=!1){super(),this.ssao_mat=new Xt,this.ssao_compose_mat=new Wt,this.debug_normals=new Gt,this.ssaa=e?2:1,this.main_RT=new c(Le.width*this.ssaa,Le.height*this.ssaa),this.SSAO_RT=new c(Le.width,Le.height),this.blurrer=new Ht,Ee.generate_depth_normal_texture=!0}render(){this.__check_RT_size(),Ee.clear(this.main_RT,Pe.current,!0,!1),Ee.render(De.current,Pe.current,this.main_RT),this.__update_uniforms(),Ee.blit(Ee.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),Ee.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,Ee.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value=Pe.current.projectionMatrix.clone().invert(),this.ssao_mat.uniforms._ProjectionMatrix.value=Pe.current.projectionMatrix.clone(),this.ssao_mat.uniforms._FarPlane.value=Pe.current.far}__check_RT_size(){this.main_RT.width===Le.width*this.ssaa&&this.main_RT.height===Le.height*this.ssaa||(this.main_RT.setSize(Le.width*this.ssaa,Le.height*this.ssaa),this.SSAO_RT.setSize(Le.width,Le.height))}}class Zt extends Ce{constructor(){super()}render(){Ee.clear(void 0,Pe.current,!0,!0),De.current.on_pre_render(),De.current.render(),De.current.on_post_render()}}class Jt extends Se{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;uniform float radius;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=sampleTex(_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*radius;vec4 sample1=sampleTex(_MainTex,vUv+uvOffset);vec4 sample2=sampleTex(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new t(.5,.5)},this.uniforms.direction={value:new t(.5,.5)},this.uniforms.radius={value:1},this.defines.USE_LINEAR_COLOR_SPACE=!0}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)}set_radius(e=1){this.uniforms.radius.value=e}}class Kt extends Se{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;vec4 sampleTex(sampler2D tex,vec2 uv){vec4 col=texture2D(tex,uv);\n#ifndef USE_LINEAR_COLOR_SPACE\ncol.rgb=pow(col.rgb,vec3(2.2));\n#endif\nreturn col;}void main(){vec4 texel=sampleTex(_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);\n#ifndef USE_LINEAR_COLOR_SPACE\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(0.4545));\n#endif\n}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new n("#000000")},this.uniforms.defaultOpacity={value:0},this.defines.USE_LINEAR_COLOR_SPACE=!0}set_threshold(e){this.uniforms.luminosityThreshold.value=e}}class es{constructor(e=!1){this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.use_half_float=e,this.nMips=5,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:G,magFilter:G,format:B,type:e?W:X,colorSpace:e?Q:g},this.renderTargetBright=new c(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Kt}blur(e,t){this.resize_RT(e.width,e.height);let s=e;t&&(Ee.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat),s=this.renderTargetBright);for(let e=0;e<this.nMips;e++){const t=this.separableBlurMaterials[e];t.set_direction(1,0),Ee.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),Ee.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),s=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++){const e=new c(1,1,this.rt_pars),t=new c(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,e.texture.colorSpace=this.rt_pars.colorSpace,t.texture.colorSpace=this.rt_pars.colorSpace,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 s=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(s,r);for(let e=0;e<this.nMips;e++)this.renderTargetsVertical[e].setSize(s,r),this.renderTargetsHorizontal[e].setSize(s,r),this.separableBlurMaterials[e].set_size(s,r),s=Math.round(s/2),r=Math.round(r/2)}init_materials(){this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new Jt(this.kernelSizeArray[e]))}set_radius(e){for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].set_radius(e)}set_luminosity_threshold(e){this.luminosity_high_pass_mat.set_threshold(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 ts extends Ce{constructor(e,t,s,r=!1){super(),this.add_mat=new Me(t);const i={samples:e?8:1,type:t?W:X,format:B,colorSpace:Q,minFilter:x,magFilter:x};this.use_rendering_size=r,this.main_RT=new c(1,1,i),this.main_RT.texture.colorSpace=Q,this.main_RT.texture.minFilter=x,this.main_RT.texture.magFilter=x,this.bloom_compose_mat=new Re(5,t),this.blurrer=new es(t),this.use_hight_luminosity_pass=s,this.luminosity_threshold=.5}on_enter(){this.bloom_compose_mat.set_blur_texture_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_blur_texture_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_blur_texture_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_blur_texture_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_blur_texture_4(this.blurrer.renderTargetsVertical[4].texture),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}render(){this.__check_RT_size(),Ee.clear(this.main_RT,Pe.current,!0,!1),Ee.render(De.current,Pe.current,this.main_RT),this.blurrer.blur(this.main_RT,this.use_hight_luminosity_pass),Ee.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),Ee.blit(this.main_RT,void 0,this.add_mat)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.blurrer.set_radius(e)}set_luminosity_threshold(e){this.blurrer.set_luminosity_threshold(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)}__check_RT_size(){const e=this.use_rendering_size?Le.render_width:Le.width,t=this.use_rendering_size?Le.render_height:Le.height;this.main_RT.width===e&&this.main_RT.height===t||this.main_RT.setSize(e,t)}}class ss extends Ce{constructor(){super()}render(){De.current.on_pre_render&&De.current.on_pre_render(),De.current.render?De.current.render():Ee.render(De.current,Pe.current,Ee._renderer.getRenderTarget()),this.render_spectator_camera(),De.current.on_post_render&&De.current.on_post_render()}render_spectator_camera(){const e=Pe.spectator;if(e&&Ee._renderer.xr.isPresenting){const t=Ee._renderer.xr.getCamera();e.projectionMatrix.copy(Pe.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);const s=Ee._renderer.getRenderTarget();Ee._renderer.xr.isPresenting=!1,Ee._renderer.setRenderTarget(null),Ee._renderer.render(De.current,e),Ee._renderer.setRenderTarget(s),Ee._renderer.xr.isPresenting=!0}}}const rs=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(vt.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)}__set_components_opacities(){for(let e=0;e<this.components.length;e++)this.components[e].set_opacity(vt.current_state_data)}};class is{constructor(e,t,s){e=e||new Te,this.target_application=e,this.graphics=t,this.input=s,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0}update(e){if(this.is_running){for(mt.__update(e),1===this.frames_passed&&this.target_application.on_post_start(),this.input.update(),this.time_accumulator+=mt.delta_time,this.target_application.before_update(),vt.before_update();this.time_accumulator>mt.fixed_delta_time;)this.target_application.fixed_update(),vt.fixed_update(),this.time_accumulator-=mt.fixed_delta_time;mt.__set_frame_interpolation(this.time_accumulator/mt.fixed_delta_time),this.target_application.update(),vt.update(),wt.update(),rs.update(),this.target_application.on_pre_render(),this.graphics.update(),this.target_application.on_post_render(),Ct.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,this.input.clear(),Ct.clear()}}start(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(this),this.is_running=!0,this.graphics._renderer.setAnimationLoop(this.update.bind(this)))}stop(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(this),this.graphics._renderer.setAnimationLoop(null))}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}}const ns=new class{init(){console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.init()}update_position(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.update_position(e,t)}update(){console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.update()}update_size(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.update_size(e,t)}apply_pixel_density_v2(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.apply_pixel_density_v2(e)}apply_pixel_density(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.apply_pixel_density(e)}get_pixel_size(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.get_pixel_size()}get aspect_ratio(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),Le.aspect_ratio}};class os{constructor({name:e,container:t}){this.name=e,this.container=t,this.hidden=!0,rs.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),rs.enable_component(this),this.hidden=!1}update(){}on_exit(){this.container.classList.add("hidden"),rs.disable_component(this),this.hidden=!0}set_opacity(e){this.container.style.opacity=e[`${this.name}_opacity`],this.toggle_hidden()}toggle_hidden(){this.container.style.opacity>.001?this.hidden&&this.on_enter():this.hidden||this.on_exit()}}class as extends a{constructor(e,t,s,r){e=e||1,t=t||1,s=s||"#FF0000",r=r||new C({color:s});const i=new l(e,t);i.rotateX(-1.57),super(i,r)}}class ls extends a{constructor(e,t,s,r){e=e||1,t=t||1,s=s||"#FF0000",r=r||new C({color:s});super(new l(e,t),r)}}class _s{constructor(){}static merge_from_to(e,t){t.push.apply(t,e)}static expand_vec3_array(e,t){const s=t-e.length;for(let t=0;t<s;t++)e.push(e[t].clone())}static remove_elem(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}static get_closest_point(e,t){let s=e[0],r=s.distanceTo(t);for(let i=1;i<e.length;i++)e[i].distanceTo(t)<r&&(s=e[i],r=e[i].distanceTo(t));return s}static object_values_to_array(e){const t=Object.keys(e),s=[];for(let r=0;r<t.length;r++)s.push(e[t[r]]);return s}}class hs{constructor(){this.sphere=new O}fit_points(e,t,s,r){this.sphere.setFromPoints(e);const i=at.degToRad(s/2),n=2*Math.atan(Math.tan(i)*r)/2,o=this.get_up_plane_normal(t,i),a=this.get_down_plane_normal(t,i),l=this.get_left_plane_normal(t,n),_=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,s,r),p=c.clone().add(h.clone().multiplyScalar(-1*u)),m=(new I).setFromNormalAndCoplanarPoint(o,p),g=(new I).setFromNormalAndCoplanarPoint(a,p),f=(new I).setFromNormalAndCoplanarPoint(l,p),v=(new I).setFromNormalAndCoplanarPoint(_,p);this.apply_center_correction_to_pos(p,e,t,m,g,f,v),m.setFromNormalAndCoplanarPoint(o,p),g.setFromNormalAndCoplanarPoint(a,p),f.setFromNormalAndCoplanarPoint(l,p),v.setFromNormalAndCoplanarPoint(_,p);let w=1/0;const b=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){const s=new N(e[t].clone(),e[t].clone().add(b)),r=new d,i=new d,n=new d,o=new d;m.intersectLine(s,r),g.intersectLine(s,i),f.intersectLine(s,n),v.intersectLine(s,o),r.length()<1e-4&&console.log("up intersection not found",t),i.length()<1e-4&&console.log("down intersection not found",t),n.length()<1e-4&&console.log("left intersection not found",t),o.length()<1e-4&&console.log("right intersection not found",t);const a=e[t].clone().sub(r).length(),l=e[t].clone().sub(i).length(),_=e[t].clone().sub(n).length(),h=e[t].clone().sub(o).length(),c=Math.min(a,l),u=Math.min(_,h),p=Math.min(c,u);p<w&&(w=p)}const y=h.clone().multiplyScalar(w);return p.clone().add(y)}apply_center_correction_to_pos(e,t,s,r,i,n,o){const a=this.get_vertical_correction(t,i,r,s),l=this.get_hozirontal_correction(t,n,o,s);e.add(a),e.add(l)}get_vertical_correction(e,t,s,r){let i,n,o=1/0,a=1/0;const l=new d(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const _=new N(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(-5e6))),h=new N(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(_,c),s.intersectLine(h,u);const 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<a&&(a=p,n=e[r]),m<o&&(o=m,i=e[r])}console.log(i,n);const _=(o-a)/2;return l.clone().multiplyScalar(-_)}get_hozirontal_correction(e,t,s,r){let i,n,o=1/0,a=1/0;const l=new d(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const _=new N(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(-5e6))),h=new N(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(5e6))),c=new d,u=new d;t.intersectLine(_,c),s.intersectLine(h,u);const 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<a&&(a=p,n=e[r]),m<o&&(o=m,i=e[r])}const _=(o-a)/2;return console.log(i,n),l.clone().multiplyScalar(-_)}get_up_plane_normal(e,t){const s=new d(0,-1,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new d(0,1,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new d(1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new d(-1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new d(0,1,0),-t)),s.applyQuaternion(e),s}get_distance_to_fit_rect(e,t,s,r){const i=s/2*Math.PI/180,n=2*Math.atan(Math.tan(i)*r)/2,o=t/Math.tan(i),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class cs{static convert_to_non_indexed_geometry(e){const t=e.index,s=e.getAttribute("position"),r=[];for(let e=0;e<t.count;e+=3)r.push(s.getX(t.array[e+0])),r.push(s.getY(t.array[e+0])),r.push(s.getZ(t.array[e+0])),r.push(s.getX(t.array[e+1])),r.push(s.getY(t.array[e+1])),r.push(s.getZ(t.array[e+1])),r.push(s.getX(t.array[e+2])),r.push(s.getY(t.array[e+2])),r.push(s.getZ(t.array[e+2]));const i=new M;return i.setAttribute("position",new H(new Float32Array(r),3)),cs.add_barycentric_attribute(i),i}static add_barycentric_attribute(e){const t=[],s=e.getAttribute("position");for(let e=0;e<s.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 H(new Float32Array(t),3))}}class ds{static load_images(e){const t=e.querySelectorAll("img");for(let e=0;e<t.length;e++){const s=t[e];s.dataset.src&&(s.src=s.dataset.src)}const s=e.querySelectorAll("object");for(let e=0;e<s.length;e++){const t=s[e];t.dataset.src&&(t.data=t.dataset.src)}}static load_videos(e){const t=e.querySelectorAll("video");for(let e=0;e<t.length;e++){const s=t[e];s.dataset.src&&(s.src=s.dataset.src)}}static load_iframes(e){const t=e.querySelectorAll("iframe");for(let e=0;e<t.length;e++){const s=t[e];s.dataset.src&&(s.src=s.dataset.src)}}static load_elements(e,t){const s=e.querySelectorAll(t);for(let e=0;e<s.length;e++){const t=s[e];t.dataset.src&&(t.src=t.dataset.src)}}}class us{constructor(){}static get_image_data(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return s.drawImage(e,0,0),s.getImageData(0,0,e.width,e.height)}static get_pixel(e,t,s){const r=4*(t+e.width*s),i=e.data;return new h(i[r+0],i[r+1],i[r+2],i[r+3])}}const ps=new class{constructor(){}sample(e,s){const r=[];let i=99999999;const n=e.getAttribute("position"),o=e.getAttribute("normal"),a=e.getAttribute("tangent"),l=e.getAttribute("uv"),_=e.index,h=[];for(let e=0;e<_.count;e+=3){const s=_.array[e+0],c=_.array[e+1],u=_.array[e+2],p=new d;p.x=n.getX(s),p.y=n.getY(s),p.z=n.getZ(s);const m=new d;m.x=n.getX(c),m.y=n.getY(c),m.z=n.getZ(c);const g=new d;g.x=n.getX(u),g.y=n.getY(u),g.z=n.getZ(u);const f={a:p,b:m,c:g,normal:void 0,tangent:void 0,uv_a:void 0,uv_b:void 0,uv_c:void 0};if(o){const e=new d;e.x=o.getX(s),e.y=o.getY(s),e.z=o.getZ(s);const t=new d;t.x=o.getX(c),t.y=o.getY(c),t.z=o.getZ(c);const r=new d;r.x=o.getX(u),r.y=o.getY(u),r.z=o.getZ(u);const i=e.clone().add(t).add(r).normalize();f.normal=i}if(a){const e=new d;e.x=a.getX(s),e.y=a.getY(s),e.z=a.getZ(s);const t=new d;t.x=a.getX(c),t.y=a.getY(c),t.z=a.getZ(c);const r=new d;r.x=a.getX(u),r.y=a.getY(u),r.z=a.getZ(u);const i=e.clone().add(t).add(r).normalize();f.tangent=i}if(l){const e=new t;e.x=l.getX(s),e.y=l.getY(s);const r=new t;r.x=l.getX(c),r.y=l.getY(c);const i=new t;i.x=l.getX(u),i.y=l.getY(u),f.uv_a=e,f.uv_b=r,f.uv_c=i}h.push(f);const v=this.get_face_area(f);i=Math.min(v,i),r.push(v)}const c=this.get_uniform_face_distribution(r,i,h),u=this.select_random_faces(c,s);return this.sample_data_from_faces(u)}sample_data_from_faces(e){const t=[],s=[],r=[],i=[];for(let n=0;n<e.length;n++){const o=e[n],a=Math.random(),l=Math.random();t.push(this.sample_point_in_face(a,l,o.a,o.b,o.c).clone()),o.normal&&s.push(o.normal.clone()),o.tangent&&r.push(o.tangent.clone()),o.uv_a&&i.push(this.sample_point_in_face(a,l,o.uv_a,o.uv_b,o.uv_c).clone())}return{points:t,normals:s,tangents:r,uvs:i}}select_random_faces(e,t){const s=[];for(let r=0;r<t;r++){const t=e[Math.floor(Math.random()*e.length)];s.push(t)}return s}get_uniform_face_distribution(e,t,s){const r=[];for(let i=0;i<e.length;i++){e[i]/=t;const n=Math.floor(Math.round(e[i]));for(let e=0;e<n;e++)r.push(s[i])}return r}get_face_area(e){const t=e.b.clone().sub(e.a),s=e.c.clone().sub(e.a);return t.cross(s).length()/2}sample_point_in_face(e,t,s,r,i){e+t>1&&(e=1-e,t=1-t);const n=1-(e+t);return s.clone().multiplyScalar(e).add(r.clone().multiplyScalar(t)).add(i.clone().multiplyScalar(n))}};const ms=new class{get_mesh(e,t){e.traverse((e=>{e instanceof a&&(e.geometry&&(e.geometry=e.geometry.clone()),t(e))}))}get_geometries(e){const t=[];return this.get_mesh(e,(e=>{t.push(e.geometry)})),t}assign_material(e,t,s){e.traverse((e=>{e instanceof a&&(void 0===s||e.name===s)&&(e.material=t)}))}clone_animated_gltf(e){const t={animations:e.animations,scene:e.scene.clone(!0)},s={};e.scene.traverse((e=>{e.isSkinnedMesh&&(s[e.name]=e)}));const r={},i={};t.scene.traverse((e=>{e.isBone&&(r[e.name]=e),e.isSkinnedMesh&&(i[e.name]=e)}));for(const e in s){const t=s[e].skeleton,n=i[e],o=[];for(let e=0;e<t.bones.length;++e){const s=r[t.bones[e].name];o.push(s)}n.bind(new $(o,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,s){e.traverse((e=>{e instanceof a&&(e.castShadow=t,e.receiveShadow=s)}))}__find_object(e,t,s){e.traverse((e=>{e.name===t&&s(e)}))}get_object(e,t){let s;return e.traverse((e=>{e.name===t&&(s=e)})),s}get_object_by_type(e,t){let s;return e.traverse((e=>{e.constructor.name===t&&(s=e)})),s}};class gs{static is_object(e){return e&&"object"==typeof e&&!Array.isArray(e)}static merge_deep(e,...t){if(!t.length)return e;const s=t.shift();if(gs.is_object(e)&&gs.is_object(s))for(const t in s)gs.is_object(s[t])?(e[t]||Object.assign(e,{[t]:{}}),gs.merge_deep(e[t],s[t])):Object.assign(e,{[t]:s[t]});return gs.merge_deep(e,...t)}static xml_to_json(e){let t={};if(1===e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(let s=0;s<e.attributes.length;s++){const r=e.attributes.item(s);t["@attributes"][r.nodeName]=r.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let s=0;s<e.childNodes.length;s++){const r=e.childNodes.item(s),i=r.nodeName;if(void 0===t[i])t[i]=this.xml_to_json(r);else{if(void 0===t[i].push){const e=t[i];t[i]=[],t[i].push(e)}t[i].push(this.xml_to_json(r))}}return t}}class fs{constructor(){}static get_random_color(){const e=[0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"];let t="#";for(let s=0;s<6;s++){t+=e[Math.floor(Math.random()*e.length)]}return t}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.toLowerCase().replace(/[-_][a-z0-9]/g,(e=>e.slice(-1).toUpperCase()))}}class vs{constructor(){}time_str_to_ms(e){const t=e.split(":");let s=Number(t[0]);s=60*s*60*1e3;let r=Number(t[1]);r=60*r*1e3;let i=Number(t[2]);return i*=1e3,s+r+i}}class ws{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 bs extends a{constructor(){const{colorNode:e,opacityNode:t}=function(e="#4a4a4a"){const t=ue(new n(e)),s=(e=>{const t=fe(e),s=ve(me(0),t.mul(1.5),e);return we(we(s.x,s.y),s.z)})(pe("barycentric","vec3").add(me(1,1,0)));return{colorNode:ge(t,me(0),s),opacityNode:s.oneMinus().mul(.2)}}("#4a4a4a"),s=new le({transparent:!0,depthWrite:!1});s.colorNode=e,s.opacityNode=t;const r=new l(100,100,100,100);super(cs.convert_to_non_indexed_geometry(r),s),this.rotation.x=-1.57}}class ys extends a{constructor(t){const s=new M;s.setAttribute("position",new H(new Float32Array([]),3)),s.setAttribute("next_position",new H(new Float32Array([]),3)),s.setAttribute("previous_position",new H(new Float32Array([]),3)),s.setAttribute("orientation",new H(new Float32Array([]),1)),s.setAttribute("coverage",new H(new Float32Array([]),1));const r=new e({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new n("#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});super(s,r),this.material=r,t&&this.setup(t)}setup(e){const t=[],s=[],r=[],i=[],n=[];let o=0;for(let a=0;a<e.length;a++){t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),i.push(1),t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),i.push(-1);const l=this.__get_next_position(e,a);s.push(l.x),s.push(l.y),s.push(l.z),s.push(l.x),s.push(l.y),s.push(l.z);const _=this.__get_previous_position(e,a);r.push(_.x),r.push(_.y),r.push(_.z),r.push(_.x),r.push(_.y),r.push(_.z),n.push(o),n.push(o),a<e.length-1&&(o+=e[a].distanceTo(l))}const a=new Float32Array(t),l=new Float32Array(s),_=new Float32Array(r),h=new Float32Array(i),c=new Float32Array(n),d=[];for(let e=0;e<(a.length/3-2)/2;e++){const t=2*e+1;d.push(t),d.push(t+1),d.push(t-1),d.push(t),d.push(t+2),d.push(t+1)}this.geometry.setIndex(d),this.geometry.getAttribute("position").copy(new H(a,3)),this.geometry.getAttribute("next_position").copy(new H(l,3)),this.geometry.getAttribute("previous_position").copy(new H(_,3)),this.geometry.getAttribute("orientation").copy(new H(h,1)),this.geometry.getAttribute("coverage").copy(new H(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=o,this._length=o,this.accumulated_length=o}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 xs extends a{constructor(s,r){r=r||new t(0,0);const i=new e({uniforms:{_MainTex:{value:s},_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:Z}),n=new l(1,1,1);n.translate(-r.x/2,-r.y/2,0);const o=s.image.width/s.image.height;n.scale(o,1,1),super(n,i),this.current_scale=o,this.geometry.computeBoundingBox(),this.tmp_bb_size=new d,this.geometry.boundingBox.getSize(this.tmp_bb_size),this.material=i}update_texture(){this.material.uniforms._MainTex.value.needsUpdate=!0;const 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.copy(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 Ts extends xs{constructor(e,t,s,r){const i=new xt,n={font:t,font_color:s||"#000000"},o=i.draw_on_texture(e,n);o.minFilter=J,o.minFilter=G,o.needsUpdate=!0,super(o,r),this.simple_text_drawer=i,this.canvas_texture=o,this.draw_settings=n}set text(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()}get text(){return"not implemented"}}class Ss extends a{constructor(e,t){super(e,t),this.material=t;const s=this;this.onBeforeRender=()=>{"update"in s.material&&"function"==typeof s.material.update&&s.material.update()}}}class Ms extends Ae{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 t(1,1)}}),this.transparent=!0,this.depthWrite=!1,this.side=Z,e.minFilter=G,e.magFilter=G,e.generateMipmaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(e){this.uniforms._Boldness.value=at.lerp(.5,.2,e)}}class Fs{constructor(e,s,r){const i=s.right-s.left,n=s.top-s.bottom;this.scale=new t(i,n),this.position=new t(e+s.left,s.bottom),this.atlas_bounds=new h(r.left,r.right,r.top,r.bottom)}}class zs{constructor(e,s=""){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 E,this.scale=new d(1,1,1),this.matrix=new j,this.color=new n("#FFFFFF"),this.pivot_point=new t,this.__opacity=1,this.__text=s,this.__generate_glyphs(s)}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){const s=(new E).setFromAxisAngle(new d(0,1,0),e/360*Math.PI*2),r=(new E).setFromAxisAngle(new d(1,0,0),-t/360*Math.PI*2);this.quaternion.copy(s.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 s=0;this.glyphs.length=0;for(let t=0;t<e.length;t++){const r=e.charCodeAt(t),i=this.glyph_layout.find((e=>e.unicode===r));if(i){if(i.planeBounds){const e=new Fs(s,i.planeBounds,i.atlasBounds);this.glyphs.push(e)}s+=i.advance}}const r=new K,i=this.glyphs[0];r.setFromCenterAndSize(i.position.clone().add(new t(i.scale.x/2,i.scale.y/2)),i.scale);for(let e=1;e<this.glyphs.length;e++){const s=this.glyphs[e],i=(new K).setFromCenterAndSize(s.position.clone().add(new t(s.scale.x/2,s.scale.y/2)),s.scale);r.union(i)}const n=new t;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 As extends a{constructor(e,s){const r=new ee;r.instanceCount=0;const i=new l(1,1);i.translate(.5,.5,0),r.setAttribute("position",new te(i.getAttribute("position").array,3)),r.setAttribute("uv",new te(i.getAttribute("uv").array,2)),r.index=i.index;const n=new se(new Float32Array(8e3),4,!1),o=new se(new Float32Array(8e3),4,!1),a=new se(new Float32Array(8e3),4,!1),_=new se(new Float32Array(8e3),4,!1),h=new se(new Float32Array(8e3),4,!1),c=new se(new Float32Array(8e3),4,!1),d=new se(new Float32Array(8e3),4,!1);n.usage=re,o.usage=re,a.usage=re,_.usage=re,h.usage=re,c.usage=re,d.usage=re,r.setAttribute("transformsCol0",n),r.setAttribute("transformsCol1",o),r.setAttribute("transformsCol2",a),r.setAttribute("transformsCol3",_),r.setAttribute("glyph_bounds",h),r.setAttribute("plane_bounds",c),r.setAttribute("color",d),super(r,new Ms(s)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new t(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){const t=new zs(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){_s.remove_elem(this.text_elements,e),this.update(!0)}update(e){const t=this.geometry.getAttribute("glyph_bounds"),s=this.geometry.getAttribute("plane_bounds"),r=this.geometry.getAttribute("transformsCol0"),i=this.geometry.getAttribute("transformsCol1"),n=this.geometry.getAttribute("transformsCol2"),o=this.geometry.getAttribute("transformsCol3"),a=this.geometry.getAttribute("color");let l=!0===e,_=!0===e,h=!0===e,c=0;for(let e=0;e<this.text_elements.length;e++){const d=this.text_elements[e];d.matrix_is_dirty&&(l=!0,d.update_matrix()),d.glyph_is_dirty&&(_=!0,d.clear_glyph_dirty()),d.color_is_dirty&&(h=!0,d.clear_color_dirty());const u=d.matrix,p=d.color,m=d.opacity;for(let e=0;e<d.glyphs.length;e++){const l=d.glyphs[e],_=c;t.setXYZW(_,l.atlas_bounds.x,l.atlas_bounds.y,l.atlas_bounds.z,l.atlas_bounds.w),s.setXYZW(_,l.position.x,l.position.y,l.scale.x,l.scale.y),r.setXYZW(_,u.elements[0],u.elements[1],u.elements[2],u.elements[3]),i.setXYZW(_,u.elements[4],u.elements[5],u.elements[6],u.elements[7]),n.setXYZW(_,u.elements[8],u.elements[9],u.elements[10],u.elements[11]),o.setXYZW(_,u.elements[12],u.elements[13],u.elements[14],u.elements[15]),a.setXYZW(_,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),l&&(r.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0,o.needsUpdate=!0),_&&(t.needsUpdate=!0,s.needsUpdate=!0),h&&(a.needsUpdate=!0)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rs extends ht{constructor(e,t=new d,s=new d(1,1,1),r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=s}update(e,t){const s=this.from.clone();s.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(s)}}class Cs extends Se{constructor(){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 ks extends Se{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 Ps{constructor(){this.current_width=1,this.current_height=1,this.RT0=new c(1,1),this.RT1=new c(1,1),this.RT2=new c(1,1),this.RT3=new c(1,1),this.RT4=new c(1,1),this.upscale_blur_mat=new ks(!0),this.downscale_blur_mat=new ks(!1),this.alpha_filter_mat=new Cs}blur(e){this.check_RT_resize(e.width,e.height),Ee.blit(e,this.RT1,this.alpha_filter_mat),Ee.blit(this.RT1,this.RT2,this.downscale_blur_mat),Ee.blit(this.RT2,this.RT3,this.downscale_blur_mat),Ee.blit(this.RT3,this.RT4,this.downscale_blur_mat),Ee.blit(this.RT4,this.RT3,this.upscale_blur_mat),Ee.blit(this.RT3,this.RT2,this.upscale_blur_mat),Ee.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 Ls extends Se{constructor(){super("#define GLSLIFY 1\nuniform 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 t(1,1)}}set_texture(e){this.uniforms._SourceTex.value=e;const t=this.get_size(e);this.uniforms._SourceTexSize.value.copy(t)}get_size(e){return e.isVideoTexture?new t(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new t(e.width,e.height):e.isTexture?new t(e.image.width,e.image.height):new t(1,1)}}class Ds{constructor(){this.RT=new c(1,1,{type:ie,format:B,minFilter:x,magFilter:x}),this.RT1=new c(1,1,{type:ie,format:B,minFilter:x,magFilter:x}),this.median_filter_mat=new Ls}filter(e){const 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),Ee.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),Ee.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),Ee.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new t(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isRenderTarget?new t(e.width,e.height):e.isTexture?new t(e.image.width,e.image.height):new t(1,1)}}class Us{constructor(e,t){this.read=void 0,this.write=void 0,this.name=e,this.update_material=t}init_from_geometry(e){}init_from_attribute(e){}build_RT(e){const t=Us.calculate_resolution(e),s={minFilter:x,magFilter:x,format:B,colorScape:f,type:Tt.fp_textures_available?ie:W,stencilBuffer:!1,depthBuffer:!1};return new c(t.width,t.height,s)}static calculate_resolution(e){const t=Math.min(e,512);return{width:t,height:Math.max(1,Math.ceil(e/t))}}swap_RT(){const e=this.read;this.read=this.write,this.write=e}update(e){this.update_material&&(this.update_material.update(),e.children[0]instanceof a&&(e.children[0].material=this.update_material),this.update_material.uniforms._MainTex.value=this.read.texture,Ee.render(e,void 0,this.write),e.children[0]instanceof a&&(e.children[0].material=void 0),this.swap_RT())}store_geometry_attribute_in_RT(e,t,s,r){r.children[0]instanceof a&&(r.children[0].geometry.setAttribute("data",e),r.children[0].material=s),Ee.render(r,void 0,t),r.children[0]instanceof a&&(r.children[0].geometry.deleteAttribute("data"),r.children[0].material=void 0)}get_texture(){return this.read.texture}}class Os extends T{constructor(e,t){super(),this.attributes=[],this.mesh=this.build_point_mesh(e,t),this.add(this.mesh),this.attribute_writter_mesh=this.build_attribute_writter_mesh(e),this.attribute_writter_scene=new o,this.attribute_writter_scene.add(this.attribute_writter_mesh)}add_texture_attribute(e){this.attributes.push(e)}add_update_attribute_array(e,t,s){this.attribute_writter_mesh.geometry.setAttribute(e,new H(t,s,!1))}add_attribute_array(e,t,s){this.mesh.geometry.setAttribute(e,new se(t,s,!1))}update(){const e=this.mesh.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e.dispose();for(let e=0;e<this.attributes.length;e++)this.attributes[e].update(this.attribute_writter_scene)}dispose(){this.mesh.geometry.dispose();const e=this.mesh.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e.dispose()}build_point_mesh(e=1,t){const s=new l,r=new ee;r.setAttribute("position",s.getAttribute("position")),r.index=s.index,r.setAttribute("storage_uv",this.build_uv_storage_attribute(e)),r.instanceCount=e;const i=new a(r,t);return i.frustumCulled=!1,i}build_attribute_writter_mesh(e){const{width:t,height:s}=Us.calculate_resolution(e),r=new Float32Array(3*e);for(let i=0;i<e;i++){const e=i%t,n=Math.floor(i/t);r[3*i+0]=(e+.5)/t,r[3*i+1]=(n+.5)/s,r[3*i+2]=i}const i=new M;i.setAttribute("position",new H(r,3,!1));const n=new ne(i);return n.frustumCulled=!1,n}build_uv_storage_attribute(e){const{width:t,height:s}=Us.calculate_resolution(e),r=new Float32Array(2*e);for(let i=0;i<e;i++){const e=i%t,n=Math.floor(i/t);r[2*i+0]=(e+.5)/t,r[2*i+1]=(n+.5)/s}return new se(r,2,!1)}}class Is extends e{constructor(e){super({uniforms:{},vertexShader:e=e||"\n varying vec4 value;\n attribute vec4 data;\n\n void main()\n {\n gl_Position = vec4(position.xy * 2.0 - 1.0, 1.0,1.0);\n gl_PointSize = 1.0;\n\n value = data;\n }\n ",fragmentShader:"#define GLSLIFY 1\nvarying vec4 value;void main(){gl_FragColor=value;}",depthWrite:!1,blending:s,depthTest:!1,depthFunc:r})}}class Ns extends Us{constructor(e){super("_Position",e)}store_geometry(e,t){const s=e.getAttribute("position");this.read=this.build_RT(s.count),this.write=this.build_RT(s.count);const r=new Is;this.store_geometry_attribute_in_RT(e.getAttribute("position"),this.read,r,t)}store_positions(e,t){this.read=this.build_RT(e.length),this.write=this.build_RT(e.length);const s=new Float32Array(4*e.length);for(let t=0;t<e.length;t++)s[4*t+0]=e[t].x,s[4*t+1]=e[t].y,s[4*t+2]=e[t].z,s[4*t+3]=10*(2*Math.random()-1);const r=new Is;this.store_geometry_attribute_in_RT(new H(s,4),this.read,r,t)}}class Es extends ke{constructor(e,t,s){super(e,t,s),this.loader=new be}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class js extends ke{constructor(e,t,s){super(e,t,s),this.loader=new oe}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__set_error(e),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class qs extends ke{constructor(e,t,s){super(e,t,s),this.loader=new ye}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Vs extends ke{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?fetch(this.url).then((t=>{t.json().then((t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Bs extends ke{constructor(e,t,s){super(e,t,s),this.loader=new xe}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__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"),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Ys extends ke{constructor(e,t,s){super(e,t,s),this.loader=new oe}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,this.parse_path(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__set_error(e),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}parse_path(e){const t=e.split("\n");""===t[t.length-1]&&t.pop();const s=[];for(let e=0;e<t.length;e+=3){const r=parseFloat(t[e+0]),i=parseFloat(t[e+1]),n=parseFloat(t[e+2]);s.push(new d(r,i,n))}return s}}class Gs extends ke{constructor(e,t,s){super(e,t,s),this.loader=new oe}on_preloaded_finished(e){void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>{e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended()}),(()=>{}),(e=>{this.__set_error(e),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Ws extends ke{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){void 0===e.resources_by_url[this.url]?t.blob().then((t=>{const s=new i,r=URL.createObjectURL(t),n=new Image;n.src=r,n.onload=()=>{s.image=n,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended()},n.onerror=()=>{console.error("Error loading texture. Maybe the resource is not an image?",this.url)}})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Xs extends ke{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){void 0===e.resources_by_url[this.url]?t.blob().then((t=>{e.set_resource(this.resource_id,this.url,URL.createObjectURL(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended()})):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended())}}class Qs{constructor(e){this.name=e,this.resources={},this.resources_by_url={}}set_resource(e,t,s){Object.keys(this.resources_by_url).includes(t)?this.resources[e]=this.resources_by_url[t]:(this.resources[e]=s,this.resources_by_url[t]=s)}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}}class Hs{constructor(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}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||Qs)}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 $s{start(){this.finished=!1}update(){this.finished=!0}}export{ke as AbstractLoader,nt as AbstractScene,ot as ActionEvent,ht as ActionInterpolator,lt as ActionSequencer,ut as ActionSequencerBuilder,Me as AddMaterial,bt as ApplicationView,_s as ArrayUtilities,zt as Arrow,Be as AsyncAbstractLoader,Ye as AsyncAudiosLoader,Xe as AsyncObjectsLoader,He as AsyncTextureLoader,et as AsyncTexturesLoader,qe as AudioLoader,Te as BaseApplication,Ce as BaseRender,Ae as BaseShaderMaterial,$e as BasisLoader,Se as BlitMaterial,Ht as Blurrer,Qe as Browser,Lt as CSSAnimator,Pe as CameraManager,Nt as CameraUtilities,yt as CanvasDrawer,Tt as Capabilities,$s as Compilator,At as Cube,Ze as CubemapLoader,Es as DAELoader,Ct as Debug,Bt as DebugNormalsRender,dt as DrawIOAnimationSheet,ks as DualFilteringBlurMaterial,Ps as DualFilteringBlurrer,_t as EasingFunctions,js as FileLoader,qs as FontLoader,hs as FrustumPointFitter,Ge as GLTFDRACOLoader,We as GLTFLoader,Os as GPUParticleSystem,es as GaussianBlurrer,cs as GeometryUtilities,Ee as Graphics,bs as Grid,Je as HDRCubeTextureLoader,Ke as HDRTextureLoader,ds as HTMLUtilities,rt as HighQualityLoadingState,as as HorizontalPlane,us as ImageUtilities,Et as Initializer,Vs as JSONLoader,jt as KeyboardInput,ys as Line,st as LoadingState,Ds as MedianFilter,ps as MeshSampler,ms as ModelUtilities,$t as NormalAORender,Zt as NormalRender,ct as NumberInterpolator,Bs as OBJLoader,at as OMath,Dt as OS,Le as OScreen,gs as ObjectUtilities,qt as OrthographicCamera,Ot as OrthographicFrustumPointFitter,Us as ParticleAttribute,Ns as ParticlePositionAttribute,Ft as PerspectiveCamera,It as PerspectiveFrustumPointFitter,Ys as PointArrayLoader,it as RegularLoadingState,is as RenderLoop,Hs as ResourceBatch,Ve as ResourceContainer,As as SDFTextBatch,De as SceneManager,ns as Screen,xt as SimpleTextDrawer,Rt as Sphere,fs as StringUtilities,Ts as Text2D,Gs as TextLoader,Ws as TextureLoader,mt as Time,vs as TimeUtilities,vt as TransitionManager,pt as TransitionTable,Re as UnrealBloomComposeMaterial,ts as UnrealBloomRender,Ss as UpdatableMaterialMesh,ss as VRRender,ws as Validation,Rs as VectorInterpolator,ls as VerticalPlane,Xs as VideoLoader,os as ViewComponent,rs as ViewComponentManager,wt as ViewManager,xs as WorldImage};
2
2
  //# sourceMappingURL=index.mjs.map