ohzi-core 13.0.3 → 13.0.5

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.
@@ -1,2 +1,3056 @@
1
- import{ShaderMaterial as e,Vector2 as t,NoBlending as s,AlwaysDepth as i,Color as r,Clock as n,CanvasTexture as o,UVMapping as a,ClampToEdgeWrapping as _,NearestFilter as l,Object3D as h,Vector3 as c,LineBasicMaterial as u,BufferGeometry as d,Line as p,Scene as m,Mesh as g,BoxGeometry as f,MeshBasicMaterial as v,SphereGeometry as x,CylinderGeometry as w,ConeGeometry as b,PerspectiveCamera as y,PlaneGeometry as T,Vector4 as M,Box3 as S,Box3Helper as z,CatmullRomCurve3 as F,OrthographicCamera as R,WebGLRenderTarget as A,WebGLRenderer as C,RGBAFormat as P,LinearSRGBColorSpace as k,FloatType as D,DataTexture as L,BufferAttribute as U,Sphere as j,Plane as O,Line3 as I,Quaternion as N,Matrix4 as B,Ray as V,RepeatWrapping as Y,LinearFilter as q,Skeleton as G,DoubleSide as W,LinearMipMapLinearFilter as E,Box2 as X,InstancedBufferGeometry as $,Float32BufferAttribute as Q,InstancedBufferAttribute as H,DynamicDrawUsage as Z,HalfFloatType as J,Points as K,Texture as ee,SRGBColorSpace as te,NoColorSpace as se,PositionalAudio as ie,Audio as re,AudioContext as ne,CubeTextureLoader as oe,FileLoader as ae}from"three";import*as _e from"three/examples/jsm/utils/BufferGeometryUtils.js";export{_e as BufferGeometryUtils};import{ColladaLoader as le}from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as he}from"three/examples/jsm/loaders/FontLoader.js";import{GLTFLoader as ce}from"three/examples/jsm/loaders/GLTFLoader.js";import{HDRCubeTextureLoader as ue}from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import{OBJLoader as de}from"three/examples/jsm/loaders/OBJLoader.js";import{RGBELoader as pe}from"three/examples/jsm/loaders/RGBELoader.js";class me{on_post_start(){}on_enter(){}on_exit(){}before_update(){}update(){}fixed_update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}dispose(){}}class ge 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 fe extends ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}var ve="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",xe="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class we extends e{constructor(e,t,s){super({vertexShader:e||ve,fragmentShader:t||xe,uniforms:s||{_Color:{value:new r("#FF0000")}}})}}class be extends ge{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};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 ye{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}const Te=new class{async init(e,t){switch(this.browser_name="",this.agent=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&&!!e:this.browser_name="opera";break;case this.agent.indexOf("chrome")>-1&&!!t: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 Me{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 Se{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=Me.is_number(e)?e:1,t=Me.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=Te.is_safari?"no-cache":"default";fetch(this.url,{method:"GET",mode:"cors",cache:t,credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}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)}this.on_preloaded_finished(e,s)}on_preloaded_finished(e,t){}__on_error(e){console.error(e)}}const ze=new class{constructor(){this.views=[],this.main_to_worker=void 0,this.browser_title_suffix=""}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)),this.main_to_worker.push("go_to_view_controller",[e,s])}go_to_scene(e,t=!1,s=!1){const i=this.get("transition");i.set_next_view_name(e),this.go_to_view(i.name,t,s)}set_browser_title_suffix(e){this.browser_title_suffix=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)}register_view(e){this.views.push(e)}set_main_to_worker(e){this.main_to_worker=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}__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 Fe{constructor(e){this.name=e}start(){}before_enter(){}on_enter(){}before_update(){}update(){}fixed_update(){}update_enter_transition(e,t,s){}update_exit_transition(e,t,s){}before_exit(){}on_exit(){}}class Re extends Fe{constructor({name:e,url:t,container:s}){super(e),this.container=s,this.url=t,ze.register_view(this)}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){this.container.style.opacity=e}}const Ae=new class{constructor(){this.methods=[],this.args=[]}push(e,t=[]){this.methods.push(e),this.args.push(t)}clear(){this.methods=[],this.args=[]}};class Ce{constructor(e,t,s){this.name=e,this.method=t,this.args=s}trigger(){Ae.push(`${this.name}.${this.method}`,this.args.split(","))}}class Pe{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(Pe.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 Pe.clamp(e,0,1)}}class ke{constructor(e={},t){this.previous_elapsed_time=-1e-5,this.elapsed_time=-1e-5,this.playback_speed=this.__get_playback_speed(t),this.playing=!0,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};const s=Object.keys(e);for(let e=0;e<s.length;e++)this.channels[s[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=Pe.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=Pe.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return Pe.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;Pe.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(Pe.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 Pe.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(e){return e?Number(e):1}}class De{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 Le{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?De[e]:e}update(e,t){}}class Ue extends Le{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]=Pe.lerp(this.from,this.to,this.easing_function(t))}evaluate(e){return Pe.lerp(this.from,this.to,this.easing_function(e))}}class je{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 Oe{constructor(e){this.default_state_data=e}from_animation_sheet(e,t,s,i){s=s||this.default_state_data;const r=e.animation_tracks,n=e.triggers,o=this.state_to_tracks(this.default_state_data,this.get_longest_time(e.animation_tracks));for(let e=0;e<o.length;e++)void 0===r.find((t=>t.attribute_name===o[e].attribute_name))&&r.push(o[e]);const a=new ke(t,i);for(let e=0;e<r.length;e++){const s=r[e],i=new Ue(s.attribute_name,t[s.attribute_name],s.to_value,s.initial,s.easing_function);a.add_action_interpolator(s.from_time,s.to_time,i,!0)}for(let e=0;e<n.length;e++){const t=n[e],s=new Ce(t.name,t.method,t.args);a.add_action_event(t.at_time,s)}return a}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 je).parse(e),i=s.animation_tracks,r=s.triggers,n=new ke(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Ue(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 Ce(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 Ie{constructor(){this.transitions=[],this.default_state_data={},this.transitions_velocity=1}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 Oe(this.default_state_data).from_animation_sheet(this.transitions[i].data,s,this.transitions_velocity)}for(let e=0;e<this.transitions.length;e++)if(this.transitions[e].to===t&&void 0===this.transitions[e].from){return new Oe(this.default_state_data).from_animation_sheet(this.transitions[e].data,s,this.transitions_velocity)}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}set_transitions_velocity(e){this.transitions_velocity=e}}const Ne=new class{constructor(){this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016]}init(){this.___time=new n,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}to_json(){return{elapsed_time:this.elapsed_time,delta_time:this.delta_time,smooth_delta_time: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 Be{constructor(e){this.last_state=new Fe,this.current_state=new Fe,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(Ne.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 Ve=new class{constructor(){this.transition_table=new Ie,this.transition_handler=new Be(this.transition_table)}get action_sequencer(){return this.transition_handler.action_sequencer}get current_state_data(){return this.transition_handler.current_state_data}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_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)}};class Ye{constructor(){this.view_controllers=[]}go_to_view_controller(e,t=!1){const s=this.get(e);Ve.transition_handler.go_to_state(s,t)}update(){this.__set_view_controllers_opacities()}register_view_controller(e){this.view_controllers.push(e)}set_view_controller(e){const t=this.get(e);Ve.transition_handler.set_state(t)}get_current_view_controller(){return Ve.transition_handler.current_state}get(e){for(let t=0;t<this.view_controllers.length;t++)if(this.view_controllers[t].name===e)return this.view_controllers[t];console.error("[ViewControllerManager.get] no view controller found for: ",e)}__set_view_controllers_opacities(){for(let e=0;e<this.view_controllers.length;e++)this.view_controllers[e].set_opacity(Ve.transition_handler.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("_"," ")))}}const qe=new class extends Ye{};class Ge extends Fe{constructor({name:e,url:t,transition_data:s}){super(e),this.url=t;const i=[{to:e,data:s=s||{animation_tracks:[],triggers:[]}}];this.current_opacity=0,qe.register_view_controller(this),Ve.add_transitions(i)}before_enter(){Ae.push(`${this.name}_view.before_enter`)}on_enter(){Ae.push(`${this.name}_view.on_enter`)}before_exit(){Ae.push(`${this.name}_view.before_exit`)}on_exit(){Ae.push(`${this.name}_view.on_exit`)}update(){Ae.push(`${this.name}_view.update`)}fixed_update(){}update_enter_transition(e,t,s){Ae.push(`${this.name}_view.update_enter_transition`,[e,t])}update_exit_transition(e,t,s){Ae.push(`${this.name}_view.update_exit_transition`,[e,t])}set_opacity(e){const t=e[`${this.name}_opacity`];(this.current_opacity>t||this.current_opacity<t)&&(this.current_opacity=t,Ae.push(`${this.name}_view.set_opacity`,[t]))}}const We=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 Ee{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 o(s,a,_,_,l,l);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 Xe extends Ee{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 $e=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class Qe extends h{constructor(e=1){super();const t=[];t.push(new c(0,0,0)),t.push(new c(0,0,1e3));const s=new u({color:4474111,depthFunc:i}),r=(new d).setFromPoints(t),n=new p(r,s);n.renderOrder=5e4;const o=[];o.push(new c(0,0,0)),o.push(new c(0,1e3,0));const a=new u({color:4521796,depthFunc:i}),_=(new d).setFromPoints(o),l=new p(_,a);l.renderOrder=5e4;const h=[];h.push(new c(0,0,0)),h.push(new c(1e3,0,0));const m=new u({color:16729156,depthFunc:i}),g=(new d).setFromPoints(h),f=new p(g,m);f.renderOrder=5e4,this.renderOrder=1e5,this.add(n),this.add(l),this.add(f),this.scale.set(e,e,e)}update(){}dispose(){}}const He=new class{init(){this._current=new m,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 Ze extends g{constructor(e,t,s){e=e||new c(1,1,1),t=t||new c(1,1,1),s=s||16711680;super(new f(e.x,e.y,e.z,t.x,t.y,t.z),new v({color:s}))}}class Je extends g{constructor(e,t){t=t||"#FF0000";super(new x(e=e||1,64,64),new v({color:t}))}}class Ke extends g{constructor(e,t,s){e=e||"#FF0000";const i=(t=t||1)-.4,r=new w(.01,.01,i,32);r.translate(0,i/2,0);const n=new b(.1,.4,32);n.translate(0,i+.2,0);const o=_e.mergeGeometries([r,n]);o.rotateX(1.57);super(o,new v({color:e})),s&&this.quaternion.setFromUnitVectors(new c(0,0,1),s),this._dir=s}set dir(e){this.quaternion.setFromUnitVectors(new c(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 et=new class{init(){this.width=1,this.height=1,this.position=new t,this.render_width=1,this.render_height=1,this.width_height=new t(this.width,this.height),this.dpr=1,this.pixel_size=new t(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update(){this.size_changed=!1}update_size(e,s){this.width=e,this.height=s,this.pixel_size=new t(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=s,this.render_width=e*this.dpr,this.render_height=s*this.dpr,this.size_changed=!0}apply_pixel_density_v2(e){return e.multiplyScalar(1/this.dpr),e}apply_pixel_density(e){return e*(1/this.dpr)}get_pixel_size(){return this.pixel_size}get aspect_ratio(){return this.width/this.height}get portrait(){return this.width<this.height}};class tt extends we{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 st extends y{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 it=new class{init(){this.Vector3_one=new c(1,1,1),this.Vector3_zero=new c(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new m,this.camera=new st(60,et.aspect_ratio,.1,1e3),this.camera.clear_alpha=0}draw_arrow(e,t,s=16711680){const i=new Ke(s,t.length(),t.clone().normalize());return i.position.copy(e),this.scene.add(i),i}draw_axis(){const e=new Qe;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 u({color:t}),i=(new d).setFromPoints(e),r=new p(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 c;const i=new Ze(new c(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 Ze(new c(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 c(0,0,-1),_),this.scene.add(o),o}draw_plane(t,s,i){const r=new T(t,s),n=new e({uniforms:{_Color:{value:new M(0,1,0,.2)}},vertexShader:ve,fragmentShader:xe,transparent:!0,depthWrite:!1}),o=new g(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 S).setFromCenterAndSize(new c,new c(t,t,t)),r=new z(i,s);return r.position.copy(e||new c),r}draw_sphere(e,t,s){t=t||1,s=s||16711680,e=e||new c;const i=new Je(t,s);return i.position.copy(e),this.scene.add(i),i}draw_point_array(e,t=!1,s=16711680){const i=new F(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 x(e.radius,32,32),i=new v({color:t}),r=new g(s,i);return r.position.copy(e.center),He.current.add(r),r}draw_math_sphere(t){const s=new x(t.radius,32,32),i=new e({uniforms:{_Color:{value:new M(1,0,0,.2)}},vertexShader:ve,fragmentShader:xe,transparent:!0}),r=new g(s,i);r.position.copy(t.center),He.current.add(r)}draw_bounding_box(e){const t=new z(e,16776960);He.current.add(t)}draw_curve(e,t){const s=new c(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 g(new T(1,1),new tt);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(et.width,et.height);this.scene.children.length>0&&e.render(this.scene,We.current)}};class rt{constructor(e){this.renderer=e,this._blit_scene=new m,this._blit_material=new ge,this._blit_quad=new g(new T(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new R(-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 nt extends ge{constructor(e,t){super("#define GLSLIFY 1\nuniform vec4 _DepthNormal;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(_DepthNormal.x),EncodeNormal(normalize(_DepthNormal.yzw)));}"),this.uniforms._DepthNormal={value:new M(e,t.x,t.y,t.z)}}}class ot 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 at{constructor(){this.RT=new A(et.width,et.height),this.clear_depth_normal_mat=new nt(1,new c(0,0,1)),this.depth_normal_material=new ot}render(e){this.__resize_RT_if_necessary(),e.clear(this.RT,void 0,!0,!0),e.blit_clear_with_material(this.RT,this.clear_depth_normal_mat),this.depth_normal_material.far_plane=We.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===et.width&&this.RT.height===et.height||this.RT.setSize(et.width,et.height)}get render_target(){return this.RT}}const _t=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 C(this.threejs_attributes),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,et.dpr=r,this._renderer.setPixelRatio(1),this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new rt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new ye,this.current_render_mode=this.no_render,$e.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),$e.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,$e.fp_textures_available=this.is_floating_point_texture_available(),this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new at}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(),We.current&&this.current_render_mode.render(),et.update()}__update_current_camera(){We.current&&(We.current.aspect=et.aspect_ratio,We.current.updateProjectionMatrix(),We.current.updateMatrix(),We.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||He.current,t||We.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||He.current,t||We.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||He.current,t||We.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:He.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)et.dpr=t,et.update_position(s.contentRect.x,s.contentRect.y),et.update_size(s.contentRect.width,s.contentRect.height),this.canvas.width=et.render_width,this.canvas.height=et.render_height,this._renderer.setViewport(0,0,et.render_width,et.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=et.width,s=et.height){const i=et.width,r=et.height,n=t,o=s,a=1024,_=1024,l=parseInt(Math.ceil(n/a)),h=parseInt(Math.ceil(o/_));et.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,We.current.aspect=et.aspect_ratio,We.current.updateMatrix(),We.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)We.current.setViewOffset(n,o,et.width*e,et.height*t,et.width,et.height),this.current_render_mode.render(),u.drawImage(this._renderer.domElement,et.width*e,et.height*t);u.canvas.toBlob(e,"image/png;base64;"),We.current.clearViewOffset(),et.update_size(i,r),this._renderer.setPixelRatio(c),this._renderer.setSize(i,r,!1),We.current.aspect=et.aspect_ratio,We.current.updateMatrix(),We.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 A(1,1,{minFilter:l,magFilter:l,format:P,colorSpace:k,type:D,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 lt{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class ht{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(e){this.t+=Ne.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=Pe.clamp(this.easing_function_t,0,1),e.set_property_value(Pe.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 lt),e.finished_callback(e))}on_exit(e){}}class ct{constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n="",value_suffix:o="",easing_function:a=De.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 lt}animate(){this.set_current_state(new ht)}stop(){this.set_current_state(new lt)}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 ut=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=navigator.userAgent,t=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 dt=new class{init(){this.target_geometry=void 0,this.target_position=new c}set_target_geometry(e){this.target_geometry=e}};const pt=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 mt{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 g(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 L(t,e,e,P)}__create_rgba_texture(e){const t=new Uint8Array(4*e*e);return new L(t,e,e,P)}__create_rgba_float_texture(e){const t=new Float32Array(4*e*e);return new L(t,e,e,P,D)}__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 gt=new class{init(){this.batches=[]}batch(e){const t=[],s=Pe.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 U(new Float32Array(t),2),n=_e.mergeGeometries(e);return n.setAttribute("attr_accessor_uv",r),this.batches.push(new mt(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 ft=new class{init(e){this.input=e,this.ui_elements=[],this._tmp_normalized_pos=new t,this.ss_scene=new m,this.ss_scene.matrixWorldAutoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new m,this.ws_scene.matrixWorldAutoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new R(-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&&_t.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&_t.render(this.ws_scene,We.current)}clear(){this.current_clicked_element=void 0}};class vt{constructor(){this.sphere=new j}fit_points(e,t,s,i){this.sphere.setFromPoints(e);const r=Pe.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 c(0,0,-1).applyQuaternion(t),u=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,s,i),p=u.clone().add(h.clone().multiplyScalar(-1*d)),m=(new O).setFromNormalAndCoplanarPoint(o,p),g=(new O).setFromNormalAndCoplanarPoint(a,p),f=(new O).setFromNormalAndCoplanarPoint(_,p),v=(new O).setFromNormalAndCoplanarPoint(l,p);this.apply_center_correction_to_pos(p,e,t,m,g,f,v),m.setFromNormalAndCoplanarPoint(o,p),g.setFromNormalAndCoplanarPoint(a,p),f.setFromNormalAndCoplanarPoint(_,p),v.setFromNormalAndCoplanarPoint(l,p);let x=1/0;const w=h.clone().multiplyScalar(-2*d);for(let t=0;t<e.length;t++){const s=new I(e[t].clone(),e[t].clone().add(w)),i=new c,r=new c,n=new c,o=new c;m.intersectLine(s,i),g.intersectLine(s,r),f.intersectLine(s,n),v.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(),u=Math.min(a,_),d=Math.min(l,h),p=Math.min(u,d);p<x&&(x=p)}const b=h.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,t,s,i){let r=1/0,n=1/0;const o=new c(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new I(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new I(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new c,h=new c;t.intersectLine(a,l),s.intersectLine(_,h);const u=l.distanceTo(e[i]),d=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),u<n&&(n=u),d<r&&(r=d)}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 c(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new I(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new I(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new c,h=new c;t.intersectLine(a,l),s.intersectLine(_,h);const u=l.distanceTo(e[i]),d=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),u<n&&(n=u),d<r&&(r=d)}const a=(r-n)/2;return o.clone().multiplyScalar(-a)}get_up_plane_normal(e,t){const s=new c(0,-1,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new c(0,1,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new c(1,0,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new c(-1,0,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(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 xt{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 S).setFromPoints(n),a=new c;o.getSize(a);const _=this.get_distance_to_fit_rect(a.x/2,a.y/2,s,i),l=new c;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 wt=new class{init(e){this.tmp_mat=new B,this.plane=new O,this.ray=new V,this.tmp_size=new c,this.tmp_unproj=new c,this.input=e}get_up_dir(e){e=e||We.current;const t=new c;return t.set(0,1,0),t.applyQuaternion(e.quaternion),t}get_forward_dir(e){e=e||We.current;const t=new c;return t.set(0,0,-1),t.applyQuaternion(e.quaternion),t}get_right_dir(e){e=e||We.current;const t=new c;return t.set(1,0,0),t.applyQuaternion(e.quaternion),t}unproject_mouse_position(e,t){t=t||We.current;const s=new c,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||We.current,s=s||this.input.NDC;const r=new c;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 j).setFromPoints(e).center,i=this.get_forward_dir(We.current).clone(),r=(new O).setFromNormalAndCoplanarPoint(i,s),n=Pe.project_points_on_plane(e,r),o=new c;let a=(new S).setFromPoints(n);a.getCenter(o);const _=new c(0,1,0).applyQuaternion(We.current.quaternion),l=_.clone().cross(i).normalize(),h=(new B).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),u=(new B).getInverse(h);for(let e=0;e<n.length;e++)n[e].applyMatrix4(u);const d=new c;a=(new S).setFromPoints(n),a.getSize(d),d.multiplyScalar(t);const p=new c;return a.getCenter(p),{position:o,zoom:this.get_zoom_to_fit_rect(d.x/2,d.y/2)}}get_zoom_to_fit_rect(e,t){const s=We.current.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(s)*We.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 et.aspect_ratio/i>1?et.height/s:et.width/t}{const t=new c;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){t=t||We.current;const s=new c;return e.getWorldPosition(s),s.project(t),s.x=(.5*s.x+.5)*et.width,s.y=(1-(.5*s.y+.5))*et.height,s}world_pos_to_screen(e,t){t=t||We.current;const s=new c;return s.copy(e),s.project(t),s.x=(.5*s.x+.5)*et.width,s.y=(1-(.5*s.y+.5))*et.height,s}update_projection(e){e.left=-et.width/2,e.right=et.width/2,e.top=et.height/2,e.bottom=-et.height/2,e.aspect=et.aspect_ratio,e.updateProjectionMatrix(!0)}fit_bounding_box_points(e,t,s=1){const i=new c;i.copy(t.max).sub(t.min);const r=t.min.clone(),n=r.clone().add(new c(i.x,0,0)),o=r.clone().add(new c(0,i.y,0)),a=r.clone().add(new c(0,0,i.z)),_=r.clone().add(new c(i.x,0,i.z)),l=r.clone().add(new c(0,i.y,i.z)),h=t.max.clone(),u=r.clone().add(new c(i.x,i.y,0));return this.fit_points(e,[r,n,o,a,_,l,h,u],s)}fit_points(e,t,s=1){if(e.isPerspectiveCamera){const i=new c(0,0,-1).applyQuaternion(e.quaternion),r=i.clone().multiplyScalar(-1),n=new vt,o=et.aspect_ratio,a=n.fit_points(t,e.quaternion,e.fov*s,o),_=(new S).setFromPoints(t),l=new c;_.getCenter(l);const h=(new O).setFromNormalAndCoplanarPoint(r,l),u=new V(a,i),d=new c;u.intersectPlane(h,d);return{zoom:a.distanceTo(d),reference_position:d,camera_position:a}}{const i=(new xt).fit_points(t,this.reference_rotation,e.fov*s,et.aspect_ratio);this.reference_position.copy(i.center),this.reference_zoom=i.distance_to_center;const r=new c(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 bt=new class{constructor(){}init(e){We.init(),wt.init(e),$e.init(),gt.init(),ut.init(),dt.init(),pt.init(),He.init(),et.init(),Ne.init(),ft.init(e),it.init()}dispose(){_t.dispose(),He.dispose()}};class yt{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 Tt extends R{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 Mt 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 St extends ye{constructor(){super()}render(){_t.clear(void 0,We.current,!0,!0),_t.render(He.current,We.current,void 0,new Mt)}}var zt="#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 Ft extends ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}",zt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new B}}}class Rt extends ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _AO;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){gl_FragColor.rgb=texture2D(_MainTex,vUv).rgb*(1.0-texture2D(_AO,vUv).r);gl_FragColor.a=1.0;}"),this.uniforms._AO={value:void 0}}}class At extends ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}",zt),this.uniforms._InverseProjMatrix={value:new B},this.uniforms._ProjectionMatrix={value:new B},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 c(2*Math.random()-1,2*Math.random()-1,Math.random());s.normalize();let i=t/64;i=Pe.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 L(e,4,4,P);return t.wrapS=Y,t.wrapT=Y,t.needsUpdate=!0,t}}class Ct extends ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){vec4 sum=vec4(0.,0.,0.,0.);vec2 dir=(0.5/_Resolution)*_SampleDir;float _Distance=2.0;sum+=texture2D(_MainTex,vUv+dir*-4.*_Distance)*0.0525;sum+=texture2D(_MainTex,vUv+dir*-3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*-2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*-1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*0.*_Distance)*0.225;sum+=texture2D(_MainTex,vUv+dir*1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*4.*_Distance)*0.0525;gl_FragColor=vec4(sum);}"),this.uniforms._SampleDir={value:new t}}}class Pt{constructor(e){this.RT1=new A(1,1),this.RT2=new A(1,1),this.box_blur_mat=new Ct}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),_t.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),_t.blit(this.RT1,e,this.box_blur_mat)}}class kt extends ye{constructor(e=!1){super(),this.ssao_mat=new At,this.ssao_compose_mat=new Rt,this.debug_normals=new Ft,this.ssaa=e?2:1,this.main_RT=new A(et.width*this.ssaa,et.height*this.ssaa),this.SSAO_RT=new A(et.width,et.height),this.blurrer=new Pt,_t.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),_t.clear(this.main_RT,We.current,!0,!1),_t.render(He.current,We.current,this.main_RT),this.__update_uniforms(),_t.blit(_t.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),_t.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,_t.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(We.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(We.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=We.current.far}__check_RT_size(){this.main_RT.width===et.width*this.ssaa&&this.main_RT.height===et.height*this.ssaa||(this.main_RT.setSize(et.width*this.ssaa,et.height*this.ssaa),this.SSAO_RT.setSize(et.width,et.height))}}class Dt extends ye{constructor(){super()}render(){_t.clear(void 0,We.current,!0,!0),He.current.on_pre_render&&He.current.on_pre_render(),He.current.render?He.current.render():_t.render(He.current,We.current),He.current.on_post_render&&He.current.on_post_render()}}class Lt extends ge{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new 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 Ut extends ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new r("#000000")},this.uniforms.defaultOpacity={value:0}}}class jt{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:q,magFilter:q,format:P},this.renderTargetBright=new A(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Ut}blur(e,t){this.resize_RT(e.width,e.height),t?_t.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):_t.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),_t.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),_t.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 A(1,1,this.rt_pars),t=new A(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 Lt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class Ot extends ye{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 fe}on_enter(){this.blurrer=new jt,this.main_RT=new A(et.width,et.height),this.blur_RT=new A(et.width,et.height),this.bloom_compose_mat=new be(5),this.blurrer=new jt(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(),_t.clear(this.main_RT,We.current,!0,!1),_t.render(He.current,We.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),_t.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),_t.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===et.width&&this.main_RT.height===et.height||(this.main_RT.setSize(et.width,et.height),this.blur_RT.setSize(et.width,et.height))}}class It extends ye{constructor(){super()}render(){He.current.on_pre_render&&He.current.on_pre_render(),He.current.render?He.current.render():_t.render(He.current,We.current,_t._renderer.getRenderTarget()),this.render_spectator_camera(),He.current.on_post_render&&He.current.on_post_render()}render_spectator_camera(){const e=We.spectator;if(e&&_t._renderer.xr.isPresenting){const t=_t._renderer.xr.getCamera(We.current);e.projectionMatrix.copy(We.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);const s=_t._renderer.getRenderTarget();_t._renderer.xr.isPresenting=!1,_t._renderer.setRenderTarget(null),_t._renderer.render(He.current,e),_t._renderer.setRenderTarget(s),_t._renderer.xr.isPresenting=!0}}}const Nt=new class{constructor(){this.component_controllers=[],this.enabled_component_controllers=new Set}update(){this.__set_component_controllers_opacities();for(const e of this.enabled_component_controllers)e.update(Ve.current_state_data)}register_component_controller(e){this.component_controllers.push(e)}enable_component_controller(e){this.enabled_component_controllers.add(e)}disable_component_controller(e){this.enabled_component_controllers.delete(e)}get(e){for(let t=0;t<this.component_controllers.length;t++)if(this.component_controllers[t].name===e)return this.component_controllers[t];console.error("[ViewComponentControllerManager.get] no component_controller found for: ",e)}__set_component_controllers_opacities(){for(let e=0;e<this.component_controllers.length;e++)this.component_controllers[e].set_opacity(Ve.current_state_data)}};class Bt{constructor(e,t){e=e||new me,this.target_application=e,this.graphics=t,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0}update(){if(this.is_running){for(Ne.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.time_accumulator+=Ne.delta_time,this.target_application.before_update(),Ve.before_update();this.time_accumulator>Ne.fixed_delta_time;)this.target_application.fixed_update(),Ve.fixed_update(),this.time_accumulator-=Ne.fixed_delta_time;Ne.__set_frame_interpolation(this.time_accumulator/Ne.fixed_delta_time),this.target_application.update(),Ve.update(),qe.update(),Nt.update(),this.target_application.on_pre_render(),this.graphics.update(),ft.update(),ft.render(this.graphics),this.target_application.on_post_render(),it.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,ft.clear(),it.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}}const Vt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(Ve.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(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(Ve.current_state_data)}};class Yt{constructor({name:e,container:t}){this.name=e,this.container=t,Vt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),Vt.enable_component(this)}update(){}on_exit(){this.container.classList.add("hidden"),Vt.disable_component(this)}set_opacity(e){this.container.style.opacity=e}}class qt{constructor({name:e}){this.name=e,this.current_opacity=0,this.hidden=!0,Nt.register_component_controller(this)}start(){}on_enter(){Nt.enable_component_controller(this),Ae.push(`${this.name}_component.on_enter`),this.hidden=!1}update(){Ae.push(`${this.name}_component.update`)}on_exit(){Nt.disable_component_controller(this),Ae.push(`${this.name}_component.on_exit`),this.hidden=!0}set_opacity(e){const t=e[`${this.name}_opacity`];(this.current_opacity>t||this.current_opacity<t)&&(this.current_opacity=t,Ae.push(`${this.name}_component.set_opacity`,[t]),this.toggle_hidden())}toggle_hidden(){this.current_opacity>1e-4?this.hidden&&this.on_enter():this.hidden||this.on_exit()}}class Gt extends g{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new v({color:s});const r=new T(e,t);r.rotateX(-1.57),super(r,i)}}class Wt extends g{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new v({color:s});super(new T(e,t),i)}}class Et{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 Xt{constructor(){this.sphere=new j}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 c(0,0,-1).applyQuaternion(t),u=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,s,i),p=u.clone().add(h.clone().multiplyScalar(-1*d)),m=(new O).setFromNormalAndCoplanarPoint(o,p),g=(new O).setFromNormalAndCoplanarPoint(a,p),f=(new O).setFromNormalAndCoplanarPoint(_,p),v=(new O).setFromNormalAndCoplanarPoint(l,p);this.apply_center_correction_to_pos(p,e,t,m,g,f,v),m.setFromNormalAndCoplanarPoint(o,p),g.setFromNormalAndCoplanarPoint(a,p),f.setFromNormalAndCoplanarPoint(_,p),v.setFromNormalAndCoplanarPoint(l,p);let x=1/0;const w=h.clone().multiplyScalar(-2*d);for(let t=0;t<e.length;t++){const s=new I(e[t].clone(),e[t].clone().add(w)),i=new c,r=new c,n=new c,o=new c;m.intersectLine(s,i),g.intersectLine(s,r),f.intersectLine(s,n),v.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(),u=Math.min(a,_),d=Math.min(l,h),p=Math.min(u,d);p<x&&(x=p)}const b=h.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,t,s,i){let r,n,o=1/0,a=1/0;const _=new c(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new I(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new I(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),u=new c,d=new c;t.intersectLine(l,u),s.intersectLine(h,d);const p=u.distanceTo(e[i]),m=d.distanceTo(e[i]);d.length()<1e-4&&console.log("vertical up intersection not found",i),u.length()<1e-4&&console.log("vertical down intersection not found",i),p<a&&(a=p,n=e[i]),m<o&&(o=m,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 c(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new I(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new I(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),u=new c,d=new c;t.intersectLine(l,u),s.intersectLine(h,d);const p=u.distanceTo(e[i]),m=d.distanceTo(e[i]);u.length()<1e-4&&console.log("left intersection not found",i),d.length()<1e-4&&console.log("right intersection not found",i),p<a&&(a=p,n=e[i]),m<o&&(o=m,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 c(0,-1,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new c(0,1,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new c(1,0,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new c(-1,0,0);return s.applyQuaternion((new N).setFromAxisAngle(new c(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 $t{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 d;return r.setAttribute("position",new U(new Float32Array(i),3)),$t.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 U(new Float32Array(t),3))}}class Qt{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 Ht{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 M(r[i+0],r[i+1],r[i+2],r[i+3])}}const Zt=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],u=l.array[e+1],d=l.array[e+2],p=new c;p.x=n.getX(s),p.y=n.getY(s),p.z=n.getZ(s);const m=new c;m.x=n.getX(u),m.y=n.getY(u),m.z=n.getZ(u);const g=new c;g.x=n.getX(d),g.y=n.getY(d),g.z=n.getZ(d);const f={a:p,b:m,c:g};if(o){const e=new c;e.x=o.getX(s),e.y=o.getY(s),e.z=o.getZ(s);const t=new c;t.x=o.getX(u),t.y=o.getY(u),t.z=o.getZ(u);const i=new c;i.x=o.getX(d),i.y=o.getY(d),i.z=o.getZ(d);const r=e.clone().add(t).add(i).normalize();f.normal=r}if(a){const e=new c;e.x=a.getX(s),e.y=a.getY(s),e.z=a.getZ(s);const t=new c;t.x=a.getX(u),t.y=a.getY(u),t.z=a.getZ(u);const i=new c;i.x=a.getX(d),i.y=a.getY(d),i.z=a.getZ(d);const r=e.clone().add(t).add(i).normalize();f.tangent=r}if(_){const e=new t;e.x=_.getX(s),e.y=_.getY(s);const i=new t;i.x=_.getX(u),i.y=_.getY(u);const r=new t;r.x=_.getX(d),r.y=_.getY(d),f.uv_a=e,f.uv_b=i,f.uv_c=r}h.push(f);const v=this.get_face_area(f);r=Math.min(v,r),i.push(v)}const u=this.get_uniform_face_distribution(i,r,h),d=this.select_random_faces(u,s);return this.sample_data_from_faces(d)}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 Jt=new class{get_mesh(e,t){e.traverse((e=>{e instanceof g&&(e.geometry&&(e.geometry=(new d).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 g&&(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 G(o,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,s){e.traverse((e=>{e instanceof g&&(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 Kt{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(Kt.is_object(e)&&Kt.is_object(s))for(const t in s)Kt.is_object(s[t])?(e[t]||Object.assign(e,{[t]:{}}),Kt.merge_deep(e[t],s[t])):Object.assign(e,{[t]:s[t]});return Kt.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 es{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 ts{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 ss extends g{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 T(100,100,100,100);super($t.convert_to_non_indexed_geometry(s),t),this.rotation.x=-1.57}}class is extends g{constructor(t){const s=new d;s.setAttribute("position",new U(new Float32Array([]),3)),s.setAttribute("next_position",new U(new Float32Array([]),3)),s.setAttribute("previous_position",new U(new Float32Array([]),3)),s.setAttribute("orientation",new U(new Float32Array([]),1)),s.setAttribute("coverage",new U(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 U(a,3)),this.geometry.getAttribute("next_position").copy(new U(_,3)),this.geometry.getAttribute("previous_position").copy(new U(l,3)),this.geometry.getAttribute("orientation").copy(new U(h,1)),this.geometry.getAttribute("coverage").copy(new U(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 rs extends g{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:W}),n=new T(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 c,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 ns extends rs{constructor(e,t,s,i,r){const n=new Xe(r),o={font:t,font_color:s||"#000000"},a=n.draw_on_texture(e,o);a.minFilter=E,a.minFilter=q,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 os extends we{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(et.width,et.height)},_TextureSize:{value:new t},_PixelOffset:{value:new t(0,0)},_NDC:{value:new c},_PivotPoint:{value:new t},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class as{constructor(){this.tmp_vec=new t}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class _s{constructor(){this.tmp_vec3=new c,this.tmp_vec2=new t}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(We.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class ls{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class hs extends ls{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class cs extends ls{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 us extends ls{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class ds extends ls{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 ps extends g{constructor(e,s){super(new T(1,1),new os),this.is_clickable=!1,this.position_strategy=new _s,this.current_state=new hs,this._position=new c,this._on_idle_state=new hs,this._on_enter_state=new cs,this._on_exit_state=new us,this._on_hover_state=new ds,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 _s}set_screen_space_coordinate_system(){this.position_strategy=new as}set_texture(e){e.minFilter=l,e.magFilter=l,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(et.width,et.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 X).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)*et.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*et.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/et.width*2-1,this.position.y=e.y/et.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/et.dpr):(new t).copy(this.texture_size).multiplyScalar(this.size/et.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class ms extends g{constructor(e,t){super(e,t);const s=this;this.onBeforeRender=()=>{s.material.update()}}}class gs{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 M(i.left,i.right,i.top,i.bottom)}}class fs{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 c,this.quaternion=new N,this.scale=new c(1,1,1),this.matrix=new B,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 N).setFromAxisAngle(new c(0,1,0),e/360*Math.PI*2),i=(new N).setFromAxisAngle(new c(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 gs(s,r.planeBounds,r.atlasBounds);this.glyphs.push(e)}s+=r.advance}}const i=new X,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 X).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 vs extends we{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=W,e.minFilter=q,e.magFilter=q,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(e){this.uniforms._Boldness.value=Pe.lerp(.5,.2,e)}}class xs extends g{constructor(e,s){const i=new $;i.instanceCount=0;const r=new T(1,1);r.translate(.5,.5,0),i.setAttribute("position",new Q(r.getAttribute("position").array,3)),i.setAttribute("uv",new Q(r.getAttribute("uv").array,2)),i.index=r.index;const n=new H(new Float32Array(8e3),4,!1),o=new H(new Float32Array(8e3),4,!1),a=new H(new Float32Array(8e3),4,!1),_=new H(new Float32Array(8e3),4,!1),l=new H(new Float32Array(8e3),4,!1),h=new H(new Float32Array(8e3),4,!1),c=new H(new Float32Array(8e3),4,!1);n.usage=Z,o.usage=Z,a.usage=Z,_.usage=Z,l.usage=Z,h.usage=Z,c.usage=Z,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 vs(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 fs(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){Et.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 ws extends Le{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 bs extends ge{constructor(e){super(e?"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 upsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv+vec2(-halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(halfpixel.x*2.0,0.0));sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y))*2.0;sum+=texture2D(_MainTex,uv+vec2(0.0,-halfpixel.y*2.0));sum+=texture2D(_MainTex,uv+vec2(-halfpixel.x,-halfpixel.y))*2.0;return sum/12.0;}void main(){vec2 half_pixel;half_pixel.x=0.5/_Resolution.x;half_pixel.y=0.5/_Resolution.y;gl_FragColor=upsample(vUv,half_pixel);}":"#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;vec4 downsample(vec2 uv,vec2 halfpixel){vec4 sum=texture2D(_MainTex,uv)*4.0;sum+=texture2D(_MainTex,uv-halfpixel);sum+=texture2D(_MainTex,uv+halfpixel);sum+=texture2D(_MainTex,uv+vec2(halfpixel.x,-halfpixel.y));sum+=texture2D(_MainTex,uv-vec2(halfpixel.x,-halfpixel.y));return sum/8.0;}void main(){vec2 half_pixel=vec2(0.5/_Resolution.x,0.5/_Resolution.y);gl_FragColor=downsample(vUv,half_pixel);}")}}class ys extends ge{constructor(e,t){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;varying vec2 vUv;void main(){vec4 col=texture2D(_MainTex,vUv);gl_FragColor=col;gl_FragColor.a=col.a;}")}set offset(e){this.uniforms._Offset.value=e}get offset(){return this.uniforms._Offset.value}}class Ts{constructor(e){this.current_width=1,this.current_height=1,this.RT0=new A(1,1),this.RT1=new A(1,1),this.RT2=new A(1,1),this.RT3=new A(1,1),this.RT4=new A(1,1),this.upscale_blur_mat=new bs(!0),this.downscale_blur_mat=new bs(!1),this.alpha_filter_mat=new ys}blur(e){this.check_RT_resize(e.width,e.height),_t.blit(e,this.RT1,this.alpha_filter_mat),_t.blit(this.RT1,this.RT2,this.downscale_blur_mat),_t.blit(this.RT2,this.RT3,this.downscale_blur_mat),_t.blit(this.RT3,this.RT4,this.downscale_blur_mat),_t.blit(this.RT4,this.RT3,this.upscale_blur_mat),_t.blit(this.RT3,this.RT2,this.upscale_blur_mat),_t.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 Ms extends ge{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 Ss{constructor(e){this.RT=new A(1,1,{type:D,format:P,minFilter:l,magFilter:l}),this.RT1=new A(1,1,{type:D,format:P,minFilter:l,magFilter:l}),this.median_filter_mat=new Ms}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),_t.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),_t.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),_t.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 zs{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=zs.calculate_resolution(e),s={minFilter:l,magFilter:l,format:P,colorSpace:k,type:$e.fp_textures_available?D:J,stencilBuffer:!1,depthBuffer:!1};return new A(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,_t.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,_t.render(i,void 0,t),i.children[0].geometry.deleteAttribute("data"),i.children[0].material=void 0}get_texture(){return this.read.texture}}class Fs extends h{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 m,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 U(t,s,!1))}add_attribute_array(e,t,s){this.mesh.geometry.setAttribute(e,new H(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 T,i=new $;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 g(i,t);return r.frustumCulled=!1,r}build_attribute_writter_mesh(e){const{width:t,height:s}=zs.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 d;r.setAttribute("position",new U(i,3,!1));const n=new K(r);return n.frustumCulled=!1,n}build_uv_storage_attribute(e){const{width:t,height:s}=zs.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 H(i,2,!1)}}class Rs 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 As extends zs{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 Rs;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 Rs;this.store_geometry_attribute_in_RT(new U(s,4),this.read,i,t)}}class Cs extends L{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 Ps extends Cs{constructor(e,t){super(new Uint8Array(e*t*3),e,t,P),this.multiplier=255}}class ks extends Cs{constructor(e,t){super(new Uint8Array(e*t*4),e,t,P),this.multiplier=255}}class Ds extends Cs{constructor(e,t){super(new Float32Array(e*t*3),e,t,P,D)}}class Ls extends Cs{constructor(e,t){super(new Float32Array(e*t*4),e,t,P,D)}}class Us extends g{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 Ps(this.batch_width,this.batch_height)}attach_rgba_texture(e){this.material.uniforms[e].value=new ks(this.batch_width,this.batch_height)}attach_rgb_float_texture(e){this.material.uniforms[e].value=new Ds(this.batch_width,this.batch_height)}attach_rgba_float_texture(e){this.material.uniforms[e].value=new Ls(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 js{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 U(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 Us(e,t,s,i)}}class Os extends Se{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){Te.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 ee,s=new Image;s.src=this.url,s.onload=()=>{t.image=s,t.flipY=this.flipY,t.premultiplyAlpha=this.premultiplyAlpha,t.colorSpace=this.colorSpaceConversion?te:se,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 ee(t);s.flipY=this.flipY,s.premultiplyAlpha=this.premultiplyAlpha,s.colorSpace=this.colorSpaceConversion?te:se,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 Is{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 ie(e):this.audio=new re(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 Ns extends Se{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=ne.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 Is(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 Is(s,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended())}))}}class Bs extends Se{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 Vs extends Se{constructor(e,t,s,i){super(e,t,i),this.loader=new oe,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 Ys extends Se{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 qs extends Se{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 Gs extends Se{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 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 Ws extends Se{constructor(e,t,s,i){super(e,t,i),this.loader=new ce,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 Es extends Se{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 Xs extends Se{constructor(e,t,s,i){super(e,t,i),this.loader=new ue,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 $s extends Se{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){void 0===e.resources_by_url[this.url]?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 Qs extends Se{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 Hs extends Se{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 c(i,r,n))}return s}}class Zs extends Se{constructor(e,t,s){super(e,t,s),this.loader=new pe}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 Js extends Se{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 Ks extends Se{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 ee,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 ei extends Se{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 ti{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||pt)}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{Se as AbstractLoader,Ce as ActionEvent,Le as ActionInterpolator,ke as ActionSequencer,Oe as ActionSequencerBuilder,fe as AddMaterial,Re as ApplicationView,Ge as ApplicationViewController,Et as ArrayUtilities,Ke as Arrow,Os as AsyncTextureLoader,Ns as AudioLoader,me as BaseApplication,ye as BaseRender,we as BaseShaderMaterial,Bs as BasisLoader,ge as BlitMaterial,Pt as Blurrer,Te as Browser,ct as CSSAnimator,We as CameraManager,wt as CameraUtilities,Ee as CanvasDrawer,$e as Capabilities,Ze as Cube,Vs as CubemapLoader,Ys as DAELoader,it as Debug,St as DebugNormalsRender,je as DrawIOAnimationSheet,bs as DualFilteringBlurMaterial,Ts as DualFilteringBlurrer,De as EasingFunctions,qs as FileLoader,Gs as FontLoader,Xt as FrustumPointFitter,Ws as GLTFDRACOLoader,Es as GLTFLoader,Fs as GPUParticleSystem,jt as GaussianBlurrer,$t as GeometryUtilities,_t as Graphics,ss as Grid,Xs as HDRCubeTextureLoader,Qt as HTMLUtilities,Gt as HorizontalPlane,Ht as ImageUtilities,bt as Initializer,$s as JSONLoader,yt as KeyboardInput,is as Line,Ss as MedianFilter,js as MeshBatcher,Zt as MeshSampler,Jt as ModelUtilities,kt as NormalAORender,Dt as NormalRender,Ue as NumberInterpolator,Qs as OBJLoader,Pe as OMath,ut as OS,et as OScreen,Kt as ObjectUtilities,Tt as OrthographicCamera,xt as OrthographicFrustumPointFitter,zs as ParticleAttribute,As as ParticlePositionAttribute,st as PerspectiveCamera,vt as PerspectiveFrustumPointFitter,Hs as PointArrayLoader,Zs as RGBETextureLoader,Bt as RenderLoop,ti as ResourceBatch,pt as ResourceContainer,xs as SDFTextBatch,He as SceneManager,Xe as SimpleTextDrawer,Je as Sphere,es as StringUtilities,ns as Text2D,Js as TextLoader,Ks as TextureLoader,Ne as Time,ts as TimeUtilities,Ve as TransitionManager,Ie as TransitionTable,ft as UI,ps as UIElement,be as UnrealBloomComposeMaterial,Ot as UnrealBloomRender,ms as UpdatableMaterialMesh,qe as VCManager,It as VRRender,Me as Validation,ws as VectorInterpolator,Wt as VerticalPlane,ei as VideoLoader,Yt as ViewComponent,qt as ViewComponentController,Nt as ViewComponentControllerManager,Vt as ViewComponentManager,ze as ViewManager,Ae as WorkerToMain,rs as WorldImage};
1
+ import{Vector3 as e,Clock as t,Vector2 as s,ShaderMaterial as i,Color as r,NoBlending as n,AlwaysDepth as o,CanvasTexture as a,UVMapping as _,ClampToEdgeWrapping as l,NearestFilter as h,Object3D as c,LineBasicMaterial as d,BufferGeometry as u,Line as p,Scene as m,Mesh as g,BoxGeometry as f,MeshBasicMaterial as v,SphereGeometry as x,CylinderGeometry as w,ConeGeometry as b,PerspectiveCamera as y,PlaneGeometry as T,Vector4 as S,Box3 as M,Box3Helper as z,CatmullRomCurve3 as F,OrthographicCamera as R,WebGLRenderTarget as A,WebGLRenderer as C,RGBAFormat as P,NoColorSpace as k,FloatType as D,DataTexture as L,BufferAttribute as U,Sphere as j,Plane as O,Line3 as I,Quaternion as N,Matrix4 as q,Ray as B,RepeatWrapping as V,LinearFilter as Y,Skeleton as G,DoubleSide as E,LinearMipMapLinearFilter as W,Box2 as X,InstancedBufferGeometry as Q,Float32BufferAttribute as H,InstancedBufferAttribute as $,DynamicDrawUsage as Z,HalfFloatType as J,Points as K,PositionalAudio as ee,Audio as te,AudioContext as se,CubeTextureLoader as ie,FileLoader as re,Texture as ne,SRGBColorSpace as oe}from'three';import*as ae from'three/examples/jsm/utils/BufferGeometryUtils.js';export{ae as BufferGeometryUtils};import{ColladaLoader as _e}from'three/examples/jsm/loaders/ColladaLoader.js';import{FontLoader as le}from'three/examples/jsm/loaders/FontLoader.js';import{GLTFLoader as he}from'three/examples/jsm/loaders/GLTFLoader.js';import{HDRCubeTextureLoader as ce}from'three/examples/jsm/loaders/HDRCubeTextureLoader.js';import{OBJLoader as de}from'three/examples/jsm/loaders/OBJLoader.js';import{RGBELoader as ue}from'three/examples/jsm/loaders/RGBELoader.js';const pe=new (class
2
+ {
3
+ async init()
4
+ {
5
+ 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)
6
+ {
7
+ 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';
8
+ }this.version=this.get_version();
9
+ }get name()
10
+ {
11
+ return this.browser_name;
12
+ }get is_safari()
13
+ {
14
+ return'safari'===this.browser_name;
15
+ }get is_chrome()
16
+ {
17
+ return'chrome'===this.browser_name;
18
+ }get is_edge()
19
+ {
20
+ return'edge_ie'===this.browser_name;
21
+ }get is_edge_chromium()
22
+ {
23
+ return'edge_chromium'===this.browser_name;
24
+ }get has_webm()
25
+ {
26
+ return!!(this.is_chrome||this.is_firefox||this.is_edge_chromium);
27
+ }get has_hvec()
28
+ {
29
+ return this.is_safari;
30
+ }get preferred_video_extension()
31
+ {
32
+ return this.has_webm?'webm':this.has_hvec?'hvec.mp4':'mp4';
33
+ }get_version()
34
+ {
35
+ 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]);
36
+ }
37
+ });class me
38
+ {
39
+ constructor()
40
+ {}static is_int(e)
41
+ {
42
+ return Number(e)===e&&e%1==0;
43
+ }static is_float(e)
44
+ {
45
+ return Number(e)===e&&e%1!=0;
46
+ }static is_number(e)
47
+ {
48
+ return this.is_int(e)||this.is_float(e);
49
+ }static is_json(e)
50
+ {
51
+ try
52
+ {
53
+ JSON.parse(e);
54
+ }
55
+ catch(e)
56
+ {
57
+ return!1;
58
+ }return!0;
59
+ }
60
+ }class ge
61
+ {
62
+ constructor(e,t,s=1)
63
+ {
64
+ 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';
65
+ }__update_downloaded_bytes(e,t)
66
+ {
67
+ e=me.is_number(e)?e:1,t=me.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);
68
+ }__loading_ended()
69
+ {
70
+ this.has_finished=!0;
71
+ }__set_error(e)
72
+ {
73
+ this.has_error=!0,this.error_message=e;
74
+ }print_error()
75
+ {
76
+ console.error('Error while loading '+this.resource_id+'\n\t path: '+this.url+'\n\t\t'+this.error_message);
77
+ }load(e)
78
+ {
79
+ if(void 0===e.resources_by_url[this.url])
80
+ {
81
+ const t=pe.is_safari?'no-cache':'default';fetch(this.url,{method:'GET',mode:'cors',cache:t,credentials:'same-origin',redirect:'follow'}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this));
82
+ }
83
+ else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended();
84
+ }async on_progress(e,t)
85
+ {
86
+ const s=t.clone(),i=t.body.getReader(),r=+t.headers.get('Content-Length');let n=0;for(;;)
87
+ {
88
+ const{done:e,value:t}=await i.read();if(e)break;n+=t.length,this.__update_downloaded_bytes(n,r);
89
+ }this.on_preloaded_finished(e,s);
90
+ }on_preloaded_finished(e,t)
91
+ {}__on_error(e)
92
+ {
93
+ console.error(e);
94
+ }
95
+ }class fe
96
+ {
97
+ constructor()
98
+ {}static linear_map(e,t,s,i,r)
99
+ {
100
+ return(e-t)/(s-t)*(r-i)+i;
101
+ }static between(e,t,s)
102
+ {
103
+ return e>=t&&e<=s;
104
+ }static mod(e,t)
105
+ {
106
+ return(e%t+t)%t;
107
+ }static rgb_to_hex(e)
108
+ {
109
+ 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;
110
+ }static project_points_on_plane(t,s)
111
+ {
112
+ const i=new e,r=[];for(let e=0;e<t.length;e++)s.projectPoint(t[e],i),r.push(i.clone());return r;
113
+ }static matrix4_lerp(e,t,s,i)
114
+ {
115
+ for(let r=0;r<16;r++)s.elements[r]=this.lerp(e.elements[r],t.elements[r],i);
116
+ }static equals(e,t)
117
+ {
118
+ return Math.abs(e-t)<1e-6;
119
+ }static lerp(e,t,s)
120
+ {
121
+ return(1-s)*e+s*t;
122
+ }static clamp(e,t,s)
123
+ {
124
+ return Math.max(t,Math.min(s,e));
125
+ }static euclideanModulo(e,t)
126
+ {
127
+ return(e%t+t)%t;
128
+ }static pingpong(e,t=1)
129
+ {
130
+ return t-Math.abs(fe.euclideanModulo(e,2*t)-t);
131
+ }static degToRad(e)
132
+ {
133
+ return e*(Math.PI/180);
134
+ }static radToDeg(e)
135
+ {
136
+ return e*(180/Math.PI);
137
+ }static deg_to_rad(e)
138
+ {
139
+ return e*(Math.PI/180);
140
+ }static rad_to_deg(e)
141
+ {
142
+ return e*(180/Math.PI);
143
+ }static perspective_divide(e)
144
+ {
145
+ return e.x/=e.w,e.y/=e.w,e.z/=e.w,e;
146
+ }static points_average(e)
147
+ {
148
+ const t=e[0].clone();for(let s=1;s<e.length;s++)t.add(e[s]);return t.multiplyScalar(1/e.length),t;
149
+ }static get_random_color()
150
+ {
151
+ 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;
152
+ }static saturate(e)
153
+ {
154
+ return fe.clamp(e,0,1);
155
+ }
156
+ }class ve
157
+ {
158
+ constructor(e={})
159
+ {
160
+ 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;
161
+ }play()
162
+ {
163
+ this.playing=!0;
164
+ }stop()
165
+ {
166
+ this.playing=!1;
167
+ }reset()
168
+ {
169
+ this.elapsed_time=-1e-5;
170
+ }skip()
171
+ {
172
+ const e=this.get_duration();this.__play_clips(this.elapsed_time,e+1e-4),this.elapsed_time=e;
173
+ }update(e)
174
+ {
175
+ 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));
176
+ }set_progress(e)
177
+ {
178
+ this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=fe.clamp(e,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time);
179
+ }set_normalized_progress(e)
180
+ {
181
+ this.previous_elapsed_time=this.elapsed_time,this.elapsed_time=fe.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time);
182
+ }get_progress()
183
+ {
184
+ return fe.clamp(this.elapsed_time/this.get_duration(),0,1);
185
+ }is_finished()
186
+ {
187
+ return this.elapsed_time>this.get_duration();
188
+ }add_action_event(e,t)
189
+ {
190
+ this.action_events.push({trigger_time:e,action:t}),this.duration=Math.max(this.duration,e);
191
+ }add_action_interpolator(e,t,s,i=!1)
192
+ {
193
+ if(i)
194
+ {
195
+ 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;
196
+ }const r={from:e,to:t,interpolator:s};this.duration=Math.max(this.duration,t),this.channels[s.attribute_name].push(r);
197
+ }get_current_target_value(e)
198
+ {
199
+ const t=this.__get_current_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1);
200
+ }get_current_starting_value(e)
201
+ {
202
+ return this.__get_current_keyframe(e,this.elapsed_time).interpolator.evaluate(0);
203
+ }get_current_progress(e)
204
+ {
205
+ 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);
206
+ }get_duration()
207
+ {
208
+ return this.duration;
209
+ }__play_clips(e,t)
210
+ {
211
+ 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++)
212
+ {
213
+ const i=s[t],r=this.__get_current_keyframe(i,e);this.context[i]=this.evaluate_keyframe(r,e);
214
+ }
215
+ }__play_events(e,t)
216
+ {
217
+ for(let s=0;s<this.action_events.length;s++)
218
+ {
219
+ const i=this.action_events[s].trigger_time;fe.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());
220
+ }
221
+ }evaluate_keyframe(e,t)
222
+ {
223
+ return this.tmp_t=this.__linear_map_01(t,e.from,e.to),e.interpolator.evaluate(fe.clamp(this.tmp_t,0,1));
224
+ }get_keyframes(e)
225
+ {
226
+ return this.channels[e];
227
+ }is_channel_redefined(e)
228
+ {
229
+ for(let t=0;t<this.channels[e].length;t++)
230
+ {
231
+ if(this.channels[e][t].interpolator.initial)return!1;
232
+ }return!0;
233
+ }__linear_map_01(e,t,s)
234
+ {
235
+ return fe.saturate((e-t)/(s-t)*1+0);
236
+ }__get_current_keyframe(e,t)
237
+ {
238
+ let s;const i=this.channels[e];for(let e=0;e<i.length;e++)
239
+ {
240
+ const r=i[e];if(t>=r.from&&t<=r.to)return s=r,s;
241
+ }let r=1/0;for(let e=0;e<i.length;e++)
242
+ {
243
+ const n=i[e],o=Math.abs(n.to-t);o<r&&(s=n,r=o);
244
+ }return s;
245
+ }__get_playback_speed()
246
+ {
247
+ const e=new URLSearchParams(window.location.search).get('transitions_velocity');return e?Number(e):1;
248
+ }
249
+ }class xe
250
+ {
251
+ constructor()
252
+ {}static linear(e)
253
+ {
254
+ return e;
255
+ }static triangular(e)
256
+ {
257
+ return 1-Math.abs(2*e%2-1);
258
+ }static ease_in_sine(e)
259
+ {
260
+ return 1-Math.cos(3.1415926*e/2);
261
+ }static ease_out_sine(e)
262
+ {
263
+ return Math.sin(3.1415926*e/2);
264
+ }static ease_in_out_sine(e)
265
+ {
266
+ return-(Math.cos(3.1415926*e)-1)/2;
267
+ }static ease_in_cubic(e)
268
+ {
269
+ return e*e*e;
270
+ }static ease_out_cubic(e)
271
+ {
272
+ return 1-Math.pow(1-e,3);
273
+ }static ease_in_out_cubic(e)
274
+ {
275
+ return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;
276
+ }static ease_in_quad(e)
277
+ {
278
+ return e*e;
279
+ }static ease_out_quad(e)
280
+ {
281
+ return 1-(1-e)*(1-e);
282
+ }static ease_in_out_quad(e)
283
+ {
284
+ return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2;
285
+ }static ease_in_quart(e)
286
+ {
287
+ return e*e*e*e;
288
+ }static ease_out_quart(e)
289
+ {
290
+ return 1-Math.pow(1-e,4);
291
+ }static ease_in_out_quart(e)
292
+ {
293
+ return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2;
294
+ }static ease_in_quint(e)
295
+ {
296
+ return e*e*e*e*e;
297
+ }static ease_out_quint(e)
298
+ {
299
+ return 1-Math.pow(1-e,5);
300
+ }static ease_in_out_quint(e)
301
+ {
302
+ return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2;
303
+ }static ease_in_expo(e)
304
+ {
305
+ return 0===e?0:Math.pow(2,10*e-10);
306
+ }static ease_out_expo(e)
307
+ {
308
+ return 1===e?1:1-Math.pow(2,-10*e);
309
+ }static ease_in_out_expo(e)
310
+ {
311
+ return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2;
312
+ }static ease_in_circ(e)
313
+ {
314
+ return 1-Math.sqrt(1-Math.pow(e,2));
315
+ }static ease_out_circ(e)
316
+ {
317
+ return Math.sqrt(1-Math.pow(e-1,2));
318
+ }static ease_in_out_circ(e)
319
+ {
320
+ return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2;
321
+ }static ease_in_back(e)
322
+ {
323
+ return 2.7015*e*e*e-1.7015*e*e;
324
+ }static ease_out_back(e)
325
+ {
326
+ return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2);
327
+ }static ease_in_out_back(e)
328
+ {
329
+ 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;
330
+ }static ease_in_elastic(e)
331
+ {
332
+ 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);
333
+ }static ease_out_elastic(e)
334
+ {
335
+ return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1;
336
+ }static ease_in_out_elastic(e)
337
+ {
338
+ 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;
339
+ }static ease_in_bounce(e)
340
+ {
341
+ return 1-this.ease_out_bounce(1-e);
342
+ }static ease_out_bounce(e)
343
+ {
344
+ 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;
345
+ }static ease_in_out_bounce(e)
346
+ {
347
+ return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2;
348
+ }static heartbeat(e)
349
+ {
350
+ return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8;
351
+ }
352
+ }class we
353
+ {
354
+ constructor(e='linear')
355
+ {
356
+ this.easing_function=void 0,this.easing_function='string'==typeof e?xe[e]:e;
357
+ }update(e,t)
358
+ {}
359
+ }class be extends we
360
+ {
361
+ constructor(e,t=0,s=1,i=!1,r='linear')
362
+ {
363
+ super(r),this.attribute_name=e,this.from=t,this.to=s,this.initial=i;
364
+ }update(e,t)
365
+ {
366
+ e[this.attribute_name]=fe.lerp(this.from,this.to,this.easing_function(t));
367
+ }evaluate(e)
368
+ {
369
+ return fe.lerp(this.from,this.to,this.easing_function(e));
370
+ }
371
+ }const ye=new class
372
+ {
373
+ constructor()
374
+ {
375
+ this.app=void 0;
376
+ }set_app(e)
377
+ {
378
+ this.app=e;
379
+ }
380
+ };class Te
381
+ {
382
+ constructor(e,t,s)
383
+ {
384
+ this.name=e,this.method=t,this.args=s;
385
+ }trigger()
386
+ {
387
+ ye.app[this.name][this.method](...this.args.split(','));
388
+ }
389
+ }class Se
390
+ {
391
+ constructor()
392
+ {}parse(e)
393
+ {
394
+ const t=(new DOMParser).parseFromString(e,'text/xml').querySelectorAll('mxGeometry'),s=[],i=[];for(let e=0;e<t.length;e++)
395
+ {
396
+ 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;'))
397
+ {
398
+ const e=o.split('.'),t=e[0],s=e[1];i.push({name:t,method:s,at_time:a+.5*_});
399
+ }if(n.getAttribute('style').includes('rounded=0;')&&!n.getAttribute('style').includes('text;')&&''!==o&&!o.includes(' '))
400
+ {
401
+ 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});
402
+ }
403
+ }return s.sort(((e,t)=>e.from_time-t.from_time)),{animation_tracks:s,triggers:i};
404
+ }get_node_x_position(e)
405
+ {
406
+ const t=e.getAttribute('x');return null===t?0:parseFloat(t);
407
+ }
408
+ }class Me
409
+ {
410
+ constructor(e)
411
+ {
412
+ this.default_state_data=e;
413
+ }from_animation_sheet(e,t,s)
414
+ {
415
+ 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 ve(t);for(let e=0;e<i.length;e++)
416
+ {
417
+ const s=i[e],r=new be(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);
418
+ }for(let e=0;e<r.length;e++)
419
+ {
420
+ const t=r[e],s=new Te(t.name,t.method,t.args);o.add_action_event(t.at_time,s);
421
+ }return o;
422
+ }state_to_tracks(e,t)
423
+ {
424
+ 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;
425
+ }from_draw_io(e,t)
426
+ {
427
+ const s=(new Se).parse(e),i=s.animation_tracks,r=s.triggers,n=new ve(t);for(let e=0;e<i.length;e++)
428
+ {
429
+ const s=i[e],r=new be(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);
430
+ }for(let e=0;e<r.length;e++)
431
+ {
432
+ const t=r[e],s=new Te(t.name,t.method);n.add_action_event(t.at_time,s);
433
+ }return n;
434
+ }get_longest_time(e)
435
+ {
436
+ let t=-1;for(let s=0;s<e.length;s++)
437
+ {
438
+ const i=e[s].to_time;t=i>t?i:t;
439
+ }return t;
440
+ }
441
+ }const ze=new (class
442
+ {
443
+ init()
444
+ {
445
+ this.queue={},this.zoom_changed_evt='zoom_changed',this.store_clickd_evt='store_clicked',this.point_selected_evt='point_selected',this.config_changed='config_changed',this.path_substep_completed='path_substep_completed',this.path_completed='path_completed',this.go_to_store_requested_evt='go_to_store_requested',this.resource_loaded_evt='resource_loaded',this.service_clicked_evt='service_clicked',this.unit_pos_updated_evt='unit_position_updated',this.floor_changed_evt='floor_changed',this.on_enter_floor_navigation='on_enter_floor_navigation',this.on_exit_floor_navigation='on_exit_floor_navigation',this.on_enter_floor_selection='on_enter_floor_selection',this.on_exit_floor_selection='on_exit_floor_selection',this.on_enter_outside_navigation='on_enter_outside_navigation',this.on_exit_outside_navigation='on_exit_outside_navigation',this.step_selected_evt='step_selected';
446
+ }fire(e,t)
447
+ {
448
+ const s=this.queue[e];if(void 0===s)return;let i=s.length;for(;i--;)s[i](t);
449
+ }on(e,t)
450
+ {
451
+ void 0===this.queue[e]&&(this.queue[e]=[]),this.queue[e].push(t);
452
+ }fire_zoom_changed(e)
453
+ {
454
+ this.fire(this.zoom_changed_evt,e);
455
+ }fire_store_selected(e)
456
+ {
457
+ this.fire(this.store_clickd_evt,e);
458
+ }fire_point_selected(e)
459
+ {
460
+ this.fire(this.point_selected_evt,e);
461
+ }fire_config_changed()
462
+ {
463
+ this.fire(this.config_changed);
464
+ }fire_path_substep_completed(e)
465
+ {
466
+ this.fire(this.path_substep_completed,e);
467
+ }fire_path_completed()
468
+ {
469
+ this.fire(this.path_completed);
470
+ }fire_step_selected(e)
471
+ {
472
+ this.fire(this.step_selected_evt,e);
473
+ }fire_go_to_store_requested(e)
474
+ {
475
+ this.fire(this.go_to_store_requested_evt,e);
476
+ }fire_resource_loaded(e)
477
+ {
478
+ this.fire(this.resource_loaded_evt,e);
479
+ }fire_service_clicked(e)
480
+ {
481
+ this.fire(this.service_clicked_evt,e);
482
+ }fire_unit_position_updated(e)
483
+ {
484
+ this.fire(this.unit_pos_updated_evt,e);
485
+ }fire_floor_switched(e)
486
+ {
487
+ this.fire(this.floor_changed_evt,e);
488
+ }fire_on_enter_floor_navigation(e)
489
+ {
490
+ this.fire(this.on_enter_floor_navigation,e);
491
+ }fire_on_exit_floor_navigation(e)
492
+ {
493
+ this.fire(this.on_exit_floor_navigation,e);
494
+ }fire_on_enter_floor_selection(e)
495
+ {
496
+ this.fire(this.on_enter_floor_selection,e);
497
+ }fire_on_exit_floor_selection(e)
498
+ {
499
+ this.fire(this.on_exit_floor_selection,e);
500
+ }fire_on_enter_outside_navigation(e)
501
+ {
502
+ this.fire(this.on_enter_outside_navigation,e);
503
+ }fire_on_exit_outside_navigation(e)
504
+ {
505
+ this.fire(this.on_exit_outside_navigation,e);
506
+ }
507
+ });const Fe=new (class
508
+ {
509
+ init()
510
+ {
511
+ this.resources={},this.resources_by_url={};
512
+ }set_resource(e,t,s)
513
+ {
514
+ 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),ze.fire_resource_loaded({name:e,value:s});
515
+ }get_resource(e)
516
+ {
517
+ return this.resources[e];
518
+ }get(e)
519
+ {
520
+ return this.resources[e];
521
+ }
522
+ });class Re
523
+ {
524
+ static load_images(e)
525
+ {
526
+ const t=e.querySelectorAll('img');for(let e=0;e<t.length;e++)
527
+ {
528
+ const s=t[e];s.dataset.src&&(s.src=s.dataset.src);
529
+ }const s=e.querySelectorAll('object');for(let e=0;e<s.length;e++)
530
+ {
531
+ const t=s[e];t.dataset.src&&(t.data=t.dataset.src);
532
+ }
533
+ }static load_videos(e)
534
+ {
535
+ const t=e.querySelectorAll('video');for(let e=0;e<t.length;e++)
536
+ {
537
+ const s=t[e];s.dataset.src&&(s.src=s.dataset.src);
538
+ }
539
+ }static load_iframes(e)
540
+ {
541
+ const t=e.querySelectorAll('iframe');for(let e=0;e<t.length;e++)
542
+ {
543
+ const s=t[e];s.dataset.src&&(s.src=s.dataset.src);
544
+ }
545
+ }static load_elements(e,t)
546
+ {
547
+ const s=e.querySelectorAll(t);for(let e=0;e<s.length;e++)
548
+ {
549
+ const t=s[e];t.dataset.src&&(t.src=t.dataset.src);
550
+ }
551
+ }
552
+ }class Ae
553
+ {
554
+ constructor()
555
+ {
556
+ this.transitions=[],this.default_state_data={};
557
+ }get(e,t,s)
558
+ {
559
+ for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].from===e&&this.transitions[i].to===t)
560
+ {
561
+ return new Me(this.default_state_data).from_animation_sheet(this.transitions[i].data,s);
562
+ }for(let e=0;e<this.transitions.length;e++)if(this.transitions[e].to===t&&void 0===this.transitions[e].from)
563
+ {
564
+ return new Me(this.default_state_data).from_animation_sheet(this.transitions[e].data,s);
565
+ }console.error('TransitionTable.get no data found for: ',e,t);
566
+ }add_transitions(e)
567
+ {
568
+ for(let t=0;t<e.length;t++)this.transitions.push(e[t]);
569
+ }set_transitions(e)
570
+ {
571
+ this.transitions=e;
572
+ }set_default_state_data(e)
573
+ {
574
+ this.default_state_data=e;
575
+ }
576
+ }const Ce=new (class
577
+ {
578
+ constructor()
579
+ {
580
+ this.__delta_buffer=[.016,.016,.016,.016,.016,.016,.016,.016,.016,.016];
581
+ }init()
582
+ {
583
+ this.___time=new t,this.__delta_time=0,this.__smooth_delta_time=0,this.__elapsed_time=0,this.__allocated_time=new s(0,0),this.__frame_interpolation_t=0,this.fixed_delta_time=1/30;
584
+ }get elapsed_time()
585
+ {
586
+ return this.__elapsed_time;
587
+ }get delta_time()
588
+ {
589
+ return this.__delta_time;
590
+ }get smooth_delta_time()
591
+ {
592
+ return this.__smooth_delta_time;
593
+ }get shader_time()
594
+ {
595
+ return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_time;
596
+ }get frame_interpolation()
597
+ {
598
+ return this.__frame_interpolation_t;
599
+ }get fdt()
600
+ {
601
+ return this.fixed_delta_time;
602
+ }get dt()
603
+ {
604
+ return this.delta_time;
605
+ }get sdt()
606
+ {
607
+ return this.smooth_delta_time;
608
+ }__set_frame_interpolation(e)
609
+ {
610
+ this.__frame_interpolation_t=e;
611
+ }__update()
612
+ {
613
+ 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();
614
+ }__calculate_smooth_delta_time()
615
+ {
616
+ 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;
617
+ }
618
+ });class Pe
619
+ {
620
+ constructor(e)
621
+ {
622
+ this.name=e;
623
+ }start()
624
+ {}show()
625
+ {}hide()
626
+ {}before_enter()
627
+ {}on_enter()
628
+ {}before_update()
629
+ {}update()
630
+ {}fixed_update()
631
+ {}update_enter_transition(e,t,s)
632
+ {
633
+ this.update_transition(e,t,s);
634
+ }update_exit_transition(e,t,s)
635
+ {}update_transition(e,t,s)
636
+ {}before_exit()
637
+ {}on_exit()
638
+ {}
639
+ }class ke
640
+ {
641
+ constructor(e)
642
+ {
643
+ this.last_state=new Pe,this.current_state=new Pe,this.default_state_data={},this.current_state_data={},this.transition_table=e,this.transitioning=!1;
644
+ }go_to_state(e,t=!1)
645
+ {
646
+ this.transitioning&&this.__exit_last_state(),this.last_state=this.current_state,this.current_state=e,this.last_state.before_exit(),this.current_state.show(),this.action_sequencer=this.transition_table.get(this.last_state.name,this.current_state.name,this.current_state_data),this.current_state.before_enter(),this.action_sequencer.play(),this.transitioning=!0,t&&(this.action_sequencer.skip(),this.update());
647
+ }update()
648
+ {
649
+ 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();
650
+ }before_update()
651
+ {
652
+ this.current_state.before_update();
653
+ }fixed_update()
654
+ {
655
+ this.current_state.fixed_update();
656
+ }set_state(e)
657
+ {
658
+ this.current_state=e;
659
+ }set_default_state_data(e)
660
+ {
661
+ Object.assign(this.default_state_data,e),Object.assign(this.current_state_data,e);
662
+ }__update_transitions()
663
+ {
664
+ this.action_sequencer.update(Ce.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);
665
+ }__exit_last_state()
666
+ {
667
+ this.last_state.name!==this.current_state.name&&this.last_state.hide(),this.last_state.on_exit();
668
+ }
669
+ }const De=new (class
670
+ {
671
+ constructor()
672
+ {
673
+ this.views=[],this.transition_table=new Ae,this.transition_handler=new ke(this.transition_table),this.view_change_subscribers=[],this.browser_title_suffix='';
674
+ }before_update()
675
+ {
676
+ this.transition_handler.before_update();
677
+ }update()
678
+ {
679
+ this.transition_handler.update(),this.__set_views_opacities();
680
+ }fixed_update()
681
+ {
682
+ this.transition_handler.fixed_update();
683
+ }go_to_view(e,t=!0,s=!1)
684
+ {
685
+ const i=this.get(e);this.transition_handler.go_to_state(i,s),t&&(this.__change_browser_url(i.url),this.__change_browser_title(i.url)),this.notify_view_change(e);
686
+ }go_to_scene(e,t=!1,s=!1)
687
+ {
688
+ const i=this.get(e),r=this.get('transition');r.set_next_view(i),this.go_to_view(r.name,t,s);
689
+ }subscribe_to_view_change(e)
690
+ {
691
+ this.view_change_subscribers.push(e);
692
+ }notify_view_change(e)
693
+ {
694
+ for(let t=0;t<this.view_change_subscribers.length;t++)
695
+ {
696
+ this.view_change_subscribers[t].on_view_change(e);
697
+ }
698
+ }register_view(e)
699
+ {
700
+ this.views.push(e);
701
+ }has_view(e)
702
+ {
703
+ for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1;
704
+ }add_transitions(e)
705
+ {
706
+ this.transition_table.add_transitions(e);
707
+ }set_transitions(e)
708
+ {
709
+ this.transition_table.set_transitions(e);
710
+ }set_view(e)
711
+ {
712
+ const t=this.get(e);this.transition_handler.set_state(t);
713
+ }set_browser_title_suffix(e)
714
+ {
715
+ this.browser_title_suffix=e;
716
+ }get_current_view()
717
+ {
718
+ return this.transition_handler.current_state;
719
+ }get_view_by_name(e)
720
+ {
721
+ console.warn('DEPRECATED. Use ViewManager.get instead'),this.get(e);
722
+ }get(e)
723
+ {
724
+ 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);
725
+ }get_view_by_url(e)
726
+ {
727
+ console.warn('DEPRECATED. Use ViewManager.get_by_url instead'),this.get_by_url(e);
728
+ }get_by_url(e)
729
+ {
730
+ 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);
731
+ }set_default_state_data(e)
732
+ {
733
+ this.transition_table.set_default_state_data(e),this.transition_handler.set_default_state_data(e);
734
+ }__change_browser_url(e)
735
+ {
736
+ window.history.pushState('','',e);
737
+ }__change_browser_title(e)
738
+ {
739
+ const t=this.__capitalize(e);document.title=t?`${t} | ${this.browser_title_suffix}`:this.browser_title_suffix;
740
+ }__set_views_opacities()
741
+ {
742
+ for(let e=0;e<this.views.length;e++)this.views[e].set_opacity(this.transition_handler.current_state_data);
743
+ }__capitalize(e)
744
+ {
745
+ let t=e.toUpperCase().replace('/','');return t=this.__snake_to_whitespace(t),t;
746
+ }__snake_to_whitespace(e)
747
+ {
748
+ return e.replace(/([-_][A-Z])/g,(e=>e.replace('-',' ').replace('_',' ')));
749
+ }
750
+ });class Le extends Pe
751
+ {
752
+ constructor({name:e,url:t,container:s})
753
+ {
754
+ super(e),this.container=s,this.url=t;let i=Fe.get(`${e}_data`);i=i||{animation_tracks:[],triggers:[]};const r=[{to:e,data:i}];De.register_view(this),De.add_transitions(r);
755
+ }show()
756
+ {
757
+ this.container.classList.add('before_enter'),this.container.classList.remove('before_exit'),this.container.classList.remove('hidden');
758
+ }on_enter()
759
+ {
760
+ this.container.classList.remove('before_enter'),this.container.classList.remove('before_exit'),this.container.classList.remove('hidden');
761
+ }before_exit()
762
+ {
763
+ this.container.classList.add('before_exit'),this.container.classList.remove('before_enter'),this.container.classList.remove('hidden');
764
+ }hide()
765
+ {
766
+ this.container.classList.add('hidden'),this.container.classList.remove('before_enter'),this.container.classList.remove('before_exit');
767
+ }load_html_images()
768
+ {
769
+ Re.load_images(this.container);
770
+ }load_html_videos()
771
+ {
772
+ Re.load_videos(this.container);
773
+ }set_opacity(e)
774
+ {
775
+ this.container.style.opacity=e[`${this.name}_opacity`];
776
+ }
777
+ }class Ue
778
+ {
779
+ on_post_start()
780
+ {}on_enter()
781
+ {}on_exit()
782
+ {}before_update()
783
+ {}update()
784
+ {}fixed_update()
785
+ {}on_post_render()
786
+ {}on_pre_render()
787
+ {}on_frame_end()
788
+ {}
789
+ }class je
790
+ {
791
+ constructor()
792
+ {}render()
793
+ {}on_enter(e,t)
794
+ {}on_exit(e,t)
795
+ {}resize()
796
+ {}dispose()
797
+ {}
798
+ }var Oe='#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}',Ie='#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}';class Ne extends i
799
+ {
800
+ constructor(e,t,s)
801
+ {
802
+ super({vertexShader:e||Oe,fragmentShader:t||Ie,uniforms:s||{_Color:{value:new r('#FF0000')}}});
803
+ }
804
+ }class qe extends i
805
+ {
806
+ constructor(e,t,i)
807
+ {
808
+ super({uniforms:{_MainTex:{value:null},_Resolution:{value:new s(0,0)},_TargetResolution:{value:new s(0,0)}},defines:i||{},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:n,depthTest:!1,depthFunc:o});
809
+ }
810
+ }class Be extends qe
811
+ {
812
+ constructor(e)
813
+ {
814
+ 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};
815
+ }set_add_texture(e)
816
+ {
817
+ this.uniforms._SecondTex.value=e;
818
+ }
819
+ }class Ve extends qe
820
+ {
821
+ constructor(e)
822
+ {
823
+ 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};
824
+ }set_RT_0(e)
825
+ {
826
+ this.uniforms.blurTexture1.value=e;
827
+ }set_RT_1(e)
828
+ {
829
+ this.uniforms.blurTexture2.value=e;
830
+ }set_RT_2(e)
831
+ {
832
+ this.uniforms.blurTexture3.value=e;
833
+ }set_RT_3(e)
834
+ {
835
+ this.uniforms.blurTexture4.value=e;
836
+ }set_RT_4(e)
837
+ {
838
+ this.uniforms.blurTexture5.value=e;
839
+ }set_bloom_strength(e)
840
+ {
841
+ this.uniforms.bloomStrength.value=e;
842
+ }set_bloom_radius(e)
843
+ {
844
+ this.uniforms.bloomRadius.value=e;
845
+ }set_tint_color_0(e)
846
+ {
847
+ this.uniforms.bloomTintColors.value[0].set(e);
848
+ }set_tint_color_1(e)
849
+ {
850
+ this.uniforms.bloomTintColors.value[1].set(e);
851
+ }set_tint_color_2(e)
852
+ {
853
+ this.uniforms.bloomTintColors.value[2].set(e);
854
+ }set_tint_color_3(e)
855
+ {
856
+ this.uniforms.bloomTintColors.value[3].set(e);
857
+ }set_tint_color_4(e)
858
+ {
859
+ this.uniforms.bloomTintColors.value[4].set(e);
860
+ }
861
+ }const Ye=new class
862
+ {
863
+ init()
864
+ {
865
+ this._current=void 0,this._spectator=void 0;
866
+ }set current(e)
867
+ {
868
+ this._current=e;
869
+ }get current()
870
+ {
871
+ return this._current;
872
+ }set spectator(e)
873
+ {
874
+ this._spectator=e;
875
+ }get spectator()
876
+ {
877
+ return this._spectator;
878
+ }
879
+ };const Ge=new class
880
+ {
881
+ init()
882
+ {
883
+ this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1;
884
+ }
885
+ };class Ee
886
+ {
887
+ constructor(e)
888
+ {
889
+ this.uses_dynamic_font=e,this.__textHeight=null,this.canvas=document.createElement('canvas'),this.ctx=this.canvas.getContext('2d');
890
+ }getFontHeight(e='Arial')
891
+ {
892
+ if(null==this.__textHeight||this.uses_dynamic_font)
893
+ {
894
+ 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);
895
+ }return this.__textHeight;
896
+ }get_text_size(e,t='24px Arial')
897
+ {
898
+ const i=new s;return this.ctx.font=t,i.x=Math.ceil(this.ctx.measureText(e).width),i.y=Math.ceil(this.getFontHeight(t)),i;
899
+ }draw_canvas(e,t={})
900
+ {
901
+ return t.font=t.font||'24px Arial',t.font_color=t.font_color||'#000000',this.__draw(e,t,this.canvas,this.ctx),this.canvas;
902
+ }draw_on_texture(e,t)
903
+ {
904
+ const s=this.draw_canvas(e,t),i=new a(s,_,l,l,h,h);return i.generateMipMaps=!1,i.needsUpdate=!0,i;
905
+ }__draw(e,t)
906
+ {}roundRect(e,t,s,i,r,n,o,a)
907
+ {
908
+ if(void 0===a&&(a=!0),void 0===n&&(n=5),'number'==typeof n)n={tl:n,tr:n,br:n,bl:n};else
909
+ {
910
+ const e={tl:0,tr:0,br:0,bl:0};for(const t in e)n[t]=n[t]||e[t];
911
+ }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();
912
+ }
913
+ }const We=new class
914
+ {
915
+ init(e={})
916
+ {
917
+ this.dpr=1,this.app={};
918
+ }from_json(e)
919
+ {}
920
+ };class Xe
921
+ {
922
+ constructor()
923
+ {}get is_animating()
924
+ {
925
+ return!1;
926
+ }on_enter(e)
927
+ {}update(e)
928
+ {}on_exit(e)
929
+ {}
930
+ }class Qe
931
+ {
932
+ constructor()
933
+ {
934
+ this.t=0,this.easing_function_t=0;
935
+ }get is_animating()
936
+ {
937
+ return!0;
938
+ }on_enter(e)
939
+ {}update(e)
940
+ {
941
+ this.t+=Ce.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=fe.clamp(this.easing_function_t,0,1),e.set_property_value(fe.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 Xe),e.finished_callback(e));
942
+ }on_exit(e)
943
+ {}
944
+ }class He
945
+ {
946
+ constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n='',value_suffix:o='',easing_function:a=xe.ease_in_out_cubic,finished_callback:_=(()=>
947
+ {})})
948
+ {
949
+ 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 Xe;
950
+ }animate()
951
+ {
952
+ this.set_current_state(new Qe);
953
+ }stop()
954
+ {
955
+ this.set_current_state(new Xe);
956
+ }set_property_value(e)
957
+ {
958
+ this.element.style[this.css_property]=`${this.value_prefix}${e}${this.value_suffix}`;
959
+ }update()
960
+ {
961
+ this.current_state.update(this);
962
+ }get is_animating()
963
+ {
964
+ return this.current_state.is_animating;
965
+ }set_current_state(e)
966
+ {
967
+ this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this);
968
+ }
969
+ }class $e extends c
970
+ {
971
+ constructor(t=1)
972
+ {
973
+ super();const s=[];s.push(new e(0,0,0)),s.push(new e(0,0,1e3));const i=new d({color:4474111,depthFunc:o}),r=(new u).setFromPoints(s),n=new p(r,i);n.renderOrder=5e4;const a=[];a.push(new e(0,0,0)),a.push(new e(0,1e3,0));const _=new d({color:4521796,depthFunc:o}),l=(new u).setFromPoints(a),h=new p(l,_);h.renderOrder=5e4;const c=[];c.push(new e(0,0,0)),c.push(new e(1e3,0,0));const m=new d({color:16729156,depthFunc:o}),g=(new u).setFromPoints(c),f=new p(g,m);f.renderOrder=5e4,this.renderOrder=1e5,this.add(n),this.add(h),this.add(f),this.scale.set(t,t,t);
974
+ }update()
975
+ {}dispose()
976
+ {}
977
+ }const Ze=new (class
978
+ {
979
+ init()
980
+ {
981
+ this._current=new m,this._current.name='default_scene';
982
+ }add_scene(e)
983
+ {}get current()
984
+ {
985
+ return this._current;
986
+ }set current(e)
987
+ {
988
+ this._current=e;
989
+ }dispose()
990
+ {
991
+ for(this.current.traverse((e=>
992
+ {
993
+ e.geometry&&(e.geometry.dispose(),e.material.dispose());
994
+ }));this.current.children.length>0;)this.current.remove(this.current.children[0]);
995
+ }
996
+ });class Je extends g
997
+ {
998
+ constructor(t,s,i)
999
+ {
1000
+ t=t||new e(1,1,1),s=s||new e(1,1,1),i=i||16711680;super(new f(t.x,t.y,t.z,s.x,s.y,s.z),new v({color:i}));
1001
+ }
1002
+ }class Ke extends g
1003
+ {
1004
+ constructor(e,t)
1005
+ {
1006
+ t=t||'#FF0000';super(new x(e=e||1,64,64),new v({color:t}));
1007
+ }
1008
+ }class et extends g
1009
+ {
1010
+ constructor(t,s,i)
1011
+ {
1012
+ t=t||'#FF0000';const r=(s=s||1)-.4,n=new w(.01,.01,r,32);n.translate(0,r/2,0);const o=new b(.1,.4,32);o.translate(0,r+.2,0);const a=ae.mergeGeometries([n,o]);a.rotateX(1.57);super(a,new v({color:t})),i&&this.quaternion.setFromUnitVectors(new e(0,0,1),i),this._dir=i;
1013
+ }set dir(t)
1014
+ {
1015
+ this.quaternion.setFromUnitVectors(new e(0,0,1),t),this._dir=t;
1016
+ }get dir()
1017
+ {
1018
+ return this._dir;
1019
+ }set length(e)
1020
+ {
1021
+ this.scale.z=e;
1022
+ }get length()
1023
+ {
1024
+ return this.scale.z;
1025
+ }
1026
+ }const tt=new (class
1027
+ {
1028
+ init()
1029
+ {
1030
+ this.width=1,this.height=1,this.position=new s,this.render_width=1,this.render_height=1,this.width_height=new s(this.width,this.height),this.dpr=1,this.pixel_size=new s(1/this.width,1/this.height);
1031
+ }update_position(e,t)
1032
+ {
1033
+ this.position.set(e,t);
1034
+ }update()
1035
+ {
1036
+ this.size_changed=!1;
1037
+ }update_size(e,t)
1038
+ {
1039
+ this.width=e,this.height=t,this.pixel_size=new s(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;
1040
+ }apply_pixel_density_v2(e)
1041
+ {
1042
+ return e.multiplyScalar(1/this.dpr),e;
1043
+ }apply_pixel_density(e)
1044
+ {
1045
+ return e*(1/this.dpr);
1046
+ }get_pixel_size()
1047
+ {
1048
+ return this.pixel_size;
1049
+ }get aspect_ratio()
1050
+ {
1051
+ return this.width/this.height;
1052
+ }get portrait()
1053
+ {
1054
+ return this.width<this.height;
1055
+ }
1056
+ });class st extends Ne
1057
+ {
1058
+ constructor(e,t,i,r)
1059
+ {
1060
+ 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 s},_ScreenSize:{value:new s},_TextureSize:{value:new s}});
1061
+ }set_position(e,t)
1062
+ {
1063
+ this.uniforms._ScreenSpacePosition.value.set(e,t);
1064
+ }set_texture(e,t,s)
1065
+ {
1066
+ 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);
1067
+ }set_screen_size(e,t)
1068
+ {
1069
+ this.uniforms._ScreenSize.value.set(e,t);
1070
+ }
1071
+ }class it extends y
1072
+ {
1073
+ constructor(e,t,s,i)
1074
+ {
1075
+ super(e,t,s,i),this.clear_color=new r('#000000'),this.clear_alpha=1;
1076
+ }copy(e)
1077
+ {
1078
+ return super.copy(e),this.clear_color.copy(e.clear_color),this.clear_alpha=e.clear_alpha,this;
1079
+ }
1080
+ }const rt=new (class
1081
+ {
1082
+ init()
1083
+ {
1084
+ this.Vector3_one=new e(1,1,1),this.Vector3_zero=new e(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new m,this.camera=new it(60,tt.aspect_ratio,.1,1e3),this.camera.clear_alpha=0;
1085
+ }draw_arrow(e,t,s=16711680)
1086
+ {
1087
+ const i=new et(s,t.length(),t.clone().normalize());return i.position.copy(e),this.scene.add(i),i;
1088
+ }draw_axis()
1089
+ {
1090
+ const e=new $e;return this.scene.add(e),e;
1091
+ }set_debug_RT(e)
1092
+ {
1093
+ this.rt_debug=e;
1094
+ }draw_rectangle(e,t,s,i)
1095
+ {
1096
+ 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);
1097
+ }clear()
1098
+ {
1099
+ this.ctx&&this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);
1100
+ }draw_line_2D(e,t,s)
1101
+ {
1102
+ 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();
1103
+ }draw_line(e,t=16711680)
1104
+ {
1105
+ const s=new d({color:t}),i=(new u).setFromPoints(e),r=new p(i,s);return r.frustumCulled=!1,this.scene.add(r),r;
1106
+ }draw_cube(t,s,i)
1107
+ {
1108
+ s=s||1,i=i||16711680,t=t||new e;const r=new Je(new e(s,s,s),void 0,i);return r.position.copy(t),this.scene.add(r),r;
1109
+ }draw_oriented_cube(t,s,i=1,r='#FF0000',n=.1)
1110
+ {
1111
+ const o=t.distanceTo(s),a=new Je(new e(n,i,o),void 0,r),_=s.clone().sub(t).multiplyScalar(.5),l=_.clone().normalize();return _.add(t),a.position.copy(_),a.quaternion.setFromUnitVectors(new e(0,0,-1),l),this.scene.add(a),a;
1112
+ }draw_plane(e,t,s)
1113
+ {
1114
+ const r=new T(e,t),n=new i({uniforms:{_Color:{value:new S(0,1,0,.2)}},vertexShader:Oe,fragmentShader:Ie,transparent:!0,depthWrite:!1}),o=new g(r,n);return o.renderOrder=-1e4,this.scene.add(o),o;
1115
+ }draw_empty_cube(t,s,i)
1116
+ {
1117
+ s=s||1,i=i||16711680;const r=(new M).setFromCenterAndSize(new e,new e(s,s,s)),n=new z(r,i);return n.position.copy(t||new e),n;
1118
+ }draw_sphere(t,s,i)
1119
+ {
1120
+ s=s||1,i=i||16711680,t=t||new e;const r=new Ke(s,i);return r.position.copy(t),this.scene.add(r),r;
1121
+ }draw_point_array(e,t=!1,s=16711680)
1122
+ {
1123
+ const i=new F(e,t);i.updateArcLengths();const r=i.getSpacedPoints(200);return this.draw_line(r,65280);
1124
+ }draw_sphere_helper(e,t)
1125
+ {
1126
+ t=t||16711680;const s=new x(e.radius,32,32),i=new v({color:t}),r=new g(s,i);return r.position.copy(e.center),Ze.current.add(r),r;
1127
+ }draw_math_sphere(e)
1128
+ {
1129
+ const t=new x(e.radius,32,32),s=new i({uniforms:{_Color:{value:new S(1,0,0,.2)}},vertexShader:Oe,fragmentShader:Ie,transparent:!0}),r=new g(t,s);r.position.copy(e.center),Ze.current.add(r);
1130
+ }draw_bounding_box(e)
1131
+ {
1132
+ const t=new z(e,16776960);Ze.current.add(t);
1133
+ }draw_curve(t,s)
1134
+ {
1135
+ const i=new e(0,0,0);s&&(i.y=s.offset||0);for(let e=0;e<t.length-1;e++)this.draw_line(t[e].clone().add(i),t[e+1].clone().add(i));
1136
+ }draw_texture(e,t,s)
1137
+ {
1138
+ const i=new g(new T(1,1),new st);return this.display_texture_meshes.push(i),this.scene.add(i),i.material.set_texture(e,t,s),i;
1139
+ }render(e)
1140
+ {
1141
+ for(let e=0;e<this.display_texture_meshes.length;e++)this.display_texture_meshes[e].material.set_screen_size(tt.width,tt.height);this.scene.children.length>0&&e.render(this.scene,Ye.current);
1142
+ }
1143
+ });class nt
1144
+ {
1145
+ constructor(e)
1146
+ {
1147
+ this.renderer=e,this._blit_scene=new m,this._blit_material=new qe,this._blit_quad=new g(new T(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new R(-1,1,1,-1,-1e4,1e4);
1148
+ }blit(e,t)
1149
+ {
1150
+ 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);
1151
+ }material_pass(e,t)
1152
+ {
1153
+ this._blit_quad.material=e,this.__render(t);
1154
+ }blit_with_material(e,t,s)
1155
+ {
1156
+ 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);
1157
+ }blit_clear_with_material(e,t)
1158
+ {
1159
+ this._blit_quad.material=t,this.__render(e);
1160
+ }dispose()
1161
+ {
1162
+ this._blit_quad.geometry.dispose(),this._blit_quad.material.dispose();
1163
+ }__render(e)
1164
+ {
1165
+ 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);
1166
+ }
1167
+ }class ot extends qe
1168
+ {
1169
+ constructor(e,t)
1170
+ {
1171
+ 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 S(e,t.x,t.y,t.z)};
1172
+ }
1173
+ }class at extends i
1174
+ {
1175
+ constructor()
1176
+ {
1177
+ 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)));}'});
1178
+ }set far_plane(e)
1179
+ {
1180
+ this.uniforms._FarPlane.value=e;
1181
+ }get far_plane()
1182
+ {
1183
+ return this.uniforms._FarPlane.value;
1184
+ }
1185
+ }class _t
1186
+ {
1187
+ constructor()
1188
+ {
1189
+ this.RT=new A(tt.width,tt.height),this.clear_depth_normal_mat=new ot(1,new e(0,0,1)),this.depth_normal_material=new at;
1190
+ }render(e)
1191
+ {
1192
+ 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=Ye.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material);
1193
+ }__resize_RT_if_necessary()
1194
+ {
1195
+ this.RT.width===tt.width&&this.RT.height===tt.height||this.RT.setSize(tt.width,tt.height);
1196
+ }get render_target()
1197
+ {
1198
+ return this.RT;
1199
+ }
1200
+ }const lt=new (class
1201
+ {
1202
+ init(e,t,s,i)
1203
+ {
1204
+ 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 C(this.threejs_attributes),this.core_attributes.xr_enabled?this._renderer.xr.enabled=!0:this._renderer.autoClear=!1,this._renderer.setPixelRatio(1),tt.dpr=We.dpr,this.is_webgl2||this._renderer.extensions.get('ANGLE_instanced_arrays'),this.blitter=new nt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new je,this.current_render_mode=this.no_render,Ge.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),Ge.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,Ge.fp_textures_available=this.is_floating_point_texture_available(),this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new _t,this.resize_observer=new ResizeObserver(this.on_resize.bind(this)),this.resize_observer.observe(this.canvas);
1205
+ }get dom_element()
1206
+ {
1207
+ return this._renderer.domElement;
1208
+ }get depth_normals_RT()
1209
+ {
1210
+ return this.depth_and_normals_renderer.render_target;
1211
+ }set_state(e)
1212
+ {
1213
+ this.current_render_mode.on_exit(this,this._renderer),this.current_render_mode=e,this.current_render_mode.on_enter(this,this._renderer);
1214
+ }update()
1215
+ {
1216
+ this.generateDepthNormalTexture&&this.depth_and_normals_renderer.render(this),this.__update_current_camera(),Ye.current&&this.current_render_mode.render(),tt.update();
1217
+ }__update_current_camera()
1218
+ {
1219
+ Ye.current&&(Ye.current.aspect=tt.aspect_ratio,Ye.current.updateProjectionMatrix(),Ye.current.updateMatrix(),Ye.current.updateMatrixWorld(!0));
1220
+ }render(e,t,s,i)
1221
+ {
1222
+ this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.render(e||Ze.current,t||Ye.current),this.__apply_override_material(e,void 0);
1223
+ }compile(e,t,s,i)
1224
+ {
1225
+ this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s),this._renderer.compile(e||Ze.current,t||Ye.current),this.__apply_override_material(e,void 0);
1226
+ }async compile_async(e,t,s,i,r)
1227
+ {
1228
+ this.__apply_override_material(e,i),this._renderer.setRenderTarget(void 0===s?null:s);const n=this._renderer.compileAsync(e||Ze.current,t||Ye.current,r);return this.__apply_override_material(e,void 0),n;
1229
+ }render_scene(e)
1230
+ {
1231
+ 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();
1232
+ }__apply_override_material(e,t)
1233
+ {
1234
+ t=void 0===t?null:t,e?e.overrideMaterial=t:Ze.current.overrideMaterial=t;
1235
+ }readback_RT(e,t)
1236
+ {
1237
+ this._renderer.readRenderTargetPixels(e,0,0,e.width,e.height,t);
1238
+ }clear(e,t,s,i)
1239
+ {
1240
+ this._renderer.setRenderTarget(void 0===e?null:e),t&&this._renderer.setClearColor(t.clear_color,t.clear_alpha),this._renderer.clear(!!t,!!s,!!i);
1241
+ }on_resize(e)
1242
+ {
1243
+ for(const t of e)tt.dpr=We.dpr,tt.update_position(t.contentRect.x,t.contentRect.y),tt.update_size(t.contentRect.width,t.contentRect.height),this.canvas.width=tt.render_width,this.canvas.height=tt.render_height,this._renderer.setViewport(0,0,tt.render_width,tt.render_height),this.__update_current_camera();
1244
+ }material_pass(e,t)
1245
+ {
1246
+ this.blitter.material_pass(e,t);
1247
+ }blit(e,t,s)
1248
+ {
1249
+ s?this.blitter.blit_with_material(e,t,s):this.blitter.blit(e,t);
1250
+ }blit_clear_with_material(e,t)
1251
+ {
1252
+ this.blitter.blit_clear_with_material(e,t);
1253
+ }take_screenshot(e,t=tt.width,s=tt.height)
1254
+ {
1255
+ const i=tt.width,r=tt.height,n=t,o=s,a=1024,_=1024,l=parseInt(Math.ceil(n/a)),h=parseInt(Math.ceil(o/_));tt.update_size(a,_);const c=this._renderer.getPixelRatio();this._renderer.setPixelRatio(1),this._renderer.setSize(a,_,!1);const d=document.createElement('canvas').getContext('2d');d.canvas.width=n,d.canvas.height=o,Ye.current.aspect=tt.aspect_ratio,Ye.current.updateMatrix(),Ye.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)Ye.current.setViewOffset(n,o,tt.width*e,tt.height*t,tt.width,tt.height),this.current_render_mode.render(),d.drawImage(this._renderer.domElement,tt.width*e,tt.height*t);d.canvas.toBlob(e,'image/png;base64;'),Ye.current.clearViewOffset(),tt.update_size(i,r),this._renderer.setPixelRatio(c),this._renderer.setSize(i,r,!1),Ye.current.aspect=tt.aspect_ratio,Ye.current.updateMatrix(),Ye.current.updateMatrixWorld(!0);
1256
+ }download_screenshot(e)
1257
+ {
1258
+ const t=document.createElement('a');t.download='Snapshot.png',t.href=URL.createObjectURL(e),t.click(),t.onclick=function()
1259
+ {
1260
+ requestAnimationFrame((function()
1261
+ {
1262
+ URL.revokeObjectURL(t.href);
1263
+ })),t.removeAttribute('href');
1264
+ };
1265
+ }dispose()
1266
+ {
1267
+ this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose();
1268
+ }is_floating_point_texture_available()
1269
+ {
1270
+ const e=new A(1,1,{minFilter:h,magFilter:h,format:P,colorSpace:k,type:D,stencilBuffer:!1,depthBuffer:!1}),t=new i({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:n,depthTest:!1,depthFunc:o});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;
1271
+ }
1272
+ });class ht extends i
1273
+ {
1274
+ constructor()
1275
+ {
1276
+ 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);}'});
1277
+ }
1278
+ }class ct extends je
1279
+ {
1280
+ constructor()
1281
+ {
1282
+ super();
1283
+ }render()
1284
+ {
1285
+ lt.clear(void 0,Ye.current,!0,!0),lt.render(Ze.current,Ye.current,void 0,new ht);
1286
+ }
1287
+ }class dt
1288
+ {
1289
+ init(e)
1290
+ {
1291
+ 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);
1292
+ }on_key_down(e)
1293
+ {
1294
+ 90===e.keyCode&&e.ctrlKey&&!this.ctrlz_fired&&(this.ctrlz_pressed=!0,this.ctrlz_fired=!0),e.code&&this.press_key(e.code);
1295
+ }on_key_up(e)
1296
+ {
1297
+ this.release_key(e.code);
1298
+ }clear()
1299
+ {
1300
+ 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;
1301
+ }release_key(e)
1302
+ {
1303
+ const t=this.keys[e];t&&(t.fired=!1,t.down=!1,t.released=!0);
1304
+ }release_keys()
1305
+ {
1306
+ 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;
1307
+ }press_key(e)
1308
+ {
1309
+ const t=this.keys[e];t&&(!1===t.down&&(t.pressed=!0),t.down=!0,t.fired=!0);
1310
+ }is_key_pressed(e)
1311
+ {
1312
+ const t=this.keys[e];return!!t&&t.pressed;
1313
+ }is_key_down(e)
1314
+ {
1315
+ const t=this.keys[e];return!!t&&t.down;
1316
+ }is_key_released(e)
1317
+ {
1318
+ const t=this.keys[e];return!!t&&t.released;
1319
+ }register_key(e)
1320
+ {
1321
+ this.keys[e]={key_name:e,pressed:!1,down:!1,fired:!1},this.keys_keys=Object.keys(this.keys);
1322
+ }unregister_key(e)
1323
+ {
1324
+ delete this.keys[e];
1325
+ }dispose()
1326
+ {
1327
+ this.container.removeEventListener('keydown',this.on_key_down.bind(this),!1),this.container.removeEventListener('keyup',this.on_key_up.bind(this),!1);
1328
+ }
1329
+ }const ut=new (class
1330
+ {
1331
+ init()
1332
+ {
1333
+ 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;
1334
+ }get_os()
1335
+ {
1336
+ 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;
1337
+ }
1338
+ });const pt=new class
1339
+ {
1340
+ init()
1341
+ {
1342
+ this.target_geometry=void 0,this.target_position=new e;
1343
+ }set_target_geometry(e)
1344
+ {
1345
+ this.target_geometry=e;
1346
+ }
1347
+ };class mt
1348
+ {
1349
+ constructor(e,t)
1350
+ {
1351
+ 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 s,this.write_offset=new s,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0;
1352
+ }init(e,t,s)
1353
+ {
1354
+ this.material=new i({uniforms:this.uniforms,vertexShader:t,fragmentShader:s}),this.object_names=e;
1355
+ }add_global_uniform(e,t)
1356
+ {
1357
+ this.uniforms[e]={value:t},this.material.needsUpdate=!0;
1358
+ }set_global_uniform(e,t)
1359
+ {
1360
+ this.uniforms[e].value=t;
1361
+ }add_object_uniform_v3(e,t)
1362
+ {
1363
+ 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);
1364
+ }add_object_uniform_v4(e,t)
1365
+ {
1366
+ 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);
1367
+ }add_object_uniform_v4_float(e,t)
1368
+ {
1369
+ 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);
1370
+ }set_object_uniform_v3(e,t,s,i,r,n)
1371
+ {
1372
+ 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++;
1373
+ }set_object_uniform_v4(e,t,s,i,r,n,o)
1374
+ {
1375
+ 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++;
1376
+ }upload_texture_data(e,t)
1377
+ {
1378
+ 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--);
1379
+ }get_uniform_dirty_count()
1380
+ {
1381
+ 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;
1382
+ }__full_texture_data_upload(e,t)
1383
+ {
1384
+ t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst);
1385
+ }__partial_texture_data_upload(e,t)
1386
+ {
1387
+ 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));
1388
+ }get_mesh()
1389
+ {
1390
+ return new g(this.geometry,this.material);
1391
+ }__set_pixel_rgb(e,t,s,i,r,n)
1392
+ {
1393
+ 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);
1394
+ }__set_pixel_rgba(e,t,s,i,r,n,o)
1395
+ {
1396
+ 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);
1397
+ }__flood_data_texture_rgb(e,t)
1398
+ {
1399
+ 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++;
1400
+ }__flood_data_texture_rgba(e,t)
1401
+ {
1402
+ 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++;
1403
+ }__create_rgb_texture(e)
1404
+ {
1405
+ const t=new Uint8Array(3*e*e);return new L(t,e,e,P);
1406
+ }__create_rgba_texture(e)
1407
+ {
1408
+ const t=new Uint8Array(4*e*e);return new L(t,e,e,P);
1409
+ }__create_rgba_float_texture(e)
1410
+ {
1411
+ const t=new Float32Array(4*e*e);return new L(t,e,e,P,D);
1412
+ }__get_data_texture(e)
1413
+ {
1414
+ 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');
1415
+ }__get_object_index(e)
1416
+ {
1417
+ 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');
1418
+ }__add_data_texture(e,t,s,i)
1419
+ {
1420
+ 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];
1421
+ }dispose()
1422
+ {
1423
+ 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();
1424
+ }
1425
+ }const gt=new (class
1426
+ {
1427
+ init()
1428
+ {
1429
+ this.batches=[];
1430
+ }batch(e)
1431
+ {
1432
+ const t=[],s=fe.ceilPowerOfTwo(Math.sqrt(e.length));this.__init_uv_array(t,s);let i=0;for(let r=0;r<e.length;r++)
1433
+ {
1434
+ 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;
1435
+ }const r=new U(new Float32Array(t),2),n=ae.mergeGeometries(e);return n.setAttribute('attr_accessor_uv',r),this.batches.push(new mt(n,s)),this.batches[this.batches.length-1];
1436
+ }upload_texture_data(e)
1437
+ {
1438
+ for(let t=0;t<this.batches.length;t++)this.batches[t].upload_texture_data(e,1);
1439
+ }__init_uv_array(e,t)
1440
+ {
1441
+ for(let s=0;s<t*t*2;s++)e.push(0);
1442
+ }
1443
+ });const ft=new (class
1444
+ {
1445
+ init(e)
1446
+ {
1447
+ this.input=e,this.ui_elements=[],this._tmp_normalized_pos=new s,this.ss_scene=new m,this.ss_scene.matrixWorldAutoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new m,this.ws_scene.matrixWorldAutoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new R(-1,1,1,-1,-100,100);
1448
+ }delete_element(e)
1449
+ {
1450
+ 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();
1451
+ }add_screen_space_element(e)
1452
+ {
1453
+ this.ui_elements.push(e),this.ss_scene.add(e),e.set_screen_space_coordinate_system();
1454
+ }add_world_space_element(e)
1455
+ {
1456
+ this.ui_elements.push(e),this.ws_scene.add(e),e.set_world_space_coordinate_system();
1457
+ }update()
1458
+ {
1459
+ 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);
1460
+ }render(e)
1461
+ {
1462
+ this.ss_scene.children.length>0&&lt.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&lt.render(this.ws_scene,Ye.current);
1463
+ }clear()
1464
+ {
1465
+ this.current_clicked_element=void 0;
1466
+ }
1467
+ });class vt
1468
+ {
1469
+ constructor()
1470
+ {
1471
+ this.sphere=new j;
1472
+ }fit_points(t,s,i,r)
1473
+ {
1474
+ this.sphere.setFromPoints(t);const n=fe.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 e(0,0,-1).applyQuaternion(s),d=this.sphere.center.clone(),u=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=d.clone().add(c.clone().multiplyScalar(-1*u)),m=(new O).setFromNormalAndCoplanarPoint(a,p),g=(new O).setFromNormalAndCoplanarPoint(_,p),f=(new O).setFromNormalAndCoplanarPoint(l,p),v=(new O).setFromNormalAndCoplanarPoint(h,p);this.apply_center_correction_to_pos(p,t,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*u);for(let s=0;s<t.length;s++)
1475
+ {
1476
+ const i=new I(t[s].clone(),t[s].clone().add(w)),r=new e,n=new e,o=new e,a=new e;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 _=t[s].clone().sub(r).length(),l=t[s].clone().sub(n).length(),h=t[s].clone().sub(o).length(),c=t[s].clone().sub(a).length(),d=Math.min(_,l),u=Math.min(h,c),p=Math.min(d,u);p<x&&(x=p);
1477
+ }const b=c.clone().multiplyScalar(x);return p.clone().add(b);
1478
+ }apply_center_correction_to_pos(e,t,s,i,r,n,o)
1479
+ {
1480
+ const a=this.get_vertical_correction(t,r,i,s),_=this.get_horizontal_correction(t,n,o,s);e.add(a),e.add(_);
1481
+ }get_vertical_correction(t,s,i,r)
1482
+ {
1483
+ let n=1/0,o=1/0;const a=new e(0,1,0).applyQuaternion(r);for(let r=0;r<t.length;r++)
1484
+ {
1485
+ const _=new I(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new I(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(5e6))),h=new e,c=new e;s.intersectLine(_,h),i.intersectLine(l,c);const d=h.distanceTo(t[r]),u=c.distanceTo(t[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),d<o&&(o=d),u<n&&(n=u);
1486
+ }const _=(n-o)/2;return a.clone().multiplyScalar(-_);
1487
+ }get_horizontal_correction(t,s,i,r)
1488
+ {
1489
+ let n=1/0,o=1/0;const a=new e(1,0,0).applyQuaternion(r);for(let r=0;r<t.length;r++)
1490
+ {
1491
+ const _=new I(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new I(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(5e6))),h=new e,c=new e;s.intersectLine(_,h),i.intersectLine(l,c);const d=h.distanceTo(t[r]),u=c.distanceTo(t[r]);h.length()<1e-4&&console.log('left intersection not found',r),c.length()<1e-4&&console.log('right intersection not found',r),d<o&&(o=d),u<n&&(n=u);
1492
+ }const _=(n-o)/2;return a.clone().multiplyScalar(-_);
1493
+ }get_up_plane_normal(t,s)
1494
+ {
1495
+ const i=new e(0,-1,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(1,0,0),s)),i.applyQuaternion(t),i;
1496
+ }get_down_plane_normal(t,s)
1497
+ {
1498
+ const i=new e(0,1,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(1,0,0),-s)),i.applyQuaternion(t),i;
1499
+ }get_left_plane_normal(t,s)
1500
+ {
1501
+ const i=new e(1,0,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(0,1,0),s)),i.applyQuaternion(t),i;
1502
+ }get_right_plane_normal(t,s)
1503
+ {
1504
+ const i=new e(-1,0,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(0,1,0),-s)),i.applyQuaternion(t),i;
1505
+ }get_distance_to_fit_rect(e,t,s,i)
1506
+ {
1507
+ 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));
1508
+ }
1509
+ }class xt
1510
+ {
1511
+ constructor()
1512
+ {}fit_points(t,s,i,r)
1513
+ {
1514
+ const n=s.clone().inverse(),o=[];for(let e=0;e<t.length;e++)o.push(t[e].clone().applyQuaternion(n));const a=(new M).setFromPoints(o),_=new e;a.getSize(_);const l=this.get_distance_to_fit_rect(_.x/2,_.y/2,i,r),h=new e;return a.getCenter(h),h.applyQuaternion(s),{center:h,distance_to_center:l};
1515
+ }get_distance_to_fit_rect(e,t,s,i)
1516
+ {
1517
+ 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));
1518
+ }
1519
+ }const wt=new (class
1520
+ {
1521
+ init(t)
1522
+ {
1523
+ this.tmp_mat=new q,this.plane=new O,this.ray=new B,this.tmp_size=new e,this.tmp_unproj=new e,this.input=t;
1524
+ }get_up_dir(t)
1525
+ {
1526
+ t=t||Ye.current;const s=new e;return s.set(0,1,0),s.applyQuaternion(t.quaternion),s;
1527
+ }get_forward_dir(t)
1528
+ {
1529
+ t=t||Ye.current;const s=new e;return s.set(0,0,-1),s.applyQuaternion(t.quaternion),s;
1530
+ }get_right_dir(t)
1531
+ {
1532
+ t=t||Ye.current;const s=new e;return s.set(1,0,0),s.applyQuaternion(t.quaternion),s;
1533
+ }unproject_mouse_position(t,s)
1534
+ {
1535
+ s=s||Ye.current;const i=new e,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*t.x,o*t.y,-s.far).normalize(),i.applyQuaternion(s.quaternion);
1536
+ }get_plane_intersection(t,s,i,r)
1537
+ {
1538
+ r=r||Ye.current,i=i||this.input.NDC;const n=new e;return this.plane.setFromNormalAndCoplanarPoint(s||this.get_forward_dir(r),t),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;
1539
+ }fit_points_on_camera(t,s=1)
1540
+ {
1541
+ const i=(new j).setFromPoints(t).center,r=this.get_forward_dir(Ye.current).clone(),n=(new O).setFromNormalAndCoplanarPoint(r,i),o=fe.project_points_on_plane(t,n),a=new e;let _=(new M).setFromPoints(o);_.getCenter(a);const l=new e(0,1,0).applyQuaternion(Ye.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),d=(new q).getInverse(c);for(let e=0;e<o.length;e++)o[e].applyMatrix4(d);const u=new e;_=(new M).setFromPoints(o),_.getSize(u),u.multiplyScalar(s);const p=new e;return _.getCenter(p),{position:a,zoom:this.get_zoom_to_fit_rect(u.x/2,u.y/2)};
1542
+ }get_zoom_to_fit_rect(e,t)
1543
+ {
1544
+ const s=Ye.current.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(s)*Ye.current.aspect)/2,r=t/Math.tan(s),n=e/Math.tan(i);return Math.max(Math.abs(n),Math.abs(r));
1545
+ }get_zoom_to_fit_box(t,s)
1546
+ {
1547
+ if(s.isOrthographicCamera)
1548
+ {
1549
+ t.getSize(this.tmp_size);const e=this.tmp_size.x,s=this.tmp_size.y,i=e/s;return tt.aspect_ratio/i>1?tt.height/s:tt.width/e;
1550
+ }{const s=new e;return t.getSize(s),this.get_zoom_to_fit_rect(s.x,s.y);}
1551
+ }get_html_screen_pos(t,s)
1552
+ {
1553
+ s=s||Ye.current;const i=new e;return t.getWorldPosition(i),i.project(s),i.x=(.5*i.x+.5)*tt.width,i.y=(1-(.5*i.y+.5))*tt.height,i;
1554
+ }world_pos_to_screen(t,s)
1555
+ {
1556
+ s=s||Ye.current;const i=new e;return i.copy(t),i.project(s),i.x=(.5*i.x+.5)*tt.width,i.y=(1-(.5*i.y+.5))*tt.height,i;
1557
+ }update_projection(e)
1558
+ {
1559
+ e.left=-tt.width/2,e.right=tt.width/2,e.top=tt.height/2,e.bottom=-tt.height/2,e.aspect=tt.aspect_ratio,e.updateProjectionMatrix(!0);
1560
+ }fit_bounding_box_points(t,s,i=1)
1561
+ {
1562
+ const r=new e;r.copy(s.max).sub(s.min);const n=s.min.clone(),o=n.clone().add(new e(r.x,0,0)),a=n.clone().add(new e(0,r.y,0)),_=n.clone().add(new e(0,0,r.z)),l=n.clone().add(new e(r.x,0,r.z)),h=n.clone().add(new e(0,r.y,r.z)),c=s.max.clone(),d=n.clone().add(new e(r.x,r.y,0));return this.fit_points(t,[n,o,a,_,l,h,c,d],i);
1563
+ }fit_points(t,s,i=1)
1564
+ {
1565
+ if(t.isPerspectiveCamera)
1566
+ {
1567
+ const r=new e(0,0,-1).applyQuaternion(t.quaternion),n=r.clone().multiplyScalar(-1),o=new vt,a=tt.aspect_ratio,_=o.fit_points(s,t.quaternion,t.fov*i,a),l=(new M).setFromPoints(s),h=new e;l.getCenter(h);const c=(new O).setFromNormalAndCoplanarPoint(n,h),d=new B(_,r),u=new e;d.intersectPlane(c,u);return{zoom:_.distanceTo(u),reference_position:u,camera_position:_};
1568
+ }{const r=(new xt).fit_points(s,this.reference_rotation,t.fov*i,tt.aspect_ratio);this.reference_position.copy(r.center),this.reference_zoom=r.distance_to_center;const n=new e(0,0,1).applyQuaternion(t.quaternion);return{zoom:r.distance_to_center,reference_position:r.center,camera_position:n.multiplyScalar(r.distance_to_center)};}
1569
+ }
1570
+ });const bt=new (class
1571
+ {
1572
+ constructor()
1573
+ {}init(e)
1574
+ {
1575
+ Ye.init(),wt.init(e),Ge.init(),We.init(),ze.init(),gt.init(),ut.init(),pe.init(),pt.init(),Fe.init(),Ze.init(),tt.init(),Ce.init(),ft.init(e),rt.init();
1576
+ }dispose(e)
1577
+ {
1578
+ lt.dispose(),Ze.dispose(),e.dispose();
1579
+ }
1580
+ });var yt='#define GLSLIFY 1\nvarying vec2 vUv;varying vec4 vRay;uniform mat4 _InverseProjMatrix;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vRay=_InverseProjMatrix*vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}';class Tt extends qe
1581
+ {
1582
+ constructor()
1583
+ {
1584
+ super('#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}',yt),this.uniforms._InverseProjMatrix={value:new 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()};
1585
+ }__get_sample_kernel()
1586
+ {
1587
+ const t=[];for(let s=0;s<64;s++)
1588
+ {
1589
+ const i=new e(2*Math.random()-1,2*Math.random()-1,Math.random());i.normalize();let r=s/64;r=fe.lerp(.1,1,r*r),i.multiplyScalar(r),t.push(i);
1590
+ }return t;
1591
+ }__get_rotation_kernel()
1592
+ {
1593
+ 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 L(e,4,4,P);return t.wrapS=V,t.wrapT=V,t.needsUpdate=!0,t;
1594
+ }
1595
+ }class St extends qe
1596
+ {
1597
+ constructor()
1598
+ {
1599
+ 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};
1600
+ }
1601
+ }class Mt extends qe
1602
+ {
1603
+ constructor()
1604
+ {
1605
+ super('#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}',yt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new q};
1606
+ }
1607
+ }class zt extends qe
1608
+ {
1609
+ constructor()
1610
+ {
1611
+ 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 s};
1612
+ }
1613
+ }class Ft
1614
+ {
1615
+ constructor(e)
1616
+ {
1617
+ this.RT1=new A(1,1),this.RT2=new A(1,1),this.box_blur_mat=new zt;
1618
+ }blur(e)
1619
+ {
1620
+ 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),lt.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),lt.blit(this.RT1,e,this.box_blur_mat);
1621
+ }
1622
+ }class Rt extends je
1623
+ {
1624
+ constructor()
1625
+ {
1626
+ super(),this.ssao_mat=new Tt,this.ssao_compose_mat=new St,this.debug_normals=new Mt,this.ssaa=We.use_ssaa?2:1,this.main_RT=new A(tt.width*this.ssaa,tt.height*this.ssaa),this.SSAO_RT=new A(tt.width,tt.height),this.blurrer=new Ft,lt.generateDepthNormalTexture=!0;
1627
+ }render()
1628
+ {
1629
+ this.__check_RT_size(),lt.clear(this.main_RT,Ye.current,!0,!1),lt.render(Ze.current,Ye.current,this.main_RT),this.__update_uniforms(),lt.blit(lt.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),lt.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,lt.blit(this.main_RT,void 0,this.ssao_compose_mat);
1630
+ }__update_uniforms()
1631
+ {
1632
+ this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(Ye.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(Ye.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=Ye.current.far;
1633
+ }__check_RT_size()
1634
+ {
1635
+ this.main_RT.width===tt.width*this.ssaa&&this.main_RT.height===tt.height*this.ssaa||(this.main_RT.setSize(tt.width*this.ssaa,tt.height*this.ssaa),this.SSAO_RT.setSize(tt.width,tt.height));
1636
+ }
1637
+ }class At extends je
1638
+ {
1639
+ constructor()
1640
+ {
1641
+ super();
1642
+ }render()
1643
+ {
1644
+ lt.clear(void 0,Ye.current,!0,!0),Ze.current.on_pre_render&&Ze.current.on_pre_render(),Ze.current.render?Ze.current.render():lt.render(Ze.current,Ye.current),Ze.current.on_post_render&&Ze.current.on_post_render();
1645
+ }
1646
+ }class Ct extends je
1647
+ {
1648
+ constructor()
1649
+ {
1650
+ super();
1651
+ }render()
1652
+ {
1653
+ Ze.current.on_pre_render&&Ze.current.on_pre_render(),Ze.current.render?Ze.current.render():lt.render(Ze.current,Ye.current,lt._renderer.getRenderTarget()),this.render_spectator_camera(),Ze.current.on_post_render&&Ze.current.on_post_render();
1654
+ }render_spectator_camera()
1655
+ {
1656
+ const e=Ye.spectator;if(e&&lt._renderer.xr.isPresenting)
1657
+ {
1658
+ const t=lt._renderer.xr.getCamera(Ye.current);e.projectionMatrix.copy(Ye.current.projectionMatrix),e.position.copy(t.position),e.quaternion.copy(t.quaternion);const s=lt._renderer.getRenderTarget();lt._renderer.xr.isPresenting=!1,lt._renderer.setRenderTarget(null),lt._renderer.render(Ze.current,e),lt._renderer.setRenderTarget(s),lt._renderer.xr.isPresenting=!0;
1659
+ }
1660
+ }
1661
+ }class Pt extends qe
1662
+ {
1663
+ constructor(e)
1664
+ {
1665
+ 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 s(.5,.5)},this.uniforms.direction={value:new s(.5,.5)};
1666
+ }set_size(e,t)
1667
+ {
1668
+ this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t;
1669
+ }set_direction(e,t)
1670
+ {
1671
+ this.uniforms.direction.value.set(e,t);
1672
+ }
1673
+ }class kt extends qe
1674
+ {
1675
+ constructor(e)
1676
+ {
1677
+ 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};
1678
+ }
1679
+ }class Dt
1680
+ {
1681
+ constructor(e=5)
1682
+ {
1683
+ this.current_width=1,this.current_height=1,this.separableBlurMaterials=[],this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=e,this.kernelSizeArray=[3,5,7,9,11],this.rt_pars={minFilter:Y,magFilter:Y,format:P},this.renderTargetBright=new A(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new kt;
1684
+ }blur(e,t)
1685
+ {
1686
+ this.resize_RT(e.width,e.height),t?lt.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):lt.blit(e,this.renderTargetBright);let s=this.renderTargetBright;for(let e=0;e<this.nMips;e++)
1687
+ {
1688
+ const t=this.separableBlurMaterials[e];t.set_direction(1,0),lt.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),lt.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),s=this.renderTargetsVertical[e];
1689
+ }
1690
+ }get_blurred_texture()
1691
+ {
1692
+ return this.renderTargetsHorizontal[0].texture;
1693
+ }get_blurred_RT()
1694
+ {
1695
+ return this.renderTargetsHorizontal[0];
1696
+ }init_RT()
1697
+ {
1698
+ this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(let e=0;e<this.nMips;e++)
1699
+ {
1700
+ const e=new A(1,1,this.rt_pars),t=new A(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e),this.renderTargetsVertical.push(t);
1701
+ }
1702
+ }resize_RT(e,t)
1703
+ {
1704
+ 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);
1705
+ }init_materials(e,t)
1706
+ {
1707
+ this.dispose_materials();for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(new Pt(this.kernelSizeArray[e]));
1708
+ }dispose_materials()
1709
+ {
1710
+ for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0;
1711
+ }dispose_RT()
1712
+ {
1713
+ 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;
1714
+ }
1715
+ }class Lt extends je
1716
+ {
1717
+ constructor()
1718
+ {
1719
+ 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 Be;
1720
+ }on_enter()
1721
+ {
1722
+ this.blurrer=new Dt,this.main_RT=new A(tt.width,tt.height),this.blur_RT=new A(tt.width,tt.height),this.bloom_compose_mat=new Ve(5),this.blurrer=new Dt(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);
1723
+ }set_bloom_strength(e)
1724
+ {
1725
+ this.bloom_compose_mat.set_bloom_strength(e);
1726
+ }set_bloom_radius(e)
1727
+ {
1728
+ this.bloom_compose_mat.set_bloom_radius(e);
1729
+ }set_tint_color_0(e)
1730
+ {
1731
+ this.bloom_compose_mat.set_tint_color_0(e);
1732
+ }set_tint_color_1(e)
1733
+ {
1734
+ this.bloom_compose_mat.set_tint_color_1(e);
1735
+ }set_tint_color_2(e)
1736
+ {
1737
+ this.bloom_compose_mat.set_tint_color_2(e);
1738
+ }set_tint_color_3(e)
1739
+ {
1740
+ this.bloom_compose_mat.set_tint_color_3(e);
1741
+ }set_tint_color_4(e)
1742
+ {
1743
+ this.bloom_compose_mat.set_tint_color_4(e);
1744
+ }render()
1745
+ {
1746
+ this.__check_RT_size(),lt.clear(this.main_RT,Ye.current,!0,!1),lt.render(Ze.current,Ye.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),lt.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),lt.blit(this.main_RT,void 0,this.add_mat);
1747
+ }__check_RT_size()
1748
+ {
1749
+ this.main_RT.width===tt.width&&this.main_RT.height===tt.height||(this.main_RT.setSize(tt.width,tt.height),this.blur_RT.setSize(tt.width,tt.height));
1750
+ }
1751
+ }class Ut extends R
1752
+ {
1753
+ constructor(e,t,s,i,n,o)
1754
+ {
1755
+ super(e,t,s,i,n,o),this.clear_color=new r('#000000'),this.clear_alpha=1;
1756
+ }copy(e)
1757
+ {
1758
+ return super.copy(e),this.clear_color.copy(e.clear_color),this.clear_alpha=e.clear_alpha,this;
1759
+ }
1760
+ }const jt=new (class
1761
+ {
1762
+ constructor()
1763
+ {
1764
+ this.components=[],this.enabled_components=new Set;
1765
+ }update()
1766
+ {
1767
+ this.__set_components_opacities();for(const e of this.enabled_components)e.update(De.transition_handler.current_state_data);
1768
+ }register_component(e)
1769
+ {
1770
+ this.components.push(e);
1771
+ }enable_component(e)
1772
+ {
1773
+ this.enabled_components.add(e);
1774
+ }disable_component(e)
1775
+ {
1776
+ this.enabled_components.delete(e);
1777
+ }get_component_by_name(e)
1778
+ {
1779
+ console.warn('DEPRECATED. Use ViewComponentManager.get instead'),this.get(e);
1780
+ }get(e)
1781
+ {
1782
+ 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);
1783
+ }__set_components_opacities()
1784
+ {
1785
+ for(let e=0;e<this.components.length;e++)this.components[e].set_opacity(De.transition_handler.current_state_data);
1786
+ }
1787
+ });class Ot
1788
+ {
1789
+ constructor(e,t,s)
1790
+ {
1791
+ e=e||new Ue,this.target_application=e,this.graphics=t,this.input=s,this.is_running=!1,this.frames_passed=0,this.time_accumulator=0;
1792
+ }update()
1793
+ {
1794
+ if(this.is_running)
1795
+ {
1796
+ for(Ce.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.input.update(),this.time_accumulator+=Ce.delta_time,this.target_application.before_update(),De.before_update();this.time_accumulator>Ce.fixed_delta_time;)this.target_application.fixed_update(),De.fixed_update(),this.time_accumulator-=Ce.fixed_delta_time;Ce.__set_frame_interpolation(this.time_accumulator/Ce.fixed_delta_time),this.target_application.update(),De.update(),jt.update(),this.target_application.on_pre_render(),this.graphics.update(),ft.update(),ft.render(this.graphics),this.target_application.on_post_render(),rt.render(this.graphics),this.target_application.on_frame_end(),this.frames_passed++,this.input.clear(),ft.clear(),rt.clear();
1797
+ }
1798
+ }start()
1799
+ {
1800
+ this.is_running||(0===this.frames_passed&&this.target_application.on_enter(),this.is_running=!0,this.graphics._renderer.setAnimationLoop(this.update.bind(this)));
1801
+ }stop()
1802
+ {
1803
+ !1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(),this.graphics._renderer.setAnimationLoop(null));
1804
+ }set_state(e)
1805
+ {
1806
+ this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this);
1807
+ }dispose()
1808
+ {
1809
+ this.stop(),this.frames_passed=0;
1810
+ }
1811
+ }const It=new (class
1812
+ {
1813
+ init()
1814
+ {
1815
+ console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.init();
1816
+ }update_position(e,t)
1817
+ {
1818
+ console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.update_position(e,t);
1819
+ }update()
1820
+ {
1821
+ console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.update();
1822
+ }update_size(e,t)
1823
+ {
1824
+ console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.update_size(e,t);
1825
+ }apply_pixel_density_v2(e)
1826
+ {
1827
+ return console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.apply_pixel_density_v2(e);
1828
+ }apply_pixel_density(e)
1829
+ {
1830
+ return console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.apply_pixel_density(e);
1831
+ }get_pixel_size()
1832
+ {
1833
+ return console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.get_pixel_size();
1834
+ }get aspect_ratio()
1835
+ {
1836
+ return console.warn('Screen Singleton is deprecated. Please use OScreen.'),tt.aspect_ratio;
1837
+ }
1838
+ });class Nt extends Ee
1839
+ {
1840
+ constructor()
1841
+ {
1842
+ super(),this.text_margin=new s(2,0);
1843
+ }__draw(e,t,s,i)
1844
+ {
1845
+ 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);
1846
+ }
1847
+ }class qt
1848
+ {
1849
+ constructor({name:e,container:t})
1850
+ {
1851
+ this.name=e,this.container=t,this.hidden=!0,jt.register_component(this);
1852
+ }start()
1853
+ {}on_enter()
1854
+ {
1855
+ this.container.classList.remove('hidden'),jt.enable_component(this),this.hidden=!1;
1856
+ }update()
1857
+ {}on_exit()
1858
+ {
1859
+ this.container.classList.add('hidden'),jt.disable_component(this),this.hidden=!0;
1860
+ }set_opacity(e)
1861
+ {
1862
+ this.container.style.opacity=e[`${this.name}_opacity`],this.toggle_hidden();
1863
+ }toggle_hidden()
1864
+ {
1865
+ this.container.style.opacity>.001?this.hidden&&this.on_enter():this.hidden||this.on_exit();
1866
+ }load_html_images()
1867
+ {
1868
+ Re.load_images(this.container);
1869
+ }load_html_videos()
1870
+ {
1871
+ Re.load_videos(this.container);
1872
+ }
1873
+ }class Bt extends g
1874
+ {
1875
+ constructor(e,t,s,i)
1876
+ {
1877
+ e=e||1,t=t||1,s=s||'#FF0000',i=i||new v({color:s});const r=new T(e,t);r.rotateX(-1.57),super(r,i);
1878
+ }
1879
+ }class Vt extends g
1880
+ {
1881
+ constructor(e,t,s,i)
1882
+ {
1883
+ e=e||1,t=t||1,s=s||'#FF0000',i=i||new v({color:s});super(new T(e,t),i);
1884
+ }
1885
+ }class Yt
1886
+ {
1887
+ constructor()
1888
+ {}static merge_from_to(e,t)
1889
+ {
1890
+ t.push.apply(t,e);
1891
+ }static expand_vec3_array(e,t)
1892
+ {
1893
+ const s=t-e.length;for(let t=0;t<s;t++)e.push(e[t].clone());
1894
+ }static remove_elem(e,t)
1895
+ {
1896
+ const s=e.indexOf(t);s>-1&&e.splice(s,1);
1897
+ }static get_closest_point(e,t)
1898
+ {
1899
+ 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;
1900
+ }static object_values_to_array(e)
1901
+ {
1902
+ const t=Object.keys(e),s=[];for(let i=0;i<t.length;i++)s.push(e[t[i]]);return s;
1903
+ }
1904
+ }class Gt
1905
+ {
1906
+ constructor()
1907
+ {
1908
+ this.sphere=new j;
1909
+ }fit_points(t,s,i,r)
1910
+ {
1911
+ this.sphere.setFromPoints(t);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 e(0,0,-1).applyQuaternion(s),d=this.sphere.center.clone(),u=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=d.clone().add(c.clone().multiplyScalar(-1*u)),m=(new O).setFromNormalAndCoplanarPoint(a,p),g=(new O).setFromNormalAndCoplanarPoint(_,p),f=(new O).setFromNormalAndCoplanarPoint(l,p),v=(new O).setFromNormalAndCoplanarPoint(h,p);this.apply_center_correction_to_pos(p,t,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*u);for(let s=0;s<t.length;s++)
1912
+ {
1913
+ const i=new I(t[s].clone(),t[s].clone().add(w)),r=new e,n=new e,o=new e,a=new e;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 _=t[s].clone().sub(r).length(),l=t[s].clone().sub(n).length(),h=t[s].clone().sub(o).length(),c=t[s].clone().sub(a).length(),d=Math.min(_,l),u=Math.min(h,c),p=Math.min(d,u);p<x&&(x=p);
1914
+ }const b=c.clone().multiplyScalar(x);return p.clone().add(b);
1915
+ }apply_center_correction_to_pos(e,t,s,i,r,n,o)
1916
+ {
1917
+ const a=this.get_vertical_correction(t,r,i,s),_=this.get_hozirontal_correction(t,n,o,s);e.add(a),e.add(_);
1918
+ }get_vertical_correction(t,s,i,r)
1919
+ {
1920
+ let n,o,a=1/0,_=1/0;const l=new e(0,1,0).applyQuaternion(r);for(let r=0;r<t.length;r++)
1921
+ {
1922
+ const h=new I(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new I(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(5e6))),d=new e,u=new e;s.intersectLine(h,d),i.intersectLine(c,u);const p=d.distanceTo(t[r]),m=u.distanceTo(t[r]);u.length()<1e-4&&console.log('vertical up intersection not found',r),d.length()<1e-4&&console.log('vertical down intersection not found',r),p<_&&(_=p,o=t[r]),m<a&&(a=m,n=t[r]);
1923
+ }console.log(n,o);const h=(a-_)/2;return l.clone().multiplyScalar(-h);
1924
+ }get_hozirontal_correction(t,s,i,r)
1925
+ {
1926
+ let n,o,a=1/0,_=1/0;const l=new e(1,0,0).applyQuaternion(r);for(let r=0;r<t.length;r++)
1927
+ {
1928
+ const h=new I(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new I(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(5e6))),d=new e,u=new e;s.intersectLine(h,d),i.intersectLine(c,u);const p=d.distanceTo(t[r]),m=u.distanceTo(t[r]);d.length()<1e-4&&console.log('left intersection not found',r),u.length()<1e-4&&console.log('right intersection not found',r),p<_&&(_=p,o=t[r]),m<a&&(a=m,n=t[r]);
1929
+ }const h=(a-_)/2;return console.log(n,o),l.clone().multiplyScalar(-h);
1930
+ }get_up_plane_normal(t,s)
1931
+ {
1932
+ const i=new e(0,-1,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(1,0,0),s)),i.applyQuaternion(t),i;
1933
+ }get_down_plane_normal(t,s)
1934
+ {
1935
+ const i=new e(0,1,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(1,0,0),-s)),i.applyQuaternion(t),i;
1936
+ }get_left_plane_normal(t,s)
1937
+ {
1938
+ const i=new e(1,0,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(0,1,0),s)),i.applyQuaternion(t),i;
1939
+ }get_right_plane_normal(t,s)
1940
+ {
1941
+ const i=new e(-1,0,0);return i.applyQuaternion((new N).setFromAxisAngle(new e(0,1,0),-s)),i.applyQuaternion(t),i;
1942
+ }get_distance_to_fit_rect(e,t,s,i)
1943
+ {
1944
+ 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));
1945
+ }
1946
+ }class Et
1947
+ {
1948
+ static convert_to_non_indexed_geometry(e)
1949
+ {
1950
+ 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 u;return r.setAttribute('position',new U(new Float32Array(i),3)),Et.add_barycentric_attribute(r),r;
1951
+ }static add_barycentric_attribute(e)
1952
+ {
1953
+ 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 U(new Float32Array(t),3));
1954
+ }
1955
+ }class Wt
1956
+ {
1957
+ constructor()
1958
+ {}static get_image_data(e)
1959
+ {
1960
+ 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);
1961
+ }static get_pixel(e,t,s)
1962
+ {
1963
+ const i=4*(t+e.width*s),r=e.data;return new S(r[i+0],r[i+1],r[i+2],r[i+3]);
1964
+ }
1965
+ }const Xt=new (class
1966
+ {
1967
+ constructor()
1968
+ {}sample(t,i)
1969
+ {
1970
+ const r=[];let n=99999999;const o=t.getAttribute('position'),a=t.getAttribute('normal'),_=t.getAttribute('tangent'),l=t.getAttribute('uv'),h=t.index,c=[];for(let t=0;t<h.count;t+=3)
1971
+ {
1972
+ const i=h.array[t+0],d=h.array[t+1],u=h.array[t+2],p=new e;p.x=o.getX(i),p.y=o.getY(i),p.z=o.getZ(i);const m=new e;m.x=o.getX(d),m.y=o.getY(d),m.z=o.getZ(d);const g=new e;g.x=o.getX(u),g.y=o.getY(u),g.z=o.getZ(u);const f={a:p,b:m,c:g};if(a)
1973
+ {
1974
+ const t=new e;t.x=a.getX(i),t.y=a.getY(i),t.z=a.getZ(i);const s=new e;s.x=a.getX(d),s.y=a.getY(d),s.z=a.getZ(d);const r=new e;r.x=a.getX(u),r.y=a.getY(u),r.z=a.getZ(u);const n=t.clone().add(s).add(r).normalize();f.normal=n;
1975
+ }if(_)
1976
+ {
1977
+ const t=new e;t.x=_.getX(i),t.y=_.getY(i),t.z=_.getZ(i);const s=new e;s.x=_.getX(d),s.y=_.getY(d),s.z=_.getZ(d);const r=new e;r.x=_.getX(u),r.y=_.getY(u),r.z=_.getZ(u);const n=t.clone().add(s).add(r).normalize();f.tangent=n;
1978
+ }if(l)
1979
+ {
1980
+ const e=new s;e.x=l.getX(i),e.y=l.getY(i);const t=new s;t.x=l.getX(d),t.y=l.getY(d);const r=new s;r.x=l.getX(u),r.y=l.getY(u),f.uv_a=e,f.uv_b=t,f.uv_c=r;
1981
+ }c.push(f);const v=this.get_face_area(f);n=Math.min(v,n),r.push(v);
1982
+ }const d=this.get_uniform_face_distribution(r,n,c),u=this.select_random_faces(d,i);return this.sample_data_from_faces(u);
1983
+ }sample_data_from_faces(e)
1984
+ {
1985
+ const t=[],s=[],i=[],r=[];for(let n=0;n<e.length;n++)
1986
+ {
1987
+ 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());
1988
+ }return{points:t,normals:s,tangents:i,uvs:r};
1989
+ }select_random_faces(e,t)
1990
+ {
1991
+ const s=[];for(let i=0;i<t;i++)
1992
+ {
1993
+ const t=e[Math.floor(Math.random()*e.length)];s.push(t);
1994
+ }return s;
1995
+ }get_uniform_face_distribution(e,t,s)
1996
+ {
1997
+ const i=[];for(let r=0;r<e.length;r++)
1998
+ {
1999
+ e[r]/=t;const n=Math.floor(Math.round(e[r]));for(let e=0;e<n;e++)i.push(s[r]);
2000
+ }return i;
2001
+ }get_face_area(e)
2002
+ {
2003
+ const t=e.b.clone().sub(e.a),s=e.c.clone().sub(e.a);return t.cross(s).length()/2;
2004
+ }sample_point_in_face(e,t,s,i,r)
2005
+ {
2006
+ 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));
2007
+ }
2008
+ });const Qt=new (class
2009
+ {
2010
+ get_mesh(e,t)
2011
+ {
2012
+ e.traverse((e=>
2013
+ {
2014
+ e instanceof g&&(e.geometry&&(e.geometry=(new u).fromGeometry(e.geometry)),t(e));
2015
+ }));
2016
+ }get_geometries(e)
2017
+ {
2018
+ const t=[];return this.get_mesh(e,(e=>
2019
+ {
2020
+ t.push(e.geometry);
2021
+ })),t;
2022
+ }assign_material(e,t,s)
2023
+ {
2024
+ e.traverse((e=>
2025
+ {
2026
+ e instanceof g&&(void 0===s||e.name===s)&&(e.material=t);
2027
+ }));
2028
+ }clone_animated_gltf(e)
2029
+ {
2030
+ const t={animations:e.animations,scene:e.scene.clone(!0)},s={};e.scene.traverse((e=>
2031
+ {
2032
+ e.isSkinnedMesh&&(s[e.name]=e);
2033
+ }));const i={},r={};t.scene.traverse((e=>
2034
+ {
2035
+ e.isBone&&(i[e.name]=e),e.isSkinnedMesh&&(r[e.name]=e);
2036
+ }));for(const e in s)
2037
+ {
2038
+ const t=s[e].skeleton,n=r[e],o=[];for(let e=0;e<t.bones.length;++e)
2039
+ {
2040
+ const s=i[t.bones[e].name];o.push(s);
2041
+ }n.bind(new G(o,t.boneInverses),n.matrixWorld);
2042
+ }return t;
2043
+ }set_shadow_config(e,t,s)
2044
+ {
2045
+ e.traverse((e=>
2046
+ {
2047
+ e instanceof g&&(e.castShadow=t,e.receiveShadow=s);
2048
+ }));
2049
+ }__find_object(e,t,s)
2050
+ {
2051
+ e.traverse((e=>
2052
+ {
2053
+ e.name===t&&s(e);
2054
+ }));
2055
+ }get_object(e,t)
2056
+ {
2057
+ let s;return e.traverse((e=>
2058
+ {
2059
+ e.name===t&&(s=e);
2060
+ })),s;
2061
+ }get_object_by_type(e,t)
2062
+ {
2063
+ let s;return e.traverse((e=>
2064
+ {
2065
+ e.constructor.name===t&&(s=e);
2066
+ })),s;
2067
+ }
2068
+ });class Ht
2069
+ {
2070
+ static is_object(e)
2071
+ {
2072
+ return e&&'object'==typeof e&&!Array.isArray(e);
2073
+ }static merge_deep(e,...t)
2074
+ {
2075
+ if(!t.length)return e;const s=t.shift();if(Ht.is_object(e)&&Ht.is_object(s))for(const t in s)Ht.is_object(s[t])?(e[t]||Object.assign(e,{[t]:{}}),Ht.merge_deep(e[t],s[t])):Object.assign(e,{[t]:s[t]});return Ht.merge_deep(e,...t);
2076
+ }static xml_to_json(e)
2077
+ {
2078
+ let t={};if(1===e.nodeType)
2079
+ {
2080
+ if(e.attributes.length>0)
2081
+ {
2082
+ t['@attributes']={};for(let s=0;s<e.attributes.length;s++)
2083
+ {
2084
+ const i=e.attributes.item(s);t['@attributes'][i.nodeName]=i.nodeValue;
2085
+ }
2086
+ }
2087
+ }
2088
+ else 3===e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(let s=0;s<e.childNodes.length;s++)
2089
+ {
2090
+ const i=e.childNodes.item(s),r=i.nodeName;if(void 0===t[r])t[r]=this.xml_to_json(i);else
2091
+ {
2092
+ if(void 0===t[r].push)
2093
+ {
2094
+ const e=t[r];t[r]=[],t[r].push(e);
2095
+ }t[r].push(this.xml_to_json(i));
2096
+ }
2097
+ }return t;
2098
+ }
2099
+ }class $t
2100
+ {
2101
+ constructor()
2102
+ {}static get_random_color()
2103
+ {
2104
+ 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++)
2105
+ {
2106
+ t+=e[Math.floor(Math.random()*e.length)];
2107
+ }return t;
2108
+ }static capitalize(e)
2109
+ {
2110
+ 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(' ');
2111
+ }static capitalize_first_letter(e)
2112
+ {
2113
+ return e.charAt(0).toUpperCase()+e.slice(1);
2114
+ }static snake_to_camelcase(e)
2115
+ {
2116
+ return e.toLowerCase().replace(/[-_][a-z0-9]/g,(e=>e.slice(-1).toUpperCase()));
2117
+ }
2118
+ }class Zt
2119
+ {
2120
+ constructor()
2121
+ {}time_str_to_ms(e)
2122
+ {
2123
+ 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;
2124
+ }
2125
+ }class Jt extends g
2126
+ {
2127
+ constructor()
2128
+ {
2129
+ const e=new i({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}),t=new T(100,100,100,100);super(Et.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57;
2130
+ }
2131
+ }class Kt extends g
2132
+ {
2133
+ constructor(e)
2134
+ {
2135
+ const t=new u;t.setAttribute('position',new U(new Float32Array([]),3)),t.setAttribute('next_position',new U(new Float32Array([]),3)),t.setAttribute('previous_position',new U(new Float32Array([]),3)),t.setAttribute('orientation',new U(new Float32Array([]),1)),t.setAttribute('coverage',new U(new Float32Array([]),1));super(t,new i({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}})),e&&this.setup(e);
2136
+ }setup(e)
2137
+ {
2138
+ const t=[],s=[],i=[],r=[],n=[];let o=0;for(let a=0;a<e.length;a++)
2139
+ {
2140
+ 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(_));
2141
+ }const a=new Float32Array(t),_=new Float32Array(s),l=new Float32Array(i),h=new Float32Array(r),c=new Float32Array(n),d=[];for(let e=0;e<(a.length/3-2)/2;e++)
2142
+ {
2143
+ const t=2*e+1;d.push(t),d.push(t+1),d.push(t-1),d.push(t),d.push(t+2),d.push(t+1);
2144
+ }this.geometry.setIndex(d),this.geometry.getAttribute('position').copy(new U(a,3)),this.geometry.getAttribute('next_position').copy(new U(_,3)),this.geometry.getAttribute('previous_position').copy(new U(l,3)),this.geometry.getAttribute('orientation').copy(new U(h,1)),this.geometry.getAttribute('coverage').copy(new U(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;
2145
+ }set thickness(e)
2146
+ {
2147
+ this.material.uniforms._Thickness.value=e;
2148
+ }get thickness()
2149
+ {
2150
+ return this.material.uniforms._Thickness.value;
2151
+ }__get_previous_position(e,t)
2152
+ {
2153
+ return 0===t?e[1].clone().sub(e[0]).multiplyScalar(-1).add(e[0]):e[t-1];
2154
+ }__get_next_position(e,t)
2155
+ {
2156
+ 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];
2157
+ }update()
2158
+ {}distance()
2159
+ {
2160
+ return this.accumulated_length;
2161
+ }total_length()
2162
+ {
2163
+ return this.accumulated_length;
2164
+ }dispose()
2165
+ {
2166
+ this.geometry.dispose(),this.material.dispose(),this.parent&&this.parent.remove(this);
2167
+ }set color(e)
2168
+ {
2169
+ this.material.uniforms._Color.value.set(e);
2170
+ }get color()
2171
+ {
2172
+ return this.material.uniforms._Color.value;
2173
+ }copy_color(e)
2174
+ {
2175
+ this.material.uniforms._Color.value.copy(e);
2176
+ }
2177
+ }class es extends g
2178
+ {
2179
+ constructor(t,r)
2180
+ {
2181
+ r=r||new s(0,0);const n=new i({uniforms:{_MainTex:{value:t},_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:E}),o=new T(1,1,1);o.translate(-r.x/2,-r.y/2,0);const a=t.image.width/t.image.height;o.scale(a,1,1),super(o,n),this.current_scale=a,this.geometry.computeBoundingBox(),this.tmp_bb_size=new e,this.geometry.boundingBox.getSize(this.tmp_bb_size);
2182
+ }update_texture()
2183
+ {
2184
+ 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);
2185
+ }get size()
2186
+ {
2187
+ return this.tmp_bb_size.clone().multiplyScalar(this.scale.x);
2188
+ }set size(e)
2189
+ {
2190
+ this.scale.set(e,e,e),this.material.uniforms._Scale.value=e;
2191
+ }set screen_aligned(e)
2192
+ {
2193
+ this.material.uniforms._ScreenAligned.value=!0===e?1:0;
2194
+ }get screen_aligned()
2195
+ {
2196
+ return 1===this.material.uniforms._ScreenAligned.value;
2197
+ }set opacity(e)
2198
+ {
2199
+ this.material.uniforms._Opacity.value=e;
2200
+ }get opacity()
2201
+ {
2202
+ return this.material.uniforms._Opacity.value;
2203
+ }dispose()
2204
+ {
2205
+ this.geometry.dispose(),this.parent.remove(this),this.material.uniforms._MainTex.value.dispose(),this.material.dispose();
2206
+ }
2207
+ }class ts extends es
2208
+ {
2209
+ constructor(e,t,s,i,r)
2210
+ {
2211
+ const n=new Nt(r),o={font:t,font_color:s||'#000000'},a=n.draw_on_texture(e,o);a.minFilter=W,a.minFilter=Y,a.needsUpdate=!0,super(a,i),this.simple_text_drawer=n,this.canvas_texture=a,this.draw_settings=o;
2212
+ }set text(e)
2213
+ {
2214
+ this.simple_text_drawer.draw_canvas(e,this.draw_settings),this.update_texture();
2215
+ }get text()
2216
+ {
2217
+ return'not implemented';
2218
+ }
2219
+ }class ss extends Ne
2220
+ {
2221
+ constructor(t=1)
2222
+ {
2223
+ 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 s(tt.width,tt.height)},_TextureSize:{value:new s},_PixelOffset:{value:new s(0,0)},_NDC:{value:new e},_PivotPoint:{value:new s},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1;
2224
+ }
2225
+ }class is
2226
+ {
2227
+ constructor()
2228
+ {
2229
+ this.tmp_vec=new s;
2230
+ }get_pos_NDC(e)
2231
+ {
2232
+ return this.tmp_vec.set(e.x,e.y);
2233
+ }
2234
+ }class rs
2235
+ {
2236
+ constructor()
2237
+ {
2238
+ this.tmp_vec3=new e,this.tmp_vec2=new s;
2239
+ }get_pos_NDC(e)
2240
+ {
2241
+ return this.tmp_vec3.copy(e),this.tmp_vec3.project(Ye.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y);
2242
+ }
2243
+ }class ns
2244
+ {
2245
+ constructor()
2246
+ {}update(e,t)
2247
+ {}on_enter(e)
2248
+ {}on_exit(e)
2249
+ {}
2250
+ }class os extends ns
2251
+ {
2252
+ constructor()
2253
+ {
2254
+ super();
2255
+ }update(e,t)
2256
+ {
2257
+ e.is_mouse_over(t)&&e.set_state(e._on_enter_state);
2258
+ }
2259
+ }class as extends ns
2260
+ {
2261
+ constructor()
2262
+ {
2263
+ super();
2264
+ }on_enter(e)
2265
+ {
2266
+ e.on_mouse_enter();
2267
+ }update(e,t)
2268
+ {
2269
+ e.is_mouse_over(t)?e.set_state(e._on_hover_state):e.set_state(e._on_exit_state);
2270
+ }
2271
+ }class _s extends ns
2272
+ {
2273
+ constructor()
2274
+ {
2275
+ super();
2276
+ }on_enter(e)
2277
+ {
2278
+ e.on_mouse_exit(),e.set_state(e._on_idle_state);
2279
+ }
2280
+ }class ls extends ns
2281
+ {
2282
+ constructor()
2283
+ {
2284
+ super();
2285
+ }on_enter(e)
2286
+ {
2287
+ this.__trigger_on_hover(e);
2288
+ }update(e,t)
2289
+ {
2290
+ e.is_mouse_over(t)?this.__trigger_on_hover(e):e.set_state(e._on_exit_state);
2291
+ }__trigger_on_hover(e)
2292
+ {
2293
+ e.on_mouse_hover();
2294
+ }
2295
+ }class hs extends g
2296
+ {
2297
+ constructor(t,i)
2298
+ {
2299
+ super(new T(1,1),new ss),this.is_clickable=!1,this.position_strategy=new rs,this.current_state=new os,this._position=new e,this._on_idle_state=new os,this._on_enter_state=new as,this._on_exit_state=new _s,this._on_hover_state=new ls,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new s,this.cached_NDC_position=new s,this.screen_pos_tmp=new s,this.texture_size=new s(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new s;
2300
+ }set_render_order(e)
2301
+ {
2302
+ this.renderOrder=e;
2303
+ }get pivot_point()
2304
+ {
2305
+ return this.material.uniforms._PivotPoint.value;
2306
+ }set_pixel_offset(e)
2307
+ {
2308
+ this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e);
2309
+ }set_state(e)
2310
+ {
2311
+ this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this);
2312
+ }get position()
2313
+ {
2314
+ return this._position;
2315
+ }set use_depth(e)
2316
+ {
2317
+ this.material.depthTest=e;
2318
+ }get use_depth()
2319
+ {
2320
+ return this.material.depthTest;
2321
+ }set depth_offset(e)
2322
+ {
2323
+ this.material.uniforms._DepthOffset.value=e;
2324
+ }get depth_offset()
2325
+ {
2326
+ return this.material.uniforms._DepthOffset.value;
2327
+ }clear_state()
2328
+ {
2329
+ this.visible=!1;
2330
+ }set_world_space_coordinate_system()
2331
+ {
2332
+ this.position_strategy=new rs;
2333
+ }set_screen_space_coordinate_system()
2334
+ {
2335
+ this.position_strategy=new is;
2336
+ }set_texture(e)
2337
+ {
2338
+ e.minFilter=h,e.magFilter=h,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;
2339
+ }update_state(e)
2340
+ {
2341
+ this.material.uniforms._ScreenSize.value.set(tt.width,tt.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);
2342
+ }is_mouse_over(e)
2343
+ {
2344
+ 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 X).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);
2345
+ }to_screen_position(e)
2346
+ {
2347
+ e.x=(.5*e.x+.5)*tt.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*tt.height+this.pixel_offset.y;
2348
+ }get_screen_space_position()
2349
+ {
2350
+ const e=this.cached_NDC_position.clone();return this.to_screen_position(e),e;
2351
+ }set_screen_space_position(e)
2352
+ {
2353
+ this.position.x=e.x/tt.width*2-1,this.position.y=e.y/tt.height*2-1;
2354
+ }dispose()
2355
+ {
2356
+ this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),this.geometry.dispose(),this.material.dispose();
2357
+ }get_size(e)
2358
+ {
2359
+ return e?e.copy(this.texture_size).multiplyScalar(this.size/tt.dpr):(new s).copy(this.texture_size).multiplyScalar(this.size/tt.dpr);
2360
+ }on_mouse_enter()
2361
+ {}on_mouse_exit()
2362
+ {}on_mouse_hover()
2363
+ {}
2364
+ }class cs extends g
2365
+ {
2366
+ constructor(e,t)
2367
+ {
2368
+ super(e,t);const s=this;this.onBeforeRender=()=>
2369
+ {
2370
+ s.material.update();
2371
+ };
2372
+ }
2373
+ }class ds
2374
+ {
2375
+ constructor(e,t,i)
2376
+ {
2377
+ const r=t.right-t.left,n=t.top-t.bottom;this.scale=new s(r,n),this.position=new s(e+t.left,t.bottom),this.atlas_bounds=new S(i.left,i.right,i.top,i.bottom);
2378
+ }
2379
+ }class us
2380
+ {
2381
+ constructor(t,i='')
2382
+ {
2383
+ this.glyph_layout=t,this.glyphs=[],this.glyph_is_dirty=!0,this.matrix_is_dirty=!0,this.color_is_dirty=!0,this.position=new e,this.quaternion=new N,this.scale=new e(1,1,1),this.matrix=new q,this.color=new r('#FFFFFF'),this.pivot_point=new s,this.__opacity=1,this.__text=i,this.__generate_glyphs(i);
2384
+ }set text(e)
2385
+ {
2386
+ this.__text=e,this.__generate_glyphs(e),this.matrix_is_dirty=!0;
2387
+ }get text()
2388
+ {
2389
+ return this.__text;
2390
+ }update_matrix()
2391
+ {
2392
+ this.matrix.compose(this.position,this.quaternion,this.scale),this.matrix_is_dirty=!1,this.glyph_is_dirty=!0;
2393
+ }clear_glyph_dirty()
2394
+ {
2395
+ this.glyph_is_dirty=!1;
2396
+ }clear_color_dirty()
2397
+ {
2398
+ this.color_is_dirty=!1;
2399
+ }set_rotation(t=0,s=0)
2400
+ {
2401
+ const i=(new N).setFromAxisAngle(new e(0,1,0),t/360*Math.PI*2),r=(new N).setFromAxisAngle(new e(1,0,0),-s/360*Math.PI*2);this.quaternion.copy(i.multiply(r)),this.matrix_is_dirty=!0;
2402
+ }set_position(e)
2403
+ {
2404
+ this.position.copy(e),this.matrix_is_dirty=!0;
2405
+ }set_size(e)
2406
+ {
2407
+ this.scale.set(e,e,e),this.matrix_is_dirty=!0;
2408
+ }set_color(e)
2409
+ {
2410
+ this.color.set(e),this.color_is_dirty=!0;
2411
+ }set_pivot(e)
2412
+ {
2413
+ this.pivot_point.copy(e),this.update_glyphs();
2414
+ }set opacity(e)
2415
+ {
2416
+ this.__opacity=e,this.color_is_dirty=!0;
2417
+ }get opacity()
2418
+ {
2419
+ return this.__opacity;
2420
+ }update_glyphs()
2421
+ {
2422
+ this.__generate_glyphs(this.text);
2423
+ }__generate_glyphs(e)
2424
+ {
2425
+ let t=0;this.glyphs.length=0;for(let s=0;s<e.length;s++)
2426
+ {
2427
+ const i=e.charCodeAt(s),r=this.glyph_layout.find((e=>e.unicode===i));if(r)
2428
+ {
2429
+ if(r.planeBounds)
2430
+ {
2431
+ const e=new ds(t,r.planeBounds,r.atlasBounds);this.glyphs.push(e);
2432
+ }t+=r.advance;
2433
+ }
2434
+ }const i=new X,r=this.glyphs[0];i.setFromCenterAndSize(r.position.clone().add(new s(r.scale.x/2,r.scale.y/2)),r.scale);for(let e=1;e<this.glyphs.length;e++)
2435
+ {
2436
+ const t=this.glyphs[e],r=(new X).setFromCenterAndSize(t.position.clone().add(new s(t.scale.x/2,t.scale.y/2)),t.scale);i.union(r);
2437
+ }const n=new s;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;
2438
+ }
2439
+ }class ps extends Ne
2440
+ {
2441
+ constructor(e)
2442
+ {
2443
+ 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 s(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=E,e.minFilter=Y,e.magFilter=Y,e.generateMipMaps=!1;
2444
+ }set_atlas_size(e)
2445
+ {
2446
+ this.uniforms._AtlasSize.value.copy(e);
2447
+ }set_boldness(e)
2448
+ {
2449
+ this.uniforms._Boldness.value=fe.lerp(.5,.2,e);
2450
+ }
2451
+ }class ms extends g
2452
+ {
2453
+ constructor(e,t)
2454
+ {
2455
+ const i=new Q;i.instanceCount=0;const r=new T(1,1);r.translate(.5,.5,0),i.setAttribute('position',new H(r.getAttribute('position').array,3)),i.setAttribute('uv',new H(r.getAttribute('uv').array,2)),i.index=r.index;const n=new $(new Float32Array(8e3),4,!1),o=new $(new Float32Array(8e3),4,!1),a=new $(new Float32Array(8e3),4,!1),_=new $(new Float32Array(8e3),4,!1),l=new $(new Float32Array(8e3),4,!1),h=new $(new Float32Array(8e3),4,!1),c=new $(new Float32Array(8e3),4,!1);n.usage=Z,o.usage=Z,a.usage=Z,_.usage=Z,l.usage=Z,h.usage=Z,c.usage=Z,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 ps(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new s(e.atlas.width,e.atlas.height)),this.frustumCulled=!1;
2456
+ }set_boldness(e)
2457
+ {
2458
+ this.material.set_boldness(e);
2459
+ }add_text(e)
2460
+ {
2461
+ const t=new us(this.font_layout.glyphs,e);return this.text_elements.push(t),t;
2462
+ }remove_text(e)
2463
+ {
2464
+ Yt.remove_elem(this.text_elements,e),this.update(!0);
2465
+ }update(e)
2466
+ {
2467
+ 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++)
2468
+ {
2469
+ const d=this.text_elements[e];d.matrix_is_dirty&&(_=!0,d.update_matrix()),d.glyph_is_dirty&&(l=!0,d.clear_glyph_dirty()),d.color_is_dirty&&(h=!0,d.clear_color_dirty());const u=d.matrix,p=d.color,m=d.opacity;for(let e=0;e<d.glyphs.length;e++)
2470
+ {
2471
+ const _=d.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,u.elements[0],u.elements[1],u.elements[2],u.elements[3]),r.setXYZW(l,u.elements[4],u.elements[5],u.elements[6],u.elements[7]),n.setXYZW(l,u.elements[8],u.elements[9],u.elements[10],u.elements[11]),o.setXYZW(l,u.elements[12],u.elements[13],u.elements[14],u.elements[15]),a.setXYZW(l,p.r,p.g,p.b,m),c++;
2472
+ }
2473
+ }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);
2474
+ }dispose()
2475
+ {
2476
+ this.geometry.dispose(),this.material.dispose();
2477
+ }
2478
+ }class gs extends we
2479
+ {
2480
+ constructor(e,t=0,s=1,i='linear')
2481
+ {
2482
+ super(i),this.attribute_name=e,this.from=t,this.to=s;
2483
+ }update(e,t)
2484
+ {
2485
+ const s=this.from.clone();s.lerp(this.to,this.easing_function(t)),e[this.attribute_name].copy(s);
2486
+ }
2487
+ }class fs extends qe
2488
+ {
2489
+ constructor()
2490
+ {
2491
+ 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 s(1,1)};
2492
+ }set_texture(e)
2493
+ {
2494
+ this.uniforms._SourceTex.value=e;const t=this.get_size(e);this.uniforms._SourceTexSize.value.copy(t);
2495
+ }get_size(e)
2496
+ {
2497
+ return e.isVideoTexture?new s(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new s(e.width,e.height):e.isTexture?new s(e.image.width,e.image.height):new s(1,1);
2498
+ }
2499
+ }class vs
2500
+ {
2501
+ constructor(e)
2502
+ {
2503
+ this.RT=new A(1,1,{type:D,format:P,minFilter:h,magFilter:h}),this.RT1=new A(1,1,{type:D,format:P,minFilter:h,magFilter:h}),this.median_filter_mat=new fs;
2504
+ }filter(e)
2505
+ {
2506
+ 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),lt.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),lt.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),lt.material_pass(this.median_filter_mat,this.RT);return this.RT;
2507
+ }get_size(e)
2508
+ {
2509
+ return e.isVideoTexture?new s(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new s(e.width,e.height):e.isTexture?new s(e.image.width,e.image.height):new s(1,1);
2510
+ }
2511
+ }class xs extends qe
2512
+ {
2513
+ constructor(e)
2514
+ {
2515
+ 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);}');
2516
+ }
2517
+ }class ws extends qe
2518
+ {
2519
+ constructor(e,t)
2520
+ {
2521
+ 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;}');
2522
+ }set offset(e)
2523
+ {
2524
+ this.uniforms._Offset.value=e;
2525
+ }get offset()
2526
+ {
2527
+ return this.uniforms._Offset.value;
2528
+ }
2529
+ }class bs
2530
+ {
2531
+ constructor(e)
2532
+ {
2533
+ this.current_width=1,this.current_height=1,this.RT0=new A(1,1),this.RT1=new A(1,1),this.RT2=new A(1,1),this.RT3=new A(1,1),this.RT4=new A(1,1),this.upscale_blur_mat=new xs(!0),this.downscale_blur_mat=new xs(!1),this.alpha_filter_mat=new ws;
2534
+ }blur(e)
2535
+ {
2536
+ this.check_RT_resize(e.width,e.height),lt.blit(e,this.RT1,this.alpha_filter_mat),lt.blit(this.RT1,this.RT2,this.downscale_blur_mat),lt.blit(this.RT2,this.RT3,this.downscale_blur_mat),lt.blit(this.RT3,this.RT4,this.downscale_blur_mat),lt.blit(this.RT4,this.RT3,this.upscale_blur_mat),lt.blit(this.RT3,this.RT2,this.upscale_blur_mat),lt.blit(this.RT2,e,this.upscale_blur_mat);
2537
+ }check_RT_resize(e,t)
2538
+ {
2539
+ 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));
2540
+ }
2541
+ }class ys
2542
+ {
2543
+ constructor(e,t)
2544
+ {
2545
+ this.read=void 0,this.write=void 0,this.name=e,this.update_material=t;
2546
+ }init_from_geometry(e)
2547
+ {}init_from_attribute(e)
2548
+ {}build_RT(e)
2549
+ {
2550
+ const t=ys.calculate_resolution(e),s={minFilter:h,magFilter:h,format:P,colorScape:k,type:Ge.fp_textures_available?D:J,stencilBuffer:!1,depthBuffer:!1};return new A(t.width,t.height,s);
2551
+ }static calculate_resolution(e)
2552
+ {
2553
+ const t=Math.min(e,512);return{width:t,height:Math.max(1,Math.ceil(e/t))};
2554
+ }swap_RT()
2555
+ {
2556
+ const e=this.read;this.read=this.write,this.write=e;
2557
+ }update(e)
2558
+ {
2559
+ this.update_material&&(this.update_material.update(),e.children[0].material=this.update_material,this.update_material.uniforms._MainTex.value=this.read.texture,lt.render(e,void 0,this.write),e.children[0].material=void 0,this.swap_RT());
2560
+ }store_geometry_attribute_in_RT(e,t,s,i)
2561
+ {
2562
+ i.children[0].geometry.setAttribute('data',e),i.children[0].material=s,lt.render(i,void 0,t),i.children[0].geometry.deleteAttribute('data'),i.children[0].material=void 0;
2563
+ }get_texture()
2564
+ {
2565
+ return this.read.texture;
2566
+ }
2567
+ }class Ts extends c
2568
+ {
2569
+ constructor(e,t)
2570
+ {
2571
+ 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 m,this.attribute_writter_scene.add(this.attribute_writter_mesh);
2572
+ }add_texture_attribute(e)
2573
+ {
2574
+ this.attributes.push(e);
2575
+ }add_update_attribute_array(e,t,s)
2576
+ {
2577
+ this.attribute_writter_mesh.geometry.setAttribute(e,new U(t,s,!1));
2578
+ }add_attribute_array(e,t,s)
2579
+ {
2580
+ this.mesh.geometry.setAttribute(e,new $(t,s,!1));
2581
+ }update()
2582
+ {
2583
+ this.mesh.material.update();for(let e=0;e<this.attributes.length;e++)this.attributes[e].update(this.attribute_writter_scene);
2584
+ }dispose()
2585
+ {
2586
+ this.mesh.geometry.dispose(),this.mesh.material.dispose();
2587
+ }build_point_mesh(e=1,t)
2588
+ {
2589
+ const s=new T,i=new Q;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 g(i,t);return r.frustumCulled=!1,r;
2590
+ }build_attribute_writter_mesh(e)
2591
+ {
2592
+ const{width:t,height:s}=ys.calculate_resolution(e),i=new Float32Array(3*e);for(let r=0;r<e;r++)
2593
+ {
2594
+ 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;
2595
+ }const r=new u;r.setAttribute('position',new U(i,3,!1));const n=new K(r);return n.frustumCulled=!1,n;
2596
+ }build_uv_storage_attribute(e)
2597
+ {
2598
+ const{width:t,height:s}=ys.calculate_resolution(e),i=new Float32Array(2*e);for(let r=0;r<e;r++)
2599
+ {
2600
+ const e=r%t,n=Math.floor(r/t);i[2*r+0]=(e+.5)/t,i[2*r+1]=(n+.5)/s;
2601
+ }return new $(i,2,!1);
2602
+ }
2603
+ }class Ss extends i
2604
+ {
2605
+ constructor()
2606
+ {
2607
+ 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:n,depthTest:!1,depthFunc:o});
2608
+ }
2609
+ }class Ms extends ys
2610
+ {
2611
+ constructor(e)
2612
+ {
2613
+ super('_Position',e);
2614
+ }store_geometry(e,t)
2615
+ {
2616
+ const s=e.getAttribute('position');this.read=this.build_RT(s.count),this.write=this.build_RT(s.count);const i=new Ss;this.store_geometry_attribute_in_RT(e.getAttribute('position'),this.read,i,t);
2617
+ }store_positions(e,t)
2618
+ {
2619
+ 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 Ss;this.store_geometry_attribute_in_RT(new U(s,4),this.read,i,t);
2620
+ }
2621
+ }class zs extends L
2622
+ {
2623
+ constructor(e,t,s,i,r)
2624
+ {
2625
+ super(e,t,s,i,r),this.multiplier=1;
2626
+ }set_rgba(e,t,s,i,r)
2627
+ {
2628
+ 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;
2629
+ }set_rgb(e,t,s,i)
2630
+ {
2631
+ 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;
2632
+ }set_r(e,t)
2633
+ {
2634
+ this.data[3*e+0]=t*this.multiplier,this.needsUpdate=!0;
2635
+ }set_g(e,t)
2636
+ {
2637
+ this.data[3*e+1]=t*this.multiplier,this.needsUpdate=!0;
2638
+ }set_b(e,t)
2639
+ {
2640
+ this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0;
2641
+ }set_a(e,t)
2642
+ {
2643
+ this.data[3*e+2]=t*this.multiplier,this.needsUpdate=!0;
2644
+ }
2645
+ }class Fs extends zs
2646
+ {
2647
+ constructor(e,t)
2648
+ {
2649
+ super(new Uint8Array(e*t*3),e,t,P),this.multiplier=255;
2650
+ }
2651
+ }class Rs extends zs
2652
+ {
2653
+ constructor(e,t)
2654
+ {
2655
+ super(new Uint8Array(e*t*4),e,t,P),this.multiplier=255;
2656
+ }
2657
+ }class As extends zs
2658
+ {
2659
+ constructor(e,t)
2660
+ {
2661
+ super(new Float32Array(e*t*3),e,t,P,D);
2662
+ }
2663
+ }class Cs extends zs
2664
+ {
2665
+ constructor(e,t)
2666
+ {
2667
+ super(new Float32Array(e*t*4),e,t,P,D);
2668
+ }
2669
+ }class Ps extends g
2670
+ {
2671
+ constructor(e,t,s,i)
2672
+ {
2673
+ 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);
2674
+ }attach_rgb_texture(e)
2675
+ {
2676
+ this.material.uniforms[e].value=new Fs(this.batch_width,this.batch_height);
2677
+ }attach_rgba_texture(e)
2678
+ {
2679
+ this.material.uniforms[e].value=new Rs(this.batch_width,this.batch_height);
2680
+ }attach_rgb_float_texture(e)
2681
+ {
2682
+ this.material.uniforms[e].value=new As(this.batch_width,this.batch_height);
2683
+ }attach_rgba_float_texture(e)
2684
+ {
2685
+ this.material.uniforms[e].value=new Cs(this.batch_width,this.batch_height);
2686
+ }get_mesh_index(e)
2687
+ {
2688
+ return this.id_table[e];
2689
+ }set_rgb_value(e,t,s,i,r)
2690
+ {
2691
+ this.material.uniforms[e].set_rgb(this.get_mesh_index(t),s,i,r);
2692
+ }set_rgba_value(e,t,s,i,r,n)
2693
+ {
2694
+ this.material.uniforms[e].set_rgba(this.get_mesh_index(t),s,i,r,n);
2695
+ }
2696
+ }class ks
2697
+ {
2698
+ batch(e,t)
2699
+ {
2700
+ const s=[],i={},r=[];for(let t=0;t<e.length;t++)
2701
+ {
2702
+ 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);
2703
+ }const n=ae.mergeGeometries(s),o=new U(new Float32Array(r),1);return n.setAttribute('mesh_id',o),this.create_batched_mesh(i,n,t,2048);
2704
+ }create_batched_mesh(e,t,s,i)
2705
+ {
2706
+ return new Ps(e,t,s,i);
2707
+ }
2708
+ }class Ds
2709
+ {
2710
+ constructor(e,t=!0,s=1,i=!1)
2711
+ {
2712
+ this.buffer=e,this.loop=t,this.volume=s,this.positional=i,this.audio=void 0;
2713
+ }init(e)
2714
+ {
2715
+ this.positional?this.audio=new ee(e):this.audio=new te(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);
2716
+ }play()
2717
+ {
2718
+ this.audio.play();
2719
+ }pause()
2720
+ {
2721
+ this.audio.pause();
2722
+ }stop()
2723
+ {
2724
+ this.audio.stop();
2725
+ }get is_playing()
2726
+ {
2727
+ return this.audio.isPlaying;
2728
+ }
2729
+ }class Ls extends ge
2730
+ {
2731
+ constructor(e,t,s=!0,i=0,r,n=!1)
2732
+ {
2733
+ super(e,t,r),this.loop=s,this.volume=i,this.positional=n;
2734
+ }on_preloaded_finished(e)
2735
+ {
2736
+ 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());
2737
+ }instantiate_audio(e)
2738
+ {
2739
+ const t=se.getContext(),s=t.createBuffer(2,22050,44100);fetch(this.url).then((e=>e.blob())).then((i=>
2740
+ {
2741
+ i.arrayBuffer?i.arrayBuffer().then((s=>
2742
+ {
2743
+ t.decodeAudioData(s,(t=>
2744
+ {
2745
+ e.set_resource(this.resource_id,this.url,new Ds(t,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2746
+ }));
2747
+ })):(e.set_resource(this.resource_id,this.url,new Ds(s,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2748
+ }));
2749
+ }
2750
+ }class Us extends ge
2751
+ {
2752
+ constructor(e,t,s,i)
2753
+ {
2754
+ super(e,t,i),this.loader=s;
2755
+ }on_preloaded_finished(e)
2756
+ {
2757
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2758
+ {
2759
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2760
+ }),(e=>
2761
+ {}),(e=>
2762
+ {
2763
+ 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();
2764
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2765
+ }
2766
+ }class js extends ge
2767
+ {
2768
+ constructor(e,t,s,i)
2769
+ {
2770
+ super(e,t,i),this.loader=new ie,this.loader.setPath(t+'/'),this.urls=[`px.${s}`,`nx.${s}`,`py.${s}`,`ny.${s}`,`pz.${s}`,`nz.${s}`];
2771
+ }on_preloaded_finished(e)
2772
+ {
2773
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(t=>
2774
+ {
2775
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2776
+ }),(e=>
2777
+ {}),(e=>
2778
+ {
2779
+ this.__set_error('Image could not be loaded. Maybe wrong name or path, I don\'t know¯\\_(ツ)_/¯',e),this.__loading_ended();
2780
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2781
+ }
2782
+ }class Os extends ge
2783
+ {
2784
+ constructor(e,t,s)
2785
+ {
2786
+ super(e,t,s),this.loader=new _e;
2787
+ }on_preloaded_finished(e)
2788
+ {
2789
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2790
+ {
2791
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2792
+ }),(e=>
2793
+ {}),(e=>
2794
+ {
2795
+ 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();
2796
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2797
+ }
2798
+ }class Is extends ge
2799
+ {
2800
+ constructor(e,t,s)
2801
+ {
2802
+ super(e,t,s),this.loader=new re;
2803
+ }on_preloaded_finished(e)
2804
+ {
2805
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2806
+ {
2807
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2808
+ }),(e=>
2809
+ {}),(e=>
2810
+ {
2811
+ this.__set_error(e),this.__loading_ended();
2812
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2813
+ }
2814
+ }class Ns extends ge
2815
+ {
2816
+ constructor(e,t,s)
2817
+ {
2818
+ super(e,t,s),this.loader=new le;
2819
+ }on_preloaded_finished(e)
2820
+ {
2821
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2822
+ {
2823
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2824
+ }),(e=>
2825
+ {}),(e=>
2826
+ {
2827
+ 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();
2828
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2829
+ }
2830
+ }class qs extends ge
2831
+ {
2832
+ constructor(e,t,s)
2833
+ {
2834
+ super(e,t,s),this.loader=new he;
2835
+ }on_preloaded_finished(e)
2836
+ {
2837
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2838
+ {
2839
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2840
+ }),(e=>
2841
+ {}),(e=>
2842
+ {
2843
+ 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();
2844
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2845
+ }
2846
+ }class Bs extends ge
2847
+ {
2848
+ constructor(e,t,s,i)
2849
+ {
2850
+ super(e,t,i),this.loader=new he,this.loader.setDRACOLoader(s);
2851
+ }on_preloaded_finished(e)
2852
+ {
2853
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2854
+ {
2855
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2856
+ }),(e=>
2857
+ {}),(e=>
2858
+ {
2859
+ 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();
2860
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2861
+ }
2862
+ }class Vs extends ge
2863
+ {
2864
+ constructor(e,t,s,i)
2865
+ {
2866
+ super(e,t,i),this.loader=new ce,this.loader.setPath(t+'/'),this.urls=[`px.${s}`,`nx.${s}`,`py.${s}`,`ny.${s}`,`pz.${s}`,`nz.${s}`];
2867
+ }on_preloaded_finished(e)
2868
+ {
2869
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.urls,(t=>
2870
+ {
2871
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2872
+ }),(e=>
2873
+ {}),(e=>
2874
+ {
2875
+ 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();
2876
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2877
+ }
2878
+ }class Ys extends ge
2879
+ {
2880
+ constructor(e,t,s)
2881
+ {
2882
+ super(e,t,s);
2883
+ }on_preloaded_finished(e,t)
2884
+ {
2885
+ void 0===e.resources_by_url[this.url]?t.json().then((t=>
2886
+ {
2887
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2888
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2889
+ }
2890
+ }class Gs extends ge
2891
+ {
2892
+ constructor(e,t,s)
2893
+ {
2894
+ super(e,t,s),this.loader=new de;
2895
+ }on_preloaded_finished(e)
2896
+ {
2897
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2898
+ {
2899
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2900
+ }),(e=>
2901
+ {}),(e=>
2902
+ {
2903
+ 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();
2904
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2905
+ }
2906
+ }class Es extends ge
2907
+ {
2908
+ constructor(e,t,s)
2909
+ {
2910
+ super(e,t,s),this.loader=new re;
2911
+ }on_preloaded_finished(e)
2912
+ {
2913
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2914
+ {
2915
+ e.set_resource(this.resource_id,this.url,this.parse_path(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2916
+ }),(e=>
2917
+ {}),(e=>
2918
+ {
2919
+ this.__set_error(e),this.__loading_ended();
2920
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2921
+ }parse_path(t)
2922
+ {
2923
+ const s=t.split('\n');''===s[s.length-1]&&s.pop();const i=[];for(let t=0;t<s.length;t+=3)
2924
+ {
2925
+ const r=parseFloat(s[t+0]),n=parseFloat(s[t+1]),o=parseFloat(s[t+2]);i.push(new e(r,n,o));
2926
+ }return i;
2927
+ }
2928
+ }class Ws extends ge
2929
+ {
2930
+ constructor(e,t,s)
2931
+ {
2932
+ super(e,t,s),this.loader=new ue;
2933
+ }on_preloaded_finished(e)
2934
+ {
2935
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2936
+ {
2937
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2938
+ }),(e=>
2939
+ {}),(e=>
2940
+ {
2941
+ 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();
2942
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2943
+ }
2944
+ }class Xs extends ge
2945
+ {
2946
+ constructor(e,t,s)
2947
+ {
2948
+ super(e,t,s),this.loader=new re;
2949
+ }on_preloaded_finished(e)
2950
+ {
2951
+ void 0===e.resources_by_url[this.url]?this.loader.load(this.url,(t=>
2952
+ {
2953
+ e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2954
+ }),(e=>
2955
+ {}),(e=>
2956
+ {
2957
+ this.__set_error(e),this.__loading_ended();
2958
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
2959
+ }
2960
+ }class Qs extends ge
2961
+ {
2962
+ constructor(e,t,s,i=!0,r=!1,n=!0)
2963
+ {
2964
+ super(e,t,s),this.colorSpaceConversion=n,this.premultiplyAlpha=r,this.flipY=i;
2965
+ }on_preloaded_finished(e)
2966
+ {
2967
+ pe.is_safari?this.load_with_old_method(e):this.load_with_new_method(e);
2968
+ }load_with_old_method(e)
2969
+ {
2970
+ if(void 0===e.resources_by_url[this.url])
2971
+ {
2972
+ const t=new ne,s=new Image;s.src=this.url,s.onload=()=>
2973
+ {
2974
+ t.image=s,t.flipY=this.flipY,t.premultiplyAlpha=this.premultiplyAlpha,t.colorSpace=this.colorSpaceConversion?oe:k,t.needsUpdate=!0,e.set_resource(this.resource_id,this.url,t),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2975
+ },s.onerror=()=>
2976
+ {
2977
+ console.error('Error loading texture. Maybe the resource is not an image?',this.url,this.original_url);
2978
+ };
2979
+ }
2980
+ else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2981
+ }load_with_new_method(e)
2982
+ {
2983
+ if(void 0===e.resources_by_url[this.url])
2984
+ {
2985
+ 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=>
2986
+ {
2987
+ const s=new ne(t);s.flipY=this.flipY,s.premultiplyAlpha=this.premultiplyAlpha,s.colorSpace=this.colorSpaceConversion?oe:k,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2988
+ })).catch((function(e)
2989
+ {
2990
+ console.error(e);
2991
+ }));
2992
+ }
2993
+ else e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended();
2994
+ }
2995
+ }class Hs extends ge
2996
+ {
2997
+ constructor(e,t,s)
2998
+ {
2999
+ super(e,t,s);
3000
+ }on_preloaded_finished(e,t)
3001
+ {
3002
+ void 0===e.resources_by_url[this.url]?t.blob().then((t=>
3003
+ {
3004
+ const s=new ne,i=URL.createObjectURL(t),r=new Image;r.src=i,r.onload=()=>
3005
+ {
3006
+ s.image=r,s.needsUpdate=!0,e.set_resource(this.resource_id,this.url,s),this.__update_downloaded_bytes(1,1),this.__loading_ended();
3007
+ },r.onerror=()=>
3008
+ {
3009
+ console.error('Error loading texture. Maybe the resource is not an image?',this.url);
3010
+ };
3011
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
3012
+ }
3013
+ }class $s extends ge
3014
+ {
3015
+ constructor(e,t,s)
3016
+ {
3017
+ super(e,t,s);
3018
+ }on_preloaded_finished(e,t)
3019
+ {
3020
+ void 0===e.resources_by_url[this.url]?t.blob().then((t=>
3021
+ {
3022
+ e.set_resource(this.resource_id,this.url,URL.createObjectURL(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended();
3023
+ })):(e.set_resource(this.resource_id,this.url,e.resources_by_url[this.url]),this.__update_downloaded_bytes(1,1),this.__loading_ended());
3024
+ }
3025
+ }class Zs
3026
+ {
3027
+ constructor(e)
3028
+ {
3029
+ this.resource_loaders=[],this.batch_name=e||'unnamed batch';
3030
+ }add_loader(e)
3031
+ {
3032
+ this.resource_loaders.push(e);
3033
+ }load(e)
3034
+ {
3035
+ for(let t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||Fe);
3036
+ }get loading_finished()
3037
+ {
3038
+ let e=!0;for(let t=0;t<this.resource_loaders.length;t++)e=e&&this.resource_loaders[t].has_finished;return e;
3039
+ }get has_errors()
3040
+ {
3041
+ let e=!1;for(let t=0;t<this.resource_loaders.length;t++)e=e||this.resource_loaders[t].has_error;return e;
3042
+ }print_errors()
3043
+ {
3044
+ 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();
3045
+ }get_progress()
3046
+ {
3047
+ return this.get_loaded_bytes()/this.get_total_bytes();
3048
+ }get_loaded_bytes()
3049
+ {
3050
+ let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].loaded_bytes;return e;
3051
+ }get_total_bytes()
3052
+ {
3053
+ let e=1;for(let t=0;t<this.resource_loaders.length;t++)e+=this.resource_loaders[t].total_bytes;return e;
3054
+ }
3055
+ }export{ge as AbstractLoader,Te as ActionEvent,we as ActionInterpolator,ve as ActionSequencer,Me as ActionSequencerBuilder,Be as AddMaterial,Le as ApplicationView,Yt as ArrayUtilities,et as Arrow,Qs as AsyncTextureLoader,Ls as AudioLoader,Ue as BaseApplication,je as BaseRender,Ne as BaseShaderMaterial,Us as BasisLoader,qe as BlitMaterial,Ft as Blurrer,pe as Browser,He as CSSAnimator,Ye as CameraManager,wt as CameraUtilities,Ee as CanvasDrawer,Ge as Capabilities,We as Configuration,Je as Cube,js as CubemapLoader,Os as DAELoader,rt as Debug,ct as DebugNormalsRender,Se as DrawIOAnimationSheet,xs as DualFilteringBlurMaterial,bs as DualFilteringBlurrer,xe as EasingFunctions,ze as EventManager,Is as FileLoader,Ns as FontLoader,Gt as FrustumPointFitter,Bs as GLTFDRACOLoader,qs as GLTFLoader,Ts as GPUParticleSystem,Dt as GaussianBlurrer,Et as GeometryUtilities,lt as Graphics,Jt as Grid,Vs as HDRCubeTextureLoader,Re as HTMLUtilities,Bt as HorizontalPlane,Wt as ImageUtilities,bt as Initializer,Ys as JSONLoader,dt as KeyboardInput,Kt as Line,vs as MedianFilter,ks as MeshBatcher,Xt as MeshSampler,Qt as ModelUtilities,Rt as NormalAORender,At as NormalRender,be as NumberInterpolator,Gs as OBJLoader,fe as OMath,ut as OS,tt as OScreen,Ht as ObjectUtilities,Ut as OrthographicCamera,xt as OrthographicFrustumPointFitter,ys as ParticleAttribute,Ms as ParticlePositionAttribute,it as PerspectiveCamera,vt as PerspectiveFrustumPointFitter,Es as PointArrayLoader,Ws as RGBETextureLoader,Ot as RenderLoop,Zs as ResourceBatch,Fe as ResourceContainer,ms as SDFTextBatch,Ze as SceneManager,It as Screen,Nt as SimpleTextDrawer,Ke as Sphere,$t as StringUtilities,ts as Text2D,Xs as TextLoader,Hs as TextureLoader,Ce as Time,Zt as TimeUtilities,Ae as TransitionTable,ft as UI,hs as UIElement,Ve as UnrealBloomComposeMaterial,Lt as UnrealBloomRender,cs as UpdatableMaterialMesh,Ct as VRRender,me as Validation,gs as VectorInterpolator,Vt as VerticalPlane,$s as VideoLoader,qt as ViewComponent,jt as ViewComponentManager,ye as ViewContext,De as ViewManager,es as WorldImage};
2
3056
  //# sourceMappingURL=index.module.js.map