ohzi-core 12.2.0 → 12.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) 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 +2 -1
  6. package/src/BaseApplication.js +11 -2
  7. package/src/Browser.js +10 -3
  8. package/src/CameraManager.js +5 -0
  9. package/src/Capabilities.js +1 -0
  10. package/src/CustomBezierCurve.js +12 -0
  11. package/src/Debug.js +99 -5
  12. package/src/Graphics.js +86 -6
  13. package/src/Initializer.js +5 -0
  14. package/src/KeyboardInput.js +40 -1
  15. package/src/OS.js +1 -1
  16. package/src/OScreen.js +19 -4
  17. package/src/OrthographicCamera.js +13 -0
  18. package/src/PerspectiveCamera.js +11 -0
  19. package/src/ReflectionPlaneContext.js +5 -1
  20. package/src/RenderLayers.js +1 -1
  21. package/src/RenderLoop.js +9 -0
  22. package/src/RenderOrder.js +1 -1
  23. package/src/ResourceContainer.js +21 -0
  24. package/src/SceneManager.js +14 -4
  25. package/src/Screen.js +71 -0
  26. package/src/Time.js +4 -0
  27. package/src/UI.js +16 -1
  28. package/src/action_sequencer/ActionEvent.js +6 -1
  29. package/src/action_sequencer/ActionInterpolator.js +16 -2
  30. package/src/action_sequencer/ActionSequencer.js +65 -2
  31. package/src/action_sequencer/NumberInterpolator.js +15 -0
  32. package/src/action_sequencer/VectorInterpolator.js +13 -1
  33. package/src/blitter_index.js +1 -0
  34. package/src/canvas_drawer/CanvasDrawer.js +37 -4
  35. package/src/canvas_drawer/MultiLineTextDrawer.js +8 -1
  36. package/src/canvas_drawer/SimpleTextDrawer.js +7 -1
  37. package/src/components/AudioClip.js +11 -1
  38. package/src/components/AxisHelper.js +1 -1
  39. package/src/components/BaseObject.js +8 -5
  40. package/src/components/EdgeMesh.js +30 -2
  41. package/src/components/GeometryEdgeVisualizer.js +10 -1
  42. package/src/components/Grid.js +4 -0
  43. package/src/components/Line.js +31 -7
  44. package/src/components/MultiLinePath.js +9 -5
  45. package/src/components/MultiLineText2D.js +13 -2
  46. package/src/components/ObjectAxis.js +5 -0
  47. package/src/components/ObjectOrientedBoundingBox.js +26 -1
  48. package/src/components/PlaneHelper.js +1 -1
  49. package/src/components/Shape2D.js +11 -3
  50. package/src/components/Shape3D.js +10 -4
  51. package/src/components/Text2D.js +11 -3
  52. package/src/components/UIElement.js +40 -4
  53. package/src/components/UpdatableMaterialMesh.js +11 -3
  54. package/src/components/WorldImage.js +10 -2
  55. package/src/index.js +3 -1
  56. package/src/loaders/AsyncAbstractLoader.js +16 -0
  57. package/src/loaders/AsyncObjectsLoader.js +6 -0
  58. package/src/primitives/Arrow.js +6 -0
  59. package/src/primitives/Cube.js +6 -1
  60. package/src/primitives/HorizontalPlane.js +8 -1
  61. package/src/primitives/Sphere.js +7 -0
  62. package/src/primitives/VerticalPlane.js +8 -1
  63. package/src/ui/ui_element_state/OnIdle.js +5 -0
  64. package/src/ui/ui_element_state/OnMouseEnter.js +11 -0
  65. package/src/ui/ui_element_state/OnMouseExit.js +5 -0
  66. package/src/ui/ui_element_state/OnMouseHover.js +13 -0
  67. package/src/ui/ui_element_state/UIElementState.js +17 -3
  68. package/src/utilities/EasingFunctions.js +5 -0
  69. package/types/BaseApplication.d.ts +18 -11
  70. package/types/Browser.d.ts +20 -19
  71. package/types/CameraManager.d.ts +14 -13
  72. package/types/Capabilities.d.ts +8 -8
  73. package/types/CustomBezierCurve.d.ts +19 -7
  74. package/types/Debug.d.ts +198 -37
  75. package/types/Graphics.d.ts +143 -61
  76. package/types/Initializer.d.ts +10 -6
  77. package/types/KeyboardInput.d.ts +65 -20
  78. package/types/OS.d.ts +20 -20
  79. package/types/OScreen.d.ts +37 -22
  80. package/types/OrthographicCamera.d.ts +20 -6
  81. package/types/PerspectiveCamera.d.ts +18 -6
  82. package/types/ReflectionPlaneContext.d.ts +13 -8
  83. package/types/RenderLayers.d.ts +6 -6
  84. package/types/RenderLoop.d.ts +132 -14
  85. package/types/RenderOrder.d.ts +8 -8
  86. package/types/ResourceContainer.d.ts +29 -10
  87. package/types/SceneManager.d.ts +15 -12
  88. package/types/Screen.d.ts +27 -0
  89. package/types/Time.d.ts +29 -24
  90. package/types/UI.d.ts +92 -18
  91. package/types/action_sequencer/ActionEvent.d.ts +12 -7
  92. package/types/action_sequencer/ActionInterpolator.d.ts +18 -5
  93. package/types/action_sequencer/ActionSequencer.d.ts +104 -36
  94. package/types/action_sequencer/NumberInterpolator.d.ts +18 -9
  95. package/types/action_sequencer/VectorInterpolator.d.ts +13 -7
  96. package/types/blitter_index.d.ts +6 -6
  97. package/types/canvas_drawer/CanvasDrawer.d.ts +51 -13
  98. package/types/canvas_drawer/MultiLineTextDrawer.d.ts +13 -5
  99. package/types/canvas_drawer/SimpleTextDrawer.d.ts +13 -6
  100. package/types/components/AudioClip.d.ts +25 -13
  101. package/types/components/AxisHelper.d.ts +6 -6
  102. package/types/components/BaseObject.d.ts +12 -5
  103. package/types/components/EdgeMesh.d.ts +42 -13
  104. package/types/components/GeometryEdgeVisualizer.d.ts +12 -4
  105. package/types/components/Grid.d.ts +4 -2
  106. package/types/components/Line.d.ts +42 -16
  107. package/types/components/MultiLinePath.d.ts +10 -4
  108. package/types/components/MultiLineText2D.d.ts +22 -10
  109. package/types/components/ObjectAxis.d.ts +8 -3
  110. package/types/components/ObjectOrientedBoundingBox.d.ts +45 -18
  111. package/types/components/PlaneHelper.d.ts +6 -6
  112. package/types/components/Shape2D.d.ts +14 -4
  113. package/types/components/Shape3D.d.ts +10 -3
  114. package/types/components/Text2D.d.ts +21 -13
  115. package/types/components/UIElement.d.ts +87 -52
  116. package/types/components/UpdatableMaterialMesh.d.ts +12 -4
  117. package/types/components/WorldImage.d.ts +23 -13
  118. package/types/components/mouse_interactors/ObjectRotator.d.ts +12 -0
  119. package/types/components/sdf_text/SDFText.d.ts +35 -30
  120. package/types/components/sdf_text/SDFTextBatch.d.ts +12 -12
  121. package/types/components/sdf_text/TextGlyph.d.ts +8 -6
  122. package/types/data_textures/CustomDataTexture.d.ts +11 -11
  123. package/types/data_textures/RGBADataTexture.d.ts +4 -4
  124. package/types/data_textures/RGBAFloatDataTexture.d.ts +4 -4
  125. package/types/data_textures/RGBDataTexture.d.ts +4 -4
  126. package/types/data_textures/RGBFloatDataTexture.d.ts +4 -4
  127. package/types/editor/ManipulatorHandle.d.ts +23 -14
  128. package/types/editor/ObjectEditor.d.ts +18 -16
  129. package/types/editor/ObjectManipulator.d.ts +23 -19
  130. package/types/editor/ObjectPicker.d.ts +19 -16
  131. package/types/gpu_particles/GPUParticleSystem.d.ts +22 -15
  132. package/types/gpu_particles/ParticleAttribute.d.ts +19 -18
  133. package/types/gpu_particles/ParticlePositionAttribute.d.ts +6 -6
  134. package/types/html_utilities/CSSAnimator.d.ts +31 -31
  135. package/types/html_utilities/css_animator_states/Animating.d.ts +8 -8
  136. package/types/html_utilities/css_animator_states/Idle.d.ts +6 -6
  137. package/types/index.d.ts +110 -108
  138. package/types/loaders/AsyncAbstractLoader.d.ts +41 -27
  139. package/types/loaders/AsyncAudiosLoader.d.ts +6 -5
  140. package/types/loaders/AsyncObjectsLoader.d.ts +6 -6
  141. package/types/loaders/AsyncTexturesLoader.d.ts +9 -8
  142. package/types/loaders/assets_loader/AssetLoader.d.ts +4 -0
  143. package/types/loaders/assets_loader/AsyncAssetsLoaderWorker.d.ts +1 -0
  144. package/types/loaders/assets_loader/ResourceBatch.d.ts +14 -0
  145. package/types/loaders/assets_loader/ResourceContainer.d.ts +9 -0
  146. package/types/loaders/assets_loader/ResourceLoaderChecker.d.ts +8 -0
  147. package/types/materials/AddMaterial.d.ts +5 -5
  148. package/types/materials/AlphaFilterMaterial.d.ts +6 -6
  149. package/types/materials/BaseShaderMaterial.d.ts +4 -3
  150. package/types/materials/BlitMaterial.d.ts +4 -3
  151. package/types/materials/BloomComposeMaterial.d.ts +4 -7
  152. package/types/materials/BoxBlurMaterial.d.ts +4 -4
  153. package/types/materials/ClearAlphaMaterial.d.ts +3 -3
  154. package/types/materials/ClearColorMaterial.d.ts +7 -7
  155. package/types/materials/ClearDepthNormalMaterial.d.ts +4 -4
  156. package/types/materials/DeferredRendererComposeMaterial.d.ts +7 -7
  157. package/types/materials/DepthNormalMaterial.d.ts +6 -4
  158. package/types/materials/DisplayNormalTextureMaterial.d.ts +4 -4
  159. package/types/materials/DualFilteringBlurMaterial.d.ts +4 -4
  160. package/types/materials/FXAAMaterial.d.ts +3 -3
  161. package/types/materials/GaussianBlurMaterial.d.ts +6 -6
  162. package/types/materials/LuminosityHighPassMaterial.d.ts +4 -4
  163. package/types/materials/MedianFilterMaterial.d.ts +7 -6
  164. package/types/materials/NormalMaterial.d.ts +4 -2
  165. package/types/materials/SDFScreenTextMaterial.d.ts +9 -11
  166. package/types/materials/SDFTextMaterial.d.ts +10 -12
  167. package/types/materials/SSAOComposeMaterial.d.ts +4 -4
  168. package/types/materials/SSAOMaterial.d.ts +8 -6
  169. package/types/materials/ScreenSpaceTextureMaterial.d.ts +7 -7
  170. package/types/materials/UIElementMaterial.d.ts +4 -7
  171. package/types/materials/UnrealBloomComposeMaterial.d.ts +16 -16
  172. package/types/materials/UnrealBlurMaterial.d.ts +4 -4
  173. package/types/materials/UnrealComposeMaterial.d.ts +4 -4
  174. package/types/materials/ViewPositionMaterial.d.ts +4 -3
  175. package/types/materials/deferred/DeferredPointLightMaterial.d.ts +9 -10
  176. package/types/materials/gpu_particles/AttributeUpdateMaterial.d.ts +7 -0
  177. package/types/materials/gpu_particles/BasicParticleMaterial.d.ts +4 -0
  178. package/types/materials/gpu_particles/ParticleStorageMaterial.d.ts +4 -2
  179. package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +3 -4
  180. package/types/object_pool/Pool.d.ts +10 -10
  181. package/types/primitives/Arrow.d.ts +15 -8
  182. package/types/primitives/Cube.d.ts +10 -3
  183. package/types/primitives/HorizontalPlane.d.ts +11 -3
  184. package/types/primitives/Sphere.d.ts +11 -3
  185. package/types/primitives/VerticalPlane.d.ts +11 -3
  186. package/types/raycast/GroupRaycaster.d.ts +15 -13
  187. package/types/raycast/PlaneDragResolver.d.ts +16 -15
  188. package/types/raycast/PlaneRaycastResolver.d.ts +5 -5
  189. package/types/raycast/PlaneRaycaster.d.ts +9 -7
  190. package/types/raycast/RaycastResolver.d.ts +5 -5
  191. package/types/raycast/SurfaceDragResolver.d.ts +15 -13
  192. package/types/raycast/states/BaseState.d.ts +5 -5
  193. package/types/raycast/states/IdleState.d.ts +3 -5
  194. package/types/raycast/states/OnRaycastEnter.d.ts +3 -5
  195. package/types/raycast/states/OnRaycastExit.d.ts +3 -4
  196. package/types/raycast/states/OnRaycastHover.d.ts +3 -5
  197. package/types/render_mode/BaseRender.d.ts +7 -7
  198. package/types/render_mode/BloomRender.d.ts +12 -10
  199. package/types/render_mode/DebugNormalsRender.d.ts +3 -3
  200. package/types/render_mode/DeferredRender.d.ts +13 -9
  201. package/types/render_mode/NormalAORender.d.ts +18 -17
  202. package/types/render_mode/NormalRender.d.ts +3 -3
  203. package/types/render_mode/OutlineRender.d.ts +25 -20
  204. package/types/render_mode/PlanarReflectionsRender.d.ts +19 -13
  205. package/types/render_mode/UnrealBloomRender.d.ts +21 -20
  206. package/types/render_mode/VRRender.d.ts +4 -4
  207. package/types/render_utilities/Blitter.d.ts +19 -15
  208. package/types/render_utilities/Blurrer.d.ts +9 -8
  209. package/types/render_utilities/DepthAndNormalsRenderer.d.ts +11 -10
  210. package/types/render_utilities/DualFilteringBlurrer.d.ts +18 -17
  211. package/types/render_utilities/GaussianBlurrer.d.ts +27 -26
  212. package/types/render_utilities/MedianFilter.d.ts +11 -9
  213. package/types/render_utilities/ViewPositionRenderer.d.ts +10 -9
  214. package/types/resource_loader/AbstractLoader.d.ts +21 -21
  215. package/types/resource_loader/AsyncTextureLoader.d.ts +11 -11
  216. package/types/resource_loader/AudioLoader.d.ts +9 -9
  217. package/types/resource_loader/BasisLoader.d.ts +6 -6
  218. package/types/resource_loader/CubemapLoader.d.ts +8 -7
  219. package/types/resource_loader/DAELoader.d.ts +7 -6
  220. package/types/resource_loader/DDSLoader.d.ts +7 -6
  221. package/types/resource_loader/FileLoader.d.ts +7 -6
  222. package/types/resource_loader/FontLoader.d.ts +7 -6
  223. package/types/resource_loader/GLTFDRACOLoader.d.ts +7 -6
  224. package/types/resource_loader/GLTFLoader.d.ts +7 -6
  225. package/types/resource_loader/HDRCubeTextureLoader.d.ts +8 -7
  226. package/types/resource_loader/JSONLoader.d.ts +5 -4
  227. package/types/resource_loader/OBJLoader.d.ts +7 -6
  228. package/types/resource_loader/PointArrayLoader.d.ts +9 -7
  229. package/types/resource_loader/RGBETextureLoader.d.ts +7 -6
  230. package/types/resource_loader/ResourceBatch.d.ts +13 -13
  231. package/types/resource_loader/SVGLoader.d.ts +7 -6
  232. package/types/resource_loader/TextLoader.d.ts +7 -6
  233. package/types/resource_loader/TextureLoader.d.ts +4 -4
  234. package/types/resource_loader/VideoLoader.d.ts +4 -4
  235. package/types/scenes/AbstractScene.d.ts +32 -32
  236. package/types/scenes/loading_states/CompilatorManager.d.ts +8 -8
  237. package/types/scenes/loading_states/HighQualityLoadingState.d.ts +3 -3
  238. package/types/scenes/loading_states/LoadingState.d.ts +31 -31
  239. package/types/scenes/loading_states/RegularLoadingState.d.ts +5 -5
  240. package/types/static_batcher/BatchedMesh.d.ts +16 -15
  241. package/types/static_batcher/GeometryBatch.d.ts +41 -37
  242. package/types/static_batcher/GeometryBatcher.d.ts +9 -9
  243. package/types/static_batcher/MeshBatcher.d.ts +5 -5
  244. package/types/ui/ui_element_position/ScreenSpacePosition.d.ts +5 -4
  245. package/types/ui/ui_element_position/WorldSpacePosition.d.ts +7 -5
  246. package/types/ui/ui_element_state/OnIdle.d.ts +9 -3
  247. package/types/ui/ui_element_state/OnMouseEnter.d.ts +3 -3
  248. package/types/ui/ui_element_state/OnMouseExit.d.ts +3 -3
  249. package/types/ui/ui_element_state/OnMouseHover.d.ts +8 -4
  250. package/types/ui/ui_element_state/UIElementState.d.ts +17 -5
  251. package/types/utilities/ArrayUtilities.d.ts +7 -7
  252. package/types/utilities/CameraUtilities.d.ts +40 -36
  253. package/types/utilities/EasingFunctions.d.ts +36 -35
  254. package/types/utilities/FrustumPointFitter.d.ts +14 -14
  255. package/types/utilities/GeometryUtilities.d.ts +5 -4
  256. package/types/utilities/HTMLUtilities.d.ts +6 -6
  257. package/types/utilities/ImageUtilities.d.ts +5 -4
  258. package/types/utilities/MeshSampler.d.ts +20 -20
  259. package/types/utilities/ModelUtilities.d.ts +15 -15
  260. package/types/utilities/OMath.d.ts +21 -21
  261. package/types/utilities/ObjectUtilities.d.ts +7 -7
  262. package/types/utilities/OrthographicFrustumPointFitter.d.ts +8 -7
  263. package/types/utilities/PerspectiveFrustumPointFitter.d.ts +14 -12
  264. package/types/utilities/StringUtilities.d.ts +6 -6
  265. package/types/utilities/TimeUtilities.d.ts +3 -3
  266. package/types/utilities/Validation.d.ts +6 -6
  267. package/types/view_components/ApplicationView.d.ts +13 -13
  268. package/types/view_components/TransitionManager.d.ts +20 -20
  269. package/types/view_components/ViewComponent.d.ts +15 -15
  270. package/types/view_components/ViewComponentManager.d.ts +13 -13
  271. package/types/view_components/ViewManager.d.ts +22 -23
  272. package/types/view_components/ViewState.d.ts +14 -14
  273. package/types/view_components/transition/ActionSequencerBuilder.d.ts +16 -16
  274. package/types/view_components/transition/DrawIOAnimationSheet.d.ts +17 -17
  275. package/types/view_components/transition/TransitionTable.d.ts +8 -8
  276. package/types/view_components/transition/ViewStateTransitionHandler.d.ts +19 -19
package/build/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{ShaderMaterial as e,Vector2 as t,NoBlending as s,AlwaysDepth as i,Color as r,PositionalAudio as n,Audio as o,AudioContext as a,Texture as _,SRGBColorSpace as l,NoColorSpace as h,CubeTextureLoader as c,Scene as u,Clock as d,CanvasTexture as p,UVMapping as m,ClampToEdgeWrapping as g,NearestFilter as f,Object3D as v,Vector3 as x,LineBasicMaterial as w,BufferGeometry as b,Line as y,Mesh as T,BoxGeometry as M,MeshBasicMaterial as S,SphereGeometry as z,CylinderGeometry as F,ConeGeometry as A,PerspectiveCamera as R,PlaneGeometry as C,Vector4 as k,Box3 as P,Box3Helper as D,CatmullRomCurve3 as L,OrthographicCamera as U,WebGLRenderTarget as j,WebGLRenderer as O,RGBAFormat as I,LinearSRGBColorSpace as N,FloatType as B,DataTexture as V,BufferAttribute as q,Sphere as Y,Plane as G,Line3 as E,Quaternion as W,Matrix4 as X,Ray as Q,RepeatWrapping as H,LinearFilter as $,Skeleton as Z,DoubleSide as J,LinearMipMapLinearFilter as K,Box2 as ee,InstancedBufferGeometry as te,Float32BufferAttribute as se,InstancedBufferAttribute as ie,DynamicDrawUsage as re,HalfFloatType as ne,Points as oe,FileLoader as ae}from"three";import{ResourceContainer as _e}from"ohzi-core";import{GLTFLoader as le}from"three/examples/jsm/loaders/GLTFLoader.js";import{RGBELoader as he}from"three/examples/jsm/loaders/RGBELoader.js";import*as ce from"three/examples/jsm/utils/BufferGeometryUtils.js";export{ce as BufferGeometryUtils};import{ColladaLoader as ue}from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as de}from"three/examples/jsm/loaders/FontLoader.js";import{HDRCubeTextureLoader as pe}from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import{OBJLoader as me}from"three/examples/jsm/loaders/OBJLoader.js";class ge{on_post_start(){}on_enter(){}on_exit(){}before_update(){}update(){}fixed_update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}}class fe extends e{constructor(e,r,n){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new t(0,0)},_TargetResolution:{value:new t(0,0)}},defines:n||{},vertexShader:r||"#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:i})}}class ve extends fe{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}var xe="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",we="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class be extends e{constructor(e,t,s){super({vertexShader:e||xe,fragmentShader:t||we,uniforms:s||{_Color:{value:new r("#FF0000")}}})}}class ye extends fe{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};const t=[new r("#FFFFFF"),new r("#FFFFFF"),new r("#FFFFFF"),new r("#FFFFFF"),new r("#FFFFFF")];this.uniforms.bloomTintColors={value:t}}set_RT_0(e){this.uniforms.blurTexture1.value=e}set_RT_1(e){this.uniforms.blurTexture2.value=e}set_RT_2(e){this.uniforms.blurTexture3.value=e}set_RT_3(e){this.uniforms.blurTexture4.value=e}set_RT_4(e){this.uniforms.blurTexture5.value=e}set_bloom_strength(e){this.uniforms.bloomStrength.value=e}set_bloom_radius(e){this.uniforms.bloomRadius.value=e}set_tint_color_0(e){this.uniforms.bloomTintColors.value[0].set(e)}set_tint_color_1(e){this.uniforms.bloomTintColors.value[1].set(e)}set_tint_color_2(e){this.uniforms.bloomTintColors.value[2].set(e)}set_tint_color_3(e){this.uniforms.bloomTintColors.value[3].set(e)}set_tint_color_4(e){this.uniforms.bloomTintColors.value[4].set(e)}}class Te{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}class Me{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(),i=t.body.getReader(),r=+t.headers.get("Content-Length");let n=0;for(;;){const{done:e,value:t}=await i.read();if(e)break;n+=t.length,this.__update_downloaded_bytes(n,r)}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)}}class Se{constructor(e,t=!0,s=1,i=!1){this.buffer=e,this.loop=t,this.volume=s,this.positional=i,this.audio=void 0}init(e){this.positional?this.audio=new n(e):this.audio=new o(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 ze extends Me{constructor(e,t,s=!0,i=0,r,n=!1){super(e,t,r),this.loop=s,this.volume=i,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=a.getContext(),s=t.createBuffer(2,22050,44100);fetch(this.url).then((e=>e.blob())).then((i=>{i.arrayBuffer?i.arrayBuffer().then((s=>{t.decodeAudioData(s,(t=>{e.set_resource(this.resource_id,this.url,new Se(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 Se(s,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended())}))}}const Fe=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 Ae{constructor(e,t,s){this.resource_container=Fe,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.js",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(){console.warn("Not implemented")}}class Re extends Ae{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 ze(s.name,s.url,s.loop,s.volume,s.size,s.positional))}return e}}class Ce extends Me{constructor(e,t,s,i){super(e,t,i),this.loader=new le,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=>{}),(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 Me{constructor(e,t,s){super(e,t,s),this.loader=new le}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 Pe extends Ae{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=Fe.get("draco_loader");e.push(new Ce(s.name,s.url,t,s.size))}else e.push(new ke(s.name,s.url,s.size))}return e}}const De=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_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,i=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(i[1])&&(t=/\brv[ :]+(\d+)/g.exec(e)||[],s="IE "+(t[1]||"")),"Chrome"===i[1]&&(t=e.match(/\b(OPR|Edge)\/(\d+)/),null!=t&&(s=t.slice(1).join(" ").replace("OPR","Opera"))),i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+(\.\d+)?)/i))&&i.splice(1,1,t[1]),s=i.join(" "),Number(s.split(" ")[1])}};class Le extends Me{constructor(e,t,s,i=!0,r=!1,n=!0){super(e,t,s),this.original_url="",this.colorSpaceConversion=n,this.premultiplyAlpha=r,this.flipY=i}on_preloaded_finished(e){De.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 _,s=new Image;s.src=this.url,s.onload=()=>{t.image=s,t.flipY=this.flipY,t.premultiplyAlpha=this.premultiplyAlpha,t.colorSpace=this.colorSpaceConversion?l:h,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":"none",premultiplyAlpha:this.premultiplyAlpha?"premultiply":"none"}))).then((t=>{const s=new _(t);s.flipY=this.flipY,s.premultiplyAlpha=this.premultiplyAlpha,s.colorSpace=this.colorSpaceConversion?l:h,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 Ue extends Me{constructor(e,t,s,i){super(e,t,i),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 je extends Me{constructor(e,t,s,i){super(e,t,i),this.loader=new c,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=>{}),(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 Oe extends Me{constructor(e,t,s){super(e,t,s),this.loader=new he}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 Ie extends Ae{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 Le(s.name,s.url,s.size));break;case"basis":e.push(new Ue(s.name,s.url,Fe.get("basis_loader"),s.size));break;case"hdr":e.push(new Oe(s.name,s.url,s.size));break;case"cubemap":e.push(new je(s.name,s.url,s.extension,s.size))}}return e}}class Ne{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 Be{constructor(e,{SceneCompilator:t,TexturesCompilator:s,AudiosCompilator:i}){this.scene=e,this.SceneCompilator=t,this.TexturesCompilator=s,this.AudiosCompilator=i,this.loaders=[],this.compilators=[],this.callback_called=!1}set_assets(e,t,s,i=[],r=[],n=[]){this.scene_objects=e,this.scene_textures=t,this.scene_sounds=s,this.custom_loaders=i,this.custom_compilators=r,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=_e.get("assets_worker");t.postMessage({type:"reset",loader_name:this.scene.name});const s=new Pe(this.scene.name,this.scene_objects,t);this.loaders.push(s),e.push(new this.SceneCompilator(this.scene));const i=new Ie(this.scene.name,this.scene_textures,t);this.loaders.push(i),e.push(new this.TexturesCompilator(i.get_assets_names()));const r=new Re(this.scene.name,this.scene_sounds,t);this.loaders.push(r),e.push(new this.AudiosCompilator(r.get_assets_names()));for(let s=0;s<this.custom_loaders.length;s++){const i=new this.custom_loaders[s](this.scene.name,this.custom_data[s],t);this.loaders.push(i),e.push(new this.custom_compilators[s](i.get_assets_names()))}this.compilator_manager=new Ne(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 Ve extends Be{on_enter(){super.on_enter()}on_exit(){super.on_exit()}update(){super.update(),this.is_loaded()&&this.scene.on_high_quality_assets_ready()}}class qe extends Be{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 Ye extends u{constructor({name:e,compilators:t}){super(),this.name=e,this.is_loaded=!1,this.is_high_loaded=!1,this.loading_states={regular:new qe(this,t),high:new Ve(this,t)},this.current_loading_state=new Be(this,t)}get loading_progress(){return this.current_loading_state.loading_progress}init(){}load(){this.init(),this.set_loading_state(this.loading_states.regular),this.current_loading_state.load()}get_objects(){const e=[];return this.traverse((t=>{t.geometry&&e.push(t)})),e}dispose_cpu(){this.traverse((e=>{if(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)}))}dispose(){this.traverse((e=>{e.material&&(e.material.map&&e.material.map.dispose(),e.material.dispose(),e.geometry.dispose())}))}set_assets(e,t,s,i,r,n){this.loading_states.regular.set_assets(e,t,s,i,r,n)}set_high_assets(e,t,s,i,r,n){this.loading_states.high.set_assets(e,t,s,i,r,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}}class Ge{constructor(){}static linear_map(e,t,s,i,r){return(e-t)/(s-t)*(r-i)+i}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*e.r).toString(16),e.g=Math.round(255*e.g).toString(16),e.b=Math.round(255*e.b).toString(16),1===e.r.length&&(e.r="0"+e.r),1===e.g.length&&(e.g="0"+e.g),1===e.b.length&&(e.b="0"+e.b),"#"+e.r+e.g+e.b}static project_points_on_plane(e,t){const s=e[0].clone();s.set(0,0,0);const i=[];for(let r=0;r<e.length;r++)t.projectPoint(e[r],s),i.push(s.clone());return i}static matrix4_lerp(e,t,s,i){for(let r=0;r<16;r++)s.elements[r]=this.lerp(e.elements[r],t.elements[r],i)}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(Ge.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 Ge.clamp(e,0,1)}}class Ee{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=Ge.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=Ge.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return Ge.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,i=!1){if(i){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 r={from:e,to:t,interpolator:s};this.duration=Math.max(this.duration,t),this.channels[s.attribute_name].push(r)}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 i=s[t],r=this.__get_current_keyframe(i,e);this.context[i]=this.evaluate_keyframe(r,e)}}__play_events(e,t){for(let s=0;s<this.action_events.length;s++){const i=this.action_events[s].trigger_time;Ge.between(i,e,t)&&(console.log("Play event: "+this.action_events[s].action.constructor.name+" at "+this.action_events[s].trigger_time),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(Ge.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 Ge.saturate((e-t)/(s-t)*1+0)}__get_current_keyframe(e,t){let s;const i=this.channels[e];for(let e=0;e<i.length;e++){const r=i[e];if(t>=r.from&&t<=r.to)return s=r,s}let r=1/0;for(let e=0;e<i.length;e++){const n=i[e],o=Math.abs(n.to-t);o<r&&(s=n,r=o)}return s}__get_playback_speed(){const e=new URLSearchParams(window.location.search).get("transitions_velocity");return e?Number(e):1}}class We{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 Xe{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?We[e]:e}update(e,t){}}class Qe extends Xe{constructor(e,t=0,s=1,i=!1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=s,this.initial=i}update(e,t){e[this.attribute_name]=Ge.lerp(this.from,this.to,this.easing_function(t))}evaluate(e){return Ge.lerp(this.from,this.to,this.easing_function(e))}}class He{constructor(e,t,s){this.name=e,this.method=t,this.args=s}trigger(){ViewApi.application[this.name][this.method](...this.args.split(","))}}class $e{constructor(){}parse(e){const t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),s=[],i=[];for(let e=0;e<t.length;e++){const r=t[e],n=r.parentElement,o=n.getAttribute("value"),a=this.get_node_x_position(r)/100,_=parseFloat(r.getAttribute("width"))/100;if(n.getAttribute("style").includes("rhombus;")){const e=o.split("."),t=e[0],s=e[1];i.push({name:t,method:s,at_time:a+.5*_})}if(n.getAttribute("style").includes("rounded=0;")&&!n.getAttribute("style").includes("text;")&&""!==o&&!o.includes(" ")){const e=o.split("="),t=e[0],i=e[1].split("--"),r=parseFloat(i[0]),n=i[1];2!==e.length&&console.error("DrawIO data is malformed:",o),2!==i.length&&console.error("DrawIO data is malformed:",o),s.push({attribute_name:t,from_time:a,to_time:a+_,to_value:r,easing_function:n})}}return s.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:s,triggers:i}}get_node_x_position(e){const t=e.getAttribute("x");return null===t?0:parseFloat(t)}}class Ze{constructor(e){this.default_state_data=e}from_animation_sheet(e,t,s){s=s||this.default_state_data;const i=e.animation_tracks,r=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===i.find((t=>t.attribute_name===n[e].attribute_name))&&i.push(n[e]);const o=new Ee(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Qe(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,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new He(t.name,t.method,t.args);o.add_action_event(t.at_time,s)}return o}state_to_tracks(e,t){const s=[],i=Object.keys(e);for(let r=0;r<i.length;r++)s.push({attribute_name:i[r],from_time:0,to_time:t<1?t:1,to_value:e[i[r]],initial:!0,easing_function:"ease_in_out_cubic"});return s}from_draw_io(e,t){const s=(new $e).parse(e),i=s.animation_tracks,r=s.triggers,n=new Ee(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Qe(s.attribute_name,t[s.attribute_name],s.to_value,s.initial,s.easing_function);n.add_action_interpolator(s.from_time,s.to_time,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new He(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 i=e[s].to_time;t=i>t?i:t}return t}}class Je{constructor(){this.transitions=[],this.default_state_data={}}get(e,t,s){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].from===e&&this.transitions[i].to===t){return new Ze(this.default_state_data).from_animation_sheet(this.transitions[i].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 Ze(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 Ke=new class{constructor(){this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016]}init(){this.___time=new d,this.__delta_time=0,this.__smooth_delta_time=0,this.__elapsed_time=0,this.__allocated_time=new t(0,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 shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_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(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime(),this.__delta_buffer.shift(),this.__delta_buffer.push(this.delta_time<.32?this.delta_time:.032),this.__calculate_smooth_delta_time()}__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 et{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 tt{constructor(e){this.last_state=new et,this.current_state=new et,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(Ke.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 st=new class{constructor(){this.transition_table=new Je,this.transition_handler=new tt(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)}set_transitions_velocity(e){this.transition_table.set_transitions_velocity(e)}};const it=new class{constructor(){this.views=[],this.browser_title_suffix=""}update(){this.__set_views_opacities()}go_to_view(e,t=!0,s=!1){const i=this.get(e);t&&(this.__change_browser_url(i.url),this.__change_browser_title(i.url)),st.go_to_state(i,s)}go_to_scene(e,t=!1,s=!1){const i=this.get(e),r=this.get("transition");r.set_next_view(i),this.go_to_view(r.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);st.set_state(t)}set_browser_title_suffix(e){this.browser_title_suffix=e}get_current_view(){return st.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(st.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 rt extends et{constructor({name:e,url:t,container:s,transition_data:i}){super(e),this.container=s,this.url=t,this.current_opacity=0;const r=[{to:e,data:i=i||{animation_tracks:[],triggers:[]}}];it.register_view(this),st.add_transitions(r)}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)}}const nt=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}};class ot{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"),i=document.createTextNode("MÉqgOLAKTAL");s.appendChild(i),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 i=new t;return this.ctx.font=s,i.x=Math.ceil(this.ctx.measureText(e).width),i.y=Math.ceil(this.getFontHeight(s)),i}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),i=new p(s,m,g,g,f,f);return i.generateMipMaps=!1,i.needsUpdate=!0,i}__draw(e,t){}roundRect(e,t,s,i,r,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)n[t]=n[t]||e[t]}e.beginPath(),e.moveTo(t+n.tl,s),e.lineTo(t+i-n.tr,s),e.quadraticCurveTo(t+i,s,t+i,s+n.tr),e.lineTo(t+i,s+r-n.br),e.quadraticCurveTo(t+i,s+r,t+i-n.br,s+r),e.lineTo(t+n.bl,s+r),e.quadraticCurveTo(t,s+r,t,s+r-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 at extends ot{constructor(){super(),this.text_margin=new t(2,0)}__draw(e,t,s,i){i.font=t.font;const r=this.get_text_size(e,t.font);s.width=Math.ceil(r.x+2*this.text_margin.x),s.height=Math.ceil(r.y+2*this.text_margin.y),i.clearRect(0,0,s.width,s.height),i.globalAlpha=0,i.fillStyle=t.font_color||"#000000",i.fillRect(0,0,s.width,s.height),i.globalAlpha=1,i.globalAlpha=1,i.font=t.font,i.fillStyle=t.font_color||"#000000",i.textBaseline="middle",i.textAlign=t.textAlign||"center","center"===i.textAlign?i.fillText(e,s.width/2,s.height/2):i.fillText(e,0,s.height/2)}}const _t=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class lt extends v{constructor(e=1){super();const t=[];t.push(new x(0,0,0)),t.push(new x(0,0,1e3));const s=new w({color:4474111,depthFunc:i}),r=(new b).setFromPoints(t),n=new y(r,s);n.renderOrder=5e4;const o=[];o.push(new x(0,0,0)),o.push(new x(0,1e3,0));const a=new w({color:4521796,depthFunc:i}),_=(new b).setFromPoints(o),l=new y(_,a);l.renderOrder=5e4;const h=[];h.push(new x(0,0,0)),h.push(new x(1e3,0,0));const c=new w({color:16729156,depthFunc:i}),u=(new b).setFromPoints(h),d=new y(u,c);d.renderOrder=5e4,this.renderOrder=1e5,this.add(n),this.add(l),this.add(d),this.scale.set(e,e,e)}update(){}dispose(){}}const ht=new class{init(){this._current=new u,this._current.name="default_scene"}add_scene(e){}get current(){return this._current}set current(e){this._current=e}dispose(){for(this.current.traverse((e=>{e.geometry&&(e.geometry.dispose(),e.material.dispose())}));this.current.children.length>0;)this.current.remove(this.current.children[0])}};class ct extends T{constructor(e,t,s){e=e||new x(1,1,1),t=t||new x(1,1,1),s=s||16711680;super(new M(e.x,e.y,e.z,t.x,t.y,t.z),new S({color:s}))}}class ut extends T{constructor(e,t){t=t||"#FF0000";super(new z(e=e||1,64,64),new S({color:t}))}}class dt extends T{constructor(e,t,s){e=e||"#FF0000";const i=(t=t||1)-.4,r=new F(.01,.01,i,32);r.translate(0,i/2,0);const n=new A(.1,.4,32);n.translate(0,i+.2,0);const o=ce.mergeGeometries([r,n]);o.rotateX(1.57);super(o,new S({color:e})),s&&this.quaternion.setFromUnitVectors(new x(0,0,1),s),this._dir=s}set dir(e){this.quaternion.setFromUnitVectors(new x(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}}const pt=new class{init(){this.width=window.innerWidth,this.height=window.innerHeight,this.position=new t,this.render_width=window.innerWidth,this.render_height=window.innerHeight,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}};class mt extends be{constructor(e,s,i,r){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 gt extends R{constructor(e,t,s,i){super(e,t,s,i),this.clear_color=new r("#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}}const ft=new class{init(){this.Vector3_one=new x(1,1,1),this.Vector3_zero=new x(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new u,this.camera=new gt(60,pt.aspect_ratio,.1,1e3),this.camera.clear_alpha=0}draw_arrow(e,t,s=16711680){const i=new dt(s,t.length(),t.clone().normalize());return i.position.copy(e),this.scene.add(i),i}draw_axis(){const e=new lt;return this.scene.add(e),e}set_debug_RT(e){this.rt_debug=e}draw_rectangle(e,t,s,i){t=t||100,s=s||100,this.ctx.fillStyle=i||"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 w({color:t}),i=(new b).setFromPoints(e),r=new y(i,s);return r.frustumCulled=!1,this.scene.add(r),r}draw_cube(e,t,s){t=t||1,s=s||16711680,e=e||new x;const i=new ct(new x(t,t,t),void 0,s);return i.position.copy(e),this.scene.add(i),i}draw_oriented_cube(e,t,s=1,i="#FF0000",r=.1){const n=e.distanceTo(t),o=new ct(new x(r,s,n),void 0,i),a=t.clone().sub(e).multiplyScalar(.5),_=a.clone().normalize();return a.add(e),o.position.copy(a),o.quaternion.setFromUnitVectors(new x(0,0,-1),_),this.scene.add(o),o}draw_plane(t,s,i){const r=new C(t,s),n=new e({uniforms:{_Color:{value:new k(0,1,0,.2)}},vertexShader:xe,fragmentShader:we,transparent:!0,depthWrite:!1}),o=new T(r,n);return o.renderOrder=-1e4,this.scene.add(o),o}draw_empty_cube(e,t,s){t=t||1,s=s||16711680;const i=(new P).setFromCenterAndSize(new x,new x(t,t,t)),r=new D(i,s);return r.position.copy(e||new x),r}draw_sphere(e,t,s){t=t||1,s=s||16711680,e=e||new x;const i=new ut(t,s);return i.position.copy(e),this.scene.add(i),i}draw_point_array(e,t=!1,s=16711680){const i=new L(e,t);i.updateArcLengths();const r=i.getSpacedPoints(200);return this.draw_line(r,65280)}draw_sphere_helper(e,t){t=t||16711680;const s=new z(e.radius,32,32),i=new S({color:t}),r=new T(s,i);return r.position.copy(e.center),ht.current.add(r),r}draw_math_sphere(t){const s=new z(t.radius,32,32),i=new e({uniforms:{_Color:{value:new k(1,0,0,.2)}},vertexShader:xe,fragmentShader:we,transparent:!0}),r=new T(s,i);r.position.copy(t.center),ht.current.add(r)}draw_bounding_box(e){const t=new D(e,16776960);ht.current.add(t)}draw_curve(e,t){const s=new x(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 i=new T(new C(1,1),new mt);return this.display_texture_meshes.push(i),this.scene.add(i),i.material.set_texture(e,t,s),i}render(e){for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(pt.width,pt.height);this.scene.children.length>0&&e.render(this.scene,nt.current)}};class vt{constructor(e){this.renderer=e,this._blit_scene=new u,this._blit_material=new fe,this._blit_quad=new T(new C(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new U(-1,1,1,-1,-1e4,1e4)}blit(e,t){this._blit_quad.material=this._blit_material;const s=!0===e.isWebGLRenderTarget?e.texture:e,i=!0===e.isWebGLRenderTarget?e.width:e.image.width,r=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=s,this._blit_quad.material.uniforms._Resolution.value.set(i,r),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 i=!0===e.isWebGLRenderTarget?e.texture:e,r=!0===e.isWebGLRenderTarget?e.width:e.image.width,n=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material=s,this._blit_quad.material.uniforms._MainTex.value=i,this._blit_quad.material.uniforms._Resolution.value.set(r,n),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}blit_clear_with_material(e,t){this._blit_quad.material=t,this.__render(e)}dispose(){this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose()}__render(e){e=void 0===e?null:e;const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(void 0===e?null:e),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(t)}}class xt extends fe{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 k(e,t.x,t.y,t.z)}}}class wt 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 bt{constructor(){this.RT=new j(pt.width,pt.height),this.clear_depth_normal_mat=new xt(1,new x(0,0,1)),this.depth_normal_material=new wt}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=nt.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===pt.width&&this.RT.height===pt.height||this.RT.setSize(pt.width,pt.height)}get render_target(){return this.RT}}const yt=new class{init({canvas:e,core_attributes:t,context_attributes:s,threejs_attributes:i,dpr:r}){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.core_attributes={force_webgl2:!0,xr_enabled:!1},this.context_attributes={alpha:!0,antialias:!1,depth:!0,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!1},this.threejs_attributes={logarithmicDepthBuffer:!1},Object.assign(this.core_attributes,t),Object.assign(this.context_attributes,s),Object.assign(this.threejs_attributes,this.context_attributes),Object.assign(this.threejs_attributes,i),this.core_attributes.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,this.threejs_attributes.canvas=e,this.threejs_attributes.context=this.canvas_context,this._renderer=new O(this.threejs_attributes),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,pt.dpr=r,this._renderer.setPixelRatio(1),this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new vt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new Te,this.current_render_mode=this.no_render,_t.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),_t.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,_t.fp_textures_available=this.is_floating_point_texture_available(),this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new bt}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.generateDepthNormalTexture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),nt.current&&this.current_render_mode.render(),pt.update()}__update_current_camera(){nt.current&&(nt.current.aspect=pt.aspect_ratio,nt.current.updateProjectionMatrix(),nt.current.updateMatrix(),nt.current.updateMatrixWorld(!0))}render(e,t,s,i){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.render(e||ht.current,t||nt.current),this.__apply_override_material(e,void 0)}compile(e,t,s,i){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.compile(e||ht.current,t||nt.current),this.__apply_override_material(e,void 0)}async compile_async(e,t,s,i,r){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s);const n=this._renderer.compileAsync(e||ht.current,t||nt.current,r);return this.__apply_override_material(e,void 0),n}render_scene(e){e.on_pre_render&&e.on_pre_render(),e.render?e.render():this.render(e,void 0),e.on_post_render&&e.on_post_render()}__apply_override_material(e,t){t=void 0===t?null:t,e?e.overrideMaterial=t:ht.current.overrideMaterial=t}readback_RT(e,t){this._renderer.readRenderTargetPixels(e,0,0,e.width,e.height,t)}clear(e,t,s,i){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!s,!!i)}on_resize(e,t){for(const s of e)pt.dpr=t,pt.update_position(s.contentRect.x,s.contentRect.y),pt.update_size(s.contentRect.width,s.contentRect.height),this.canvas.width=pt.render_width,this.canvas.height=pt.render_height,this._renderer.setViewport(0,0,pt.render_width,pt.render_height),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=pt.width,s=pt.height){const i=pt.width,r=pt.height,n=t,o=s,a=1024,_=1024,l=parseInt(Math.ceil(n/a)),h=parseInt(Math.ceil(o/_));pt.update_size(a,_);const c=this._renderer.getPixelRatio();this._renderer.setPixelRatio(1),this._renderer.setSize(a,_,!1);const u=document.createElement("canvas").getContext("2d");u.canvas.width=n,u.canvas.height=o,nt.current.aspect=pt.aspect_ratio,nt.current.updateMatrix(),nt.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)nt.current.setViewOffset(n,o,pt.width*e,pt.height*t,pt.width,pt.height),this.current_render_mode.render(),u.drawImage(this._renderer.domElement,pt.width*e,pt.height*t);u.canvas.toBlob(e,"image/png;base64;"),nt.current.clearViewOffset(),pt.update_size(i,r),this._renderer.setPixelRatio(c),this._renderer.setSize(i,r,!1),nt.current.aspect=pt.aspect_ratio,nt.current.updateMatrix(),nt.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()}is_floating_point_texture_available(){const t=new j(1,1,{minFilter:f,magFilter:f,format:I,colorSpace:N,type:B,stencilBuffer:!1,depthBuffer:!1}),r=new e({vertexShader:"\n void main()\n {\n gl_Position = vec4(uv * 2.0 - 1.0, 1.0, 1.0);\n }\n ",fragmentShader:"\n void main()\n {\n gl_FragColor = vec4(0.0, 4865.35, 0.0, 1.0);\n }\n ",depthWrite:!1,blending:s,depthTest:!1,depthFunc:i});this.material_pass(r,t);const n=new Float32Array(4);return this._renderer.readRenderTargetPixels(t,0,0,1,1,n),Math.abs(n[1]-4865.35)<.001}};class Tt{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Mt{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(e){this.t+=Ke.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=Ge.clamp(this.easing_function_t,0,1),e.set_property_value(Ge.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 Tt),e.finished_callback(e))}on_exit(e){}}class St{constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n="",value_suffix:o="",easing_function:a=We.ease_in_out_cubic,finished_callback:_=()=>{}}){this.element=e,this.css_property=t,this.from=s,this.to=i,this.value_prefix=n,this.value_suffix=o,this.duration=r,this.easing_function=a,this.finished_callback=_,this.current_state=new Tt}animate(){this.set_current_state(new Mt)}stop(){this.set_current_state(new Tt)}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 zt=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 Ft=new class{init(){this.target_geometry=void 0,this.target_position=new x}set_target_geometry(e){this.target_geometry=e}};class At{constructor(e,s){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=s,this.data_textures=[],this.object_names=void 0,this.zero_offset=new t,this.write_offset=new t,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(t,s,i){this.material=new e({uniforms:this.uniforms,vertexShader:s,fragmentShader:i}),this.object_names=t}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){const s=this.__create_rgb_texture(this.batch_width),i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){const s=this.__create_rgba_texture(this.batch_width),i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){const s=this.__create_rgba_float_texture(this.batch_width),i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,s,i,r,n){const o=this.__get_object_index(e),a=this.__get_data_texture(t);this.__set_pixel_rgb(a.src,o,s,i,r,n),this.__set_pixel_rgb(a.one_pixel,0,s,i,r,n),a.last_accessed_index=o,a.dirty_count++}set_object_uniform_v4(e,t,s,i,r,n,o){const a=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,a,s,i,r,n,o),this.__set_pixel_rgba(_.one_pixel,0,s,i,r,n,o),_.last_accessed_index=a,_.dirty_count++}upload_texture_data(e,t){for(let s=0;s<this.data_textures.length;s++)t>0&&this.data_textures[s].dirty_count>0&&(1===this.data_textures[s].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){const s=t.last_accessed_index;-1!==s&&(this.write_offset.y=Math.floor(s/this.batch_width),this.write_offset.x=s-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new T(this.geometry,this.material)}__set_pixel_rgb(e,t,s,i,r,n){i&&(e.image.data[3*t+0]=s.x),r&&(e.image.data[3*t+1]=s.y),n&&(e.image.data[3*t+2]=s.z)}__set_pixel_rgba(e,t,s,i,r,n,o){i&&(e.image.data[4*t+0]=s.x),r&&(e.image.data[4*t+1]=s.y),n&&(e.image.data[4*t+2]=s.z),o&&(e.image.data[4*t+3]=s.w)}__flood_data_texture_rgb(e,t){for(let s=0;s<this.batch_width*this.batch_width;s++)this.__set_pixel_rgb(e.src,s,t,!0,!0,!0),e.dirty_count++}__flood_data_texture_rgba(e,t){for(let s=0;s<this.batch_width*this.batch_width;s++)this.__set_pixel_rgba(e.src,s,t,!0,!0,!0,!0),e.dirty_count++}__create_rgb_texture(e){const t=new Uint8Array(3*e*e);return new V(t,e,e,I)}__create_rgba_texture(e){const t=new Uint8Array(4*e*e);return new V(t,e,e,I)}__create_rgba_float_texture(e){const t=new Float32Array(4*e*e);return new V(t,e,e,I,B)}__get_data_texture(e){for(let t=0;t<this.data_textures.length;t++)if(this.data_textures[t].name===e)return this.data_textures[t];console.error("Data texture "+e+" does not exist")}__get_object_index(e){for(let t=0;t<this.object_names.length;t++)if(this.object_names[t]===e)return t;console.error("the name "+e+" is not contained in this batch")}__add_data_texture(e,t,s,i){return s.needsUpdate=!0,this.data_textures.push({name:e,src:t,dst:s,one_pixel:i,last_accessed_index:-1,dirty_count:0}),this.uniforms[e]={value:s},this.data_textures[this.data_textures.length-1]}dispose(){for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].src.dispose(),this.data_textures[e].dst.dispose(),this.data_textures[e].one_pixel.dispose()}}const Rt=new class{init(){this.batches=[]}batch(e){const t=[],s=Ge.ceilPowerOfTwo(Math.sqrt(e.length));this.__init_uv_array(t,s);let i=0;for(let r=0;r<e.length;r++){const n=e[r].getAttribute("position").count,o=Math.floor(r/s),a=r-s*o;for(let e=0;e<n;e++)t[i]=a/s+.5/s,t[i+1]=o/s+.5/s,i+=2}const r=new q(new Float32Array(t),2),n=ce.mergeGeometries(e);return n.setAttribute("attr_accessor_uv",r),this.batches.push(new At(n,s)),this.batches[this.batches.length-1]}upload_texture_data(e){for(let t=0;t<this.batches.length;t++)this.batches[t].upload_texture_data(e,1)}__init_uv_array(e,t){for(let s=0;s<t*t*2;s++)e.push(0)}};const Ct=new class{init(e){this.input=e,this.ui_elements=[],this._tmp_normalized_pos=new t,this.ss_scene=new u,this.ss_scene.matrixWorldAutoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new u,this.ws_scene.matrixWorldAutoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new U(-1,1,1,-1,-100,100)}delete_element(e){const t=this.ui_elements.indexOf(e);t>-1&&this.ui_elements.splice(t,1),this.ss_scene.remove(e),this.ws_scene.remove(e),e.dispose()}add_screen_space_element(e){this.ui_elements.push(e),this.ss_scene.add(e),e.set_screen_space_coordinate_system()}add_world_space_element(e){this.ui_elements.push(e),this.ws_scene.add(e),e.set_world_space_coordinate_system()}update(){this.ss_camera.updateProjectionMatrix(),this._tmp_normalized_pos.copy(this.input.NDC);for(let e=0;e<this.ui_elements.length;e++)this.ui_elements[e].update_state(this._tmp_normalized_pos)}render(e){this.ss_scene.children.length>0&&yt.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&yt.render(this.ws_scene,nt.current)}clear(){this.current_clicked_element=void 0}};class kt{constructor(){this.sphere=new Y}fit_points(e,t,s,i){this.sphere.setFromPoints(e);const r=Ge.degToRad(s/2),n=2*Math.atan(Math.tan(r)*i)/2,o=this.get_up_plane_normal(t,r),a=this.get_down_plane_normal(t,r),_=this.get_left_plane_normal(t,n),l=this.get_right_plane_normal(t,n),h=new x(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,i),d=c.clone().add(h.clone().multiplyScalar(-1*u)),p=(new G).setFromNormalAndCoplanarPoint(o,d),m=(new G).setFromNormalAndCoplanarPoint(a,d),g=(new G).setFromNormalAndCoplanarPoint(_,d),f=(new G).setFromNormalAndCoplanarPoint(l,d);this.apply_center_correction_to_pos(d,e,t,p,m,g,f),p.setFromNormalAndCoplanarPoint(o,d),m.setFromNormalAndCoplanarPoint(a,d),g.setFromNormalAndCoplanarPoint(_,d),f.setFromNormalAndCoplanarPoint(l,d);let v=1/0;const w=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){const s=new E(e[t].clone(),e[t].clone().add(w)),i=new x,r=new x,n=new x,o=new x;p.intersectLine(s,i),m.intersectLine(s,r),g.intersectLine(s,n),f.intersectLine(s,o),i.length()<1e-4&&console.log("up intersection not found",t),r.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(i).length(),_=e[t].clone().sub(r).length(),l=e[t].clone().sub(n).length(),h=e[t].clone().sub(o).length(),c=Math.min(a,_),u=Math.min(l,h),d=Math.min(c,u);d<v&&(v=d)}const b=h.clone().multiplyScalar(v);return d.clone().add(b)}apply_center_correction_to_pos(e,t,s,i,r,n,o){const a=this.get_vertical_correction(t,r,i,s),_=this.get_horizontal_correction(t,n,o,s);e.add(a),e.add(_)}get_vertical_correction(e,t,s,i){let r=1/0,n=1/0;const o=new x(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new E(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new E(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new x,h=new x;t.intersectLine(a,l),s.intersectLine(_,h);const c=l.distanceTo(e[i]),u=h.distanceTo(e[i]);h.length()<1e-4&&console.log("vertical up intersection not found",i),l.length()<1e-4&&console.log("vertical down intersection not found",i),c<n&&(n=c),u<r&&(r=u)}const a=(r-n)/2;return o.clone().multiplyScalar(-a)}get_horizontal_correction(e,t,s,i){let r=1/0,n=1/0;const o=new x(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new E(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new E(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new x,h=new x;t.intersectLine(a,l),s.intersectLine(_,h);const c=l.distanceTo(e[i]),u=h.distanceTo(e[i]);l.length()<1e-4&&console.log("left intersection not found",i),h.length()<1e-4&&console.log("right intersection not found",i),c<n&&(n=c),u<r&&(r=u)}const a=(r-n)/2;return o.clone().multiplyScalar(-a)}get_up_plane_normal(e,t){const s=new x(0,-1,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new x(0,1,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new x(1,0,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new x(-1,0,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(0,1,0),-t)),s.applyQuaternion(e),s}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class Pt{constructor(){}fit_points(e,t,s,i){const r=t.clone().inverse(),n=[];for(let t=0;t<e.length;t++)n.push(e[t].clone().applyQuaternion(r));const o=(new P).setFromPoints(n),a=new x;o.getSize(a);const _=this.get_distance_to_fit_rect(a.x/2,a.y/2,s,i),l=new x;return o.getCenter(l),l.applyQuaternion(t),{center:l,distance_to_center:_}}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}const Dt=new class{init(e){this.tmp_mat=new X,this.plane=new G,this.ray=new Q,this.tmp_size=new x,this.tmp_unproj=new x,this.input=e}get_up_dir(e){e=e||nt.current;const t=new x;return t.set(0,1,0),t.applyQuaternion(e.quaternion),t}get_forward_dir(e){e=e||nt.current;const t=new x;return t.set(0,0,-1),t.applyQuaternion(e.quaternion),t}get_right_dir(e){e=e||nt.current;const t=new x;return t.set(1,0,0),t.applyQuaternion(e.quaternion),t}unproject_mouse_position(e,t){t=t||nt.current;const s=new x,i=t.fov/2*Math.PI/180,r=2*Math.atan(Math.tan(i)*t.aspect)/2,n=Math.tan(i)*t.far,o=Math.tan(r)*t.far;return s.set(o*e.x,n*e.y,-t.far).normalize(),s.applyQuaternion(t.quaternion)}get_plane_intersection(e,t,s,i){i=i||nt.current,s=s||this.input.NDC;const r=new x;return this.plane.setFromNormalAndCoplanarPoint(t||this.get_forward_dir(i),e),i.isPerspectiveCamera?this.ray.set(i.position,this.unproject_mouse_position(s,i)):(this.tmp_unproj.set(s.x,s.y,1).unproject(i),this.ray.set(i.position,this.tmp_unproj)),this.ray.intersectPlane(this.plane,r),r}fit_points_on_camera(e,t=1){const s=(new Y).setFromPoints(e).center,i=this.get_forward_dir(nt.current).clone(),r=(new G).setFromNormalAndCoplanarPoint(i,s),n=Ge.project_points_on_plane(e,r),o=new x;let a=(new P).setFromPoints(n);a.getCenter(o);const _=new x(0,1,0).applyQuaternion(nt.current.quaternion),l=_.clone().cross(i).normalize(),h=(new X).set(l.x,_.x,i.x,s.x,l.y,_.y,i.y,s.y,l.z,_.z,i.z,s.z,0,0,0,1),c=(new X).getInverse(h);for(let e=0;e<n.length;e++)n[e].applyMatrix4(c);const u=new x;a=(new P).setFromPoints(n),a.getSize(u),u.multiplyScalar(t);const d=new x;return a.getCenter(d),{position:o,zoom:this.get_zoom_to_fit_rect(u.x/2,u.y/2)}}get_zoom_to_fit_rect(e,t){const s=nt.current.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(s)*nt.current.aspect)/2,r=t/Math.tan(s),n=e/Math.tan(i);return Math.max(Math.abs(n),Math.abs(r))}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,i=t/s;return pt.aspect_ratio/i>1?pt.height/s:pt.width/t}{const t=new x;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){t=t||nt.current;const s=new x;return e.getWorldPosition(s),s.project(t),s.x=(.5*s.x+.5)*pt.width,s.y=(1-(.5*s.y+.5))*pt.height,s}world_pos_to_screen(e,t){t=t||nt.current;const s=new x;return s.copy(e),s.project(t),s.x=(.5*s.x+.5)*pt.width,s.y=(1-(.5*s.y+.5))*pt.height,s}update_projection(e){e.left=-pt.width/2,e.right=pt.width/2,e.top=pt.height/2,e.bottom=-pt.height/2,e.aspect=pt.aspect_ratio,e.updateProjectionMatrix(!0)}fit_bounding_box_points(e,t,s=1){const i=new x;i.copy(t.max).sub(t.min);const r=t.min.clone(),n=r.clone().add(new x(i.x,0,0)),o=r.clone().add(new x(0,i.y,0)),a=r.clone().add(new x(0,0,i.z)),_=r.clone().add(new x(i.x,0,i.z)),l=r.clone().add(new x(0,i.y,i.z)),h=t.max.clone(),c=r.clone().add(new x(i.x,i.y,0));return this.fit_points(e,[r,n,o,a,_,l,h,c],s)}fit_points(e,t,s=1){if(e.isPerspectiveCamera){const i=new x(0,0,-1).applyQuaternion(e.quaternion),r=i.clone().multiplyScalar(-1),n=new kt,o=pt.aspect_ratio,a=n.fit_points(t,e.quaternion,e.fov*s,o),_=(new P).setFromPoints(t),l=new x;_.getCenter(l);const h=(new G).setFromNormalAndCoplanarPoint(r,l),c=new Q(a,i),u=new x;c.intersectPlane(h,u);return{zoom:a.distanceTo(u),reference_position:u,camera_position:a}}{const i=(new Pt).fit_points(t,this.reference_rotation,e.fov*s,pt.aspect_ratio);this.reference_position.copy(i.center),this.reference_zoom=i.distance_to_center;const r=new x(0,0,1).applyQuaternion(e.quaternion);return{zoom:i.distance_to_center,reference_position:i.center,camera_position:r.multiplyScalar(i.distance_to_center)}}}};const Lt=new class{constructor(){}init(e){nt.init(),Dt.init(e),_t.init(),Rt.init(),zt.init(),De.init(),Ft.init(),Fe.init(),ht.init(),pt.init(),Ke.init(),Ct.init(e),ft.init()}dispose(e){yt.dispose(),ht.dispose(),e.dispose()}};class Ut{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},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 jt extends U{constructor(e,t,s,i,n,o){super(e,t,s,i,n,o),this.clear_color=new r("#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 Ot 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 It extends Te{constructor(){super()}render(){yt.clear(void 0,nt.current,!0,!0),yt.render(ht.current,nt.current,void 0,new Ot)}}var Nt="#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 Bt extends fe{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);}",Nt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new X}}}class Vt extends fe{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 qt extends fe{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;}",Nt),this.uniforms._InverseProjMatrix={value:new X},this.uniforms._ProjectionMatrix={value:new X},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 x(2*Math.random()-1,2*Math.random()-1,Math.random());s.normalize();let i=t/64;i=Ge.lerp(.1,1,i*i),s.multiplyScalar(i),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,I);return t.wrapS=H,t.wrapT=H,t.needsUpdate=!0,t}}class Yt extends fe{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 Gt{constructor(e){this.RT1=new j(1,1),this.RT2=new j(1,1),this.box_blur_mat=new Yt}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),yt.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),yt.blit(this.RT1,e,this.box_blur_mat)}}class Et extends Te{constructor(e=!1){super(),this.ssao_mat=new qt,this.ssao_compose_mat=new Vt,this.debug_normals=new Bt,this.ssaa=e?2:1,this.main_RT=new j(pt.width*this.ssaa,pt.height*this.ssaa),this.SSAO_RT=new j(pt.width,pt.height),this.blurrer=new Gt,yt.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),yt.clear(this.main_RT,nt.current,!0,!1),yt.render(ht.current,nt.current,this.main_RT),this.__update_uniforms(),yt.blit(yt.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),yt.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,yt.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(nt.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(nt.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=nt.current.far}__check_RT_size(){this.main_RT.width===pt.width*this.ssaa&&this.main_RT.height===pt.height*this.ssaa||(this.main_RT.setSize(pt.width*this.ssaa,pt.height*this.ssaa),this.SSAO_RT.setSize(pt.width,pt.height))}}class Wt extends Te{constructor(){super()}render(){yt.clear(void 0,nt.current,!0,!0),ht.current.on_pre_render&&ht.current.on_pre_render(),ht.current.render?ht.current.render():yt.render(ht.current,nt.current),ht.current.on_post_render&&ht.current.on_post_render()}}class Xt extends fe{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new t(.5,.5)},this.uniforms.direction={value:new t(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class Qt extends fe{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new r("#000000")},this.uniforms.defaultOpacity={value:0}}}class Ht{constructor(e=5){this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=e,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:$,magFilter:$,format:I},this.renderTargetBright=new j(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Qt}blur(e,t){this.resize_RT(e.width,e.height),t?yt.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):yt.blit(e,this.renderTargetBright);let s=this.renderTargetBright;for(let e=0;e<this.nMips;e++){const t=this.separableBlurMaterials[e];t.set_direction(1,0),yt.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),yt.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 j(1,1,this.rt_pars),t=new j(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e),this.renderTargetsVertical.push(t)}}resize_RT(e,t){if(this.current_width===e&&this.current_height===t)return;this.current_width=e,this.current_height=t;let s=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(s,i);for(let e=0;e<this.nMips;e++)this.renderTargetsVertical[e].setSize(s,i),this.renderTargetsHorizontal[e].setSize(s,i),this.separableBlurMaterials[e].set_size(s,i),s=Math.round(s/2),i=Math.round(i/2)}init_materials(e,t){this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new Xt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class $t extends Te{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new ve}on_enter(){this.blurrer=new Ht,this.main_RT=new j(pt.width,pt.height),this.blur_RT=new j(pt.width,pt.height),this.bloom_compose_mat=new ye(5),this.blurrer=new Ht(5),this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture),this.bloom_compose_mat.set_bloom_strength(1),this.bloom_compose_mat.set_bloom_radius(1),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.bloom_compose_mat.set_bloom_radius(e)}set_tint_color_0(e){this.bloom_compose_mat.set_tint_color_0(e)}set_tint_color_1(e){this.bloom_compose_mat.set_tint_color_1(e)}set_tint_color_2(e){this.bloom_compose_mat.set_tint_color_2(e)}set_tint_color_3(e){this.bloom_compose_mat.set_tint_color_3(e)}set_tint_color_4(e){this.bloom_compose_mat.set_tint_color_4(e)}render(){this.__check_RT_size(),yt.clear(this.main_RT,nt.current,!0,!1),yt.render(ht.current,nt.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),yt.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),yt.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===pt.width&&this.main_RT.height===pt.height||(this.main_RT.setSize(pt.width,pt.height),this.blur_RT.setSize(pt.width,pt.height))}}class Zt extends Te{constructor(){super()}render(){ht.current.on_pre_render&&ht.current.on_pre_render(),ht.current.render?ht.current.render():yt.render(ht.current,nt.current,yt._renderer.getRenderTarget()),this.render_spectator_camera(),ht.current.on_post_render&&ht.current.on_post_render()}render_spectator_camera(){const e=nt.spectator;if(e&&yt._renderer.xr.isPresenting){const t=yt._renderer.xr.getCamera(nt.current);e.projectionMatrix.copy(nt.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);const s=yt._renderer.getRenderTarget();yt._renderer.xr.isPresenting=!1,yt._renderer.setRenderTarget(null),yt._renderer.render(ht.current,e),yt._renderer.setRenderTarget(s),yt._renderer.xr.isPresenting=!0}}}const Jt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(st.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(st.current_state_data)}};class Kt{constructor(e,t,s){e=e||new ge,this.target_application=e,this.graphics=t,this.input=s,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0}update(){if(this.is_running){for(Ke.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.input.update(),this.time_accumulator+=Ke.delta_time,this.target_application.before_update(),st.before_update();this.time_accumulator>Ke.fixed_delta_time;)this.target_application.fixed_update(),st.fixed_update(),this.time_accumulator-=Ke.fixed_delta_time;Ke.__set_frame_interpolation(this.time_accumulator/Ke.fixed_delta_time),this.target_application.update(),st.update(),it.update(),Jt.update(),this.target_application.on_pre_render(),this.graphics.update(),this.target_application.on_post_render(),ft.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,this.input.clear(),ft.clear()}}start(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(),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.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}}class es{constructor({name:e,container:t}){this.name=e,this.container=t,this.hidden=!0,Jt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),Jt.enable_component(this),this.hidden=!1}update(){}on_exit(){this.container.classList.add("hidden"),Jt.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 ts extends T{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new S({color:s});const r=new C(e,t);r.rotateX(-1.57),super(r,i)}}class ss extends T{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new S({color:s});super(new C(e,t),i)}}class is{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],i=s.distanceTo(t);for(let r=1;r<e.length;r++)e[r].distanceTo(t)<i&&(s=e[r],i=e[r].distanceTo(t));return s}static object_values_to_array(e){const t=Object.keys(e),s=[];for(let i=0;i<t.length;i++)s.push(e[t[i]]);return s}}class rs{constructor(){this.sphere=new Y}fit_points(e,t,s,i){this.sphere.setFromPoints(e);const r=Math.degToRad(s/2),n=2*Math.atan(Math.tan(r)*i)/2,o=this.get_up_plane_normal(t,r),a=this.get_down_plane_normal(t,r),_=this.get_left_plane_normal(t,n),l=this.get_right_plane_normal(t,n),h=new x(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,i),d=c.clone().add(h.clone().multiplyScalar(-1*u)),p=(new G).setFromNormalAndCoplanarPoint(o,d),m=(new G).setFromNormalAndCoplanarPoint(a,d),g=(new G).setFromNormalAndCoplanarPoint(_,d),f=(new G).setFromNormalAndCoplanarPoint(l,d);this.apply_center_correction_to_pos(d,e,t,p,m,g,f),p.setFromNormalAndCoplanarPoint(o,d),m.setFromNormalAndCoplanarPoint(a,d),g.setFromNormalAndCoplanarPoint(_,d),f.setFromNormalAndCoplanarPoint(l,d);let v=1/0;const w=h.clone().multiplyScalar(-2*u);for(let t=0;t<e.length;t++){const s=new E(e[t].clone(),e[t].clone().add(w)),i=new x,r=new x,n=new x,o=new x;p.intersectLine(s,i),m.intersectLine(s,r),g.intersectLine(s,n),f.intersectLine(s,o),i.length()<1e-4&&console.log("up intersection not found",t),r.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(i).length(),_=e[t].clone().sub(r).length(),l=e[t].clone().sub(n).length(),h=e[t].clone().sub(o).length(),c=Math.min(a,_),u=Math.min(l,h),d=Math.min(c,u);d<v&&(v=d)}const b=h.clone().multiplyScalar(v);return d.clone().add(b)}apply_center_correction_to_pos(e,t,s,i,r,n,o){const a=this.get_vertical_correction(t,r,i,s),_=this.get_hozirontal_correction(t,n,o,s);e.add(a),e.add(_)}get_vertical_correction(e,t,s,i){let r,n,o=1/0,a=1/0;const _=new x(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new E(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new E(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),c=new x,u=new x;t.intersectLine(l,c),s.intersectLine(h,u);const d=c.distanceTo(e[i]),p=u.distanceTo(e[i]);u.length()<1e-4&&console.log("vertical up intersection not found",i),c.length()<1e-4&&console.log("vertical down intersection not found",i),d<a&&(a=d,n=e[i]),p<o&&(o=p,r=e[i])}console.log(r,n);const l=(o-a)/2;return _.clone().multiplyScalar(-l)}get_hozirontal_correction(e,t,s,i){let r,n,o=1/0,a=1/0;const _=new x(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new E(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new E(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),c=new x,u=new x;t.intersectLine(l,c),s.intersectLine(h,u);const d=c.distanceTo(e[i]),p=u.distanceTo(e[i]);c.length()<1e-4&&console.log("left intersection not found",i),u.length()<1e-4&&console.log("right intersection not found",i),d<a&&(a=d,n=e[i]),p<o&&(o=p,r=e[i])}const l=(o-a)/2;return console.log(r,n),_.clone().multiplyScalar(-l)}get_up_plane_normal(e,t){const s=new x(0,-1,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new x(0,1,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new x(1,0,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new x(-1,0,0);return s.applyQuaternion((new W).setFromAxisAngle(new x(0,1,0),-t)),s.applyQuaternion(e),s}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class ns{static convert_to_non_indexed_geometry(e){const t=e.index,s=e.getAttribute("position"),i=[];for(let e=0;e<t.count;e+=3)i.push(s.getX(t.array[e+0])),i.push(s.getY(t.array[e+0])),i.push(s.getZ(t.array[e+0])),i.push(s.getX(t.array[e+1])),i.push(s.getY(t.array[e+1])),i.push(s.getZ(t.array[e+1])),i.push(s.getX(t.array[e+2])),i.push(s.getY(t.array[e+2])),i.push(s.getZ(t.array[e+2]));const r=new b;return r.setAttribute("position",new q(new Float32Array(i),3)),ns.add_barycentric_attribute(r),r}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 q(new Float32Array(t),3))}}class os{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 as{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 i=4*(t+e.width*s),r=e.data;return new k(r[i+0],r[i+1],r[i+2],r[i+3])}}const _s=new class{constructor(){}sample(e,s){const i=[];let r=99999999;const n=e.getAttribute("position"),o=e.getAttribute("normal"),a=e.getAttribute("tangent"),_=e.getAttribute("uv"),l=e.index,h=[];for(let e=0;e<l.count;e+=3){const s=l.array[e+0],c=l.array[e+1],u=l.array[e+2],d=new x;d.x=n.getX(s),d.y=n.getY(s),d.z=n.getZ(s);const p=new x;p.x=n.getX(c),p.y=n.getY(c),p.z=n.getZ(c);const m=new x;m.x=n.getX(u),m.y=n.getY(u),m.z=n.getZ(u);const g={a:d,b:p,c:m};if(o){const e=new x;e.x=o.getX(s),e.y=o.getY(s),e.z=o.getZ(s);const t=new x;t.x=o.getX(c),t.y=o.getY(c),t.z=o.getZ(c);const i=new x;i.x=o.getX(u),i.y=o.getY(u),i.z=o.getZ(u);const r=e.clone().add(t).add(i).normalize();g.normal=r}if(a){const e=new x;e.x=a.getX(s),e.y=a.getY(s),e.z=a.getZ(s);const t=new x;t.x=a.getX(c),t.y=a.getY(c),t.z=a.getZ(c);const i=new x;i.x=a.getX(u),i.y=a.getY(u),i.z=a.getZ(u);const r=e.clone().add(t).add(i).normalize();g.tangent=r}if(_){const e=new t;e.x=_.getX(s),e.y=_.getY(s);const i=new t;i.x=_.getX(c),i.y=_.getY(c);const r=new t;r.x=_.getX(u),r.y=_.getY(u),g.uv_a=e,g.uv_b=i,g.uv_c=r}h.push(g);const f=this.get_face_area(g);r=Math.min(f,r),i.push(f)}const c=this.get_uniform_face_distribution(i,r,h),u=this.select_random_faces(c,s);return this.sample_data_from_faces(u)}sample_data_from_faces(e){const t=[],s=[],i=[],r=[];for(let n=0;n<e.length;n++){const o=e[n],a=Math.random(),_=Math.random();t.push(this.sample_point_in_face(a,_,o.a,o.b,o.c).clone()),o.normal&&s.push(o.normal.clone()),o.tangent&&i.push(o.tangent.clone()),o.uv_a&&r.push(this.sample_point_in_face(a,_,o.uv_a,o.uv_b,o.uv_c).clone())}return{points:t,normals:s,tangents:i,uvs:r}}select_random_faces(e,t){const s=[];for(let i=0;i<t;i++){const t=e[Math.floor(Math.random()*e.length)];s.push(t)}return s}get_uniform_face_distribution(e,t,s){const i=[];for(let r=0;r<e.length;r++){e[r]/=t;const n=Math.floor(Math.round(e[r]));for(let e=0;e<n;e++)i.push(s[r])}return i}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,i,r){e+t>1&&(e=1-e,t=1-t);const n=1-(e+t);return s.clone().multiplyScalar(e).add(i.clone().multiplyScalar(t)).add(r.clone().multiplyScalar(n))}};const ls=new class{get_mesh(e,t){e.traverse((e=>{e instanceof T&&(e.geometry&&(e.geometry=(new b).fromGeometry(e.geometry)),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 T&&(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 i={},r={};t.scene.traverse((e=>{e.isBone&&(i[e.name]=e),e.isSkinnedMesh&&(r[e.name]=e)}));for(const e in s){const t=s[e].skeleton,n=r[e],o=[];for(let e=0;e<t.bones.length;++e){const s=i[t.bones[e].name];o.push(s)}n.bind(new Z(o,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,s){e.traverse((e=>{e instanceof T&&(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 hs{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(hs.is_object(e)&&hs.is_object(s))for(const t in s)hs.is_object(s[t])?(e[t]||Object.assign(e,{[t]:{}}),hs.merge_deep(e[t],s[t])):Object.assign(e,{[t]:s[t]});return hs.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 i=e.attributes.item(s);t["@attributes"][i.nodeName]=i.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes.item(s),r=i.nodeName;if(void 0===t[r])t[r]=this.xml_to_json(i);else{if(void 0===t[r].push){const e=t[r];t[r]=[],t[r].push(e)}t[r].push(this.xml_to_json(i))}}return t}}class cs{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 us{constructor(){}time_str_to_ms(e){e=e.split(":");let t=Number(e[0]);t=60*t*60*1e3;let s=Number(e[1]);s=60*s*1e3;let i=Number(e[2]);return i*=1e3,t+s+i}}class ds{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 ps extends T{constructor(){const t=new e({uniforms:{_Color:{value:new r("#919191")}},vertexShader:"#define GLSLIFY 1\nattribute vec3 barycentric;varying vec3 vBarycentric;void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=(modelMatrix*vec4(position,1.0)).xyz;gl_Position=VP*vec4(pos,1.0);vBarycentric=barycentric;}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 _Color;varying vec3 vBarycentric;float edgeFactor(vec3 baryc){vec3 d=fwidth(baryc);vec3 a3=smoothstep(vec3(0.0),d*1.5,baryc);return min(min(a3.x,a3.y),a3.z);}void main(){float alpha=edgeFactor(vBarycentric+vec3(1.,1.,0.));gl_FragColor.rgb=mix(_Color,vec3(0.),alpha);gl_FragColor.a=1.0-alpha;gl_FragColor.a*=0.2;}",extensions:{derivatives:!0},transparent:!0,depthWrite:!1}),s=new C(100,100,100,100);super(ns.convert_to_non_indexed_geometry(s),t),this.rotation.x=-1.57}}class ms extends T{constructor(t){const s=new b;s.setAttribute("position",new q(new Float32Array([]),3)),s.setAttribute("next_position",new q(new Float32Array([]),3)),s.setAttribute("previous_position",new q(new Float32Array([]),3)),s.setAttribute("orientation",new q(new Float32Array([]),1)),s.setAttribute("coverage",new q(new Float32Array([]),1));super(s,new e({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new r("#FF0000")}},vertexShader:"#define GLSLIFY 1\nuniform float _Thickness;attribute vec3 next_position;attribute vec3 previous_position;attribute float orientation;attribute float coverage;varying float line_coverage;varying float uv_u;vec3 w_space_normal(vec3 from,vec3 to){vec3 w_from=(modelMatrix*vec4(from,1.0)).xyz;vec3 w_to=(modelMatrix*vec4(to,1.0)).xyz;vec3 z=normalize(w_to-w_from);return normalize(cross(z,normalize(cameraPosition-w_from)));}void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=position;vec3 normal=w_space_normal(next_position,previous_position);pos=(modelMatrix*vec4(pos,1.0)).xyz;pos+=normal*(_Thickness*0.5)*orientation;gl_Position=VP*vec4(pos,1.0);line_coverage=coverage;uv_u=orientation*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nuniform float _Length;uniform float _ElapsedTime;uniform float _Thickness;uniform vec3 _Color;varying float line_coverage;varying float uv_u;float aastep(float threshold,float value){\n#ifdef GL_OES_standard_derivatives\nfloat afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757;return smoothstep(threshold-afwidth,threshold+afwidth,value);\n#else\nreturn step(threshold,value);\n#endif\n}void main(){float u=(1.0-abs(uv_u*2.0-1.0));float diffuse=dot(vec2(u,u),vec2(0.0,1.0))*0.5+0.5;gl_FragColor=vec4(_Color*diffuse,1.0);}",transparent:!0,depthWrite:!1,extensions:{derivatives:!0}})),t&&this.setup(t)}setup(e){const t=[],s=[],i=[],r=[],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),r.push(1),t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),r.push(-1);const _=this.__get_next_position(e,a);s.push(_.x),s.push(_.y),s.push(_.z),s.push(_.x),s.push(_.y),s.push(_.z);const l=this.__get_previous_position(e,a);i.push(l.x),i.push(l.y),i.push(l.z),i.push(l.x),i.push(l.y),i.push(l.z),n.push(o),n.push(o),a<e.length-1&&(o+=e[a].distanceTo(_))}const a=new Float32Array(t),_=new Float32Array(s),l=new Float32Array(i),h=new Float32Array(r),c=new Float32Array(n),u=[];for(let e=0;e<(a.length/3-2)/2;e++){const t=2*e+1;u.push(t),u.push(t+1),u.push(t-1),u.push(t),u.push(t+2),u.push(t+1)}this.geometry.setIndex(u),this.geometry.getAttribute("position").copy(new q(a,3)),this.geometry.getAttribute("next_position").copy(new q(_,3)),this.geometry.getAttribute("previous_position").copy(new q(l,3)),this.geometry.getAttribute("orientation").copy(new q(h,1)),this.geometry.getAttribute("coverage").copy(new q(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}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 gs extends T{constructor(s,i){i=i||new t(0,0);const r=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:J}),n=new C(1,1,1);n.translate(-i.x/2,-i.y/2,0);const o=s.image.width/s.image.height;n.scale(o,1,1),super(n,r),this.current_scale=o,this.geometry.computeBoundingBox(),this.tmp_bb_size=new x,this.geometry.boundingBox.getSize(this.tmp_bb_size)}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.set(e,e,e),this.material.uniforms._Scale.value=e}set screen_aligned(e){this.material.uniforms._ScreenAligned.value=!0===e?1:0}get screen_aligned(){return 1===this.material.uniforms._ScreenAligned.value}set opacity(e){this.material.uniforms._Opacity.value=e}get opacity(){return this.material.uniforms._Opacity.value}dispose(){this.geometry.dispose(),this.parent.remove(this),this.material.uniforms._MainTex.value.dispose(),this.material.dispose()}}class fs extends gs{constructor(e,t,s,i,r){const n=new at(r),o={font:t,font_color:s||"#000000"},a=n.draw_on_texture(e,o);a.minFilter=K,a.minFilter=$,a.needsUpdate=!0,super(a,i),this.simple_text_drawer=n,this.canvas_texture=a,this.draw_settings=o}set text(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()}get text(){return"not implemented"}}class vs extends be{constructor(e=1){super("#define GLSLIFY 1\nuniform vec2 _ScreenSize;uniform vec2 _TextureSize;uniform vec2 _PixelOffset;uniform vec3 _NDC;uniform vec2 _PivotPoint;uniform float _DepthOffset;varying vec2 vUv;vec2 add_pixel_offset(vec2 pos){pos=pos*0.5+0.5;pos*=_ScreenSize;pos=ceil(pos+_PixelOffset)+0.5;pos/=_ScreenSize;return pos*2.0-1.0;}void main(){vec4 projected_pos=projectionMatrix*viewMatrix*vec4(_NDC,1.0);projected_pos.zw+=_DepthOffset;projected_pos.xyz/=projected_pos.w;vec2 normalized_size=_TextureSize/_ScreenSize;vec2 dir=uv*2.0-1.0;dir-=_PivotPoint;vec2 pos=projected_pos.xy+dir*normalized_size;gl_Position=vec4(add_pixel_offset(pos),projected_pos.z,1.0);vUv=uv;}","#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _ScreenSize;uniform vec2 _TextureSize;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv+vec2(0.5,0.5)/_TextureSize);}",{_MainTex:{value:void 0},_ScreenSize:{value:new t(pt.width,pt.height)},_TextureSize:{value:new t},_PixelOffset:{value:new t(0,0)},_NDC:{value:new x},_PivotPoint:{value:new t},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class xs{constructor(){this.tmp_vec=new t}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class ws{constructor(){this.tmp_vec3=new x,this.tmp_vec2=new t}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(nt.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class bs{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class ys extends bs{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class Ts extends bs{constructor(){super()}on_enter(e){e.on_mouse_enter()}update(e,t){e.is_mouse_over(t)?e.set_state(e._on_hover_state):e.set_state(e._on_exit_state)}}class Ms extends bs{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class Ss extends bs{constructor(){super()}on_enter(e){this.__trigger_on_hover(e)}update(e,t){e.is_mouse_over(t)?this.__trigger_on_hover(e):e.set_state(e._on_exit_state)}__trigger_on_hover(e){e.on_mouse_hover()}}class zs extends T{constructor(e,s){super(new C(1,1),new vs),this.is_clickable=!1,this.position_strategy=new ws,this.current_state=new ys,this._position=new x,this._on_idle_state=new ys,this._on_enter_state=new Ts,this._on_exit_state=new Ms,this._on_hover_state=new Ss,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new t,this.cached_NDC_position=new t,this.screen_pos_tmp=new t,this.texture_size=new t(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new t}set_render_order(e){this.renderOrder=e}get pivot_point(){return this.material.uniforms._PivotPoint.value}set_pixel_offset(e){this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e)}set_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}get position(){return this._position}set use_depth(e){this.material.depthTest=e}get use_depth(){return this.material.depthTest}set depth_offset(e){this.material.uniforms._DepthOffset.value=e}get depth_offset(){return this.material.uniforms._DepthOffset.value}clear_state(){this.visible=!1}set_world_space_coordinate_system(){this.position_strategy=new ws}set_screen_space_coordinate_system(){this.position_strategy=new xs}set_texture(e){e.minFilter=f,e.magFilter=f,e.needsUpdate=!0,this.texture_size.set(e.image.width,e.image.height),this.material.uniforms._MainTex.value=e,this.get_size(this.material.uniforms._TextureSize.value),this.visible=!0}update_state(e){this.material.uniforms._ScreenSize.value.set(pt.width,pt.height),this.get_size(this.material.uniforms._TextureSize.value),this.cached_NDC_position.copy(this.position_strategy.get_pos_NDC(this.position)),this.material.uniforms._NDC.value.copy(this.position),this.current_state.update(this,e)}is_mouse_over(e){this.screen_pos_tmp.copy(this.cached_NDC_position),this.to_screen_position(this.screen_pos_tmp),this.screen_pos_tmp.x+=this.pixel_offset.x,this.screen_pos_tmp.y+=this.pixel_offset.y;const t=(new ee).setFromCenterAndSize(this.screen_pos_tmp,this.get_size());return this.mouse_pos_tmp.copy(e),this.to_screen_position(this.mouse_pos_tmp),t.containsPoint(this.mouse_pos_tmp)}to_screen_position(e){e.x=(.5*e.x+.5)*pt.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*pt.height+this.pixel_offset.y}get_screen_space_position(){const e=this.cached_NDC_position.clone();return this.to_screen_position(e),e}set_screen_space_position(e){this.position.x=e.x/pt.width*2-1,this.position.y=e.y/pt.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/pt.dpr):(new t).copy(this.texture_size).multiplyScalar(this.size/pt.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class Fs extends T{constructor(e,t){super(e,t);const s=this;this.onBeforeRender=()=>{s.material.update()}}}class As{constructor(e,s,i){const r=s.right-s.left,n=s.top-s.bottom;this.scale=new t(r,n),this.position=new t(e+s.left,s.bottom),this.atlas_bounds=new k(i.left,i.right,i.top,i.bottom)}}class Rs{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 x,this.quaternion=new W,this.scale=new x(1,1,1),this.matrix=new X,this.color=new r("#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 W).setFromAxisAngle(new x(0,1,0),e/360*Math.PI*2),i=(new W).setFromAxisAngle(new x(1,0,0),-t/360*Math.PI*2);this.quaternion.copy(s.multiply(i)),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 i=e.charCodeAt(t),r=this.glyph_layout.find((e=>e.unicode===i));if(r){if(r.planeBounds){const e=new As(s,r.planeBounds,r.atlasBounds);this.glyphs.push(e)}s+=r.advance}}const i=new ee,r=this.glyphs[0];i.setFromCenterAndSize(r.position.clone().add(new t(r.scale.x/2,r.scale.y/2)),r.scale);for(let e=1;e<this.glyphs.length;e++){const s=this.glyphs[e],r=(new ee).setFromCenterAndSize(s.position.clone().add(new t(s.scale.x/2,s.scale.y/2)),s.scale);i.union(r)}const n=new t;i.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 Cs extends be{constructor(e){super("#define GLSLIFY 1\nattribute vec4 transformsCol0;attribute vec4 transformsCol1;attribute vec4 transformsCol2;attribute vec4 transformsCol3;attribute vec4 glyph_bounds;attribute vec4 plane_bounds;attribute vec4 color;varying vec2 vUv;varying vec4 v_glyph_bounds;varying vec4 v_color;void main(){vec4 pos=vec4(position,1.0);pos.x*=plane_bounds.z;pos.y*=plane_bounds.w;pos.x+=plane_bounds.x;pos.y+=plane_bounds.y;mat4 offset_matrix=mat4(transformsCol0,transformsCol1,transformsCol2,transformsCol3);gl_Position=projectionMatrix*viewMatrix*offset_matrix*pos;vUv=uv;v_glyph_bounds=glyph_bounds;v_color=color;}","#define GLSLIFY 1\nuniform sampler2D _Texture;uniform float _Boldness;varying vec2 vUv;uniform vec2 _AtlasSize;varying vec4 v_glyph_bounds;varying vec4 v_color;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){float left=v_glyph_bounds.x/_AtlasSize.x;float right=v_glyph_bounds.y/_AtlasSize.x;float top=v_glyph_bounds.z/_AtlasSize.y;float bottom=v_glyph_bounds.w/_AtlasSize.y;float width=abs(right-left);float height=abs(top-bottom);vec2 coord=vec2(vUv.x*width+left,vUv.y*height+top-height);vec4 col=texture2D(_Texture,coord);float sig_dist=median(col.r,col.g,col.b);float _Cutoff=_Boldness;float dist=(_Cutoff-sig_dist);vec2 ddist=vec2(dFdx(dist),dFdy(dist));float pixelDist=dist/length(ddist);float opacity=clamp(0.5-pixelDist,0.0,1.0);gl_FragColor=vec4(v_color.rgb,opacity*v_color.a);}",{_Texture:{value:e},_Boldness:{value:.5},_AtlasSize:{value:new t(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=J,e.minFilter=$,e.magFilter=$,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(e){this.uniforms._Boldness.value=Ge.lerp(.5,.2,e)}}class ks extends T{constructor(e,s){const i=new te;i.instanceCount=0;const r=new C(1,1);r.translate(.5,.5,0),i.setAttribute("position",new se(r.getAttribute("position").array,3)),i.setAttribute("uv",new se(r.getAttribute("uv").array,2)),i.index=r.index;const n=new ie(new Float32Array(8e3),4,!1),o=new ie(new Float32Array(8e3),4,!1),a=new ie(new Float32Array(8e3),4,!1),_=new ie(new Float32Array(8e3),4,!1),l=new ie(new Float32Array(8e3),4,!1),h=new ie(new Float32Array(8e3),4,!1),c=new ie(new Float32Array(8e3),4,!1);n.usage=re,o.usage=re,a.usage=re,_.usage=re,l.usage=re,h.usage=re,c.usage=re,i.setAttribute("transformsCol0",n),i.setAttribute("transformsCol1",o),i.setAttribute("transformsCol2",a),i.setAttribute("transformsCol3",_),i.setAttribute("glyph_bounds",l),i.setAttribute("plane_bounds",h),i.setAttribute("color",c),super(i,new Cs(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 Rs(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){is.remove_elem(this.text_elements,e),this.update(!0)}update(e){const t=this.geometry.getAttribute("glyph_bounds"),s=this.geometry.getAttribute("plane_bounds"),i=this.geometry.getAttribute("transformsCol0"),r=this.geometry.getAttribute("transformsCol1"),n=this.geometry.getAttribute("transformsCol2"),o=this.geometry.getAttribute("transformsCol3"),a=this.geometry.getAttribute("color");let _=!0===e,l=!0===e,h=!0===e,c=0;for(let e=0;e<this.text_elements.length;e++){const u=this.text_elements[e];u.matrix_is_dirty&&(_=!0,u.update_matrix()),u.glyph_is_dirty&&(l=!0,u.clear_glyph_dirty()),u.color_is_dirty&&(h=!0,u.clear_color_dirty());const d=u.matrix,p=u.color,m=u.opacity;for(let e=0;e<u.glyphs.length;e++){const _=u.glyphs[e],l=c;t.setXYZW(l,_.atlas_bounds.x,_.atlas_bounds.y,_.atlas_bounds.z,_.atlas_bounds.w),s.setXYZW(l,_.position.x,_.position.y,_.scale.x,_.scale.y),i.setXYZW(l,d.elements[0],d.elements[1],d.elements[2],d.elements[3]),r.setXYZW(l,d.elements[4],d.elements[5],d.elements[6],d.elements[7]),n.setXYZW(l,d.elements[8],d.elements[9],d.elements[10],d.elements[11]),o.setXYZW(l,d.elements[12],d.elements[13],d.elements[14],d.elements[15]),a.setXYZW(l,p.r,p.g,p.b,m),c++}}this.geometry.instanceCount=c,c>this.max_allocations&&console.error("SDFTextBatch exceeded maximum glyph allocations(max/current): ",this.max_allocations,c,this),_&&(i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,o.needsUpdate=!0),l&&(t.needsUpdate=!0,s.needsUpdate=!0),h&&(a.needsUpdate=!0)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ps extends Xe{constructor(e,t=0,s=1,i="linear"){super(i),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 Ds extends fe{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 Ls extends fe{constructor(e,t){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;void main(){vec4 col=texture2D(_MainTex,vUv);gl_FragColor=col;gl_FragColor.a=col.a;}")}set offset(e){this.uniforms._Offset.value=e}get offset(){return this.uniforms._Offset.value}}class Us{constructor(e){this.current_width=1,this.current_height=1,this.RT0=new j(1,1),this.RT1=new j(1,1),this.RT2=new j(1,1),this.RT3=new j(1,1),this.RT4=new j(1,1),this.upscale_blur_mat=new Ds(!0),this.downscale_blur_mat=new Ds(!1),this.alpha_filter_mat=new Ls}blur(e){this.check_RT_resize(e.width,e.height),yt.blit(e,this.RT1,this.alpha_filter_mat),yt.blit(this.RT1,this.RT2,this.downscale_blur_mat),yt.blit(this.RT2,this.RT3,this.downscale_blur_mat),yt.blit(this.RT3,this.RT4,this.downscale_blur_mat),yt.blit(this.RT4,this.RT3,this.upscale_blur_mat),yt.blit(this.RT3,this.RT2,this.upscale_blur_mat),yt.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 js extends fe{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 Os{constructor(e){this.RT=new j(1,1,{type:B,format:I,minFilter:f,magFilter:f}),this.RT1=new j(1,1,{type:B,format:I,minFilter:f,magFilter:f}),this.median_filter_mat=new js}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),yt.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),yt.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),yt.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.isWebGLRenderTarget?new t(e.width,e.height):e.isTexture?new t(e.image.width,e.image.height):new t(1,1)}}class Is{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=Is.calculate_resolution(e),s={minFilter:f,magFilter:f,format:I,colorScape:h,type:_t.fp_textures_available?B:ne,stencilBuffer:!1,depthBuffer:!1};return new j(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].material=this.update_material,this.update_material.uniforms._MainTex.value=this.read.texture,yt.render(e,void 0,this.write),e.children[0].material=void 0,this.swap_RT())}store_geometry_attribute_in_RT(e,t,s,i){i.children[0].geometry.setAttribute("data",e),i.children[0].material=s,yt.render(i,void 0,t),i.children[0].geometry.deleteAttribute("data"),i.children[0].material=void 0}get_texture(){return this.read.texture}}class Ns extends v{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 u,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 q(t,s,!1))}add_attribute_array(e,t,s){this.mesh.geometry.setAttribute(e,new ie(t,s,!1))}update(){this.mesh.material.update();for(let e=0;e<this.attributes.length;e++)this.attributes[e].update(this.attribute_writter_scene)}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}build_point_mesh(e=1,t){const s=new C,i=new te;i.setAttribute("position",s.getAttribute("position")),i.index=s.index,i.setAttribute("storage_uv",this.build_uv_storage_attribute(e)),i.instanceCount=e;const r=new T(i,t);return r.frustumCulled=!1,r}build_attribute_writter_mesh(e){const{width:t,height:s}=Is.calculate_resolution(e),i=new Float32Array(3*e);for(let r=0;r<e;r++){const e=r%t,n=Math.floor(r/t);i[3*r+0]=(e+.5)/t,i[3*r+1]=(n+.5)/s,i[3*r+2]=r}const r=new b;r.setAttribute("position",new q(i,3,!1));const n=new oe(r);return n.frustumCulled=!1,n}build_uv_storage_attribute(e){const{width:t,height:s}=Is.calculate_resolution(e),i=new Float32Array(2*e);for(let r=0;r<e;r++){const e=r%t,n=Math.floor(r/t);i[2*r+0]=(e+.5)/t,i[2*r+1]=(n+.5)/s}return new ie(i,2,!1)}}class Bs extends e{constructor(){super({uniforms:{},vertexShader:"\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:i})}}class Vs extends Is{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 i=new Bs;this.store_geometry_attribute_in_RT(e.getAttribute("position"),this.read,i,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 i=new Bs;this.store_geometry_attribute_in_RT(new q(s,4),this.read,i,t)}}class qs extends V{constructor(e,t,s,i,r){super(e,t,s,i,r),this.multiplier=1}set_rgba(e,t,s,i,r){this.data[3*e+0]=t*this.multiplier,this.data[3*e+1]=s*this.multiplier,this.data[3*e+2]=i*this.multiplier,this.data[3*e+3]=r*this.multiplier,this.needsUpdate=!0}set_rgb(e,t,s,i){this.data[3*e+0]=t*this.multiplier,this.data[3*e+1]=s*this.multiplier,this.data[3*e+2]=i*this.multiplier,this.needsUpdate=!0}set_r(e,t){this.data[3*e+0]=t*this.multiplier,this.needsUpdate=!0}set_g(e,t){this.data[3*e+1]=t*this.multiplier,this.needsUpdate=!0}set_b(e,t){this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0}set_a(e,t){this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0}}class Ys extends qs{constructor(e,t){super(new Uint8Array(e*t*3),e,t,I),this.multiplier=255}}class Gs extends qs{constructor(e,t){super(new Uint8Array(e*t*4),e,t,I),this.multiplier=255}}class Es extends qs{constructor(e,t){super(new Float32Array(e*t*3),e,t,I,B)}}class Ws extends qs{constructor(e,t){super(new Float32Array(e*t*4),e,t,I,B)}}class Xs extends T{constructor(e,t,s,i){super(t,s),this.id_table=e,this.batched_count=Object.keys(e).length,this.max_texture_width=i,this.batch_width=this.batched_count%i,this.batch_height=Math.ceil(this.batched_count/i)}attach_rgb_texture(e){this.material.uniforms[e].value=new Ys(this.batch_width,this.batch_height)}attach_rgba_texture(e){this.material.uniforms[e].value=new Gs(this.batch_width,this.batch_height)}attach_rgb_float_texture(e){this.material.uniforms[e].value=new Es(this.batch_width,this.batch_height)}attach_rgba_float_texture(e){this.material.uniforms[e].value=new Ws(this.batch_width,this.batch_height)}get_mesh_index(e){return this.id_table[e]}set_rgb_value(e,t,s,i,r){this.material.uniforms[e].set_rgb(this.get_mesh_index(t),s,i,r)}set_rgba_value(e,t,s,i,r,n){this.material.uniforms[e].set_rgba(this.get_mesh_index(t),s,i,r,n)}}class Qs{batch(e,t){const s=[],i={},r=[];for(let t=0;t<e.length;t++){const n=e[t],o=n.geometry.getAttribute("position").count;for(let e=0;e<o;e++)r.push(t);s.push(n.geometry),void 0===i[n.name]?i[n.name]=t:console.error("Mesh name is duplicated when trying to merge meshes. Non-unique id error.",n.name,i)}const n=ce.mergeGeometries(s),o=new q(new Float32Array(r),1);return n.setAttribute("mesh_id",o),this.create_batched_mesh(i,n,t,2048)}create_batched_mesh(e,t,s,i){return new Xs(e,t,s,i)}}class Hs extends Me{constructor(e,t,s){super(e,t,s),this.loader=new ue}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 $s extends Me{constructor(e,t,s){super(e,t,s),this.loader=new ae}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),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 Zs extends Me{constructor(e,t,s){super(e,t,s),this.loader=new de}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 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 Me{constructor(e,t,s,i){super(e,t,i),this.loader=new pe,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=>{}),(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 Ks extends Me{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 ei extends Me{constructor(e,t,s){super(e,t,s),this.loader=new me}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 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 ti extends Me{constructor(e,t,s){super(e,t,s),this.loader=new ae}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=>{}),(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 i=parseFloat(t[e+0]),r=parseFloat(t[e+1]),n=parseFloat(t[e+2]);s.push(new x(i,r,n))}return s}}class si extends Me{constructor(e,t,s){super(e,t,s),this.loader=new ae}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),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 ii extends Me{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=URL.createObjectURL(t),r=new Image;r.src=i,r.onload=()=>{s.image=r,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended()},r.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 ri extends Me{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 ni{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||Fe)}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}}export{Me as AbstractLoader,Ye as AbstractScene,He as ActionEvent,Xe as ActionInterpolator,Ee as ActionSequencer,Ze as ActionSequencerBuilder,ve as AddMaterial,rt as ApplicationView,is as ArrayUtilities,dt as Arrow,Ae as AsyncAbstractLoader,Re as AsyncAudiosLoader,Pe as AsyncObjectsLoader,Le as AsyncTextureLoader,Ie as AsyncTexturesLoader,ze as AudioLoader,ge as BaseApplication,Te as BaseRender,be as BaseShaderMaterial,Ue as BasisLoader,fe as BlitMaterial,Gt as Blurrer,De as Browser,St as CSSAnimator,nt as CameraManager,Dt as CameraUtilities,ot as CanvasDrawer,_t as Capabilities,ct as Cube,je as CubemapLoader,Hs as DAELoader,ft as Debug,It as DebugNormalsRender,$e as DrawIOAnimationSheet,Ds as DualFilteringBlurMaterial,Us as DualFilteringBlurrer,We as EasingFunctions,$s as FileLoader,Zs as FontLoader,rs as FrustumPointFitter,Ce as GLTFDRACOLoader,ke as GLTFLoader,Ns as GPUParticleSystem,Ht as GaussianBlurrer,ns as GeometryUtilities,yt as Graphics,ps as Grid,Js as HDRCubeTextureLoader,os as HTMLUtilities,Ve as HighQualityLoadingState,ts as HorizontalPlane,as as ImageUtilities,Lt as Initializer,Ks as JSONLoader,Ut as KeyboardInput,ms as Line,Be as LoadingState,Os as MedianFilter,Qs as MeshBatcher,_s as MeshSampler,ls as ModelUtilities,Et as NormalAORender,Wt as NormalRender,Qe as NumberInterpolator,ei as OBJLoader,Ge as OMath,zt as OS,pt as OScreen,hs as ObjectUtilities,jt as OrthographicCamera,Pt as OrthographicFrustumPointFitter,Is as ParticleAttribute,Vs as ParticlePositionAttribute,gt as PerspectiveCamera,kt as PerspectiveFrustumPointFitter,ti as PointArrayLoader,Oe as RGBETextureLoader,qe as RegularLoadingState,Kt as RenderLoop,ni as ResourceBatch,Fe as ResourceContainer,ks as SDFTextBatch,ht as SceneManager,at as SimpleTextDrawer,ut as Sphere,cs as StringUtilities,fs as Text2D,si as TextLoader,ii as TextureLoader,Ke as Time,us as TimeUtilities,st as TransitionManager,Je as TransitionTable,Ct as UI,zs as UIElement,ye as UnrealBloomComposeMaterial,$t as UnrealBloomRender,Fs as UpdatableMaterialMesh,Zt as VRRender,ds as Validation,Ps as VectorInterpolator,ss as VerticalPlane,ri as VideoLoader,es as ViewComponent,Jt as ViewComponentManager,it as ViewManager,gs as WorldImage};
1
+ import{Object3D as e,Vector3 as t,LineBasicMaterial as s,AlwaysDepth as i,BufferGeometry as r,Line as n,Scene as o,Mesh as a,BoxGeometry as _,MeshBasicMaterial as l,SphereGeometry as h,CylinderGeometry as c,ConeGeometry as u,Vector2 as d,PerspectiveCamera as p,Color as m,OrthographicCamera as g,ShaderMaterial as f,NoBlending as v,PlaneGeometry as x,Vector4 as w,WebGLRenderTarget as b,WebGLRenderer as y,NearestFilter as T,RGBAFormat as S,LinearSRGBColorSpace as M,FloatType as z,Box3 as F,Box3Helper as A,CatmullRomCurve3 as R,Clock as C,PositionalAudio as P,Audio as k,AudioContext as D,Texture as L,SRGBColorSpace as U,NoColorSpace as j,CubeTextureLoader as O,CanvasTexture as I,UVMapping as N,ClampToEdgeWrapping as B,DataTexture as V,BufferAttribute as q,Box2 as Y,Sphere as G,Plane as E,Line3 as W,Quaternion as X,Matrix4 as Q,Ray as $,RepeatWrapping as H,LinearFilter as Z,Skeleton as J,DoubleSide as K,LinearMipMapLinearFilter as ee,InstancedBufferGeometry as te,Float32BufferAttribute as se,InstancedBufferAttribute as ie,DynamicDrawUsage as re,HalfFloatType as ne,Points as oe,FileLoader as ae}from"three";import*as _e from"three/examples/jsm/utils/BufferGeometryUtils.js";export{_e as BufferGeometryUtils};import{ResourceContainer as le}from"ohzi-core";import{GLTFLoader as he}from"three/examples/jsm/loaders/GLTFLoader.js";import{RGBELoader as ce}from"three/examples/jsm/loaders/RGBELoader.js";import{ColladaLoader as ue}from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as de}from"three/examples/jsm/loaders/FontLoader.js";import{HDRCubeTextureLoader as pe}from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import{OBJLoader as me}from"three/examples/jsm/loaders/OBJLoader.js";class ge extends e{constructor(e=1){super();const o=[];o.push(new t(0,0,0)),o.push(new t(0,0,1e3));const a=new s({color:4474111,depthFunc:i}),_=(new r).setFromPoints(o),l=new n(_,a);l.renderOrder=5e4;const h=[];h.push(new t(0,0,0)),h.push(new t(0,1e3,0));const c=new s({color:4521796,depthFunc:i}),u=(new r).setFromPoints(h),d=new n(u,c);d.renderOrder=5e4;const p=[];p.push(new t(0,0,0)),p.push(new t(1e3,0,0));const m=new s({color:16729156,depthFunc:i}),g=(new r).setFromPoints(p),f=new n(g,m);f.renderOrder=5e4,this.renderOrder=1e5,this.add(l),this.add(d),this.add(f),this.scale.set(e,e,e)}update(){}dispose(){}}const fe=new class{init(){this._current=new o,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;"disppose"in t&&"function"==typeof t.disppose&&t.dispose()}})));this.current.children.length>0;)this.current.remove(this.current.children[0])}};class ve extends a{constructor(e,s,i){e=e||new t(1,1,1),s=s||new t(1,1,1),i=i||16711680;super(new _(e.x,e.y,e.z,s.x,s.y,s.z),new l({color:i}))}}class xe extends a{constructor(e,t){t=t||"#FF0000";super(new h(e=e||1,64,64),new l({color:t})),this.radius=e,this.color=t,this.center=this.position}}class we extends a{constructor(e,s,i){e=e||"#FF0000";const r=(s=s||1)-.4,n=new c(.01,.01,r,32);n.translate(0,r/2,0);const o=new u(.1,.4,32);o.translate(0,r+.2,0);const a=_e.mergeGeometries([n,o]);a.rotateX(1.57);super(a,new l({color:e})),i&&this.quaternion.setFromUnitVectors(new t(0,0,1),i),this._dir=i}set dir(e){this.quaternion.setFromUnitVectors(new t(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}}const be=new class{init(){this.width=1,this.height=1,this.position=new d,this.render_width=1,this.render_height=1,this.width_height=new d(this.width,this.height),this.dpr=1,this.pixel_size=new d(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update(){this.size_changed=!1}update_size(e,t){this.width=e,this.height=t,this.pixel_size=new d(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=t,this.render_width=e*this.dpr,this.render_height=t*this.dpr,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}};class ye extends p{constructor(e,t,s,i){super(e,t,s,i),this.clear_color=new m("#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}}const Te=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 Se=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class Me extends g{constructor(e,t,s,i,r,n){super(e,t,s,i,r,n),this.clear_color=new m("#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 ze{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}class Fe extends f{constructor(e,t,s){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new d(0,0)},_TargetResolution:{value:new d(0,0)}},defines:s||{},vertexShader:t||"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}",fragmentShader:e||"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);}",depthWrite:!1,blending:v,depthTest:!1,depthFunc:i})}}class Ae{constructor(e){this.renderer=e,this._blit_scene=new o,this._blit_material=new Fe,this._blit_quad=new a(new x(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new g(-1,1,1,-1,-1e4,1e4)}blit(e,t){this._blit_quad.material=this._blit_material;const s=!0===e.isWebGLRenderTarget?e.texture:e,i=!0===e.isWebGLRenderTarget?e.width:e.image.width,r=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material.uniforms._MainTex.value=s,this._blit_quad.material.uniforms._Resolution.value.set(i,r),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 i=!0===e.isWebGLRenderTarget?e.texture:e,r=!0===e.isWebGLRenderTarget?e.width:e.image.width,n=!0===e.isWebGLRenderTarget?e.height:e.image.height;this._blit_quad.material=s,this._blit_quad.material.uniforms._MainTex.value=i,this._blit_quad.material.uniforms._Resolution.value.set(r,n),t?this._blit_quad.material.uniforms._TargetResolution.value.set(t.width,t.height):this.renderer.getSize(this._blit_quad.material.uniforms._TargetResolution.value),this.__render(t)}blit_clear_with_material(e,t){this._blit_quad.material=t,this.__render(e)}dispose(){this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose()}__render(e){e=void 0===e?null:e;const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(void 0===e?null:e),this.renderer.render(this._blit_scene,this._blit_camera),this.renderer.setRenderTarget(t)}}class Re extends Fe{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 w(e,t.x,t.y,t.z)}}}class Ce extends f{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 Pe{constructor(){this.RT=new b(be.width,be.height),this.clear_depth_normal_mat=new Re(1,new t(0,0,1)),this.depth_normal_material=new Ce}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=Te.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===be.width&&this.RT.height===be.height||this.RT.setSize(be.width,be.height)}get render_target(){return this.RT}}const ke=new class{init({canvas:e,core_attributes:t,context_attributes:s,threejs_attributes:i,dpr:r}){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.core_attributes={force_webgl2:!0,xr_enabled:!1},this.context_attributes={alpha:!0,antialias:!1,depth:!0,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!1},this.threejs_attributes={logarithmicDepthBuffer:!1},Object.assign(this.core_attributes,t),Object.assign(this.context_attributes,s),Object.assign(this.threejs_attributes,this.context_attributes),Object.assign(this.threejs_attributes,i),this.core_attributes.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,this.threejs_attributes.canvas=e,this.threejs_attributes.context=this.canvas_context,this._renderer=new y(this.threejs_attributes),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,be.dpr=r,this._renderer.setPixelRatio(1),this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new Ae(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new ze,this.current_render_mode=this.no_render,Se.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),Se.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,Se.fp_textures_available=this.is_floating_point_texture_available(),this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new Pe}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.generateDepthNormalTexture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),Te.current&&this.current_render_mode.render(),be.update()}__update_current_camera(){Te.current&&(Te.current.aspect=be.aspect_ratio,Te.current.updateProjectionMatrix(),Te.current.updateMatrix(),Te.current.updateMatrixWorld(!0))}render(e,t,s,i){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.render(e||fe.current,t||Te.current),this.__apply_override_material(e,void 0)}compile(e,t,s,i){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.compile(e||fe.current,t||Te.current),this.__apply_override_material(e,void 0)}async compile_async(e,t,s,i,r){this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s);const n=this._renderer.compileAsync(e||fe.current,t||Te.current,r);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:fe.current.overrideMaterial=t}readback_RT(e,t){this._renderer.readRenderTargetPixels(e,0,0,e.width,e.height,t)}clear(e,t,s,i){this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!s,!!i)}on_resize(e,t){for(const s of e)be.dpr=t,be.update_position(s.contentRect.x,s.contentRect.y),be.update_size(s.contentRect.width,s.contentRect.height),this.canvas.width=be.render_width,this.canvas.height=be.render_height,this._renderer.setViewport(0,0,be.render_width,be.render_height),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=be.width,s=be.height){const i=be.width,r=be.height,n=t,o=s,a=1024,_=1024,l=Math.ceil(n/a),h=Math.ceil(o/_);be.update_size(a,_);const c=this._renderer.getPixelRatio();this._renderer.setPixelRatio(1),this._renderer.setSize(a,_,!1);const u=document.createElement("canvas").getContext("2d");u.canvas.width=n,u.canvas.height=o,Te.current.aspect=be.aspect_ratio,Te.current.updateMatrix(),Te.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)Te.current.setViewOffset(n,o,be.width*e,be.height*t,be.width,be.height),this.current_render_mode.render(),u.drawImage(this._renderer.domElement,be.width*e,be.height*t);u.canvas.toBlob(e,"image/png;base64;"),Te.current.clearViewOffset(),be.update_size(i,r),this._renderer.setPixelRatio(c),this._renderer.setSize(i,r,!1),Te.current.aspect=be.aspect_ratio,Te.current.updateMatrix(),Te.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()}is_floating_point_texture_available(){const e=new b(1,1,{minFilter:T,magFilter:T,format:S,colorSpace:M,type:z,stencilBuffer:!1,depthBuffer:!1}),t=new f({vertexShader:"\n void main()\n {\n gl_Position = vec4(uv * 2.0 - 1.0, 1.0, 1.0);\n }\n ",fragmentShader:"\n void main()\n {\n gl_FragColor = vec4(0.0, 4865.35, 0.0, 1.0);\n }\n ",depthWrite:!1,blending:v,depthTest:!1,depthFunc:i});this.material_pass(t,e);const s=new Float32Array(4);return this._renderer.readRenderTargetPixels(e,0,0,1,1,s),Math.abs(s[1]-4865.35)<.001}};var De="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",Le="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class Ue extends f{constructor(e,t,s){super({vertexShader:e||De,fragmentShader:t||Le,uniforms:s||{_Color:{value:new m("#FF0000")}}})}}class je extends Ue{constructor(e,t,s,i){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 d},_ScreenSize:{value:new d},_TextureSize:{value:new d}})}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)}}const Oe=new class{init(){this.Vector3_one=new t(1,1,1),this.Vector3_zero=new t(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new o,this.camera=new ye(60,be.aspect_ratio,.1,1e3),this.camera.clear_alpha=0}draw_arrow(e,t,s=16711680){const i=new we(s,t.length(),t.clone().normalize());return i.position.copy(e),this.scene.add(i),i}draw_axis(){const e=new ge;return this.scene.add(e),e}set_debug_RT(e){this.rt_debug=e}draw_rectangle(e,t,s,i){t=t||100,s=s||100,this.ctx.fillStyle=i||"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 i=new s({color:t}),o=(new r).setFromPoints(e),a=new n(o,i);return a.frustumCulled=!1,this.scene.add(a),a}draw_cube(e,s,i){s=s||1,i=i||16711680,e=e||new t;const r=new ve(new t(s,s,s),void 0,i);return r.position.copy(e),this.scene.add(r),r}draw_oriented_cube(e,s,i=1,r="#FF0000",n=.1){const o=e.distanceTo(s),a=new ve(new t(n,i,o),void 0,r),_=s.clone().sub(e).multiplyScalar(.5),l=_.clone().normalize();return _.add(e),a.position.copy(_),a.quaternion.setFromUnitVectors(new t(0,0,-1),l),this.scene.add(a),a}draw_plane(e,t,s){const i=new x(e,t),r=new f({uniforms:{_Color:{value:new w(0,1,0,.2)}},vertexShader:De,fragmentShader:Le,transparent:!0,depthWrite:!1}),n=new a(i,r);return n.renderOrder=-1e4,this.scene.add(n),n}draw_empty_cube(e,s,i){s=s||1,i=i||16711680;const r=(new F).setFromCenterAndSize(new t,new t(s,s,s)),n=new A(r,i);return n.position.copy(e||new t),n}draw_sphere(e,s,i){s=s||1,i=i||16711680,e=e||new t;const r=new xe(s,i);return r.position.copy(e),this.scene.add(r),r}draw_point_array(e,t=!1,s=16711680){const i=new R(e,t);i.updateArcLengths();const r=i.getSpacedPoints(200);return this.draw_line(r,65280)}draw_sphere_helper(e,t){t=t||16711680;const s=new h(e.radius,32,32),i=new l({color:t}),r=new a(s,i);return r.position.copy(e.center),fe.current.add(r),r}draw_math_sphere(e){const t=new h(e.radius,32,32),s=new f({uniforms:{_Color:{value:new w(1,0,0,.2)}},vertexShader:De,fragmentShader:Le,transparent:!0}),i=new a(t,s);i.position.copy(e.center),fe.current.add(i)}draw_bounding_box(e){const t=new A(e,16776960);fe.current.add(t)}draw_curve(e,s){const i=new t(0,0,0);s&&(i.y=s.offset||0);for(let t=0;t<e.length-1;t++)this.draw_line([e[t].clone().add(i),e[t+1].clone().add(i)])}draw_texture(e,t,s){const i=new a(new x(1,1),new je);return this.display_texture_meshes.push(i),this.scene.add(i),i.material.set_texture(e,t,s),i}render(e){for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(be.width,be.height);this.scene.children.length>0&&e.render(this.scene,Te.current)}};const Ie=new class{constructor(){this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016]}init(){this.___time=new C,this.__delta_time=0,this.__smooth_delta_time=0,this.__elapsed_time=0,this.__allocated_time=new d(0,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 shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_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(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime(),this.__delta_buffer.shift(),this.__delta_buffer.push(this.delta_time<.32?this.delta_time:.032),this.__calculate_smooth_delta_time()}__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 Ne{constructor(){}static linear_map(e,t,s,i,r){return(e-t)/(s-t)*(r-i)+i}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*e.r).toString(16),e.g=Math.round(255*e.g).toString(16),e.b=Math.round(255*e.b).toString(16),1===e.r.length&&(e.r="0"+e.r),1===e.g.length&&(e.g="0"+e.g),1===e.b.length&&(e.b="0"+e.b),"#"+e.r+e.g+e.b}static project_points_on_plane(e,t){const s=e[0].clone();s.set(0,0,0);const i=[];for(let r=0;r<e.length;r++)t.projectPoint(e[r],s),i.push(s.clone());return i}static matrix4_lerp(e,t,s,i){for(let r=0;r<16;r++)s.elements[r]=this.lerp(e.elements[r],t.elements[r],i)}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(Ne.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 Ne.clamp(e,0,1)}}class Be{constructor(e,t,s){this.name=e,this.method=t,this.args=s}trigger(){ViewApi.application[this.name][this.method](...this.args.split(","))}}class Ve{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 qe{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?Ve[e]:e,this.attribute_name="",this.from=0,this.to=1}update(e,t){}}class Ye{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=Ne.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=Ne.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return Ne.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,i=!1){if(i){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 r={from:e,to:t,interpolator:s};this.duration=Math.max(this.duration,t),this.channels[s.attribute_name].push(r)}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 i=s[t],r=this.__get_current_keyframe(i,e);this.context[i]=this.evaluate_keyframe(r,e)}}__play_events(e,t){for(let s=0;s<this.action_events.length;s++){const i=this.action_events[s].trigger_time;Ne.between(i,e,t)&&(console.log("Play event: "+this.action_events[s].action.constructor.name+" at "+this.action_events[s].trigger_time),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(Ne.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 Ne.saturate((e-t)/(s-t)*1+0)}__get_current_keyframe(e,t){let s;const i=this.channels[e];for(let e=0;e<i.length;e++){const r=i[e];if(t>=r.from&&t<=r.to)return s=r,s}let r=1/0;for(let e=0;e<i.length;e++){const n=i[e],o=Math.abs(n.to-t);o<r&&(s=n,r=o)}return s}__get_playback_speed(){const e=new URLSearchParams(window.location.search).get("transitions_velocity");return e?Number(e):1}}class Ge extends qe{constructor(e,t=0,s=1,i=!1,r="linear"){super(r),this.attribute_name=e,this.from=t,this.to=s,this.initial=i}update(e,t){e[this.attribute_name]=Ne.lerp(this.from,this.to,this.easing_function(t))}evaluate(e){return Ne.lerp(this.from,this.to,this.easing_function(e))}}class Ee{constructor(){}parse(e){const t=(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("mxGeometry"),s=[],i=[];for(let e=0;e<t.length;e++){const r=t[e],n=r.parentElement,o=n.getAttribute("value"),a=this.get_node_x_position(r)/100,_=parseFloat(r.getAttribute("width"))/100;if(n.getAttribute("style").includes("rhombus;")){const e=o.split("."),t=e[0],s=e[1];i.push({name:t,method:s,at_time:a+.5*_})}if(n.getAttribute("style").includes("rounded=0;")&&!n.getAttribute("style").includes("text;")&&""!==o&&!o.includes(" ")){const e=o.split("="),t=e[0],i=e[1].split("--"),r=parseFloat(i[0]),n=i[1];2!==e.length&&console.error("DrawIO data is malformed:",o),2!==i.length&&console.error("DrawIO data is malformed:",o),s.push({attribute_name:t,from_time:a,to_time:a+_,to_value:r,easing_function:n})}}return s.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:s,triggers:i}}get_node_x_position(e){const t=e.getAttribute("x");return null===t?0:parseFloat(t)}}class We{constructor(e){this.default_state_data=e}from_animation_sheet(e,t,s){s=s||this.default_state_data;const i=e.animation_tracks,r=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===i.find((t=>t.attribute_name===n[e].attribute_name))&&i.push(n[e]);const o=new Ye(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Ge(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,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new Be(t.name,t.method,t.args);o.add_action_event(t.at_time,s)}return o}state_to_tracks(e,t){const s=[],i=Object.keys(e);for(let r=0;r<i.length;r++)s.push({attribute_name:i[r],from_time:0,to_time:t<1?t:1,to_value:e[i[r]],initial:!0,easing_function:"ease_in_out_cubic"});return s}from_draw_io(e,t){const s=(new Ee).parse(e),i=s.animation_tracks,r=s.triggers,n=new Ye(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Ge(s.attribute_name,t[s.attribute_name],s.to_value,s.initial,s.easing_function);n.add_action_interpolator(s.from_time,s.to_time,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new Be(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 i=e[s].to_time;t=i>t?i:t}return t}}class Xe{constructor(){this.transitions=[],this.default_state_data={}}get(e,t,s){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].from===e&&this.transitions[i].to===t){return new We(this.default_state_data).from_animation_sheet(this.transitions[i].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 We(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}}class Qe{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 $e{constructor(e){this.last_state=new Qe,this.current_state=new Qe,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(Ie.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 He=new class{constructor(){this.transition_table=new Xe,this.transition_handler=new $e(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)}set_transitions_velocity(e){this.transition_table.set_transitions_velocity(e)}};const Ze=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(He.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(He.current_state_data)}};const Je=new class{constructor(){this.views=[],this.browser_title_suffix=""}update(){this.__set_views_opacities()}go_to_view(e,t=!0,s=!1){const i=this.get(e);t&&(this.__change_browser_url(i.url),this.__change_browser_title(i.url)),He.go_to_state(i,s)}go_to_scene(e,t=!1,s=!1){const i=this.get(e),r=this.get("transition");r.set_next_view(i),this.go_to_view(r.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);He.set_state(t)}set_browser_title_suffix(e){this.browser_title_suffix=e}get_current_view(){return He.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(He.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 Ke{constructor(e,t,s){e=e||new et,this.target_application=e,this.graphics=t,this.input=s,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0}update(){if(this.is_running){for(Ie.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.input.update(),this.time_accumulator+=Ie.delta_time,this.target_application.before_update(),He.before_update();this.time_accumulator>Ie.fixed_delta_time;)this.target_application.fixed_update(),He.fixed_update(),this.time_accumulator-=Ie.fixed_delta_time;Ie.__set_frame_interpolation(this.time_accumulator/Ie.fixed_delta_time),this.target_application.update(),He.update(),Je.update(),Ze.update(),this.target_application.on_pre_render(),this.graphics.update(),this.target_application.on_post_render(),Oe.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,this.input.clear(),Oe.clear()}}start(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(),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.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}}class et{on_post_start(){}on_enter(e){}on_exit(e){}before_update(){}update(){}fixed_update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}}class tt extends Fe{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}class st extends Fe{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};const t=[new m("#FFFFFF"),new m("#FFFFFF"),new m("#FFFFFF"),new m("#FFFFFF"),new m("#FFFFFF")];this.uniforms.bloomTintColors={value:t}}set_RT_0(e){this.uniforms.blurTexture1.value=e}set_RT_1(e){this.uniforms.blurTexture2.value=e}set_RT_2(e){this.uniforms.blurTexture3.value=e}set_RT_3(e){this.uniforms.blurTexture4.value=e}set_RT_4(e){this.uniforms.blurTexture5.value=e}set_bloom_strength(e){this.uniforms.bloomStrength.value=e}set_bloom_radius(e){this.uniforms.bloomRadius.value=e}set_tint_color_0(e){this.uniforms.bloomTintColors.value[0].set(e)}set_tint_color_1(e){this.uniforms.bloomTintColors.value[1].set(e)}set_tint_color_2(e){this.uniforms.bloomTintColors.value[2].set(e)}set_tint_color_3(e){this.uniforms.bloomTintColors.value[3].set(e)}set_tint_color_4(e){this.uniforms.bloomTintColors.value[4].set(e)}}class it{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(),i=t.body.getReader(),r=+t.headers.get("Content-Length");let n=0;for(;;){const{done:e,value:t}=await i.read();if(e)break;n+=t.length,this.__update_downloaded_bytes(n,r)}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)}}class rt{constructor(e,t=!0,s=1,i=!1){this.buffer=e,this.loop=t,this.volume=s,this.positional=i,this.audio=void 0}init(e){this.positional?this.audio=new P(e):this.audio=new k(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 nt extends it{constructor(e,t,s=!0,i=0,r,n=!1){super(e,t,r),this.loop=s,this.volume=i,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=D.getContext(),s=t.createBuffer(2,22050,44100);fetch(this.url).then((e=>e.blob())).then((i=>{i.arrayBuffer?i.arrayBuffer().then((s=>{t.decodeAudioData(s,(t=>{e.set_resource(this.resource_id,this.url,new rt(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 rt(s,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended())}))}}const ot=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 at{constructor(e,t,s){this.resource_container=ot,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.js",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 _t extends at{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 nt(s.name,s.url,s.loop,s.volume,s.size,s.positional))}return e}}class lt extends it{constructor(e,t,s,i){super(e,t,i),this.loader=new he,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=>{}),(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 ht extends it{constructor(e,t,s){super(e,t,s),this.loader=new he}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 ct extends at{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=ot.get("draco_loader");e.push(new lt(s.name,s.url,t,s.size))}else e.push(new ht(s.name,s.url,s.size))}return e}}const ut=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",i=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(i[1])&&(t=/\brv[ :]+(\d+)/g.exec(e)||[],s="IE "+(t[1]||"")),"Chrome"===i[1]&&(t=e.match(/\b(OPR|Edge)\/(\d+)/),null!=t&&(s=t.slice(1).join(" ").replace("OPR","Opera"))),i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+(\.\d+)?)/i))&&i.splice(1,1,t[1]),s=i.join(" "),Number(s.split(" ")[1])}};class dt extends it{constructor(e,t,s,i=!0,r=!1,n=!0){super(e,t,s),this.original_url="",this.colorSpaceConversion=n,this.premultiplyAlpha=r,this.flipY=i}on_preloaded_finished(e){ut.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 L,s=new Image;s.src=this.url,s.onload=()=>{t.image=s,t.flipY=this.flipY,t.premultiplyAlpha=this.premultiplyAlpha,t.colorSpace=this.colorSpaceConversion?U:j,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":"none",premultiplyAlpha:this.premultiplyAlpha?"premultiply":"none"}))).then((t=>{const s=new L(t);s.flipY=this.flipY,s.premultiplyAlpha=this.premultiplyAlpha,s.colorSpace=this.colorSpaceConversion?U:j,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 pt extends it{constructor(e,t,s,i){super(e,t,i),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 mt extends it{constructor(e,t,s,i){super(e,t,i),this.loader=new O,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=>{}),(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 gt extends it{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=>{}),(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 ft extends at{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 dt(s.name,s.url,s.size));break;case"basis":e.push(new pt(s.name,s.url,ot.get("basis_loader"),s.size));break;case"hdr":e.push(new gt(s.name,s.url,s.size));break;case"cubemap":e.push(new mt(s.name,s.url,s.extension,s.size))}}return e}}class vt{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 xt{constructor(e,{SceneCompilator:t,TexturesCompilator:s,AudiosCompilator:i}){this.scene=e,this.SceneCompilator=t,this.TexturesCompilator=s,this.AudiosCompilator=i,this.loaders=[],this.compilators=[],this.callback_called=!1}set_assets(e,t,s,i=[],r=[],n=[]){this.scene_objects=e,this.scene_textures=t,this.scene_sounds=s,this.custom_loaders=i,this.custom_compilators=r,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=le.get("assets_worker");t.postMessage({type:"reset",loader_name:this.scene.name});const s=new ct(this.scene.name,this.scene_objects,t);this.loaders.push(s),e.push(new this.SceneCompilator(this.scene));const i=new ft(this.scene.name,this.scene_textures,t);this.loaders.push(i),e.push(new this.TexturesCompilator(i.get_assets_names()));const r=new _t(this.scene.name,this.scene_sounds,t);this.loaders.push(r),e.push(new this.AudiosCompilator(r.get_assets_names()));for(let s=0;s<this.custom_loaders.length;s++){const i=new this.custom_loaders[s](this.scene.name,this.custom_data[s],t);this.loaders.push(i),e.push(new this.custom_compilators[s](i.get_assets_names()))}this.compilator_manager=new vt(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 wt extends xt{on_enter(){super.on_enter()}on_exit(){super.on_exit()}update(){super.update(),this.is_loaded()&&this.scene.on_high_quality_assets_ready()}}class bt extends xt{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 yt extends o{constructor({name:e,compilators:t}){super(),this.name=e,this.is_loaded=!1,this.is_high_loaded=!1,this.loading_states={regular:new bt(this,t),high:new wt(this,t)},this.current_loading_state=new xt(this,t)}get loading_progress(){return this.current_loading_state.loading_progress}init(){}load(){this.init(),this.set_loading_state(this.loading_states.regular),this.current_loading_state.load()}get_objects(){const e=[];return this.traverse((t=>{t.geometry&&e.push(t)})),e}dispose_cpu(){this.traverse((e=>{if(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)}))}dispose(){this.traverse((e=>{e.material&&(e.material.map&&e.material.map.dispose(),e.material.dispose(),e.geometry.dispose())}))}set_assets(e,t,s,i,r,n){this.loading_states.regular.set_assets(e,t,s,i,r,n)}set_high_assets(e,t,s,i,r,n){this.loading_states.high.set_assets(e,t,s,i,r,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}}class Tt extends Qe{constructor({name:e,url:t,container:s,transition_data:i}){super(e),this.container=s,this.url=t,this.current_opacity=0;const r=[{to:e,data:i=i||{animation_tracks:[],triggers:[]}}];Je.register_view(this),He.add_transitions(r)}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 St{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"),i=document.createTextNode("MÉqgOLAKTAL");s.appendChild(i),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,t="24px Arial"){const s=new d;return this.ctx.font=t,s.x=Math.ceil(this.ctx.measureText(e).width),s.y=Math.ceil(this.getFontHeight(t)),s}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),i=new I(s,N,B,B,T,T);return i.generateMipmaps=!1,i.needsUpdate=!0,i}__draw(e,t,s,i){}roundRect(e,t,s,i,r,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+i-n.tr,s),e.quadraticCurveTo(t+i,s,t+i,s+n.tr),e.lineTo(t+i,s+r-n.br),e.quadraticCurveTo(t+i,s+r,t+i-n.br,s+r),e.lineTo(t+n.bl,s+r),e.quadraticCurveTo(t,s+r,t,s+r-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 Mt extends St{constructor(){super(),this.text_margin=new d(2,0)}__draw(e,t,s,i){i.font=t.font;const r=this.get_text_size(e,t.font);s.width=Math.ceil(r.x+2*this.text_margin.x),s.height=Math.ceil(r.y+2*this.text_margin.y),i.clearRect(0,0,s.width,s.height),i.globalAlpha=0,i.fillStyle=t.font_color||"#000000",i.fillRect(0,0,s.width,s.height),i.globalAlpha=1,i.globalAlpha=1,i.font=t.font,i.fillStyle=t.font_color||"#000000",i.textBaseline="middle",i.textAlign=t.textAlign||"center","center"===i.textAlign?i.fillText(e,s.width/2,s.height/2):i.fillText(e,0,s.height/2)}}class zt{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Ft{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(e){this.t+=Ie.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=Ne.clamp(this.easing_function_t,0,1),e.set_property_value(Ne.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 zt),e.finished_callback(e))}on_exit(e){}}class At{constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n="",value_suffix:o="",easing_function:a=Ve.ease_in_out_cubic,finished_callback:_=(()=>{})}){this.element=e,this.css_property=t,this.from=s,this.to=i,this.value_prefix=n,this.value_suffix=o,this.duration=r,this.easing_function=a,this.finished_callback=_,this.current_state=new zt}animate(){this.set_current_state(new Ft)}stop(){this.set_current_state(new zt)}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 Rt=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 Ct=new class{init(){this.target_geometry=void 0,this.target_position=new t}set_target_geometry(e){this.target_geometry=e}};class Pt{constructor(e,t){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=t,this.data_textures=[],this.object_names=void 0,this.zero_offset=new d,this.write_offset=new d,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(e,t,s){this.material=new f({uniforms:this.uniforms,vertexShader:t,fragmentShader:s}),this.object_names=e}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){const s=this.__create_rgb_texture(this.batch_width),i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){const s=this.__create_rgba_texture(this.batch_width),i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){const s=this.__create_rgba_float_texture(this.batch_width),i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,s,i,r,n){const o=this.__get_object_index(e),a=this.__get_data_texture(t);this.__set_pixel_rgb(a.src,o,s,i,r,n),this.__set_pixel_rgb(a.one_pixel,0,s,i,r,n),a.last_accessed_index=o,a.dirty_count++}set_object_uniform_v4(e,t,s,i,r,n,o){const a=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,a,s,i,r,n,o),this.__set_pixel_rgba(_.one_pixel,0,s,i,r,n,o),_.last_accessed_index=a,_.dirty_count++}upload_texture_data(e,t){for(let s=0;s<this.data_textures.length;s++)t>0&&this.data_textures[s].dirty_count>0&&(1===this.data_textures[s].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){const s=t.last_accessed_index;-1!==s&&(this.write_offset.y=Math.floor(s/this.batch_width),this.write_offset.x=s-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new a(this.geometry,this.material)}__set_pixel_rgb(e,t,s,i,r,n){i&&(e.image.data[3*t+0]=s.x),r&&(e.image.data[3*t+1]=s.y),n&&(e.image.data[3*t+2]=s.z)}__set_pixel_rgba(e,t,s,i,r,n,o){i&&(e.image.data[4*t+0]=s.x),r&&(e.image.data[4*t+1]=s.y),n&&(e.image.data[4*t+2]=s.z),o&&(e.image.data[4*t+3]=s.w)}__flood_data_texture_rgb(e,t){for(let s=0;s<this.batch_width*this.batch_width;s++)this.__set_pixel_rgb(e.src,s,t,!0,!0,!0),e.dirty_count++}__flood_data_texture_rgba(e,t){for(let s=0;s<this.batch_width*this.batch_width;s++)this.__set_pixel_rgba(e.src,s,t,!0,!0,!0,!0),e.dirty_count++}__create_rgb_texture(e){const t=new Uint8Array(3*e*e);return new V(t,e,e,S)}__create_rgba_texture(e){const t=new Uint8Array(4*e*e);return new V(t,e,e,S)}__create_rgba_float_texture(e){const t=new Float32Array(4*e*e);return new V(t,e,e,S,z)}__get_data_texture(e){for(let t=0;t<this.data_textures.length;t++)if(this.data_textures[t].name===e)return this.data_textures[t];console.error("Data texture "+e+" does not exist")}__get_object_index(e){for(let t=0;t<this.object_names.length;t++)if(this.object_names[t]===e)return t;console.error("the name "+e+" is not contained in this batch")}__add_data_texture(e,t,s,i){return s.needsUpdate=!0,this.data_textures.push({name:e,src:t,dst:s,one_pixel:i,last_accessed_index:-1,dirty_count:0}),this.uniforms[e]={value:s},this.data_textures[this.data_textures.length-1]}dispose(){for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].src.dispose(),this.data_textures[e].dst.dispose(),this.data_textures[e].one_pixel.dispose()}}const kt=new class{init(){this.batches=[]}batch(e){const t=[],s=Ne.ceilPowerOfTwo(Math.sqrt(e.length));this.__init_uv_array(t,s);let i=0;for(let r=0;r<e.length;r++){const n=e[r].getAttribute("position").count,o=Math.floor(r/s),a=r-s*o;for(let e=0;e<n;e++)t[i]=a/s+.5/s,t[i+1]=o/s+.5/s,i+=2}const r=new q(new Float32Array(t),2),n=_e.mergeGeometries(e);return n.setAttribute("attr_accessor_uv",r),this.batches.push(new Pt(n,s)),this.batches[this.batches.length-1]}upload_texture_data(e){for(let t=0;t<this.batches.length;t++)this.batches[t].upload_texture_data(e,1)}__init_uv_array(e,t){for(let s=0;s<t*t*2;s++)e.push(0)}};class Dt extends Ue{constructor(e=1){super("#define GLSLIFY 1\nuniform vec2 _ScreenSize;uniform vec2 _TextureSize;uniform vec2 _PixelOffset;uniform vec3 _NDC;uniform vec2 _PivotPoint;uniform float _DepthOffset;varying vec2 vUv;vec2 add_pixel_offset(vec2 pos){pos=pos*0.5+0.5;pos*=_ScreenSize;pos=ceil(pos+_PixelOffset)+0.5;pos/=_ScreenSize;return pos*2.0-1.0;}void main(){vec4 projected_pos=projectionMatrix*viewMatrix*vec4(_NDC,1.0);projected_pos.zw+=_DepthOffset;projected_pos.xyz/=projected_pos.w;vec2 normalized_size=_TextureSize/_ScreenSize;vec2 dir=uv*2.0-1.0;dir-=_PivotPoint;vec2 pos=projected_pos.xy+dir*normalized_size;gl_Position=vec4(add_pixel_offset(pos),projected_pos.z,1.0);vUv=uv;}","#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _ScreenSize;uniform vec2 _TextureSize;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv+vec2(0.5,0.5)/_TextureSize);}",{_MainTex:{value:void 0},_ScreenSize:{value:new d(be.width,be.height)},_TextureSize:{value:new d},_PixelOffset:{value:new d(0,0)},_NDC:{value:new t},_PivotPoint:{value:new d},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class Lt{constructor(){this.tmp_vec=new d}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class Ut{constructor(){this.tmp_vec3=new t,this.tmp_vec2=new d}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(Te.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class jt{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class Ot extends jt{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class It extends jt{constructor(){super()}on_enter(e){e.on_mouse_enter()}update(e,t){e.is_mouse_over(t)?e.set_state(e._on_hover_state):e.set_state(e._on_exit_state)}}class Nt extends jt{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class Bt extends jt{constructor(){super()}on_enter(e){this.__trigger_on_hover(e)}update(e,t){e.is_mouse_over(t)?this.__trigger_on_hover(e):e.set_state(e._on_exit_state)}__trigger_on_hover(e){e.on_mouse_hover()}}class Vt extends a{constructor(e,s){const i=new Dt;super(new x(1,1),i),this.material=i,this.is_clickable=!1,this.position_strategy=new Ut,this.current_state=new Ot,this._position=new t,this._on_idle_state=new Ot,this._on_enter_state=new It,this._on_exit_state=new Nt,this._on_hover_state=new Bt,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new d,this.cached_NDC_position=new d,this.screen_pos_tmp=new d,this.texture_size=new d(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new d}set_render_order(e){this.renderOrder=e}get pivot_point(){return this.material.uniforms._PivotPoint.value}set_pixel_offset(e){this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e)}set_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}get position(){return this._position}set use_depth(e){this.material.depthTest=e}get use_depth(){return this.material.depthTest}set depth_offset(e){this.material.uniforms._DepthOffset.value=e}get depth_offset(){return this.material.uniforms._DepthOffset.value}clear_state(){this.visible=!1}set_world_space_coordinate_system(){this.position_strategy=new Ut}set_screen_space_coordinate_system(){this.position_strategy=new Lt}set_texture(e){e.minFilter=T,e.magFilter=T,e.needsUpdate=!0,this.texture_size.set(e.image.width,e.image.height),this.material.uniforms._MainTex.value=e,this.get_size(this.material.uniforms._TextureSize.value),this.visible=!0}update_state(e){this.material.uniforms._ScreenSize.value.set(be.width,be.height),this.get_size(this.material.uniforms._TextureSize.value),this.cached_NDC_position.copy(this.position_strategy.get_pos_NDC(this.position)),this.material.uniforms._NDC.value.copy(this.position),this.current_state.update(this,e)}is_mouse_over(e){this.screen_pos_tmp.copy(this.cached_NDC_position),this.to_screen_position(this.screen_pos_tmp),this.screen_pos_tmp.x+=this.pixel_offset.x,this.screen_pos_tmp.y+=this.pixel_offset.y;const t=(new Y).setFromCenterAndSize(this.screen_pos_tmp,this.get_size());return this.mouse_pos_tmp.copy(e),this.to_screen_position(this.mouse_pos_tmp),t.containsPoint(this.mouse_pos_tmp)}to_screen_position(e){e.x=(.5*e.x+.5)*be.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*be.height+this.pixel_offset.y}get_screen_space_position(){const e=this.cached_NDC_position.clone();return this.to_screen_position(e),e}set_screen_space_position(e){this.position.x=e.x/be.width*2-1,this.position.y=e.y/be.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/be.dpr):(new d).copy(this.texture_size).multiplyScalar(this.size/be.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}const qt=new class{init(e){this.input=e,this.ui_elements=[],this._tmp_normalized_pos=new d,this.ss_scene=new o,this.ss_scene.matrixWorldAutoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new o,this.ws_scene.matrixWorldAutoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new Me(-1,1,1,-1,-100,100)}delete_element(e){const t=this.ui_elements.indexOf(e);t>-1&&this.ui_elements.splice(t,1),this.ss_scene.remove(e),this.ws_scene.remove(e),e.dispose()}add_screen_space_element(e){this.ui_elements.push(e),this.ss_scene.add(e),e.set_screen_space_coordinate_system()}add_world_space_element(e){this.ui_elements.push(e),this.ws_scene.add(e),e.set_world_space_coordinate_system()}update(){this.ss_camera.updateProjectionMatrix(),this._tmp_normalized_pos.copy(this.input.NDC);for(let e=0;e<this.ui_elements.length;e++)this.ui_elements[e].update_state(this._tmp_normalized_pos)}render(e){this.ss_scene.children.length>0&&ke.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&ke.render(this.ws_scene,Te.current)}clear(){this.current_clicked_element=void 0}};class Yt{constructor(){this.sphere=new G}fit_points(e,s,i,r){this.sphere.setFromPoints(e);const n=Ne.degToRad(i/2),o=2*Math.atan(Math.tan(n)*r)/2,a=this.get_up_plane_normal(s,n),_=this.get_down_plane_normal(s,n),l=this.get_left_plane_normal(s,o),h=this.get_right_plane_normal(s,o),c=new t(0,0,-1).applyQuaternion(s),u=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=u.clone().add(c.clone().multiplyScalar(-1*d)),m=(new E).setFromNormalAndCoplanarPoint(a,p),g=(new E).setFromNormalAndCoplanarPoint(_,p),f=(new E).setFromNormalAndCoplanarPoint(l,p),v=(new E).setFromNormalAndCoplanarPoint(h,p);this.apply_center_correction_to_pos(p,e,s,m,g,f,v),m.setFromNormalAndCoplanarPoint(a,p),g.setFromNormalAndCoplanarPoint(_,p),f.setFromNormalAndCoplanarPoint(l,p),v.setFromNormalAndCoplanarPoint(h,p);let x=1/0;const w=c.clone().multiplyScalar(-2*d);for(let s=0;s<e.length;s++){const i=new W(e[s].clone(),e[s].clone().add(w)),r=new t,n=new t,o=new t,a=new t;m.intersectLine(i,r),g.intersectLine(i,n),f.intersectLine(i,o),v.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",s),n.length()<1e-4&&console.log("down intersection not found",s),o.length()<1e-4&&console.log("left intersection not found",s),a.length()<1e-4&&console.log("right intersection not found",s);const _=e[s].clone().sub(r).length(),l=e[s].clone().sub(n).length(),h=e[s].clone().sub(o).length(),c=e[s].clone().sub(a).length(),u=Math.min(_,l),d=Math.min(h,c),p=Math.min(u,d);p<x&&(x=p)}const b=c.clone().multiplyScalar(x);return p.clone().add(b)}apply_center_correction_to_pos(e,t,s,i,r,n,o){const a=this.get_vertical_correction(t,r,i,s),_=this.get_horizontal_correction(t,n,o,s);e.add(a),e.add(_)}get_vertical_correction(e,s,i,r){let n=1/0,o=1/0;const a=new t(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const _=new W(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new W(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),h=new t,c=new t;s.intersectLine(_,h),i.intersectLine(l,c);const u=h.distanceTo(e[r]),d=c.distanceTo(e[r]);c.length()<1e-4&&console.log("vertical up intersection not found",r),h.length()<1e-4&&console.log("vertical down intersection not found",r),u<o&&(o=u),d<n&&(n=d)}const _=(n-o)/2;return a.clone().multiplyScalar(-_)}get_horizontal_correction(e,s,i,r){let n=1/0,o=1/0;const a=new t(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const _=new W(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new W(e[r].clone(),e[r].clone().add(a.clone().multiplyScalar(5e6))),h=new t,c=new t;s.intersectLine(_,h),i.intersectLine(l,c);const u=h.distanceTo(e[r]),d=c.distanceTo(e[r]);h.length()<1e-4&&console.log("left intersection not found",r),c.length()<1e-4&&console.log("right intersection not found",r),u<o&&(o=u),d<n&&(n=d)}const _=(n-o)/2;return a.clone().multiplyScalar(-_)}get_up_plane_normal(e,s){const i=new t(0,-1,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(1,0,0),s)),i.applyQuaternion(e),i}get_down_plane_normal(e,s){const i=new t(0,1,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(1,0,0),-s)),i.applyQuaternion(e),i}get_left_plane_normal(e,s){const i=new t(1,0,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(0,1,0),s)),i.applyQuaternion(e),i}get_right_plane_normal(e,s){const i=new t(-1,0,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(0,1,0),-s)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class Gt{constructor(){}fit_points(e,s,i,r){const n=s.clone().inverse(),o=[];for(let t=0;t<e.length;t++)o.push(e[t].clone().applyQuaternion(n));const a=(new F).setFromPoints(o),_=new t;a.getSize(_);const l=this.get_distance_to_fit_rect(_.x/2,_.y/2,i,r),h=new t;return a.getCenter(h),h.applyQuaternion(s),{center:h,distance_to_center:l}}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}const Et=new class{init(e){this.tmp_mat=new Q,this.plane=new E,this.ray=new $,this.tmp_size=new t,this.tmp_unproj=new t,this.input=e}get_up_dir(e){e=e||Te.current;const s=new t;return s.set(0,1,0),s.applyQuaternion(e.quaternion),s}get_forward_dir(e){e=e||Te.current;const s=new t;return s.set(0,0,-1),s.applyQuaternion(e.quaternion),s}get_right_dir(e){e=e||Te.current;const s=new t;return s.set(1,0,0),s.applyQuaternion(e.quaternion),s}unproject_mouse_position(e,s){s=s||Te.current;const i=new t,r=s.fov/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*s.aspect)/2,o=Math.tan(r)*s.far,a=Math.tan(n)*s.far;return i.set(a*e.x,o*e.y,-s.far).normalize(),i.applyQuaternion(s.quaternion)}get_plane_intersection(e,s,i,r){r=r||Te.current,i=i||this.input.NDC;const n=new t;return this.plane.setFromNormalAndCoplanarPoint(s||this.get_forward_dir(r),e),r.isPerspectiveCamera?this.ray.set(r.position,this.unproject_mouse_position(i,r)):(this.tmp_unproj.set(i.x,i.y,1).unproject(r),this.ray.set(r.position,this.tmp_unproj)),this.ray.intersectPlane(this.plane,n),n}fit_points_on_camera(e,s=1){const i=(new G).setFromPoints(e).center,r=this.get_forward_dir(Te.current).clone(),n=(new E).setFromNormalAndCoplanarPoint(r,i),o=Ne.project_points_on_plane(e,n),a=new t;let _=(new F).setFromPoints(o);_.getCenter(a);const l=new t(0,1,0).applyQuaternion(Te.current.quaternion),h=l.clone().cross(r).normalize(),c=(new Q).set(h.x,l.x,r.x,i.x,h.y,l.y,r.y,i.y,h.z,l.z,r.z,i.z,0,0,0,1),u=(new Q).getInverse(c);for(let e=0;e<o.length;e++)o[e].applyMatrix4(u);const d=new t;_=(new F).setFromPoints(o),_.getSize(d),d.multiplyScalar(s);const p=new t;return _.getCenter(p),{position:a,zoom:this.get_zoom_to_fit_rect(d.x/2,d.y/2)}}get_zoom_to_fit_rect(e,t){const s=Te.current.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(s)*Te.current.aspect)/2,r=t/Math.tan(s),n=e/Math.tan(i);return Math.max(Math.abs(n),Math.abs(r))}get_zoom_to_fit_box(e,s){if(s.isOrthographicCamera){e.getSize(this.tmp_size);const t=this.tmp_size.x,s=this.tmp_size.y,i=t/s;return be.aspect_ratio/i>1?be.height/s:be.width/t}{const s=new t;return e.getSize(s),this.get_zoom_to_fit_rect(s.x,s.y)}}get_html_screen_pos(e,s){s=s||Te.current;const i=new t;return e.getWorldPosition(i),i.project(s),i.x=(.5*i.x+.5)*be.width,i.y=(1-(.5*i.y+.5))*be.height,i}world_pos_to_screen(e,s){s=s||Te.current;const i=new t;return i.copy(e),i.project(s),i.x=(.5*i.x+.5)*be.width,i.y=(1-(.5*i.y+.5))*be.height,i}update_projection(e){e.left=-be.width/2,e.right=be.width/2,e.top=be.height/2,e.bottom=-be.height/2,e.aspect=be.aspect_ratio,e.updateProjectionMatrix(!0)}fit_bounding_box_points(e,s,i=1){const r=new t;r.copy(s.max).sub(s.min);const n=s.min.clone(),o=n.clone().add(new t(r.x,0,0)),a=n.clone().add(new t(0,r.y,0)),_=n.clone().add(new t(0,0,r.z)),l=n.clone().add(new t(r.x,0,r.z)),h=n.clone().add(new t(0,r.y,r.z)),c=s.max.clone(),u=n.clone().add(new t(r.x,r.y,0));return this.fit_points(e,[n,o,a,_,l,h,c,u],i)}fit_points(e,s,i=1){if(e.isPerspectiveCamera){const r=new t(0,0,-1).applyQuaternion(e.quaternion),n=r.clone().multiplyScalar(-1),o=new Yt,a=be.aspect_ratio,_=o.fit_points(s,e.quaternion,e.fov*i,a),l=(new F).setFromPoints(s),h=new t;l.getCenter(h);const c=(new E).setFromNormalAndCoplanarPoint(n,h),u=new $(_,r),d=new t;u.intersectPlane(c,d);return{zoom:_.distanceTo(d),reference_position:d,camera_position:_}}{const r=(new Gt).fit_points(s,this.reference_rotation,e.fov*i,be.aspect_ratio);this.reference_position.copy(r.center),this.reference_zoom=r.distance_to_center;const n=new t(0,0,1).applyQuaternion(e.quaternion);return{zoom:r.distance_to_center,reference_position:r.center,camera_position:n.multiplyScalar(r.distance_to_center)}}}};const Wt=new class{constructor(){}init(e){Te.init(),Et.init(e),Se.init(),kt.init(),Rt.init(),ut.init(),Ct.init(),ot.init(),fe.init(),be.init(),Ie.init(),qt.init(e),Oe.init()}dispose(e){ke.dispose(),fe.dispose(),e.dispose()}};class Xt{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 f{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 $t extends ze{constructor(){super()}render(){ke.clear(void 0,Te.current,!0,!0),ke.render(fe.current,Te.current,void 0,new Qt)}}var Ht="#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 Zt extends Fe{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);}",Ht),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new Q}}}class Jt extends Fe{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 Kt extends Fe{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;}",Ht),this.uniforms._InverseProjMatrix={value:new Q},this.uniforms._ProjectionMatrix={value:new Q},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 s=0;s<64;s++){const i=new t(2*Math.random()-1,2*Math.random()-1,Math.random());i.normalize();let r=s/64;r=Ne.lerp(.1,1,r*r),i.multiplyScalar(r),e.push(i)}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,S);return t.wrapS=H,t.wrapT=H,t.needsUpdate=!0,t}}class es extends Fe{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 d}}}class ts{constructor(e){this.RT1=new b(1,1),this.RT2=new b(1,1),this.box_blur_mat=new es}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),ke.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),ke.blit(this.RT1,e,this.box_blur_mat)}}class ss extends ze{constructor(e=!1){super(),this.ssao_mat=new Kt,this.ssao_compose_mat=new Jt,this.debug_normals=new Zt,this.ssaa=e?2:1,this.main_RT=new b(be.width*this.ssaa,be.height*this.ssaa),this.SSAO_RT=new b(be.width,be.height),this.blurrer=new ts,ke.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),ke.clear(this.main_RT,Te.current,!0,!1),ke.render(fe.current,Te.current,this.main_RT),this.__update_uniforms(),ke.blit(ke.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),ke.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,ke.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(Te.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(Te.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=Te.current.far}__check_RT_size(){this.main_RT.width===be.width*this.ssaa&&this.main_RT.height===be.height*this.ssaa||(this.main_RT.setSize(be.width*this.ssaa,be.height*this.ssaa),this.SSAO_RT.setSize(be.width,be.height))}}class is extends ze{constructor(){super()}render(){ke.clear(void 0,Te.current,!0,!0),fe.current.on_pre_render&&fe.current.on_pre_render(),fe.current.render?fe.current.render():ke.render(fe.current,Te.current),fe.current.on_post_render&&fe.current.on_post_render()}}class rs extends Fe{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new d(.5,.5)},this.uniforms.direction={value:new d(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class ns extends Fe{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new m("#000000")},this.uniforms.defaultOpacity={value:0}}}class os{constructor(e=5){this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=e,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:Z,magFilter:Z,format:S},this.renderTargetBright=new b(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new ns}blur(e,t){this.resize_RT(e.width,e.height),t?ke.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):ke.blit(e,this.renderTargetBright);let s=this.renderTargetBright;for(let e=0;e<this.nMips;e++){const t=this.separableBlurMaterials[e];t.set_direction(1,0),ke.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),ke.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 b(1,1,this.rt_pars),t=new b(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e),this.renderTargetsVertical.push(t)}}resize_RT(e,t){if(this.current_width===e&&this.current_height===t)return;this.current_width=e,this.current_height=t;let s=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(s,i);for(let e=0;e<this.nMips;e++)this.renderTargetsVertical[e].setSize(s,i),this.renderTargetsHorizontal[e].setSize(s,i),this.separableBlurMaterials[e].set_size(s,i),s=Math.round(s/2),i=Math.round(i/2)}init_materials(e,t){this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new rs(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class as extends ze{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new tt}on_enter(){this.blurrer=new os,this.main_RT=new b(be.width,be.height),this.blur_RT=new b(be.width,be.height),this.bloom_compose_mat=new st(5),this.blurrer=new os(5),this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture),this.bloom_compose_mat.set_bloom_strength(1),this.bloom_compose_mat.set_bloom_radius(1),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.bloom_compose_mat.set_bloom_radius(e)}set_tint_color_0(e){this.bloom_compose_mat.set_tint_color_0(e)}set_tint_color_1(e){this.bloom_compose_mat.set_tint_color_1(e)}set_tint_color_2(e){this.bloom_compose_mat.set_tint_color_2(e)}set_tint_color_3(e){this.bloom_compose_mat.set_tint_color_3(e)}set_tint_color_4(e){this.bloom_compose_mat.set_tint_color_4(e)}render(){this.__check_RT_size(),ke.clear(this.main_RT,Te.current,!0,!1),ke.render(fe.current,Te.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),ke.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),ke.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===be.width&&this.main_RT.height===be.height||(this.main_RT.setSize(be.width,be.height),this.blur_RT.setSize(be.width,be.height))}}class _s extends ze{constructor(){super()}render(){fe.current.on_pre_render&&fe.current.on_pre_render(),fe.current.render?fe.current.render():ke.render(fe.current,Te.current,ke._renderer.getRenderTarget()),this.render_spectator_camera(),fe.current.on_post_render&&fe.current.on_post_render()}render_spectator_camera(){const e=Te.spectator;if(e&&ke._renderer.xr.isPresenting){const t=ke._renderer.xr.getCamera(Te.current);e.projectionMatrix.copy(Te.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);const s=ke._renderer.getRenderTarget();ke._renderer.xr.isPresenting=!1,ke._renderer.setRenderTarget(null),ke._renderer.render(fe.current,e),ke._renderer.setRenderTarget(s),ke._renderer.xr.isPresenting=!0}}}const ls=new class{init(){console.warn("Screen Singleton is deprecated. Please use OScreen."),be.init()}update_position(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),be.update_position(e,t)}update(){console.warn("Screen Singleton is deprecated. Please use OScreen."),be.update()}update_size(e,t){console.warn("Screen Singleton is deprecated. Please use OScreen."),be.update_size(e,t)}apply_pixel_density_v2(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),be.apply_pixel_density_v2(e)}apply_pixel_density(e){return console.warn("Screen Singleton is deprecated. Please use OScreen."),be.apply_pixel_density(e)}get_pixel_size(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),be.get_pixel_size()}get aspect_ratio(){return console.warn("Screen Singleton is deprecated. Please use OScreen."),be.aspect_ratio}};class hs{constructor({name:e,container:t}){this.name=e,this.container=t,this.hidden=!0,Ze.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),Ze.enable_component(this),this.hidden=!1}update(){}on_exit(){this.container.classList.add("hidden"),Ze.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 cs extends a{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new l({color:s});const r=new x(e,t);r.rotateX(-1.57),super(r,i)}}class us extends a{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new l({color:s});super(new x(e,t),i)}}class ds{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],i=s.distanceTo(t);for(let r=1;r<e.length;r++)e[r].distanceTo(t)<i&&(s=e[r],i=e[r].distanceTo(t));return s}static object_values_to_array(e){const t=Object.keys(e),s=[];for(let i=0;i<t.length;i++)s.push(e[t[i]]);return s}}class ps{constructor(){this.sphere=new G}fit_points(e,s,i,r){this.sphere.setFromPoints(e);const n=Math.degToRad(i/2),o=2*Math.atan(Math.tan(n)*r)/2,a=this.get_up_plane_normal(s,n),_=this.get_down_plane_normal(s,n),l=this.get_left_plane_normal(s,o),h=this.get_right_plane_normal(s,o),c=new t(0,0,-1).applyQuaternion(s),u=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=u.clone().add(c.clone().multiplyScalar(-1*d)),m=(new E).setFromNormalAndCoplanarPoint(a,p),g=(new E).setFromNormalAndCoplanarPoint(_,p),f=(new E).setFromNormalAndCoplanarPoint(l,p),v=(new E).setFromNormalAndCoplanarPoint(h,p);this.apply_center_correction_to_pos(p,e,s,m,g,f,v),m.setFromNormalAndCoplanarPoint(a,p),g.setFromNormalAndCoplanarPoint(_,p),f.setFromNormalAndCoplanarPoint(l,p),v.setFromNormalAndCoplanarPoint(h,p);let x=1/0;const w=c.clone().multiplyScalar(-2*d);for(let s=0;s<e.length;s++){const i=new W(e[s].clone(),e[s].clone().add(w)),r=new t,n=new t,o=new t,a=new t;m.intersectLine(i,r),g.intersectLine(i,n),f.intersectLine(i,o),v.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",s),n.length()<1e-4&&console.log("down intersection not found",s),o.length()<1e-4&&console.log("left intersection not found",s),a.length()<1e-4&&console.log("right intersection not found",s);const _=e[s].clone().sub(r).length(),l=e[s].clone().sub(n).length(),h=e[s].clone().sub(o).length(),c=e[s].clone().sub(a).length(),u=Math.min(_,l),d=Math.min(h,c),p=Math.min(u,d);p<x&&(x=p)}const b=c.clone().multiplyScalar(x);return p.clone().add(b)}apply_center_correction_to_pos(e,t,s,i,r,n,o){const a=this.get_vertical_correction(t,r,i,s),_=this.get_hozirontal_correction(t,n,o,s);e.add(a),e.add(_)}get_vertical_correction(e,s,i,r){let n,o,a=1/0,_=1/0;const l=new t(0,1,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const h=new W(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new W(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(5e6))),u=new t,d=new t;s.intersectLine(h,u),i.intersectLine(c,d);const p=u.distanceTo(e[r]),m=d.distanceTo(e[r]);d.length()<1e-4&&console.log("vertical up intersection not found",r),u.length()<1e-4&&console.log("vertical down intersection not found",r),p<_&&(_=p,o=e[r]),m<a&&(a=m,n=e[r])}console.log(n,o);const h=(a-_)/2;return l.clone().multiplyScalar(-h)}get_hozirontal_correction(e,s,i,r){let n,o,a=1/0,_=1/0;const l=new t(1,0,0).applyQuaternion(r);for(let r=0;r<e.length;r++){const h=new W(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new W(e[r].clone(),e[r].clone().add(l.clone().multiplyScalar(5e6))),u=new t,d=new t;s.intersectLine(h,u),i.intersectLine(c,d);const p=u.distanceTo(e[r]),m=d.distanceTo(e[r]);u.length()<1e-4&&console.log("left intersection not found",r),d.length()<1e-4&&console.log("right intersection not found",r),p<_&&(_=p,o=e[r]),m<a&&(a=m,n=e[r])}const h=(a-_)/2;return console.log(n,o),l.clone().multiplyScalar(-h)}get_up_plane_normal(e,s){const i=new t(0,-1,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(1,0,0),s)),i.applyQuaternion(e),i}get_down_plane_normal(e,s){const i=new t(0,1,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(1,0,0),-s)),i.applyQuaternion(e),i}get_left_plane_normal(e,s){const i=new t(1,0,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(0,1,0),s)),i.applyQuaternion(e),i}get_right_plane_normal(e,s){const i=new t(-1,0,0);return i.applyQuaternion((new X).setFromAxisAngle(new t(0,1,0),-s)),i.applyQuaternion(e),i}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class ms{static convert_to_non_indexed_geometry(e){const t=e.index,s=e.getAttribute("position"),i=[];for(let e=0;e<t.count;e+=3)i.push(s.getX(t.array[e+0])),i.push(s.getY(t.array[e+0])),i.push(s.getZ(t.array[e+0])),i.push(s.getX(t.array[e+1])),i.push(s.getY(t.array[e+1])),i.push(s.getZ(t.array[e+1])),i.push(s.getX(t.array[e+2])),i.push(s.getY(t.array[e+2])),i.push(s.getZ(t.array[e+2]));const n=new r;return n.setAttribute("position",new q(new Float32Array(i),3)),ms.add_barycentric_attribute(n),n}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 q(new Float32Array(t),3))}}class gs{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 fs{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 i=4*(t+e.width*s),r=e.data;return new w(r[i+0],r[i+1],r[i+2],r[i+3])}}const vs=new class{constructor(){}sample(e,s){const i=[];let r=99999999;const n=e.getAttribute("position"),o=e.getAttribute("normal"),a=e.getAttribute("tangent"),_=e.getAttribute("uv"),l=e.index,h=[];for(let e=0;e<l.count;e+=3){const s=l.array[e+0],c=l.array[e+1],u=l.array[e+2],p=new t;p.x=n.getX(s),p.y=n.getY(s),p.z=n.getZ(s);const m=new t;m.x=n.getX(c),m.y=n.getY(c),m.z=n.getZ(c);const g=new t;g.x=n.getX(u),g.y=n.getY(u),g.z=n.getZ(u);const f={a:p,b:m,c:g};if(o){const e=new t;e.x=o.getX(s),e.y=o.getY(s),e.z=o.getZ(s);const i=new t;i.x=o.getX(c),i.y=o.getY(c),i.z=o.getZ(c);const r=new t;r.x=o.getX(u),r.y=o.getY(u),r.z=o.getZ(u);const n=e.clone().add(i).add(r).normalize();f.normal=n}if(a){const e=new t;e.x=a.getX(s),e.y=a.getY(s),e.z=a.getZ(s);const i=new t;i.x=a.getX(c),i.y=a.getY(c),i.z=a.getZ(c);const r=new t;r.x=a.getX(u),r.y=a.getY(u),r.z=a.getZ(u);const n=e.clone().add(i).add(r).normalize();f.tangent=n}if(_){const e=new d;e.x=_.getX(s),e.y=_.getY(s);const t=new d;t.x=_.getX(c),t.y=_.getY(c);const i=new d;i.x=_.getX(u),i.y=_.getY(u),f.uv_a=e,f.uv_b=t,f.uv_c=i}h.push(f);const v=this.get_face_area(f);r=Math.min(v,r),i.push(v)}const c=this.get_uniform_face_distribution(i,r,h),u=this.select_random_faces(c,s);return this.sample_data_from_faces(u)}sample_data_from_faces(e){const t=[],s=[],i=[],r=[];for(let n=0;n<e.length;n++){const o=e[n],a=Math.random(),_=Math.random();t.push(this.sample_point_in_face(a,_,o.a,o.b,o.c).clone()),o.normal&&s.push(o.normal.clone()),o.tangent&&i.push(o.tangent.clone()),o.uv_a&&r.push(this.sample_point_in_face(a,_,o.uv_a,o.uv_b,o.uv_c).clone())}return{points:t,normals:s,tangents:i,uvs:r}}select_random_faces(e,t){const s=[];for(let i=0;i<t;i++){const t=e[Math.floor(Math.random()*e.length)];s.push(t)}return s}get_uniform_face_distribution(e,t,s){const i=[];for(let r=0;r<e.length;r++){e[r]/=t;const n=Math.floor(Math.round(e[r]));for(let e=0;e<n;e++)i.push(s[r])}return i}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,i,r){e+t>1&&(e=1-e,t=1-t);const n=1-(e+t);return s.clone().multiplyScalar(e).add(i.clone().multiplyScalar(t)).add(r.clone().multiplyScalar(n))}};const xs=new class{get_mesh(e,t){e.traverse((e=>{e instanceof a&&(e.geometry&&(e.geometry=(new r).fromGeometry(e.geometry)),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 i={},r={};t.scene.traverse((e=>{e.isBone&&(i[e.name]=e),e.isSkinnedMesh&&(r[e.name]=e)}));for(const e in s){const t=s[e].skeleton,n=r[e],o=[];for(let e=0;e<t.bones.length;++e){const s=i[t.bones[e].name];o.push(s)}n.bind(new J(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 ws{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(ws.is_object(e)&&ws.is_object(s))for(const t in s)ws.is_object(s[t])?(e[t]||Object.assign(e,{[t]:{}}),ws.merge_deep(e[t],s[t])):Object.assign(e,{[t]:s[t]});return ws.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 i=e.attributes.item(s);t["@attributes"][i.nodeName]=i.nodeValue}}}else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes.item(s),r=i.nodeName;if(void 0===t[r])t[r]=this.xml_to_json(i);else{if(void 0===t[r].push){const e=t[r];t[r]=[],t[r].push(e)}t[r].push(this.xml_to_json(i))}}return t}}class bs{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 ys{constructor(){}time_str_to_ms(e){e=e.split(":");let t=Number(e[0]);t=60*t*60*1e3;let s=Number(e[1]);s=60*s*1e3;let i=Number(e[2]);return i*=1e3,t+s+i}}class Ts{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 Ss extends a{constructor(){const e=new f({uniforms:{_Color:{value:new m("#919191")}},vertexShader:"#define GLSLIFY 1\nattribute vec3 barycentric;varying vec3 vBarycentric;void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=(modelMatrix*vec4(position,1.0)).xyz;gl_Position=VP*vec4(pos,1.0);vBarycentric=barycentric;}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 _Color;varying vec3 vBarycentric;float edgeFactor(vec3 baryc){vec3 d=fwidth(baryc);vec3 a3=smoothstep(vec3(0.0),d*1.5,baryc);return min(min(a3.x,a3.y),a3.z);}void main(){float alpha=edgeFactor(vBarycentric+vec3(1.,1.,0.));gl_FragColor.rgb=mix(_Color,vec3(0.),alpha);gl_FragColor.a=1.0-alpha;gl_FragColor.a*=0.2;}",extensions:{derivatives:!0},transparent:!0,depthWrite:!1}),t=new x(100,100,100,100);super(ms.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57}}class Ms extends a{constructor(e){const t=new r;t.setAttribute("position",new q(new Float32Array([]),3)),t.setAttribute("next_position",new q(new Float32Array([]),3)),t.setAttribute("previous_position",new q(new Float32Array([]),3)),t.setAttribute("orientation",new q(new Float32Array([]),1)),t.setAttribute("coverage",new q(new Float32Array([]),1));const s=new f({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new m("#FF0000")}},vertexShader:"#define GLSLIFY 1\nuniform float _Thickness;attribute vec3 next_position;attribute vec3 previous_position;attribute float orientation;attribute float coverage;varying float line_coverage;varying float uv_u;vec3 w_space_normal(vec3 from,vec3 to){vec3 w_from=(modelMatrix*vec4(from,1.0)).xyz;vec3 w_to=(modelMatrix*vec4(to,1.0)).xyz;vec3 z=normalize(w_to-w_from);return normalize(cross(z,normalize(cameraPosition-w_from)));}void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=position;vec3 normal=w_space_normal(next_position,previous_position);pos=(modelMatrix*vec4(pos,1.0)).xyz;pos+=normal*(_Thickness*0.5)*orientation;gl_Position=VP*vec4(pos,1.0);line_coverage=coverage;uv_u=orientation*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nuniform float _Length;uniform float _ElapsedTime;uniform float _Thickness;uniform vec3 _Color;varying float line_coverage;varying float uv_u;float aastep(float threshold,float value){\n#ifdef GL_OES_standard_derivatives\nfloat afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757;return smoothstep(threshold-afwidth,threshold+afwidth,value);\n#else\nreturn step(threshold,value);\n#endif\n}void main(){float u=(1.0-abs(uv_u*2.0-1.0));float diffuse=dot(vec2(u,u),vec2(0.0,1.0))*0.5+0.5;gl_FragColor=vec4(_Color*diffuse,1.0);}",transparent:!0,depthWrite:!1,extensions:{derivatives:!0}});super(t,s),this.material=s,e&&this.setup(e)}setup(e){const t=[],s=[],i=[],r=[],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),r.push(1),t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),r.push(-1);const _=this.__get_next_position(e,a);s.push(_.x),s.push(_.y),s.push(_.z),s.push(_.x),s.push(_.y),s.push(_.z);const l=this.__get_previous_position(e,a);i.push(l.x),i.push(l.y),i.push(l.z),i.push(l.x),i.push(l.y),i.push(l.z),n.push(o),n.push(o),a<e.length-1&&(o+=e[a].distanceTo(_))}const a=new Float32Array(t),_=new Float32Array(s),l=new Float32Array(i),h=new Float32Array(r),c=new Float32Array(n),u=[];for(let e=0;e<(a.length/3-2)/2;e++){const t=2*e+1;u.push(t),u.push(t+1),u.push(t-1),u.push(t),u.push(t+2),u.push(t+1)}this.geometry.setIndex(u),this.geometry.getAttribute("position").copy(new q(a,3)),this.geometry.getAttribute("next_position").copy(new q(_,3)),this.geometry.getAttribute("previous_position").copy(new q(l,3)),this.geometry.getAttribute("orientation").copy(new q(h,1)),this.geometry.getAttribute("coverage").copy(new q(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 zs extends a{constructor(e,s){s=s||new d(0,0);const i=new f({uniforms:{_MainTex:{value:e},_ScreenAligned:{value:0},_Scale:{value:1},_Opacity:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;uniform float _ScreenAligned;uniform float _Scale;void main(){vec3 pos=position;mat4 local_to_camera=modelViewMatrix;float scale=_Scale;local_to_camera[0]=mix(modelViewMatrix[0],vec4(1.0*scale,0.0,0.0,0.0),_ScreenAligned);local_to_camera[1]=mix(modelViewMatrix[1],vec4(0.0,1.0*scale,0.0,0.0),_ScreenAligned);local_to_camera[2]=mix(modelViewMatrix[2],vec4(0.0,0.0,1.0*scale,0.0),_ScreenAligned);gl_Position=projectionMatrix*local_to_camera*vec4(pos,1.0);vUv=uv;}",fragmentShader:"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;uniform float _Opacity;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor.a*=_Opacity;}",transparent:!0,depthWrite:!1,side:K}),r=new x(1,1,1);r.translate(-s.x/2,-s.y/2,0);const n=e.image.width/e.image.height;r.scale(n,1,1),super(r,i),this.current_scale=n,this.geometry.computeBoundingBox(),this.tmp_bb_size=new t,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 Fs extends zs{constructor(e,t,s,i,r){const n=new Mt,o={font:t,font_color:s||"#000000"},a=n.draw_on_texture(e,o);a.minFilter=ee,a.minFilter=Z,a.needsUpdate=!0,super(a,i),this.simple_text_drawer=n,this.canvas_texture=a,this.draw_settings=o}set text(e){this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture()}get text(){return"not implemented"}}class As 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 Rs{constructor(e,t,s){const i=t.right-t.left,r=t.top-t.bottom;this.scale=new d(i,r),this.position=new d(e+t.left,t.bottom),this.atlas_bounds=new w(s.left,s.right,s.top,s.bottom)}}class Cs{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 t,this.quaternion=new X,this.scale=new t(1,1,1),this.matrix=new Q,this.color=new m("#FFFFFF"),this.pivot_point=new d,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,s=0){const i=(new X).setFromAxisAngle(new t(0,1,0),e/360*Math.PI*2),r=(new X).setFromAxisAngle(new t(1,0,0),-s/360*Math.PI*2);this.quaternion.copy(i.multiply(r)),this.matrix_is_dirty=!0}set_position(e){this.position.copy(e),this.matrix_is_dirty=!0}set_size(e){this.scale.set(e,e,e),this.matrix_is_dirty=!0}set_color(e){this.color.set(e),this.color_is_dirty=!0}set_pivot(e){this.pivot_point.copy(e),this.update_glyphs()}set opacity(e){this.__opacity=e,this.color_is_dirty=!0}get opacity(){return this.__opacity}update_glyphs(){this.__generate_glyphs(this.text)}__generate_glyphs(e){let t=0;this.glyphs.length=0;for(let s=0;s<e.length;s++){const i=e.charCodeAt(s),r=this.glyph_layout.find((e=>e.unicode===i));if(r){if(r.planeBounds){const e=new Rs(t,r.planeBounds,r.atlasBounds);this.glyphs.push(e)}t+=r.advance}}const s=new Y,i=this.glyphs[0];s.setFromCenterAndSize(i.position.clone().add(new d(i.scale.x/2,i.scale.y/2)),i.scale);for(let e=1;e<this.glyphs.length;e++){const t=this.glyphs[e],i=(new Y).setFromCenterAndSize(t.position.clone().add(new d(t.scale.x/2,t.scale.y/2)),t.scale);s.union(i)}const r=new d;s.getSize(r);for(let e=0;e<this.glyphs.length;e++)this.glyphs[e].position.x-=r.x/2,this.glyphs[e].position.y-=r.y/2,this.glyphs[e].position.x+=r.x/2*this.pivot_point.x,this.glyphs[e].position.y+=r.y/2*this.pivot_point.y;this.glyph_is_dirty=!0}}class Ps extends Ue{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 d(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=K,e.minFilter=Z,e.magFilter=Z,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(e){this.uniforms._Boldness.value=Ne.lerp(.5,.2,e)}}class ks extends a{constructor(e,t){const s=new te;s.instanceCount=0;const i=new x(1,1);i.translate(.5,.5,0),s.setAttribute("position",new se(i.getAttribute("position").array,3)),s.setAttribute("uv",new se(i.getAttribute("uv").array,2)),s.index=i.index;const r=new ie(new Float32Array(8e3),4,!1),n=new ie(new Float32Array(8e3),4,!1),o=new ie(new Float32Array(8e3),4,!1),a=new ie(new Float32Array(8e3),4,!1),_=new ie(new Float32Array(8e3),4,!1),l=new ie(new Float32Array(8e3),4,!1),h=new ie(new Float32Array(8e3),4,!1);r.usage=re,n.usage=re,o.usage=re,a.usage=re,_.usage=re,l.usage=re,h.usage=re,s.setAttribute("transformsCol0",r),s.setAttribute("transformsCol1",n),s.setAttribute("transformsCol2",o),s.setAttribute("transformsCol3",a),s.setAttribute("glyph_bounds",_),s.setAttribute("plane_bounds",l),s.setAttribute("color",h),super(s,new Ps(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new d(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){const t=new Cs(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){ds.remove_elem(this.text_elements,e),this.update(!0)}update(e){const t=this.geometry.getAttribute("glyph_bounds"),s=this.geometry.getAttribute("plane_bounds"),i=this.geometry.getAttribute("transformsCol0"),r=this.geometry.getAttribute("transformsCol1"),n=this.geometry.getAttribute("transformsCol2"),o=this.geometry.getAttribute("transformsCol3"),a=this.geometry.getAttribute("color");let _=!0===e,l=!0===e,h=!0===e,c=0;for(let e=0;e<this.text_elements.length;e++){const u=this.text_elements[e];u.matrix_is_dirty&&(_=!0,u.update_matrix()),u.glyph_is_dirty&&(l=!0,u.clear_glyph_dirty()),u.color_is_dirty&&(h=!0,u.clear_color_dirty());const d=u.matrix,p=u.color,m=u.opacity;for(let e=0;e<u.glyphs.length;e++){const _=u.glyphs[e],l=c;t.setXYZW(l,_.atlas_bounds.x,_.atlas_bounds.y,_.atlas_bounds.z,_.atlas_bounds.w),s.setXYZW(l,_.position.x,_.position.y,_.scale.x,_.scale.y),i.setXYZW(l,d.elements[0],d.elements[1],d.elements[2],d.elements[3]),r.setXYZW(l,d.elements[4],d.elements[5],d.elements[6],d.elements[7]),n.setXYZW(l,d.elements[8],d.elements[9],d.elements[10],d.elements[11]),o.setXYZW(l,d.elements[12],d.elements[13],d.elements[14],d.elements[15]),a.setXYZW(l,p.r,p.g,p.b,m),c++}}this.geometry.instanceCount=c,c>this.max_allocations&&console.error("SDFTextBatch exceeded maximum glyph allocations(max/current): ",this.max_allocations,c,this),_&&(i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,o.needsUpdate=!0),l&&(t.needsUpdate=!0,s.needsUpdate=!0),h&&(a.needsUpdate=!0)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ds extends qe{constructor(e,s=new t,i=new t(1,1,1),r="linear"){super(r),this.attribute_name=e,this.from=s,this.to=i}update(e,t){const s=this.from.clone();s.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(s)}}class Ls extends Fe{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 Us extends Fe{constructor(e,t){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;void main(){vec4 col=texture2D(_MainTex,vUv);gl_FragColor=col;gl_FragColor.a=col.a;}")}set offset(e){this.uniforms._Offset.value=e}get offset(){return this.uniforms._Offset.value}}class js{constructor(e){this.current_width=1,this.current_height=1,this.RT0=new b(1,1),this.RT1=new b(1,1),this.RT2=new b(1,1),this.RT3=new b(1,1),this.RT4=new b(1,1),this.upscale_blur_mat=new Ls(!0),this.downscale_blur_mat=new Ls(!1),this.alpha_filter_mat=new Us}blur(e){this.check_RT_resize(e.width,e.height),ke.blit(e,this.RT1,this.alpha_filter_mat),ke.blit(this.RT1,this.RT2,this.downscale_blur_mat),ke.blit(this.RT2,this.RT3,this.downscale_blur_mat),ke.blit(this.RT3,this.RT4,this.downscale_blur_mat),ke.blit(this.RT4,this.RT3,this.upscale_blur_mat),ke.blit(this.RT3,this.RT2,this.upscale_blur_mat),ke.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 Os extends Fe{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 d(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 d(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new d(e.width,e.height):e.isTexture?new d(e.image.width,e.image.height):new d(1,1)}}class Is{constructor(e){this.RT=new b(1,1,{type:z,format:S,minFilter:T,magFilter:T}),this.RT1=new b(1,1,{type:z,format:S,minFilter:T,magFilter:T}),this.median_filter_mat=new Os}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),ke.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),ke.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),ke.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new d(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new d(e.width,e.height):e.isTexture?new d(e.image.width,e.image.height):new d(1,1)}}class Ns{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=Ns.calculate_resolution(e),s={minFilter:T,magFilter:T,format:S,colorScape:j,type:Se.fp_textures_available?z:ne,stencilBuffer:!1,depthBuffer:!1};return new b(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].material=this.update_material,this.update_material.uniforms._MainTex.value=this.read.texture,ke.render(e,void 0,this.write),e.children[0].material=void 0,this.swap_RT())}store_geometry_attribute_in_RT(e,t,s,i){i.children[0].geometry.setAttribute("data",e),i.children[0].material=s,ke.render(i,void 0,t),i.children[0].geometry.deleteAttribute("data"),i.children[0].material=void 0}get_texture(){return this.read.texture}}class Bs extends e{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 q(t,s,!1))}add_attribute_array(e,t,s){this.mesh.geometry.setAttribute(e,new ie(t,s,!1))}update(){this.mesh.material.update();for(let e=0;e<this.attributes.length;e++)this.attributes[e].update(this.attribute_writter_scene)}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}build_point_mesh(e=1,t){const s=new x,i=new te;i.setAttribute("position",s.getAttribute("position")),i.index=s.index,i.setAttribute("storage_uv",this.build_uv_storage_attribute(e)),i.instanceCount=e;const r=new a(i,t);return r.frustumCulled=!1,r}build_attribute_writter_mesh(e){const{width:t,height:s}=Ns.calculate_resolution(e),i=new Float32Array(3*e);for(let r=0;r<e;r++){const e=r%t,n=Math.floor(r/t);i[3*r+0]=(e+.5)/t,i[3*r+1]=(n+.5)/s,i[3*r+2]=r}const n=new r;n.setAttribute("position",new q(i,3,!1));const o=new oe(n);return o.frustumCulled=!1,o}build_uv_storage_attribute(e){const{width:t,height:s}=Ns.calculate_resolution(e),i=new Float32Array(2*e);for(let r=0;r<e;r++){const e=r%t,n=Math.floor(r/t);i[2*r+0]=(e+.5)/t,i[2*r+1]=(n+.5)/s}return new ie(i,2,!1)}}class Vs extends f{constructor(){super({uniforms:{},vertexShader:"\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:v,depthTest:!1,depthFunc:i})}}class qs extends Ns{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 i=new Vs;this.store_geometry_attribute_in_RT(e.getAttribute("position"),this.read,i,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 i=new Vs;this.store_geometry_attribute_in_RT(new q(s,4),this.read,i,t)}}class Ys extends V{constructor(e,t,s,i,r){super(e,t,s,i,r),this.multiplier=1}set_rgba(e,t,s,i,r){this.data[3*e+0]=t*this.multiplier,this.data[3*e+1]=s*this.multiplier,this.data[3*e+2]=i*this.multiplier,this.data[3*e+3]=r*this.multiplier,this.needsUpdate=!0}set_rgb(e,t,s,i){this.data[3*e+0]=t*this.multiplier,this.data[3*e+1]=s*this.multiplier,this.data[3*e+2]=i*this.multiplier,this.needsUpdate=!0}set_r(e,t){this.data[3*e+0]=t*this.multiplier,this.needsUpdate=!0}set_g(e,t){this.data[3*e+1]=t*this.multiplier,this.needsUpdate=!0}set_b(e,t){this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0}set_a(e,t){this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0}}class Gs extends Ys{constructor(e,t){super(new Uint8Array(e*t*3),e,t,S),this.multiplier=255}}class Es extends Ys{constructor(e,t){super(new Uint8Array(e*t*4),e,t,S),this.multiplier=255}}class Ws extends Ys{constructor(e,t){super(new Float32Array(e*t*3),e,t,S,z)}}class Xs extends Ys{constructor(e,t){super(new Float32Array(e*t*4),e,t,S,z)}}class Qs extends a{constructor(e,t,s,i){super(t,s),this.id_table=e,this.batched_count=Object.keys(e).length,this.max_texture_width=i,this.batch_width=this.batched_count%i,this.batch_height=Math.ceil(this.batched_count/i)}attach_rgb_texture(e){this.material.uniforms[e].value=new Gs(this.batch_width,this.batch_height)}attach_rgba_texture(e){this.material.uniforms[e].value=new Es(this.batch_width,this.batch_height)}attach_rgb_float_texture(e){this.material.uniforms[e].value=new Ws(this.batch_width,this.batch_height)}attach_rgba_float_texture(e){this.material.uniforms[e].value=new Xs(this.batch_width,this.batch_height)}get_mesh_index(e){return this.id_table[e]}set_rgb_value(e,t,s,i,r){this.material.uniforms[e].set_rgb(this.get_mesh_index(t),s,i,r)}set_rgba_value(e,t,s,i,r,n){this.material.uniforms[e].set_rgba(this.get_mesh_index(t),s,i,r,n)}}class $s{batch(e,t){const s=[],i={},r=[];for(let t=0;t<e.length;t++){const n=e[t],o=n.geometry.getAttribute("position").count;for(let e=0;e<o;e++)r.push(t);s.push(n.geometry),void 0===i[n.name]?i[n.name]=t:console.error("Mesh name is duplicated when trying to merge meshes. Non-unique id error.",n.name,i)}const n=_e.mergeGeometries(s),o=new q(new Float32Array(r),1);return n.setAttribute("mesh_id",o),this.create_batched_mesh(i,n,t,2048)}create_batched_mesh(e,t,s,i){return new Qs(e,t,s,i)}}class Hs extends it{constructor(e,t,s){super(e,t,s),this.loader=new ue}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 Zs extends it{constructor(e,t,s){super(e,t,s),this.loader=new ae}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),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 it{constructor(e,t,s){super(e,t,s),this.loader=new de}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 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 Ks extends it{constructor(e,t,s,i){super(e,t,i),this.loader=new pe,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=>{}),(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 ei extends it{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 ti extends it{constructor(e,t,s){super(e,t,s),this.loader=new me}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 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 si extends it{constructor(e,t,s){super(e,t,s),this.loader=new ae}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=>{}),(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 s=e.split("\n");""===s[s.length-1]&&s.pop();const i=[];for(let e=0;e<s.length;e+=3){const r=parseFloat(s[e+0]),n=parseFloat(s[e+1]),o=parseFloat(s[e+2]);i.push(new t(r,n,o))}return i}}class ii extends it{constructor(e,t,s){super(e,t,s),this.loader=new ae}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),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 ri extends it{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 L,i=URL.createObjectURL(t),r=new Image;r.src=i,r.onload=()=>{s.image=r,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended()},r.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 ni extends it{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 oi{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||ot)}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}}export{it as AbstractLoader,yt as AbstractScene,Be as ActionEvent,qe as ActionInterpolator,Ye as ActionSequencer,We as ActionSequencerBuilder,tt as AddMaterial,Tt as ApplicationView,ds as ArrayUtilities,we as Arrow,at as AsyncAbstractLoader,_t as AsyncAudiosLoader,ct as AsyncObjectsLoader,dt as AsyncTextureLoader,ft as AsyncTexturesLoader,nt as AudioLoader,et as BaseApplication,ze as BaseRender,Ue as BaseShaderMaterial,pt as BasisLoader,Fe as BlitMaterial,ts as Blurrer,ut as Browser,At as CSSAnimator,Te as CameraManager,Et as CameraUtilities,St as CanvasDrawer,Se as Capabilities,ve as Cube,mt as CubemapLoader,Hs as DAELoader,Oe as Debug,$t as DebugNormalsRender,Ee as DrawIOAnimationSheet,Ls as DualFilteringBlurMaterial,js as DualFilteringBlurrer,Ve as EasingFunctions,Zs as FileLoader,Js as FontLoader,ps as FrustumPointFitter,lt as GLTFDRACOLoader,ht as GLTFLoader,Bs as GPUParticleSystem,os as GaussianBlurrer,ms as GeometryUtilities,ke as Graphics,Ss as Grid,Ks as HDRCubeTextureLoader,gs as HTMLUtilities,wt as HighQualityLoadingState,cs as HorizontalPlane,fs as ImageUtilities,Wt as Initializer,ei as JSONLoader,Xt as KeyboardInput,Ms as Line,xt as LoadingState,Is as MedianFilter,$s as MeshBatcher,vs as MeshSampler,xs as ModelUtilities,ss as NormalAORender,is as NormalRender,Ge as NumberInterpolator,ti as OBJLoader,Ne as OMath,Rt as OS,be as OScreen,ws as ObjectUtilities,Me as OrthographicCamera,Gt as OrthographicFrustumPointFitter,Ns as ParticleAttribute,qs as ParticlePositionAttribute,ye as PerspectiveCamera,Yt as PerspectiveFrustumPointFitter,si as PointArrayLoader,gt as RGBETextureLoader,bt as RegularLoadingState,Ke as RenderLoop,oi as ResourceBatch,ot as ResourceContainer,ks as SDFTextBatch,fe as SceneManager,ls as Screen,Mt as SimpleTextDrawer,xe as Sphere,bs as StringUtilities,Fs as Text2D,ii as TextLoader,ri as TextureLoader,Ie as Time,ys as TimeUtilities,He as TransitionManager,Xe as TransitionTable,qt as UI,Vt as UIElement,st as UnrealBloomComposeMaterial,as as UnrealBloomRender,As as UpdatableMaterialMesh,_s as VRRender,Ts as Validation,Ds as VectorInterpolator,us as VerticalPlane,ni as VideoLoader,hs as ViewComponent,Ze as ViewComponentManager,Je as ViewManager,zs as WorldImage};
2
2
  //# sourceMappingURL=index.mjs.map