ohzi-core 6.3.4 → 6.3.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.
package/build/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Math 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,Vector3 as u,LineBasicMaterial as d,BufferGeometry as m,Line as p,Scene as g,Mesh as v,BoxGeometry as f,MeshBasicMaterial as x,SphereBufferGeometry as w,CylinderBufferGeometry as b,ConeBufferGeometry as y,PerspectiveCamera as T,PlaneBufferGeometry as M,Vector4 as S,Box3 as z,Box3Helper as F,CatmullRomCurve3 as R,SphereGeometry as A,WebGLRenderTarget as C,OrthographicCamera as D,WebGLRenderer as P,DataTexture as L,RGBFormat as U,RGBAFormat as k,FloatType as O,BufferAttribute as j,Matrix4 as I,Plane as N,Ray as V,Sphere as B,RepeatWrapping as q,LinearFilter as G,Line3 as Y,Quaternion as E,Skeleton as W,DoubleSide as X,PlaneGeometry as Q,LinearMipMapLinearFilter as H,Box2 as Z,InstancedBufferGeometry as J,Float32BufferAttribute as $,InstancedBufferAttribute as K,DynamicDrawUsage as ee,Points as te,PositionalAudio as se,Audio as ie,AudioContext as re,sRGBEncoding as ne,CubeTextureLoader as oe,FileLoader as ae,UnsignedByteType as _e,Texture as le}from"three";import*as he from"three/examples/jsm/utils/BufferGeometryUtils.js";export{he as BufferGeometryUtils};import{InputController as ce}from"pit-js";import*as ue from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as de}from"three/examples/jsm/loaders/FontLoader.js";import*as me from"three/examples/jsm/loaders/GLTFLoader.js";import*as pe from"three/examples/jsm/loaders/DRACOLoader.js";import*as ge from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import*as ve from"three/examples/jsm/loaders/OBJLoader.js";import*as fe from"three/examples/jsm/loaders/RGBELoader.js";var xe=new class{init(){switch(this.browser_name="",this.agent=window.navigator.userAgent.toLowerCase(),!0){case this.agent.indexOf("edge")>-1:this.browser_name="edge_ie";break;case this.agent.indexOf("edg")>-1:this.browser_name="edge_chromium";break;case this.agent.indexOf("opr")>-1&&!!window.opr:this.browser_name="opera";break;case this.agent.indexOf("chrome")>-1&&!!window.chrome:this.browser_name="chrome";break;case this.agent.indexOf("trident")>-1:this.browser_name="iexplorer";break;case this.agent.indexOf("firefox")>-1:this.browser_name="firefox";break;case this.agent.indexOf("safari")>-1:this.browser_name="safari";break;default:this.browser_name="other"}}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"}};class we{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 be{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=we.is_number(e)?e:1,t=we.is_number(t)?t:1,this.loaded_bytes=e,t>0&&(this.total_bytes=t),this.loaded_bytes>this.total_bytes&&console.warn("Total bytes is smaller than loaded ones. Please set total bytes by hand to:",this.url)}__loading_ended(){this.has_finished=!0}__set_error(e){this.has_error=!0,this.error_message=e}print_error(){console.error("Error while loading "+this.resource_id+"\n\t path: "+this.url+"\n\t\t"+this.error_message)}load(e){const t=xe.is_safari?"no-cache":"default";fetch(this.url,{method:"GET",mode:"cors",cache:t,credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}async on_progress(e,t){const 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)}}class ye{constructor(e){this.elapsed_time=-1e-5,this.playback_speed=1,this.playing=!1,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};const t=Object.keys(e);for(let e=0;e<t.length;e++)this.channels[t[e]]=[];this.duration=0}play(){this.playing=!0}stop(){this.playing=!1}reset(){this.elapsed_time=-1e-5}skip(){const e=this.get_duration();this.__play_clips(this.elapsed_time,e+1e-4),this.elapsed_time=e}update(e){this.playing&&(this.__play_clips(this.elapsed_time,this.elapsed_time+e*this.playback_speed),this.elapsed_time=this.elapsed_time+e*this.playback_speed)}set_progress(t){this.elapsed_time=e.clamp(t,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)}set_normalized_progress(t){this.elapsed_time=e.clamp(t,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return e.clamp(this.elapsed_time/this.get_duration(),0,1)}is_finished(){return this.elapsed_time>this.get_duration()}add_action_event(e,t){this.action_events.push({trigger_time:e,action:t}),this.duration=Math.max(this.duration,e)}add_action_interpolator(e,t,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_property_target_value(e){const t=this.__get_nearest_keyframe(e,this.elapsed_time);return this.elapsed_time<t.from?t.interpolator.evaluate(0):t.interpolator.evaluate(1)}get_duration(){return this.duration}__play_clips(e,t){for(let s=0;s<this.action_events.length;s++)this.action_events[s].trigger_time>e-Number.EPSILON&&this.action_events[s].trigger_time<t+Number.EPSILON&&this.action_events[s].action.trigger();const s=Object.keys(this.initial_context);for(let t=0;t<s.length;t++){const i=s[t],r=this.__get_nearest_keyframe(i,e);this.context[i]=this.evaluate_keyframe(r,e)}}evaluate_keyframe(t,s){return this.tmp_t=this.__linear_map_01(s,t.from,t.to),t.interpolator.evaluate(e.clamp(this.tmp_t,0,1))}get_keyframes(e){return this.channels[e]}__linear_map_01(e,t,s){return(e-t)/(s-t)*1+0}__get_nearest_keyframe(e,t){let s,i=9999999;const r=this.channels[e];for(let e=0;e<r.length;e++){const n=r[e],o=(n.to-n.from)/2+n.from,a=Math.abs(t-o);a<i&&(i=a,s=n)}return s}}var Te=new class{constructor(){}linear(e){return e}triangular(e){return 1-Math.abs(2*e%2-1)}ease_in_sine(e){return 1-Math.cos(3.1415926*e/2)}ease_out_sine(e){return Math.sin(3.1415926*e/2)}ease_in_out_sine(e){return-(Math.cos(3.1415926*e)-1)/2}ease_in_cubic(e){return e*e*e}ease_out_cubic(e){return 1-Math.pow(1-e,3)}ease_in_out_cubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}ease_in_quad(e){return e*e}ease_out_quad(e){return 1-(1-e)*(1-e)}ease_in_out_quad(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}ease_in_quart(e){return e*e*e*e}ease_out_quart(e){return 1-Math.pow(1-e,4)}ease_in_out_quart(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2}ease_in_quint(e){return e*e*e*e*e}ease_out_quint(e){return 1-Math.pow(1-e,5)}ease_in_out_quint(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2}ease_in_expo(e){return 0===e?0:Math.pow(2,10*e-10)}ease_out_expo(e){return 1===e?1:1-Math.pow(2,-10*e)}ease_in_out_expo(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}ease_in_circ(e){return 1-Math.sqrt(1-Math.pow(e,2))}ease_out_circ(e){return Math.sqrt(1-Math.pow(e-1,2))}ease_in_out_circ(e){return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2}ease_in_back(e){return 2.7015*e*e*e-1.7015*e*e}ease_out_back(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)}ease_in_out_back(e){return e<.5?Math.pow(2*e,2)*(7.189819*e-2.5949095)/2:(Math.pow(2*e-2,2)*(3.5949095*(2*e-2)+2.5949095)+2)/2}ease_in_elastic(e){const t=2*Math.PI/3;return 0===e?0:1===e?1:-Math.pow(2,10*e-10)*Math.sin((10*e-10.75)*t)}ease_out_elastic(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1}ease_in_out_elastic(e){return 0===e?0:1===e?1:e<.5?-Math.pow(2,20*e-10)*Math.sin(1.3962633*(20*e-11.125))/2:Math.pow(2,-20*e+10)*Math.sin(1.3962633*(20*e-11.125))/2+1}ease_in_bounce(e){return 1-this.ease_out_bounce(1-e)}ease_out_bounce(e){const t=7.5625,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}ease_in_out_bounce(e){return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2}heartbeat(e){return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8}};class Me{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?Te[e]:e}update(e,t){}}class Se extends Me{constructor(e,t=0,s=1,i="linear"){super(i),this.attribute_name=e,this.from=t,this.to=s}update(t,s){t[this.attribute_name]=e.lerp(this.from,this.to,this.easing_function(s))}evaluate(t){return e.lerp(this.from,this.to,this.easing_function(t))}}var ze=new class{constructor(){this.app=void 0}set_app(e){this.app=e}};class Fe{constructor(e,t){this.name=e,this.method=t}trigger(){ze.app[this.name][this.method]()}}class Re{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 Ae{constructor(e){this.initial_state_data=e}from_animation_sheet(e,t,s){s=s||this.initial_state_data;const i=e.animation_tracks,r=e.triggers,n=this.state_to_tracks(this.initial_state_data);for(let e=0;e<n.length;e++)void 0===i.find((t=>t.attribute_name===n[e].attribute_name))&&i.push(n[e]);const o=new ye(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Se(s.attribute_name,t[s.attribute_name],s.to_value,s.easing_function);o.add_action_interpolator(s.from_time,s.to_time,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new Fe(t.name,t.method);o.add_action_event(t.at_time,s)}return o}state_to_tracks(e){const t=[],s=Object.keys(e);for(let i=0;i<s.length;i++)t.push({attribute_name:s[i],from_time:0,to_time:1,to_value:e[s[i]],easing_function:"ease_in_out_cubic"});return t}from_draw_io(e,t){const s=(new Re).parse(e),i=s.animation_tracks,r=s.triggers,n=new ye(t);for(let e=0;e<i.length;e++){const s=i[e],r=new Se(s.attribute_name,t[s.attribute_name],s.to_value,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 Fe(t.name,t.method);n.add_action_event(t.at_time,s)}return n}}var Ce=new class{init(){this.queue={},this.zoom_changed_evt="zoom_changed",this.store_clickd_evt="store_clicked",this.point_selected_evt="point_selected",this.config_changed="config_changed",this.path_substep_completed="path_substep_completed",this.path_completed="path_completed",this.go_to_store_requested_evt="go_to_store_requested",this.resource_loaded_evt="resource_loaded",this.service_clicked_evt="service_clicked",this.unit_pos_updated_evt="unit_position_updated",this.floor_changed_evt="floor_changed",this.on_enter_floor_navigation="on_enter_floor_navigation",this.on_exit_floor_navigation="on_exit_floor_navigation",this.on_enter_floor_selection="on_enter_floor_selection",this.on_exit_floor_selection="on_exit_floor_selection",this.on_enter_outside_navigation="on_enter_outside_navigation",this.on_exit_outside_navigation="on_exit_outside_navigation",this.step_selected_evt="step_selected"}fire(e,t){const s=this.queue[e];if(void 0===s)return;let i=s.length;for(;i--;)s[i](t)}on(e,t){void 0===this.queue[e]&&(this.queue[e]=[]),this.queue[e].push(t)}fire_zoom_changed(e){this.fire(this.zoom_changed_evt,e)}fire_store_selected(e){this.fire(this.store_clickd_evt,e)}fire_point_selected(e){this.fire(this.point_selected_evt,e)}fire_config_changed(){this.fire(this.config_changed)}fire_path_substep_completed(e){this.fire(this.path_substep_completed,e)}fire_path_completed(){this.fire(this.path_completed)}fire_step_selected(e){this.fire(this.step_selected_evt,e)}fire_go_to_store_requested(e){this.fire(this.go_to_store_requested_evt,e)}fire_resource_loaded(e){this.fire(this.resource_loaded_evt,e)}fire_service_clicked(e){this.fire(this.service_clicked_evt,e)}fire_unit_position_updated(e){this.fire(this.unit_pos_updated_evt,e)}fire_floor_switched(e){this.fire(this.floor_changed_evt,e)}fire_on_enter_floor_navigation(e){this.fire(this.on_enter_floor_navigation,e)}fire_on_exit_floor_navigation(e){this.fire(this.on_exit_floor_navigation,e)}fire_on_enter_floor_selection(e){this.fire(this.on_enter_floor_selection,e)}fire_on_exit_floor_selection(e){this.fire(this.on_exit_floor_selection,e)}fire_on_enter_outside_navigation(e){this.fire(this.on_enter_outside_navigation,e)}fire_on_exit_outside_navigation(e){this.fire(this.on_exit_outside_navigation,e)}};var De=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),Ce.fire_resource_loaded({name:e,value:s})}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}};class Pe{constructor(){this.transitions=[],this.initial_state_data={}}get(e,t,s){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].from===e&&this.transitions[i].to===t){return new Ae(this.initial_state_data).from_animation_sheet(this.transitions[i].data,s)}for(let e=0;e<this.transitions.length;e++)if(this.transitions[e].to===t){return new Ae(this.initial_state_data).from_animation_sheet(this.transitions[e].data,s)}console.error("TransitionTable.get no data found for: ",e,t)}add_transitions(e){for(let t=0;t<e.length;t++)this.transitions.push(e[t])}set_transitions(e){this.transitions=e}set_initial_state_data(e){this.initial_state_data=e}}var Le=new class{init(){this.___time=new t,this.__delta_time=0,this.__elapsed_time=0,this.__allocated_time=new s(0,0)}get delta_time(){return this.__delta_time<.4?this.__delta_time:.016}get elapsed_time(){return this.__elapsed_time}get shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_time}__update(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime()}};class Ue{constructor(e){this.name=e}start(){}show(){}hide(){}before_enter(){}on_enter(){}update(){}update_enter_transition(e,t,s){this.update_transition(e,t,s)}update_exit_transition(e,t,s){}update_transition(e,t,s){}before_exit(){}on_exit(){}}class ke{constructor(e){this.last_state=new Ue,this.current_state=new Ue,this.initial_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.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())}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()}set_state(e){this.current_state=e}set_initial_state_data(e){Object.assign(this.initial_state_data,e),Object.assign(this.current_state_data,e)}__update_transitions(){this.action_sequencer.update(Le.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.name!==this.current_state.name&&this.last_state.hide(),this.last_state.on_exit()}}var Oe=new class{constructor(){this.views=[],this.transition_table=new Pe,this.transition_handler=new ke(this.transition_table),this.view_change_subscribers=[]}update(){this.transition_handler.update(),this.__set_views_opacities()}go_to_view(e,t=!0,s=!1){const i=this.get(e);this.transition_handler.go_to_state(i,s),t&&this.__change_browser_url(i.url),this.notify_view_change(e)}subscribe_to_view_change(e){this.view_change_subscribers.push(e)}notify_view_change(e){for(let t=0;t<this.view_change_subscribers.length;t++){this.view_change_subscribers[t].on_view_change(e)}}register_view(e){this.views.push(e)}has_view(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1}add_transitions(e){this.transition_table.add_transitions(e)}set_transitions(e){this.transition_table.set_transitions(e)}set_view(e){const t=this.get(e);this.transition_handler.set_state(t)}get_current_view(){return this.transition_handler.current_state}get_view_by_name(e){console.warn("DEPRECATED. Use ViewManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return this.views[t];console.error("[ViewManager.get] no view found for: ",e)}get_view_by_url(e){console.warn("DEPRECATED. Use ViewManager.get_by_url instead"),this.get_by_url(e)}get_by_url(e){for(let t=0;t<this.views.length;t++)if(this.views[t].url===e)return this.views[t];console.error("[ViewManager.get_by_url] no view found for: ",e)}set_initial_state_data(e){this.transition_table.set_initial_state_data(e),this.transition_handler.set_initial_state_data(e)}__change_browser_url(e){window.history.pushState("","",e)}__set_views_opacities(){for(let e=0;e<this.views.length;e++)this.views[e].set_opacity(this.transition_handler.current_state_data)}};class je extends Ue{constructor({name:e,url:t,container:s}){super(e),this.container=s,this.url=t;const i=[{to:e,data:(new Re).parse(De.get(`${e}_data`))}];Oe.register_view(this),Oe.add_transitions(i)}show(){this.container.classList.add("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}on_enter(){this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}before_exit(){this.container.classList.add("before_exit"),this.container.classList.remove("before_enter"),this.container.classList.remove("hidden")}hide(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")}set_opacity(e){this.container.style.opacity=e[`${this.name}_opacity`]}}class Ie{on_post_start(){}on_enter(){}on_exit(){}update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}}class Ne{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}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;}",Be="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class qe extends i{constructor(e,t,s){super({vertexShader:e||Ve,fragmentShader:t||Be,uniforms:s||{_Color:{value:new r("#FF0000")}}})}}class Ge extends i{constructor(e,t,i){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})}}var Ye=new class{init(){this._current=void 0}set current(e){this._current=e}get current(){return this._current}};var Ee=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class We{constructor(e){this.uses_dynamic_font=e,this.__textHeight=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}getFontHeight(e="Arial"){if(null==this.__textHeight||this.uses_dynamic_font){const t=document.getElementsByTagName("body")[0],s=document.createElement("div"),i=document.createTextNode("MÉqgOLAKTAL");s.appendChild(i),s.setAttribute("style",`font:${e};position:absolute;top:0;left:0`),t.appendChild(s),this.__textHeight=s.offsetHeight,t.removeChild(s)}return this.__textHeight}get_text_size(e,t="24px Arial"){const 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}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 a(s,_,l,l,h,h);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()}}var Xe=new class{init(e={}){this.dpr=1,this.app={}}from_json(e){}};class Qe{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class He{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(t){this.t+=Le.delta_time/t.duration,this.easing_function_t=t.easing_function(this.t),this.easing_function_t=e.clamp(this.easing_function_t,0,1),t.set_property_value(e.lerp(t.from,t.to,this.easing_function_t)),this.easing_function_t>=.9999&&(t.set_property_value(t.to),t.set_current_state(new Qe),t.finished_callback(t))}on_exit(e){}}class Ze{constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n="",value_suffix:o="",easing_function:a=Te.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 Qe}animate(){this.set_current_state(new He)}stop(){this.set_current_state(new Qe)}set_property_value(e){this.element.style[this.css_property]=`${this.value_prefix}${e}${this.value_suffix}`}update(){this.current_state.update(this)}get is_animating(){return this.current_state.is_animating}set_current_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}}class Je extends c{constructor(e=1){super();const t=[];t.push(new u(0,0,0)),t.push(new u(0,0,1e3));const s=new d({color:4474111,depthFunc:o}),i=(new m).setFromPoints(t),r=new p(i,s);r.renderOrder=5e4;const n=[];n.push(new u(0,0,0)),n.push(new u(0,1e3,0));const a=new d({color:4521796,depthFunc:o}),_=(new m).setFromPoints(n),l=new p(_,a);l.renderOrder=5e4;const h=[];h.push(new u(0,0,0)),h.push(new u(1e3,0,0));const c=new d({color:16729156,depthFunc:o}),g=(new m).setFromPoints(h),v=new p(g,c);v.renderOrder=5e4,this.renderOrder=1e5,this.add(r),this.add(l),this.add(v),this.scale.set(e,e,e)}update(){}dispose(){}}var $e=new class{init(){this._current=new g,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 Ke extends v{constructor(e,t,s){e=e||new u(1,1,1),t=t||new u(1,1,1),s=s||16711680;super(new f(e.x,e.y,e.z,t.x,t.y,t.z),new x({color:s}))}}class et extends v{constructor(e,t){t=t||"#FF0000";super(new w(e=e||1,64,64),new x({color:t}))}}class tt extends v{constructor(e,t,s){e=e||"#FF0000";const i=(t=t||1)-.4,r=new b(.01,.01,i,32);r.translate(0,i/2,0);const n=new y(.1,.4,32);n.translate(0,i+.2,0);const o=he.mergeBufferGeometries([r,n]);o.rotateX(1.57);super(o,new x({color:e})),s&&this.quaternion.setFromUnitVectors(new u(0,0,1),s),this._dir=s}set dir(e){this.quaternion.setFromUnitVectors(new u(0,0,1),e),this._dir=e}get dir(){return this._dir}set length(e){this.scale.z=e}get length(){return this.scale.z}}var st=new class{init(){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)}update_position(e,t){this.position.set(e,t)}update(){this.size_changed=!1}update_size(e,t){this.width=e,this.height=t,this.pixel_size=new 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}apply_pixel_density_v2(e){return e.multiplyScalar(1/this.dpr),e}apply_pixel_density(e){return e*(1/this.dpr)}get_pixel_size(){return this.pixel_size}get aspect_ratio(){return this.width/this.height}};class it extends qe{constructor(e,t,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 s},_ScreenSize:{value:new s},_TextureSize:{value:new s}})}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 rt extends T{constructor(e,t,s,i){super(e,t,s,i),this.clear_color=new r("#000000"),this.clear_alpha=1}}var nt=new class{init(){this.Vector3_one=new u(1,1,1),this.Vector3_zero=new u(0,0,0),this.canvas_renderer=void 0,this.display_texture_meshes=[],this.ctx=void 0,this.scene=new g,this.camera=new rt}draw_arrow(e,t,s=16711680){const i=new tt(s,t.length(),t.clone().normalize());return i.position.copy(e),$e.current.add(i),i}draw_axis(){const e=new Je;return $e.current.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 d({color:t}),i=(new m).setFromPoints(e),r=new p(i,s);return r.frustumCulled=!1,$e.current.add(r),r}draw_cube(e,t,s){t=t||1,s=s||16711680,e=e||new u;const i=new Ke(new u(t,t,t),void 0,s);return i.position.copy(e),$e.current.add(i),i}draw_oriented_cube(e,t,s=1,i="#FF0000",r=.1){const n=e.distanceTo(t),o=new Ke(new u(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 u(0,0,-1),_),$e.current.add(o),o}draw_plane(e,t,s){const r=new M(e,t),n=new i({uniforms:{_Color:{value:new S(0,1,0,.2)}},vertexShader:Ve,fragmentShader:Be,transparent:!0,depthWrite:!1}),o=new v(r,n);return o.renderOrder=-1e4,$e.current.add(o),o}draw_empty_cube(e,t,s){t=t||1,s=s||16711680;const i=(new z).setFromCenterAndSize(new u,new u(t,t,t)),r=new F(i,s);return r.position.copy(e||new u),r}draw_sphere(e,t,s){t=t||1,s=s||16711680,e=e||new u;const i=new et(t,s);return i.position.copy(e),$e.current.add(i),i}draw_point_array(e,t=!1,s=16711680){const i=new R(e,t);i.updateArcLengths();const r=i.getSpacedPoints(200);return this.draw_line(r,65280)}draw_sphere_helper(e,t){t=t||16711680;const s=new A(e.radius,32,32),i=new x({color:t}),r=new v(s,i);return r.position.copy(e.center),$e.current.add(r),r}draw_math_sphere(e){const t=new A(e.radius,32,32),s=new i({uniforms:{_Color:{value:new S(1,0,0,.2)}},vertexShader:Ve,fragmentShader:Be,transparent:!0}),r=new v(t,s);r.position.copy(e.center),$e.current.add(r)}draw_bounding_box(e){const t=new F(e,16776960);$e.current.add(t)}draw_curve(e,t){const s=new u(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 v(new M(1,1),new it);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(st.width,st.height);this.scene.children.length>0&&e.render(this.scene,this.camera)}};class ot 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 S(e,t.x,t.y,t.z)}}}class at extends i{constructor(){super({uniforms:{_FarPlane:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;v_normal=(modelViewMatrix*vec4(normal,0.0)).xyz;v_pos=(modelViewMatrix*vec4(pos,1.0)).xyz;gl_Position=MVP*vec4(pos,1.0);}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;uniform float _FarPlane;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(length(v_pos.z)/_FarPlane),EncodeNormal(normalize(v_normal)));}"})}set far_plane(e){this.uniforms._FarPlane.value=e}get far_plane(){return this.uniforms._FarPlane.value}}class _t{constructor(){this.RT=new C(st.width,st.height),this.clear_depth_normal_mat=new ot(1,new u(0,0,1)),this.depth_normal_material=new at}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=Ye.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===st.width&&this.RT.height===st.height||this.RT.setSize(st.width,st.height)}get render_target(){return this.RT}}class lt{constructor(e){this.renderer=e,this._blit_scene=new g,this._blit_material=new Ge,this._blit_quad=new v(new M(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new D(-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)}}var ht=new class{init(e,t){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.context_attributes={alpha:!0,depth:!0,desynchronized:!1,stencil:!1,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1},Object.assign(this.context_attributes,t),t.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,this._renderer=new P({canvas:e,context:this.canvas_context}),this._renderer.autoClear=!1,this._renderer.setPixelRatio(1),st.dpr=Xe.dpr,this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new lt(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new Ne,this.current_render_mode=this.no_render,Ee.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),Ee.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,Ee.fp_textures_available=this._renderer.capabilities.floatVertexTextures,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)}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(),Ye.current&&this.current_render_mode.render(),st.update()}__update_current_camera(){Ye.current&&(Ye.current.aspect=st.aspect_ratio,Ye.current.updateProjectionMatrix(),Ye.current.updateMatrix(),Ye.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||$e.current,t||Ye.current),this.__apply_override_material(e,void 0)}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:$e.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){for(const t of e)st.dpr=Xe.dpr,st.update_position(t.contentRect.x,t.contentRect.y),st.update_size(t.contentRect.width,t.contentRect.height),this.canvas.width=st.render_width,this.canvas.height=st.render_height,this._renderer.setViewport(0,0,st.render_width,st.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=st.width,s=st.height){const i=st.width,r=st.height,n=t,o=s,a=1024,_=1024,l=parseInt(Math.ceil(n/a)),h=parseInt(Math.ceil(o/_));st.update_size(a,_),this._renderer.setPixelRatio(1),this._renderer.setSize(a,_,!1);const c=document.createElement("canvas").getContext("2d");c.canvas.width=n,c.canvas.height=o,Ye.current.aspect=st.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,st.width*e,st.height*t,st.width,st.height),this.current_render_mode.render(),c.drawImage(this._renderer.domElement,st.width*e,st.height*t);c.canvas.toBlob(e,"image/png;base64;"),Ye.current.clearViewOffset(),st.update_size(i,r),this._renderer.setPixelRatio(Xe.dpr),this._renderer.setSize(i,r,!1),Ye.current.aspect=st.aspect_ratio,Ye.current.updateMatrix(),Ye.current.updateMatrixWorld(!0)}download_screenshot(e){const t=document.createElement("a");t.download="Snapshot.png",t.href=URL.createObjectURL(e),t.click(),t.onclick=function(){requestAnimationFrame((function(){URL.revokeObjectURL(t.href)})),t.removeAttribute("href")}}dispose(){this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose()}};class ct extends i{constructor(){super({uniforms:{},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);v_normal=(modelMatrix*vec4(normal,0.0)).xyz;}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_FragColor=vec4(v_normal*0.5+vec3(0.5),1.0);}"})}}class ut extends Ne{constructor(){super()}render(){ht.clear(void 0,Ye.current,!0,!0),ht.render($e.current,Ye.current,void 0,new ct)}}var dt=new class extends ce{constructor(){super(),this.left_mouse_button_clicked=!1,this.captured_NDC={x:0,y:0}}clear(){super.clear(),this.left_mouse_button_clicked=!1}};var mt=new class{init(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"},this.is_mobile=!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/),this.is_ipad=!!(navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2),this.is_ios=!!navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad,this.is_android=this.get_os()===this.operating_systems.ANDROID,this.is_linux=this.get_os()===this.operating_systems.LINUX,this.is_mac=this.get_os()===this.operating_systems.MAC,this.is_windows=this.get_os()===this.operating_systems.WINDOWS}get_os(){const e=window.navigator.userAgent,t=window.navigator.platform;let s=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?s=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?s=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?s=this.operating_systems.WINDOWS:/Android/.test(e)?s=this.operating_systems.ANDROID:!s&&/Linux/.test(t)&&(s=this.operating_systems.LINUX),s}};var pt=new class{init(){this.target_geometry=void 0,this.target_position=new u}set_target_geometry(e){this.target_geometry=e}};class gt{constructor(e,t){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=t,this.data_textures=[],this.object_names=void 0,this.zero_offset=new s,this.write_offset=new s,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(e,t,s){this.material=new i({uniforms:this.uniforms,vertexShader:t,fragmentShader:s}),this.object_names=e}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){const s=this.__create_rgb_texture(this.batch_width),i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){const s=this.__create_rgba_texture(this.batch_width),i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){const s=this.__create_rgba_float_texture(this.batch_width),i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,s,i,r,n){const o=this.__get_object_index(e),a=this.__get_data_texture(t);this.__set_pixel_rgb(a.src,o,s,i,r,n),this.__set_pixel_rgb(a.one_pixel,0,s,i,r,n),a.last_accessed_index=o,a.dirty_count++}set_object_uniform_v4(e,t,s,i,r,n,o){const a=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,a,s,i,r,n,o),this.__set_pixel_rgba(_.one_pixel,0,s,i,r,n,o),_.last_accessed_index=a,_.dirty_count++}upload_texture_data(e,t){for(let s=0;s<this.data_textures.length;s++)t>0&&this.data_textures[s].dirty_count>0&&(1===this.data_textures[s].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){const s=t.last_accessed_index;-1!==s&&(this.write_offset.y=Math.floor(s/this.batch_width),this.write_offset.x=s-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new v(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,U)}__create_rgba_texture(e){const t=new Uint8Array(4*e*e);return new L(t,e,e,k)}__create_rgba_float_texture(e){const t=new Float32Array(4*e*e);return new L(t,e,e,k,O)}__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()}}var vt=new class{init(){this.batches=[]}batch(t){const s=[],i=e.ceilPowerOfTwo(Math.sqrt(t.length));this.__init_uv_array(s,i);let r=0;for(let e=0;e<t.length;e++){const n=t[e].getAttribute("position").count,o=Math.floor(e/i),a=e-i*o;for(let e=0;e<n;e++)s[r]=a/i+.5/i,s[r+1]=o/i+.5/i,r+=2}const n=new j(new Float32Array(s),2),o=he.mergeBufferGeometries(t);return o.setAttribute("attr_accessor_uv",n),this.batches.push(new gt(o,i)),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)}};var ft=new class{init(){this.ui_elements=[],this._tmp_normalized_pos=new s,this.ss_scene=new g,this.ss_scene.autoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new g,this.ws_scene.autoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new D(-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(dt.NDC);for(let e=0;e<this.ui_elements.length;e++)this.ui_elements[e].update_state(this._tmp_normalized_pos)}render(e){this.ss_scene.children.length>0&&ht.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&ht.render(this.ws_scene,Ye.current)}clear(){this.current_clicked_element=void 0}};class xt{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=new u,i=[];for(let r=0;r<e.length;r++)t.projectPoint(e[r],s),i.push(s.clone());return i}static matrix4_lerp(t,s,i,r){for(let n=0;n<16;n++)i.elements[n]=e.lerp(t.elements[n],s.elements[n],r)}static equals(e,t){return Math.abs(e-t)<1e-6}static lerp(e,t,s){return(1-s)*e+s*t}static clamp(e,t,s){return Math.max(t,Math.min(s,e))}static euclideanModulo(e,t){return(e%t+t)%t}static pingpong(e,t=1){return t-Math.abs(xt.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 xt.clamp(e,0,1)}}var wt=new class{init(){this.tmp_mat=new I,this.plane=new N,this.ray=new V,this.tmp_size=new u,this.tmp_unproj=new u}get_up_dir(e){e=e||Ye.current;const t=new u;return t.set(0,1,0),t.applyQuaternion(e.quaternion),t}get_forward_dir(e){e=e||Ye.current;const t=new u;return t.set(0,0,-1),t.applyQuaternion(e.quaternion),t}get_right_dir(e){e=e||Ye.current;const t=new u;return t.set(1,0,0),t.applyQuaternion(e.quaternion),t}unproject_mouse_position(e,t){t=t||Ye.current;const s=new u,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||Ye.current,s=s||dt.NDC;const r=new u;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 B).setFromPoints(e).center,i=this.get_forward_dir(Ye.current).clone(),r=(new N).setFromNormalAndCoplanarPoint(i,s),n=xt.project_points_on_plane(e,r),o=new u;let a=(new z).setFromPoints(n);a.getCenter(o);const _=new u(0,1,0).applyQuaternion(Ye.current.quaternion),l=_.clone().cross(i).normalize(),h=(new I).set(l.x,_.x,i.x,s.x,l.y,_.y,i.y,s.y,l.z,_.z,i.z,s.z,0,0,0,1),c=(new I).getInverse(h);for(let e=0;e<n.length;e++)n[e].applyMatrix4(c);const d=new u;a=(new z).setFromPoints(n),a.getSize(d),d.multiplyScalar(t);const m=new u;return a.getCenter(m),{position:o,zoom:this.get_zoom_to_fit_rect(d.x/2,d.y/2)}}get_zoom_to_fit_rect(e,t){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))}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 st.aspect_ratio/i>1?st.height/s:st.width/t}{const t=new u;return e.getSize(t),this.get_zoom_to_fit_rect(t.x,t.y)}}get_html_screen_pos(e,t){t=t||Ye.current;const s=new u;return e.getWorldPosition(s),s.project(t),s.x=(.5*s.x+.5)*st.width,s.y=(1-(.5*s.y+.5))*st.height,s}world_pos_to_screen(e,t){t=t||Ye.current;const s=new u;return s.copy(e),s.project(t),s.x=(.5*s.x+.5)*st.width,s.y=(1-(.5*s.y+.5))*st.height,s}update_projection(e){e.left=-st.width/2,e.right=st.width/2,e.top=st.height/2,e.bottom=-st.height/2,e.aspect=st.aspect_ratio,e.updateProjectionMatrix(!0)}};var bt=new class{constructor(){}init(e,t,s){Ye.init(),wt.init(),Ee.init(),Xe.init(),Ce.init(),vt.init(),dt.init(t),mt.init(),xe.init(),pt.init(),De.init(),$e.init(),st.init(),Le.init(),ft.init(),ht.init(e,s),nt.init()}dispose(e){ht.dispose(),dt.dispose(),$e.dispose(),e.dispose()}},yt="#define GLSLIFY 1\nvarying vec2 vUv;varying vec4 vRay;uniform mat4 _InverseProjMatrix;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vRay=_InverseProjMatrix*vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}";class Tt extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}",yt),this.uniforms._InverseProjMatrix={value:new I},this.uniforms._ProjectionMatrix={value:new I},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 t=[];for(let s=0;s<64;s++){const i=new u(2*Math.random()-1,2*Math.random()-1,Math.random());i.normalize();let r=s/64;r=e.lerp(.1,1,r*r),i.multiplyScalar(r),t.push(i)}return t}__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,U);return t.wrapS=q,t.wrapT=q,t.needsUpdate=!0,t}}class Mt 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 St extends Ge{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}",yt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new I}}}class zt 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 s}}}class Ft{constructor(e){this.RT1=new C(1,1),this.RT2=new C(1,1),this.box_blur_mat=new zt}blur(e){e.width===this.RT1.width&&e.height===this.RT1.height||(this.RT1.setSize(e.width,e.height),this.RT2.setSize(e.width,e.height)),this.box_blur_mat.uniforms._SampleDir.value.set(1,0),ht.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),ht.blit(this.RT1,e,this.box_blur_mat)}}class Rt extends Ne{constructor(){super(),this.ssao_mat=new Tt,this.ssao_compose_mat=new Mt,this.debug_normals=new St,this.ssaa=Xe.use_ssaa?2:1,this.main_RT=new C(st.width*this.ssaa,st.height*this.ssaa),this.SSAO_RT=new C(st.width,st.height),this.blurrer=new Ft,ht.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),ht.clear(this.main_RT,Ye.current,!0,!1),ht.render($e.current,Ye.current,this.main_RT),this.__update_uniforms(),ht.blit(ht.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),ht.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,ht.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(Ye.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(Ye.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=Ye.current.far}__check_RT_size(){this.main_RT.width===st.width*this.ssaa&&this.main_RT.height===st.height*this.ssaa||(this.main_RT.setSize(st.width*this.ssaa,st.height*this.ssaa),this.SSAO_RT.setSize(st.width,st.height))}}class At extends Ne{constructor(){super()}render(){ht.clear(void 0,Ye.current,!0,!0),$e.current.on_pre_render&&$e.current.on_pre_render(),$e.current.render?$e.current.render():ht.render($e.current,Ye.current),$e.current.on_post_render&&$e.current.on_post_render()}}class Ct extends Ge{constructor(e){super("#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D blurTexture1;uniform sampler2D blurTexture2;uniform sampler2D blurTexture3;uniform sampler2D blurTexture4;uniform sampler2D blurTexture5;uniform float bloomStrength;uniform float bloomRadius;uniform float bloomFactors[NUM_MIPS];uniform vec3 bloomTintColors[NUM_MIPS];float lerpBloomFactor(const in float factor){float mirrorFactor=1.2-factor;return mix(factor,mirrorFactor,bloomRadius);}void main(){gl_FragColor=bloomStrength*(lerpBloomFactor(bloomFactors[0])*vec4(bloomTintColors[0],1.0)*texture2D(blurTexture1,vUv)+lerpBloomFactor(bloomFactors[1])*vec4(bloomTintColors[1],1.0)*texture2D(blurTexture2,vUv)+lerpBloomFactor(bloomFactors[2])*vec4(bloomTintColors[2],1.0)*texture2D(blurTexture3,vUv)+lerpBloomFactor(bloomFactors[3])*vec4(bloomTintColors[3],1.0)*texture2D(blurTexture4,vUv)+lerpBloomFactor(bloomFactors[4])*vec4(bloomTintColors[4],1.0)*texture2D(blurTexture5,vUv));}",void 0,{NUM_MIPS:e}),this.uniforms._MainTex={value:void 0},this.uniforms._BlurredTex={value:void 0},this.uniforms._BloomStrength={value:1},this.uniforms.blurTexture1={value:null},this.uniforms.blurTexture2={value:null},this.uniforms.blurTexture3={value:null},this.uniforms.blurTexture4={value:null},this.uniforms.blurTexture5={value:null},this.uniforms.bloomStrength={value:1},this.uniforms.bloomFactors={value:[1,.8,.6,.4,.2]},this.uniforms.bloomRadius={value:0};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 Dt extends Ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}class Pt extends Ge{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new s(.5,.5)},this.uniforms.direction={value:new s(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class Lt extends Ge{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec3 defaultColor;uniform float defaultOpacity;uniform float luminosityThreshold;uniform float smoothWidth;varying vec2 vUv;void main(){vec4 texel=texture2D(_MainTex,vUv);vec3 luma=vec3(0.299,0.587,0.114);float v=dot(texel.xyz,luma);vec4 outputColor=vec4(defaultColor.rgb,defaultOpacity);float alpha=smoothstep(luminosityThreshold,luminosityThreshold+smoothWidth,v);gl_FragColor=mix(outputColor,texel,alpha);}"),this.uniforms.luminosityThreshold={value:.23},this.uniforms.smoothWidth={value:.01},this.uniforms.defaultColor={value:new r("#000000")},this.uniforms.defaultOpacity={value:0}}}class Ut{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:G,magFilter:G,format:k},this.renderTargetBright=new C(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Lt}blur(e,t){this.resize_RT(e.width,e.height),t?ht.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):ht.blit(e,this.renderTargetBright);let s=this.renderTargetBright;for(let e=0;e<this.nMips;e++){const t=this.separableBlurMaterials[e];t.set_direction(1,0),ht.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),ht.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),s=this.renderTargetsVertical[e]}}get_blurred_texture(){return this.renderTargetsHorizontal[0].texture}get_blurred_RT(){return this.renderTargetsHorizontal[0]}init_RT(){this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(let e=0;e<this.nMips;e++){const e=new C(1,1,this.rt_pars),t=new C(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,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 Pt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class kt extends Ne{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new Dt}on_enter(){this.blurrer=new Ut,this.main_RT=new C(st.render_width,st.render_height),this.blur_RT=new C(st.render_width,st.render_height),this.bloom_compose_mat=new Ct(5),this.blurrer=new Ut(5),this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture),this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture),this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture),this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture),this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture),this.bloom_compose_mat.set_bloom_strength(1),this.bloom_compose_mat.set_bloom_radius(1),this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture)}set_bloom_strength(e){this.bloom_compose_mat.set_bloom_strength(e)}set_bloom_radius(e){this.bloom_compose_mat.set_bloom_radius(e)}set_tint_color_0(e){this.bloom_compose_mat.set_tint_color_0(e)}set_tint_color_1(e){this.bloom_compose_mat.set_tint_color_1(e)}set_tint_color_2(e){this.bloom_compose_mat.set_tint_color_2(e)}set_tint_color_3(e){this.bloom_compose_mat.set_tint_color_3(e)}set_tint_color_4(e){this.bloom_compose_mat.set_tint_color_4(e)}render(){this.__check_RT_size(),ht.clear(this.main_RT,Ye.current,!0,!1),ht.render($e.current,Ye.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),ht.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),ht.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===st.render_width&&this.main_RT.height===st.render_height||(this.main_RT.setSize(st.render_width,st.render_height),this.blur_RT.setSize(st.render_width,st.render_height))}}class Ot extends D{constructor(e,t,s,i,n,o){super(e,t,s,i,n,o),this.clear_color=new r("#000000"),this.clear_alpha=1}}var jt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(Oe.transition_handler.current_state_data)}register_component(e){this.components.push(e)}enable_component(e){this.enabled_components.add(e)}disable_component(e){this.enabled_components.delete(e)}get_component_by_name(e){console.warn("DEPRECATED. Use ViewComponentManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.components.length;t++)if(this.components[t].name===e)return this.components[t];console.error("[ViewComponentManager.get] no component found for: ",e)}__set_components_opacities(){for(let e=0;e<this.components.length;e++)this.components[e].set_opacity(Oe.transition_handler.current_state_data)}};class It{constructor(e,t){e=e||new Ie,this._frame_id=-1,this.target_application=e,this.graphics=t,this.is_running=!1,this.frames_passed=0}update(){this.is_running&&(Le.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.target_application.update(),Oe.update(),jt.update(),this.target_application.on_pre_render(),this.graphics.update(),ft.update(),ft.render(this.graphics),this.target_application.on_post_render(),nt.render(this.graphics),this._frame_id=requestAnimationFrame(this.update.bind(this)),this.target_application.on_frame_end(),this.frames_passed++,dt.clear(),ft.clear(),nt.clear())}start(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(),this.is_running=!0,this.update())}stop(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(),cancelAnimationFrame(this._frame_id))}set_state(e){this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this)}dispose(){this.stop(),this.frames_passed=0}}class Nt extends We{constructor(){super(),this.text_margin=new s(2,0)}__draw(e,t,s,i){i.font=t.font;const r=this.get_text_size(e,t.font);s.width=Math.ceil(r.x+2*this.text_margin.x),s.height=Math.ceil(r.y+2*this.text_margin.y),i.clearRect(0,0,s.width,s.height),i.globalAlpha=0,i.fillStyle=t.font_color||"#000000",i.fillRect(0,0,s.width,s.height),i.globalAlpha=1,i.globalAlpha=1,i.font=t.font,i.fillStyle=t.font_color||"#000000",i.textBaseline="middle",i.textAlign=t.textAlign||"center","center"===i.textAlign?i.fillText(e,s.width/2,s.height/2):i.fillText(e,0,s.height/2)}}class Vt{constructor({name:e,container:t}){this.name=e,this.container=t,this.hidden=!0,jt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),jt.enable_component(this),this.hidden=!1}update(){}on_exit(){this.container.classList.add("hidden"),jt.disable_component(this),this.hidden=!0}set_opacity(e){this.container.style.opacity=e[`${this.name}_opacity`],this.toggle_hidden()}toggle_hidden(){this.container.style.opacity>.001?this.hidden&&this.on_enter():this.hidden||this.on_exit()}}class Bt extends v{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new x({color:s});const r=new M(e,t);r.rotateX(-1.57),super(r,i)}}class qt extends v{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new x({color:s});super(new M(e,t),i)}}class Gt{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 Yt{constructor(){this.sphere=new B}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 u(0,0,-1).applyQuaternion(t),c=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,s,i),m=c.clone().add(h.clone().multiplyScalar(-1*d)),p=(new N).setFromNormalAndCoplanarPoint(o,m),g=(new N).setFromNormalAndCoplanarPoint(a,m),v=(new N).setFromNormalAndCoplanarPoint(_,m),f=(new N).setFromNormalAndCoplanarPoint(l,m);this.apply_center_correction_to_pos(m,e,t,p,g,v,f),p.setFromNormalAndCoplanarPoint(o,m),g.setFromNormalAndCoplanarPoint(a,m),v.setFromNormalAndCoplanarPoint(_,m),f.setFromNormalAndCoplanarPoint(l,m);let x=1/0;const w=h.clone().multiplyScalar(-2*d);for(let t=0;t<e.length;t++){const s=new Y(e[t].clone(),e[t].clone().add(w)),i=new u,r=new u,n=new u,o=new u;p.intersectLine(s,i),g.intersectLine(s,r),v.intersectLine(s,n),f.intersectLine(s,o),i.length()<1e-4&&console.log("up intersection not found",t),r.length()<1e-4&&console.log("down intersection not found",t),n.length()<1e-4&&console.log("left intersection not found",t),o.length()<1e-4&&console.log("right intersection not found",t);const a=e[t].clone().sub(i).length(),_=e[t].clone().sub(r).length(),l=e[t].clone().sub(n).length(),h=e[t].clone().sub(o).length(),c=Math.min(a,_),d=Math.min(l,h),m=Math.min(c,d);m<x&&(x=m)}const b=h.clone().multiplyScalar(x);return m.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 u(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new Y(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new Y(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),c=new u,d=new u;t.intersectLine(l,c),s.intersectLine(h,d);const m=c.distanceTo(e[i]),p=d.distanceTo(e[i]);d.length()<1e-4&&console.log("vertical up intersection not found",i),c.length()<1e-4&&console.log("vertical down intersection not found",i),m<a&&(a=m,n=e[i]),p<o&&(o=p,r=e[i])}console.log(r,n);const l=(o-a)/2;return _.clone().multiplyScalar(-l)}get_hozirontal_correction(e,t,s,i){let r,n,o=1/0,a=1/0;const _=new u(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const l=new Y(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(-5e6))),h=new Y(e[i].clone(),e[i].clone().add(_.clone().multiplyScalar(5e6))),c=new u,d=new u;t.intersectLine(l,c),s.intersectLine(h,d);const m=c.distanceTo(e[i]),p=d.distanceTo(e[i]);c.length()<1e-4&&console.log("left intersection not found",i),d.length()<1e-4&&console.log("right intersection not found",i),m<a&&(a=m,n=e[i]),p<o&&(o=p,r=e[i])}const l=(o-a)/2;return console.log(r,n),_.clone().multiplyScalar(-l)}get_up_plane_normal(e,t){const s=new u(0,-1,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new u(0,1,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new u(1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new u(-1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(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 Et{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 m;return r.setAttribute("position",new j(new Float32Array(i),3)),Et.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 j(new Float32Array(t),3))}}class Wt{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 S(r[i+0],r[i+1],r[i+2],r[i+3])}}var Xt=new class{constructor(){}sample(e,t){const s=[];let i=99999999;const r=e.getAttribute("position"),n=e.getAttribute("normal"),o=e.index,a=[];for(let e=0;e<o.count;e+=3){const t=o.array[e+0],_=o.array[e+1],l=o.array[e+2],h=new u;h.x=r.getX(t),h.y=r.getY(t),h.z=r.getZ(t);const c=new u;c.x=r.getX(_),c.y=r.getY(_),c.z=r.getZ(_);const d=new u;d.x=r.getX(l),d.y=r.getY(l),d.z=r.getZ(l);const m={a:h,b:c,c:d};if(n){const e=new u;e.x=n.getX(t),e.y=n.getY(t),e.z=n.getZ(t);const s=new u;s.x=n.getX(_),s.y=n.getY(_),s.z=n.getZ(_);const i=new u;i.x=n.getX(l),i.y=n.getY(l),i.z=n.getZ(l);const r=e.clone().add(s).add(i).normalize();m.normal=r}a.push(m);const p=this.get_face_area(m);i=Math.min(p,i),s.push(p)}const _=this.get_uniform_face_distribution(s,i,a),l=this.select_random_faces(_,t);return this.sample_data_from_faces(l)}sample_data_from_faces(e){const t=[],s=[];for(let i=0;i<e.length;i++){const r=e[i],n=Math.random(),o=Math.random();t.push(this.sample_point_in_face(n,o,r.a,r.b,r.c).clone()),r.normal&&s.push(r.normal.clone())}return{points:t,normals:s}}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))}};var Qt=new class{get_mesh(e,t){e.traverse((e=>{e instanceof v&&(e.geometry&&(e.geometry=(new m).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 v&&(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 W(o,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,s){e.traverse((e=>{e instanceof v&&(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 Ht{constructor(){}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 Zt{constructor(){}static capitalize(e){const t=e.split(" ");for(let e=0;e<t.length;e++)t[e]=t[e][0].toUpperCase()+t[e].substr(1);return t.join(" ")}static capitalize_first_letter(e){return e.charAt(0).toUpperCase()+e.slice(1)}static snake_to_camelcase(e){return e.replace(/([-_][a-z])/g,(e=>e.toUpperCase().replace("-","").replace("_","")))}}class Jt{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 $t{constructor(){this.sphere=new B}fit_points(t,s,i,r){this.sphere.setFromPoints(t);const n=e.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 u(0,0,-1).applyQuaternion(s),d=this.sphere.center.clone(),m=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),p=d.clone().add(c.clone().multiplyScalar(-1*m)),g=(new N).setFromNormalAndCoplanarPoint(a,p),v=(new N).setFromNormalAndCoplanarPoint(_,p),f=(new N).setFromNormalAndCoplanarPoint(l,p),x=(new N).setFromNormalAndCoplanarPoint(h,p);this.apply_center_correction_to_pos(p,t,s,g,v,f,x),g.setFromNormalAndCoplanarPoint(a,p),v.setFromNormalAndCoplanarPoint(_,p),f.setFromNormalAndCoplanarPoint(l,p),x.setFromNormalAndCoplanarPoint(h,p);let w=1/0;const b=c.clone().multiplyScalar(-2*m);for(let e=0;e<t.length;e++){const s=new Y(t[e].clone(),t[e].clone().add(b)),i=new u,r=new u,n=new u,o=new u;g.intersectLine(s,i),v.intersectLine(s,r),f.intersectLine(s,n),x.intersectLine(s,o),i.length()<1e-4&&console.log("up intersection not found",e),r.length()<1e-4&&console.log("down intersection not found",e),n.length()<1e-4&&console.log("left intersection not found",e),o.length()<1e-4&&console.log("right intersection not found",e);const a=t[e].clone().sub(i).length(),_=t[e].clone().sub(r).length(),l=t[e].clone().sub(n).length(),h=t[e].clone().sub(o).length(),c=Math.min(a,_),d=Math.min(l,h),m=Math.min(c,d);m<w&&(w=m)}const y=c.clone().multiplyScalar(w);return p.clone().add(y)}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 u(0,1,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new Y(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new Y(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new u,h=new u;t.intersectLine(a,l),s.intersectLine(_,h);const c=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),c<n&&(n=c),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 u(1,0,0).applyQuaternion(i);for(let i=0;i<e.length;i++){const a=new Y(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(-5e6))),_=new Y(e[i].clone(),e[i].clone().add(o.clone().multiplyScalar(5e6))),l=new u,h=new u;t.intersectLine(a,l),s.intersectLine(_,h);const c=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),c<n&&(n=c),d<r&&(r=d)}const a=(r-n)/2;return o.clone().multiplyScalar(-a)}get_up_plane_normal(e,t){const s=new u(0,-1,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(1,0,0),t)),s.applyQuaternion(e),s}get_down_plane_normal(e,t){const s=new u(0,1,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(1,0,0),-t)),s.applyQuaternion(e),s}get_left_plane_normal(e,t){const s=new u(1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(0,1,0),t)),s.applyQuaternion(e),s}get_right_plane_normal(e,t){const s=new u(-1,0,0);return s.applyQuaternion((new E).setFromAxisAngle(new u(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 Kt{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 z).setFromPoints(n),a=new u;o.getSize(a);const _=this.get_distance_to_fit_rect(a.x/2,a.y/2,s,i),l=new u;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))}}class es extends v{constructor(){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 M(100,100,100,100);super(Et.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57}}class ts extends v{constructor(e){const t=new m;t.setAttribute("position",new j(new Float32Array([]),3)),t.setAttribute("next_position",new j(new Float32Array([]),3)),t.setAttribute("previous_position",new j(new Float32Array([]),3)),t.setAttribute("orientation",new j(new Float32Array([]),1)),t.setAttribute("coverage",new j(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)}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 j(a,3)),this.geometry.getAttribute("next_position").copy(new j(_,3)),this.geometry.getAttribute("previous_position").copy(new j(l,3)),this.geometry.getAttribute("orientation").copy(new j(h,1)),this.geometry.getAttribute("coverage").copy(new j(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 ss extends v{constructor(e,t){t=t||new s(0,0);const r=new i({uniforms:{_MainTex:{value:e},_ScreenAligned:{value:0},_Scale:{value:1},_Opacity:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;uniform float _ScreenAligned;uniform float _Scale;void main(){vec3 pos=position;mat4 local_to_camera=modelViewMatrix;float scale=_Scale;local_to_camera[0]=mix(modelViewMatrix[0],vec4(1.0*scale,0.0,0.0,0.0),_ScreenAligned);local_to_camera[1]=mix(modelViewMatrix[1],vec4(0.0,1.0*scale,0.0,0.0),_ScreenAligned);local_to_camera[2]=mix(modelViewMatrix[2],vec4(0.0,0.0,1.0*scale,0.0),_ScreenAligned);gl_Position=projectionMatrix*local_to_camera*vec4(pos,1.0);vUv=uv;}",fragmentShader:"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;uniform float _Opacity;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor.a*=_Opacity;}",transparent:!0,depthWrite:!1,side:X}),n=new Q(1,1,1);n.translate(-t.x/2,-t.y/2,0);const o=e.image.width/e.image.height;n.scale(o,1,1),super(n,r),this.current_scale=o,this.geometry.computeBoundingBox(),this.tmp_bb_size=new u,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 is extends ss{constructor(e,t,s,i,r){const n=new Nt(r),o={font:t,font_color:s||"#000000"},a=n.draw_on_texture(e,o);a.minFilter=H,a.minFilter=G,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 rs extends qe{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 s(Screen.width,Screen.height)},_TextureSize:{value:new s},_PixelOffset:{value:new s(0,0)},_NDC:{value:new u},_PivotPoint:{value:new s},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class ns{constructor(){this.tmp_vec=new s}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class os{constructor(){this.tmp_vec3=new u,this.tmp_vec2=new s}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(Ye.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class as{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class _s extends as{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class ls extends as{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 hs extends as{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class cs extends as{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 us extends v{constructor(e,t){super(new Q(1,1),new rs),this.is_clickable=!1,this.position_strategy=new os,this.current_state=new _s,this._position=new u,this._on_idle_state=new _s,this._on_enter_state=new ls,this._on_exit_state=new hs,this._on_hover_state=new cs,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}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 os}set_screen_space_coordinate_system(){this.position_strategy=new ns}set_texture(e){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}update_state(e){this.material.uniforms._ScreenSize.value.set(st.width,st.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 Z).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)*st.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*st.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/st.width*2-1,this.position.y=e.y/st.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),st.remove_screen_material(this.material),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/st.dpr):(new s).copy(this.texture_size).multiplyScalar(this.size/st.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class ds extends v{constructor(e,t){super(e,t);const s=this;this.onBeforeRender=()=>{s.material.update()}}}class ms{constructor(e,t,i){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)}}class ps{constructor(e,t=""){this.glyph_layout=e,this.glyphs=[],this.glyph_is_dirty=!0,this.matrix_is_dirty=!0,this.color_is_dirty=!0,this.position=new u,this.quaternion=new E,this.scale=new u(1,1,1),this.matrix=new I,this.color=new r("#FFFFFF"),this.pivot_point=new s,this.__opacity=1,this.__text=t,this.__generate_glyphs(t)}set text(e){this.__text=e,this.__generate_glyphs(e),this.matrix_is_dirty=!0}get text(){return this.__text}update_matrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrix_is_dirty=!1,this.glyph_is_dirty=!0}clear_glyph_dirty(){this.glyph_is_dirty=!1}clear_color_dirty(){this.color_is_dirty=!1}set_rotation(e=0,t=0){const s=(new E).setFromAxisAngle(new u(0,1,0),e/360*Math.PI*2),i=(new E).setFromAxisAngle(new u(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 t=0;this.glyphs.length=0;for(let s=0;s<e.length;s++){const i=e.charCodeAt(s),r=this.glyph_layout.find((e=>e.unicode===i));if(r){if(r.planeBounds){const e=new ms(t,r.planeBounds,r.atlasBounds);this.glyphs.push(e)}t+=r.advance}}const i=new Z,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++){const t=this.glyphs[e],r=(new Z).setFromCenterAndSize(t.position.clone().add(new s(t.scale.x/2,t.scale.y/2)),t.scale);i.union(r)}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}}class gs extends qe{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 s(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=X,e.minFilter=G,e.magFilter=G,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(t){this.uniforms._Boldness.value=e.lerp(.5,.2,t)}}class vs extends v{constructor(e,t){const i=new J;i.instanceCount=0;const r=new M(1,1);r.translate(.5,.5,0),i.setAttribute("position",new $(r.getAttribute("position").array,3)),i.setAttribute("uv",new $(r.getAttribute("uv").array,2)),i.index=r.index;const n=new K(new Float32Array(8e3),4,!1),o=new K(new Float32Array(8e3),4,!1),a=new K(new Float32Array(8e3),4,!1),_=new K(new Float32Array(8e3),4,!1),l=new K(new Float32Array(8e3),4,!1),h=new K(new Float32Array(8e3),4,!1),c=new K(new Float32Array(8e3),4,!1);n.usage=ee,o.usage=ee,a.usage=ee,_.usage=ee,l.usage=ee,h.usage=ee,c.usage=ee,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 gs(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new s(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){const t=new ps(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){Gt.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,m=u.color,p=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,m.r,m.g,m.b,p),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 fs extends Me{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 xs 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 s(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 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)}}class ws{constructor(e){this.RT=new C(1,1,{type:O,format:k,minFilter:h,magFilter:h}),this.RT1=new C(1,1,{type:O,format:k,minFilter:h,magFilter:h}),this.median_filter_mat=new xs}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),ht.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),ht.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),ht.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new 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)}}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 C(1,1),this.RT1=new C(1,1),this.RT2=new C(1,1),this.RT3=new C(1,1),this.RT4=new C(1,1),this.upscale_blur_mat=new 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),ht.blit(e,this.RT1,this.alpha_filter_mat),ht.blit(this.RT1,this.RT2,this.downscale_blur_mat),ht.blit(this.RT2,this.RT3,this.downscale_blur_mat),ht.blit(this.RT3,this.RT4,this.downscale_blur_mat),ht.blit(this.RT4,this.RT3,this.upscale_blur_mat),ht.blit(this.RT3,this.RT2,this.upscale_blur_mat),ht.blit(this.RT2,e,this.upscale_blur_mat)}check_RT_resize(e,t){this.current_width===e&&this.current_height===t||(this.current_width=e,this.current_height=t,this.RT0.setSize(this.current_width/2,this.current_height/2),this.RT1.setSize(this.current_width/2,this.current_height/2),this.RT2.setSize(this.current_width/4,this.current_height/4),this.RT3.setSize(this.current_width/8,this.current_height/8),this.RT4.setSize(this.current_width/16,this.current_height/16))}}class Ms extends c{constructor(){super(),this.attributes=[],this.particles=void 0}set_from_geometry(e,t,s){if(s&&void 0===e.getAttribute("storage_uv")){const t=this.build_uv_storage_attribute(e.getAttribute("position").count);e.setAttribute("storage_uv",t)}const i=new te(e,t);i.frustumCulled=!1,this.particles=i,this.add(i)}add_texture_attribute(e){}add_attribute(e,t){}build_uv_storage_attribute(e){const t=this.calculate_resolution(e),s=new Float32Array(2*e);for(let i=0,r=0;i<2*e;i+=2,r++)s[i]=r%t/t+.5/t,s[i+1]=Math.floor(r/t)/t+.5/t;return new j(s,2)}calculate_resolution(e){return Math.ceil(Math.sqrt(e))}update(){for(let e=0;e<this.attributes.length;e++)this.attributes[e].update()}set_attribute_update_material(e,t){for(let s=0;s<this.attributes.length;s++)this.attributes[s].name===e&&(this.attributes[s].update_material=t)}dispose(){this.particles.geometry.dispose(),this.particles.material.dispose()}}class Ss 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 zs extends Ss{constructor(e,t){super(new Uint8Array(e*t*3),e,t,U),this.multiplier=255}}class Fs extends Ss{constructor(e,t){super(new Uint8Array(e*t*4),e,t,k),this.multiplier=255}}class Rs extends Ss{constructor(e,t){super(new Float32Array(e*t*3),e,t,U,O)}}class As extends Ss{constructor(e,t){super(new Float32Array(e*t*4),e,t,k,O)}}class Cs extends v{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 zs(this.batch_width,this.batch_height)}attach_rgba_texture(e){this.material.uniforms[e].value=new Fs(this.batch_width,this.batch_height)}attach_rgb_float_texture(e){this.material.uniforms[e].value=new Rs(this.batch_width,this.batch_height)}attach_rgba_float_texture(e){this.material.uniforms[e].value=new As(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 Ds{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=he.mergeBufferGeometries(s),o=new j(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 Cs(e,t,s,i)}}class Ps{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 se(e):this.audio=new ie(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 Ls extends be{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,t){window.user_interaction_for_audio?this.instantiate_audio(e,t):setTimeout(this.on_preloaded_finished.bind(this,e,t),100)}instantiate_audio(e,t){t.arrayBuffer().then((t=>{re.getContext().decodeAudioData(t,(t=>{e.set_resource(this.resource_id,this.url,new Ps(t,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))}))}}class Us extends be{constructor(e,t,s,i,r){super(e,t,r),this.loader=i,this.loader.setWorkerLimit(1),this.loader.setTranscoderPath("libs/basis/"),this.loader.detectSupport(s)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{s.encoding=ne,e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class ks extends be{constructor(e,t,s){super(e,t,s),this.loader=new oe,this.loader.setPath(t+"/"),this.urls=["px.png","nx.png","py.png","ny.png","pz.png","nz.png"]}on_preloaded_finished(e){const t=this;this.loader.load(this.urls,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class Os extends be{constructor(e,t,s){super(e,t,s),this.loader=new ue.ColladaLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class js extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class Is extends be{constructor(e,t,s){super(e,t,s),this.loader=new de}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ns extends be{constructor(e,t,s){super(e,t,s),this.loader=new me.GLTFLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Vs extends be{constructor(e,t,s){super(e,t,s),this.loader=new me.GLTFLoader,this.draco_loader=new pe.DRACOLoader,this.draco_loader.setDecoderPath(window.draco_decoder_path),this.draco_loader.setDecoderConfig({type:"js"}),this.draco_loader.setWorkerLimit(1),this.loader.setDRACOLoader(this.draco_loader)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Bs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ge.HDRCubeTextureLoader,this.url_suffix=["/px.hdr","/nx.hdr","/py.hdr","/ny.hdr","/pz.hdr","/nz.hdr"]}on_preloaded_finished(e){const t=this;this.loader.setPath(this.url).setDataType(_e).load(this.url_suffix,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class qs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,JSON.parse(s)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Gs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ve.OBJLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ys extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,t.parse_path(s)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__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 u(i,r,n))}return s}}class Es extends be{constructor(e,t,s){super(e,t,s),this.loader=new fe.RGBELoader,this.loader.setDataType(_e)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ws extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class Xs extends be{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){t.blob().then((t=>{const s=new le,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()}}))}}class Qs extends be{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){t.blob().then((t=>{e.set_resource(this.resource_id,this.url,URL.createObjectURL(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))}}class Hs{constructor(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}add_loader(e){this.resource_loaders.push(e)}load(e){for(let t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||De)}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{be as AbstractLoader,Fe as ActionEvent,Me as ActionInterpolator,ye as ActionSequencer,Ae as ActionSequencerBuilder,je as ApplicationView,Gt as ArrayUtilities,tt as Arrow,Ls as AudioLoader,Ie as BaseApplication,Ne as BaseRender,qe as BaseShaderMaterial,Us as BasisLoader,Ge as BlitMaterial,Ft as Blurrer,xe as Browser,Ze as CSSAnimator,Ye as CameraManager,wt as CameraUtilities,We as CanvasDrawer,Ee as Capabilities,Xe as Configuration,Ke as Cube,ks as CubemapLoader,Os as DAELoader,nt as Debug,ut as DebugNormalsRender,Re as DrawIOAnimationSheet,bs as DualFilteringBlurMaterial,Ts as DualFilteringBlurrer,Te as EasingFunctions,Ce as EventManager,js as FileLoader,Is as FontLoader,Yt as FrustumPointFitter,Vs as GLTFDRACOLoader,Ns as GLTFLoader,Ms as GPUParticleSystem,Ut as GaussianBlurrer,Et as GeometryUtilities,ht as Graphics,es as Grid,Bs as HDRCubeTextureLoader,Bt as HorizontalPlane,Wt as ImageUtilities,bt as Initializer,dt as Input,qs as JSONLoader,ts as Line,ws as MedianFilter,Ds as MeshBatcher,Xt as MeshSampler,Qt as ModelUtilities,Rt as NormalAORender,At as NormalRender,Se as NumberInterpolator,Gs as OBJLoader,xt as OMath,mt as OS,Ht as ObjectUtilities,Ot as OrthographicCamera,Kt as OrthographicFrustumPointFitter,rt as PerspectiveCamera,$t as PerspectiveFrustumPointFitter,Ys as PointArrayLoader,Es as RGBETextureLoader,It as RenderLoop,Hs as ResourceBatch,De as ResourceContainer,vs as SDFTextBatch,$e as SceneManager,st as Screen,Nt as SimpleTextDrawer,et as Sphere,Zt as StringUtilities,is as Text2D,Ws as TextLoader,Xs as TextureLoader,Le as Time,Jt as TimeUtilities,Pe as TransitionTable,ft as UI,us as UIElement,kt as UnrealBloomRender,ds as UpdatableMaterialMesh,we as Validation,fs as VectorInterpolator,qt as VerticalPlane,Qs as VideoLoader,Vt as ViewComponent,jt as ViewComponentManager,ze as ViewContext,Oe as ViewManager,ss as WorldImage};
|
|
1
|
+
import{Vector3 as e,Math as t,Clock as s,Vector2 as i,ShaderMaterial as r,Color as n,NoBlending as o,AlwaysDepth as a,CanvasTexture as _,UVMapping as l,ClampToEdgeWrapping as h,NearestFilter as c,Object3D as u,LineBasicMaterial as d,BufferGeometry as m,Line as p,Scene as g,Mesh as v,BoxGeometry as f,MeshBasicMaterial as x,SphereBufferGeometry as w,CylinderBufferGeometry as b,ConeBufferGeometry as y,PerspectiveCamera as T,PlaneBufferGeometry as M,Vector4 as S,Box3 as z,Box3Helper as F,CatmullRomCurve3 as R,SphereGeometry as A,WebGLRenderTarget as C,OrthographicCamera as D,WebGLRenderer as P,DataTexture as L,RGBFormat as U,RGBAFormat as k,FloatType as O,BufferAttribute as j,Matrix4 as I,Plane as N,Ray as V,Sphere as B,RepeatWrapping as q,LinearFilter as G,Line3 as Y,Quaternion as E,Skeleton as W,DoubleSide as X,PlaneGeometry as Q,LinearMipMapLinearFilter as H,Box2 as Z,InstancedBufferGeometry as J,Float32BufferAttribute as $,InstancedBufferAttribute as K,DynamicDrawUsage as ee,Points as te,PositionalAudio as se,Audio as ie,AudioContext as re,sRGBEncoding as ne,CubeTextureLoader as oe,FileLoader as ae,UnsignedByteType as _e,Texture as le}from"three";import*as he from"three/examples/jsm/utils/BufferGeometryUtils.js";export{he as BufferGeometryUtils};import{InputController as ce}from"pit-js";import*as ue from"three/examples/jsm/loaders/ColladaLoader.js";import{FontLoader as de}from"three/examples/jsm/loaders/FontLoader.js";import*as me from"three/examples/jsm/loaders/GLTFLoader.js";import*as pe from"three/examples/jsm/loaders/DRACOLoader.js";import*as ge from"three/examples/jsm/loaders/HDRCubeTextureLoader.js";import*as ve from"three/examples/jsm/loaders/OBJLoader.js";import*as fe from"three/examples/jsm/loaders/RGBELoader.js";var xe=new class{init(){switch(this.browser_name="",this.agent=window.navigator.userAgent.toLowerCase(),!0){case this.agent.indexOf("edge")>-1:this.browser_name="edge_ie";break;case this.agent.indexOf("edg")>-1:this.browser_name="edge_chromium";break;case this.agent.indexOf("opr")>-1&&!!window.opr:this.browser_name="opera";break;case this.agent.indexOf("chrome")>-1&&!!window.chrome:this.browser_name="chrome";break;case this.agent.indexOf("trident")>-1:this.browser_name="iexplorer";break;case this.agent.indexOf("firefox")>-1:this.browser_name="firefox";break;case this.agent.indexOf("safari")>-1:this.browser_name="safari";break;default:this.browser_name="other"}}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"}};class we{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 be{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=we.is_number(e)?e:1,t=we.is_number(t)?t:1,this.loaded_bytes=e,t>0&&(this.total_bytes=t),this.loaded_bytes>this.total_bytes&&console.warn("Total bytes is smaller than loaded ones. Please set total bytes by hand to:",this.url)}__loading_ended(){this.has_finished=!0}__set_error(e){this.has_error=!0,this.error_message=e}print_error(){console.error("Error while loading "+this.resource_id+"\n\t path: "+this.url+"\n\t\t"+this.error_message)}load(e){const t=xe.is_safari?"no-cache":"default";fetch(this.url,{method:"GET",mode:"cors",cache:t,credentials:"same-origin",redirect:"follow"}).then(this.on_progress.bind(this,e)).catch(this.__on_error.bind(this))}async on_progress(e,t){const 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)}}class ye{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(t,s){const i=new e,r=[];for(let e=0;e<t.length;e++)s.projectPoint(t[e],i),r.push(i.clone());return r}static matrix4_lerp(e,s,i,r){for(let n=0;n<16;n++)i.elements[n]=t.lerp(e.elements[n],s.elements[n],r)}static equals(e,t){return Math.abs(e-t)<1e-6}static lerp(e,t,s){return(1-s)*e+s*t}static clamp(e,t,s){return Math.max(t,Math.min(s,e))}static euclideanModulo(e,t){return(e%t+t)%t}static pingpong(e,t=1){return t-Math.abs(ye.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 ye.clamp(e,0,1)}}class Te{constructor(e){this.elapsed_time=-1e-5,this.playback_speed=1,this.playing=!1,this.action_events=[],this.context=e,this.initial_context=JSON.parse(JSON.stringify(e)),this.tmp_t=0,this.channels={};const t=Object.keys(e);for(let e=0;e<t.length;e++)this.channels[t[e]]=[];this.duration=0}play(){this.playing=!0}stop(){this.playing=!1}reset(){this.elapsed_time=-1e-5}skip(){const e=this.get_duration();this.__play_clips(this.elapsed_time,e+1e-4),this.elapsed_time=e}update(e){this.playing&&(this.__play_clips(this.elapsed_time,this.elapsed_time+e*this.playback_speed),this.elapsed_time=this.elapsed_time+e*this.playback_speed)}set_progress(e){this.elapsed_time=t.clamp(e,0,this.duration),this.__play_clips(this.elapsed_time,this.elapsed_time)}set_normalized_progress(e){this.elapsed_time=t.clamp(e,0,1)*this.duration,this.__play_clips(this.elapsed_time,this.elapsed_time)}get_progress(){return t.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){for(let s=0;s<this.action_events.length;s++)this.action_events[s].trigger_time>e-Number.EPSILON&&this.action_events[s].trigger_time<t+Number.EPSILON&&this.action_events[s].action.trigger();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)}}evaluate_keyframe(e,s){return this.tmp_t=this.__linear_map_01(s,e.from,e.to),e.interpolator.evaluate(t.clamp(this.tmp_t,0,1))}get_keyframes(e){return this.channels[e]}__linear_map_01(e,t,s){return ye.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}}var Me=new class{constructor(){}linear(e){return e}triangular(e){return 1-Math.abs(2*e%2-1)}ease_in_sine(e){return 1-Math.cos(3.1415926*e/2)}ease_out_sine(e){return Math.sin(3.1415926*e/2)}ease_in_out_sine(e){return-(Math.cos(3.1415926*e)-1)/2}ease_in_cubic(e){return e*e*e}ease_out_cubic(e){return 1-Math.pow(1-e,3)}ease_in_out_cubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}ease_in_quad(e){return e*e}ease_out_quad(e){return 1-(1-e)*(1-e)}ease_in_out_quad(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}ease_in_quart(e){return e*e*e*e}ease_out_quart(e){return 1-Math.pow(1-e,4)}ease_in_out_quart(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2}ease_in_quint(e){return e*e*e*e*e}ease_out_quint(e){return 1-Math.pow(1-e,5)}ease_in_out_quint(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2}ease_in_expo(e){return 0===e?0:Math.pow(2,10*e-10)}ease_out_expo(e){return 1===e?1:1-Math.pow(2,-10*e)}ease_in_out_expo(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}ease_in_circ(e){return 1-Math.sqrt(1-Math.pow(e,2))}ease_out_circ(e){return Math.sqrt(1-Math.pow(e-1,2))}ease_in_out_circ(e){return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2}ease_in_back(e){return 2.7015*e*e*e-1.7015*e*e}ease_out_back(e){return 1+2.7015*Math.pow(e-1,3)+1.7015*Math.pow(e-1,2)}ease_in_out_back(e){return e<.5?Math.pow(2*e,2)*(7.189819*e-2.5949095)/2:(Math.pow(2*e-2,2)*(3.5949095*(2*e-2)+2.5949095)+2)/2}ease_in_elastic(e){const t=2*Math.PI/3;return 0===e?0:1===e?1:-Math.pow(2,10*e-10)*Math.sin((10*e-10.75)*t)}ease_out_elastic(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(2.094395*(10*e-.75))+1}ease_in_out_elastic(e){return 0===e?0:1===e?1:e<.5?-Math.pow(2,20*e-10)*Math.sin(1.3962633*(20*e-11.125))/2:Math.pow(2,-20*e+10)*Math.sin(1.3962633*(20*e-11.125))/2+1}ease_in_bounce(e){return 1-this.ease_out_bounce(1-e)}ease_out_bounce(e){const t=7.5625,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}ease_in_out_bounce(e){return e<.5?(1-this.ease_out_bounce(1-2*e))/2:(1+this.ease_out_bounce(2*e-1))/2}heartbeat(e){return 1-Math.pow(Math.abs(Math.sin(e+1)),63)*Math.sign(Math.sin(e))*Math.sin(e+1.5+1)*.8}};class Se{constructor(e="linear"){this.easing_function=void 0,this.easing_function="string"==typeof e?Me[e]:e}update(e,t){}}class ze extends Se{constructor(e,t=0,s=1,i="linear"){super(i),this.attribute_name=e,this.from=t,this.to=s}update(e,s){e[this.attribute_name]=t.lerp(this.from,this.to,this.easing_function(s))}evaluate(e){return t.lerp(this.from,this.to,this.easing_function(e))}}var Fe=new class{constructor(){this.app=void 0}set_app(e){this.app=e}};class Re{constructor(e,t){this.name=e,this.method=t}trigger(){Fe.app[this.name][this.method]()}}class Ae{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 Ce{constructor(e){this.initial_state_data=e}from_animation_sheet(e,t,s){s=s||this.initial_state_data;const i=e.animation_tracks,r=e.triggers,n=this.state_to_tracks(this.initial_state_data);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 Te(t);for(let e=0;e<i.length;e++){const s=i[e],r=new ze(s.attribute_name,t[s.attribute_name],s.to_value,s.easing_function);o.add_action_interpolator(s.from_time,s.to_time,r,!0)}for(let e=0;e<r.length;e++){const t=r[e],s=new Re(t.name,t.method);o.add_action_event(t.at_time,s)}return o}state_to_tracks(e){const t=[],s=Object.keys(e);for(let i=0;i<s.length;i++)t.push({attribute_name:s[i],from_time:0,to_time:1,to_value:e[s[i]],easing_function:"ease_in_out_cubic"});return t}from_draw_io(e,t){const s=(new Ae).parse(e),i=s.animation_tracks,r=s.triggers,n=new Te(t);for(let e=0;e<i.length;e++){const s=i[e],r=new ze(s.attribute_name,t[s.attribute_name],s.to_value,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 Re(t.name,t.method);n.add_action_event(t.at_time,s)}return n}}var De=new class{init(){this.queue={},this.zoom_changed_evt="zoom_changed",this.store_clickd_evt="store_clicked",this.point_selected_evt="point_selected",this.config_changed="config_changed",this.path_substep_completed="path_substep_completed",this.path_completed="path_completed",this.go_to_store_requested_evt="go_to_store_requested",this.resource_loaded_evt="resource_loaded",this.service_clicked_evt="service_clicked",this.unit_pos_updated_evt="unit_position_updated",this.floor_changed_evt="floor_changed",this.on_enter_floor_navigation="on_enter_floor_navigation",this.on_exit_floor_navigation="on_exit_floor_navigation",this.on_enter_floor_selection="on_enter_floor_selection",this.on_exit_floor_selection="on_exit_floor_selection",this.on_enter_outside_navigation="on_enter_outside_navigation",this.on_exit_outside_navigation="on_exit_outside_navigation",this.step_selected_evt="step_selected"}fire(e,t){const s=this.queue[e];if(void 0===s)return;let i=s.length;for(;i--;)s[i](t)}on(e,t){void 0===this.queue[e]&&(this.queue[e]=[]),this.queue[e].push(t)}fire_zoom_changed(e){this.fire(this.zoom_changed_evt,e)}fire_store_selected(e){this.fire(this.store_clickd_evt,e)}fire_point_selected(e){this.fire(this.point_selected_evt,e)}fire_config_changed(){this.fire(this.config_changed)}fire_path_substep_completed(e){this.fire(this.path_substep_completed,e)}fire_path_completed(){this.fire(this.path_completed)}fire_step_selected(e){this.fire(this.step_selected_evt,e)}fire_go_to_store_requested(e){this.fire(this.go_to_store_requested_evt,e)}fire_resource_loaded(e){this.fire(this.resource_loaded_evt,e)}fire_service_clicked(e){this.fire(this.service_clicked_evt,e)}fire_unit_position_updated(e){this.fire(this.unit_pos_updated_evt,e)}fire_floor_switched(e){this.fire(this.floor_changed_evt,e)}fire_on_enter_floor_navigation(e){this.fire(this.on_enter_floor_navigation,e)}fire_on_exit_floor_navigation(e){this.fire(this.on_exit_floor_navigation,e)}fire_on_enter_floor_selection(e){this.fire(this.on_enter_floor_selection,e)}fire_on_exit_floor_selection(e){this.fire(this.on_exit_floor_selection,e)}fire_on_enter_outside_navigation(e){this.fire(this.on_enter_outside_navigation,e)}fire_on_exit_outside_navigation(e){this.fire(this.on_exit_outside_navigation,e)}};var Pe=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),De.fire_resource_loaded({name:e,value:s})}get_resource(e){return this.resources[e]}get(e){return this.resources[e]}};class Le{constructor(){this.transitions=[],this.initial_state_data={}}get(e,t,s){for(let i=0;i<this.transitions.length;i++)if(this.transitions[i].from===e&&this.transitions[i].to===t){return new Ce(this.initial_state_data).from_animation_sheet(this.transitions[i].data,s)}for(let e=0;e<this.transitions.length;e++)if(this.transitions[e].to===t){return new Ce(this.initial_state_data).from_animation_sheet(this.transitions[e].data,s)}console.error("TransitionTable.get no data found for: ",e,t)}add_transitions(e){for(let t=0;t<e.length;t++)this.transitions.push(e[t])}set_transitions(e){this.transitions=e}set_initial_state_data(e){this.initial_state_data=e}}var Ue=new class{init(){this.___time=new s,this.__delta_time=0,this.__elapsed_time=0,this.__allocated_time=new i(0,0)}get delta_time(){return this.__delta_time<.4?this.__delta_time:.016}get elapsed_time(){return this.__elapsed_time}get shader_time(){return this.__allocated_time.x=this.delta_time,this.__allocated_time.y=this.elapsed_time,this.__allocated_time}__update(){this.__delta_time=this.___time.getDelta(),this.__elapsed_time=this.___time.getElapsedTime()}};class ke{constructor(e){this.name=e}start(){}show(){}hide(){}before_enter(){}on_enter(){}update(){}update_enter_transition(e,t,s){this.update_transition(e,t,s)}update_exit_transition(e,t,s){}update_transition(e,t,s){}before_exit(){}on_exit(){}}class Oe{constructor(e){this.last_state=new ke,this.current_state=new ke,this.initial_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.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())}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()}set_state(e){this.current_state=e}set_initial_state_data(e){Object.assign(this.initial_state_data,e),Object.assign(this.current_state_data,e)}__update_transitions(){this.action_sequencer.update(Ue.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.name!==this.current_state.name&&this.last_state.hide(),this.last_state.on_exit()}}var je=new class{constructor(){this.views=[],this.transition_table=new Le,this.transition_handler=new Oe(this.transition_table),this.view_change_subscribers=[]}update(){this.transition_handler.update(),this.__set_views_opacities()}go_to_view(e,t=!0,s=!1){const i=this.get(e);this.transition_handler.go_to_state(i,s),t&&this.__change_browser_url(i.url),this.notify_view_change(e)}subscribe_to_view_change(e){this.view_change_subscribers.push(e)}notify_view_change(e){for(let t=0;t<this.view_change_subscribers.length;t++){this.view_change_subscribers[t].on_view_change(e)}}register_view(e){this.views.push(e)}has_view(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return!0;return!1}add_transitions(e){this.transition_table.add_transitions(e)}set_transitions(e){this.transition_table.set_transitions(e)}set_view(e){const t=this.get(e);this.transition_handler.set_state(t)}get_current_view(){return this.transition_handler.current_state}get_view_by_name(e){console.warn("DEPRECATED. Use ViewManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.views.length;t++)if(this.views[t].name===e)return this.views[t];console.error("[ViewManager.get] no view found for: ",e)}get_view_by_url(e){console.warn("DEPRECATED. Use ViewManager.get_by_url instead"),this.get_by_url(e)}get_by_url(e){for(let t=0;t<this.views.length;t++)if(this.views[t].url===e)return this.views[t];console.error("[ViewManager.get_by_url] no view found for: ",e)}set_initial_state_data(e){this.transition_table.set_initial_state_data(e),this.transition_handler.set_initial_state_data(e)}__change_browser_url(e){window.history.pushState("","",e)}__set_views_opacities(){for(let e=0;e<this.views.length;e++)this.views[e].set_opacity(this.transition_handler.current_state_data)}};class Ie extends ke{constructor({name:e,url:t,container:s}){super(e),this.container=s,this.url=t;const i=[{to:e,data:(new Ae).parse(Pe.get(`${e}_data`))}];je.register_view(this),je.add_transitions(i)}show(){this.container.classList.add("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}on_enter(){this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit"),this.container.classList.remove("hidden")}before_exit(){this.container.classList.add("before_exit"),this.container.classList.remove("before_enter"),this.container.classList.remove("hidden")}hide(){this.container.classList.add("hidden"),this.container.classList.remove("before_enter"),this.container.classList.remove("before_exit")}set_opacity(e){this.container.style.opacity=e[`${this.name}_opacity`]}}class Ne{on_post_start(){}on_enter(){}on_exit(){}update(){}on_post_render(){}on_pre_render(){}on_frame_end(){}}class Ve{constructor(){}render(){}on_enter(e,t){}on_exit(e,t){}resize(){}dispose(){}}var Be="#define GLSLIFY 1\nvarying vec2 vUv;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;gl_Position=MVP*vec4(pos,1.0);vUv=uv;}",qe="#define GLSLIFY 1\nuniform vec3 _Color;void main(){gl_FragColor=vec4(_Color,1.0);}";class Ge extends r{constructor(e,t,s){super({vertexShader:e||Be,fragmentShader:t||qe,uniforms:s||{_Color:{value:new n("#FF0000")}}})}}class Ye extends r{constructor(e,t,s){super({uniforms:{_MainTex:{value:null},_Resolution:{value:new i(0,0)},_TargetResolution:{value:new i(0,0)}},defines:s||{},vertexShader:t||"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(uv*2.0-1.0,1.0,1.0);vUv=uv;}",fragmentShader:e||"#define GLSLIFY 1\nuniform sampler2D _MainTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);}",depthWrite:!1,blending:o,depthTest:!1,depthFunc:a})}}var Ee=new class{init(){this._current=void 0}set current(e){this._current=e}get current(){return this._current}};var We=new class{init(){this.max_anisotropy=0,this.vertex_texture_sampler_available=!1,this.fp_textures_available=!1}};class Xe{constructor(e){this.uses_dynamic_font=e,this.__textHeight=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}getFontHeight(e="Arial"){if(null==this.__textHeight||this.uses_dynamic_font){const t=document.getElementsByTagName("body")[0],s=document.createElement("div"),i=document.createTextNode("MÉqgOLAKTAL");s.appendChild(i),s.setAttribute("style",`font:${e};position:absolute;top:0;left:0`),t.appendChild(s),this.__textHeight=s.offsetHeight,t.removeChild(s)}return this.__textHeight}get_text_size(e,t="24px Arial"){const s=new i;return this.ctx.font=t,s.x=Math.ceil(this.ctx.measureText(e).width),s.y=Math.ceil(this.getFontHeight(t)),s}draw_canvas(e,t={}){return t.font=t.font||"24px Arial",t.font_color=t.font_color||"#000000",this.__draw(e,t,this.canvas,this.ctx),this.canvas}draw_on_texture(e,t){const s=this.draw_canvas(e,t),i=new _(s,l,h,h,c,c);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()}}var Qe=new class{init(e={}){this.dpr=1,this.app={}}from_json(e){}};class He{constructor(){}get is_animating(){return!1}on_enter(e){}update(e){}on_exit(e){}}class Ze{constructor(){this.t=0,this.easing_function_t=0}get is_animating(){return!0}on_enter(e){}update(e){this.t+=Ue.delta_time/e.duration,this.easing_function_t=e.easing_function(this.t),this.easing_function_t=t.clamp(this.easing_function_t,0,1),e.set_property_value(t.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 He),e.finished_callback(e))}on_exit(e){}}class Je{constructor({element:e,css_property:t,from:s=0,to:i=1,duration:r=1,value_prefix:n="",value_suffix:o="",easing_function:a=Me.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 He}animate(){this.set_current_state(new Ze)}stop(){this.set_current_state(new He)}set_property_value(e){this.element.style[this.css_property]=`${this.value_prefix}${e}${this.value_suffix}`}update(){this.current_state.update(this)}get is_animating(){return this.current_state.is_animating}set_current_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}}class $e extends u{constructor(t=1){super();const s=[];s.push(new e(0,0,0)),s.push(new e(0,0,1e3));const i=new d({color:4474111,depthFunc:a}),r=(new m).setFromPoints(s),n=new p(r,i);n.renderOrder=5e4;const o=[];o.push(new e(0,0,0)),o.push(new e(0,1e3,0));const _=new d({color:4521796,depthFunc:a}),l=(new m).setFromPoints(o),h=new p(l,_);h.renderOrder=5e4;const c=[];c.push(new e(0,0,0)),c.push(new e(1e3,0,0));const u=new d({color:16729156,depthFunc:a}),g=(new m).setFromPoints(c),v=new p(g,u);v.renderOrder=5e4,this.renderOrder=1e5,this.add(n),this.add(h),this.add(v),this.scale.set(t,t,t)}update(){}dispose(){}}var Ke=new class{init(){this._current=new g,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 et extends v{constructor(t,s,i){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 x({color:i}))}}class tt extends v{constructor(e,t){t=t||"#FF0000";super(new w(e=e||1,64,64),new x({color:t}))}}class st extends v{constructor(t,s,i){t=t||"#FF0000";const r=(s=s||1)-.4,n=new b(.01,.01,r,32);n.translate(0,r/2,0);const o=new y(.1,.4,32);o.translate(0,r+.2,0);const a=he.mergeBufferGeometries([n,o]);a.rotateX(1.57);super(a,new x({color:t})),i&&this.quaternion.setFromUnitVectors(new e(0,0,1),i),this._dir=i}set dir(t){this.quaternion.setFromUnitVectors(new e(0,0,1),t),this._dir=t}get dir(){return this._dir}set length(e){this.scale.z=e}get length(){return this.scale.z}}var it=new class{init(){this.width=1,this.height=1,this.position=new i,this.render_width=1,this.render_height=1,this.width_height=new i(this.width,this.height),this.dpr=1,this.pixel_size=new i(1/this.width,1/this.height)}update_position(e,t){this.position.set(e,t)}update(){this.size_changed=!1}update_size(e,t){this.width=e,this.height=t,this.pixel_size=new i(1/this.width,1/this.height),this.width_height.x=e,this.width_height.y=t,this.render_width=e*this.dpr,this.render_height=t*this.dpr,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}};class rt extends Ge{constructor(e,t,s,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 i},_ScreenSize:{value:new i},_TextureSize:{value:new i}})}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 nt extends T{constructor(e,t,s,i){super(e,t,s,i),this.clear_color=new n("#000000"),this.clear_alpha=1}}var ot=new class{init(){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 g,this.camera=new nt}draw_arrow(e,t,s=16711680){const i=new st(s,t.length(),t.clone().normalize());return i.position.copy(e),Ke.current.add(i),i}draw_axis(){const e=new $e;return Ke.current.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 d({color:t}),i=(new m).setFromPoints(e),r=new p(i,s);return r.frustumCulled=!1,Ke.current.add(r),r}draw_cube(t,s,i){s=s||1,i=i||16711680,t=t||new e;const r=new et(new e(s,s,s),void 0,i);return r.position.copy(t),Ke.current.add(r),r}draw_oriented_cube(t,s,i=1,r="#FF0000",n=.1){const o=t.distanceTo(s),a=new et(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),Ke.current.add(a),a}draw_plane(e,t,s){const i=new M(e,t),n=new r({uniforms:{_Color:{value:new S(0,1,0,.2)}},vertexShader:Be,fragmentShader:qe,transparent:!0,depthWrite:!1}),o=new v(i,n);return o.renderOrder=-1e4,Ke.current.add(o),o}draw_empty_cube(t,s,i){s=s||1,i=i||16711680;const r=(new z).setFromCenterAndSize(new e,new e(s,s,s)),n=new F(r,i);return n.position.copy(t||new e),n}draw_sphere(t,s,i){s=s||1,i=i||16711680,t=t||new e;const r=new tt(s,i);return r.position.copy(t),Ke.current.add(r),r}draw_point_array(e,t=!1,s=16711680){const i=new R(e,t);i.updateArcLengths();const r=i.getSpacedPoints(200);return this.draw_line(r,65280)}draw_sphere_helper(e,t){t=t||16711680;const s=new A(e.radius,32,32),i=new x({color:t}),r=new v(s,i);return r.position.copy(e.center),Ke.current.add(r),r}draw_math_sphere(e){const t=new A(e.radius,32,32),s=new r({uniforms:{_Color:{value:new S(1,0,0,.2)}},vertexShader:Be,fragmentShader:qe,transparent:!0}),i=new v(t,s);i.position.copy(e.center),Ke.current.add(i)}draw_bounding_box(e){const t=new F(e,16776960);Ke.current.add(t)}draw_curve(t,s){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))}draw_texture(e,t,s){const i=new v(new M(1,1),new rt);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(it.width,it.height);this.scene.children.length>0&&e.render(this.scene,this.camera)}};class at extends Ye{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 S(e,t.x,t.y,t.z)}}}class _t extends r{constructor(){super({uniforms:{_FarPlane:{value:1}},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;void main(){vec3 pos=position;mat4 MVP=projectionMatrix*modelViewMatrix;v_normal=(modelViewMatrix*vec4(normal,0.0)).xyz;v_pos=(modelViewMatrix*vec4(pos,1.0)).xyz;gl_Position=MVP*vec4(pos,1.0);}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;varying vec3 v_pos;uniform float _FarPlane;vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}vec2 EncodeNormal(vec3 n){float scale=1.7777;vec2 enc=n.xy/(n.z+1.0);enc/=scale;enc=enc*0.5+0.5;return enc;}void main(){gl_FragColor=vec4(EncodeFloatRG(length(v_pos.z)/_FarPlane),EncodeNormal(normalize(v_normal)));}"})}set far_plane(e){this.uniforms._FarPlane.value=e}get far_plane(){return this.uniforms._FarPlane.value}}class lt{constructor(){this.RT=new C(it.width,it.height),this.clear_depth_normal_mat=new at(1,new e(0,0,1)),this.depth_normal_material=new _t}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=Ee.current.far,e.render(void 0,void 0,this.RT,this.depth_normal_material)}__resize_RT_if_necessary(){this.RT.width===it.width&&this.RT.height===it.height||this.RT.setSize(it.width,it.height)}get render_target(){return this.RT}}class ht{constructor(e){this.renderer=e,this._blit_scene=new g,this._blit_material=new Ye,this._blit_quad=new v(new M(1,1),this._blit_material),this._blit_scene.add(this._blit_quad),this._blit_camera=new D(-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)}}var ct=new class{init(e,t){this._renderer=void 0,this.blitter=void 0,this.canvas=void 0,this.no_render=void 0,this.current_render_mode=void 0,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=void 0,this.is_webgl2=!1,this.canvas_context=void 0,this.context_attributes=void 0,this.context_attributes={alpha:!0,depth:!0,desynchronized:!1,stencil:!1,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!1},Object.assign(this.context_attributes,t),t.force_webgl2?this.canvas_context=e.getContext("webgl2",this.context_attributes)||e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes):this.canvas_context=e.getContext("webgl",this.context_attributes)||e.getContext("experimental-webgl",this.context_attributes),this.is_webgl2="WebGL2RenderingContext"===this.canvas_context.constructor.name,this._renderer=new P({canvas:e,context:this.canvas_context}),this._renderer.autoClear=!1,this._renderer.setPixelRatio(1),it.dpr=Qe.dpr,this.is_webgl2||this._renderer.extensions.get("ANGLE_instanced_arrays"),this.blitter=new ht(this._renderer),this.canvas=this._renderer.domElement,this.no_render=new Ve,this.current_render_mode=this.no_render,We.max_anisotropy=this._renderer.capabilities.getMaxAnisotropy(),We.vertex_texture_sampler_available=this._renderer.capabilities.maxVertexTextures>0,We.fp_textures_available=this._renderer.capabilities.floatVertexTextures,this.generateDepthNormalTexture=!1,this.depth_and_normals_renderer=new lt,this.resize_observer=new ResizeObserver(this.on_resize.bind(this)),this.resize_observer.observe(this.canvas)}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(),Ee.current&&this.current_render_mode.render(),it.update()}__update_current_camera(){Ee.current&&(Ee.current.aspect=it.aspect_ratio,Ee.current.updateProjectionMatrix(),Ee.current.updateMatrix(),Ee.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||Ke.current,t||Ee.current),this.__apply_override_material(e,void 0)}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:Ke.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){for(const t of e)it.dpr=Qe.dpr,it.update_position(t.contentRect.x,t.contentRect.y),it.update_size(t.contentRect.width,t.contentRect.height),this.canvas.width=it.render_width,this.canvas.height=it.render_height,this._renderer.setViewport(0,0,it.render_width,it.render_height),this.__update_current_camera()}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=it.width,s=it.height){const i=it.width,r=it.height,n=t,o=s,a=1024,_=1024,l=parseInt(Math.ceil(n/a)),h=parseInt(Math.ceil(o/_));it.update_size(a,_),this._renderer.setPixelRatio(1),this._renderer.setSize(a,_,!1);const c=document.createElement("canvas").getContext("2d");c.canvas.width=n,c.canvas.height=o,Ee.current.aspect=it.aspect_ratio,Ee.current.updateMatrix(),Ee.current.updateMatrixWorld(!0);for(let e=0;e<l;e++)for(let t=0;t<h;t++)Ee.current.setViewOffset(n,o,it.width*e,it.height*t,it.width,it.height),this.current_render_mode.render(),c.drawImage(this._renderer.domElement,it.width*e,it.height*t);c.canvas.toBlob(e,"image/png;base64;"),Ee.current.clearViewOffset(),it.update_size(i,r),this._renderer.setPixelRatio(Qe.dpr),this._renderer.setSize(i,r,!1),Ee.current.aspect=it.aspect_ratio,Ee.current.updateMatrix(),Ee.current.updateMatrixWorld(!0)}download_screenshot(e){const t=document.createElement("a");t.download="Snapshot.png",t.href=URL.createObjectURL(e),t.click(),t.onclick=function(){requestAnimationFrame((function(){URL.revokeObjectURL(t.href)})),t.removeAttribute("href")}}dispose(){this._renderer.dispose(),this.current_render_mode.dispose(),this.blitter.dispose()}};class ut extends r{constructor(){super({uniforms:{},vertexShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);v_normal=(modelMatrix*vec4(normal,0.0)).xyz;}",fragmentShader:"#define GLSLIFY 1\nvarying vec3 v_normal;void main(){gl_FragColor=vec4(v_normal*0.5+vec3(0.5),1.0);}"})}}class dt extends Ve{constructor(){super()}render(){ct.clear(void 0,Ee.current,!0,!0),ct.render(Ke.current,Ee.current,void 0,new ut)}}var mt=new class extends ce{constructor(){super(),this.left_mouse_button_clicked=!1,this.captured_NDC={x:0,y:0}}clear(){super.clear(),this.left_mouse_button_clicked=!1}};var pt=new class{init(){this.operating_systems={ANDROID:"android",IOS:"ios",LINUX:"linux",MAC:"mac",WINDOWS:"windows"},this.is_mobile=!!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/),this.is_ipad=!!(navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2),this.is_ios=!!navigator.userAgent.match(/(iPhone|iPod|iPad)/)||this.is_ipad,this.is_android=this.get_os()===this.operating_systems.ANDROID,this.is_linux=this.get_os()===this.operating_systems.LINUX,this.is_mac=this.get_os()===this.operating_systems.MAC,this.is_windows=this.get_os()===this.operating_systems.WINDOWS}get_os(){const e=window.navigator.userAgent,t=window.navigator.platform;let s=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?s=this.operating_systems.MAC:-1!==["iPhone","iPad","iPod"].indexOf(t)?s=this.operating_systems.IOS:-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?s=this.operating_systems.WINDOWS:/Android/.test(e)?s=this.operating_systems.ANDROID:!s&&/Linux/.test(t)&&(s=this.operating_systems.LINUX),s}};var gt=new class{init(){this.target_geometry=void 0,this.target_position=new e}set_target_geometry(e){this.target_geometry=e}};class vt{constructor(e,t){this.geometry=e,this.material=void 0,this.uniforms={},this.batch_width=t,this.data_textures=[],this.object_names=void 0,this.zero_offset=new i,this.write_offset=new i,this.uniform_dirty_count=0,this.tmp_uploaded_data_count=0}init(e,t,s){this.material=new r({uniforms:this.uniforms,vertexShader:t,fragmentShader:s}),this.object_names=e}add_global_uniform(e,t){this.uniforms[e]={value:t},this.material.needsUpdate=!0}set_global_uniform(e,t){this.uniforms[e].value=t}add_object_uniform_v3(e,t){const s=this.__create_rgb_texture(this.batch_width),i=this.__create_rgb_texture(this.batch_width),r=this.__create_rgb_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgb(n,t)}add_object_uniform_v4(e,t){const s=this.__create_rgba_texture(this.batch_width),i=this.__create_rgba_texture(this.batch_width),r=this.__create_rgba_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}add_object_uniform_v4_float(e,t){const s=this.__create_rgba_float_texture(this.batch_width),i=this.__create_rgba_float_texture(this.batch_width),r=this.__create_rgba_float_texture(1),n=this.__add_data_texture(e,s,i,r);t&&this.__flood_data_texture_rgba(n,t)}set_object_uniform_v3(e,t,s,i,r,n){const o=this.__get_object_index(e),a=this.__get_data_texture(t);this.__set_pixel_rgb(a.src,o,s,i,r,n),this.__set_pixel_rgb(a.one_pixel,0,s,i,r,n),a.last_accessed_index=o,a.dirty_count++}set_object_uniform_v4(e,t,s,i,r,n,o){const a=this.__get_object_index(e),_=this.__get_data_texture(t);this.__set_pixel_rgba(_.src,a,s,i,r,n,o),this.__set_pixel_rgba(_.one_pixel,0,s,i,r,n,o),_.last_accessed_index=a,_.dirty_count++}upload_texture_data(e,t){for(let s=0;s<this.data_textures.length;s++)t>0&&this.data_textures[s].dirty_count>0&&(1===this.data_textures[s].dirty_count&&this.__partial_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count>1&&this.__full_texture_data_upload(e,this.data_textures[s]),this.data_textures[s].dirty_count=0,t--)}get_uniform_dirty_count(){this.uniform_dirty_count=0;for(let e=0;e<this.data_textures.length;e++)this.data_textures[e].dirty_count>0&&this.uniform_dirty_count++;return this.uniform_dirty_count}__full_texture_data_upload(e,t){t.dst.needsUpdate=!0,e.copyTextureToTexture(this.zero_offset,t.src,t.dst)}__partial_texture_data_upload(e,t){const s=t.last_accessed_index;-1!==s&&(this.write_offset.y=Math.floor(s/this.batch_width),this.write_offset.x=s-this.batch_width*this.write_offset.y,e.copyTextureToTexture(this.write_offset,t.one_pixel,t.dst))}get_mesh(){return new v(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,U)}__create_rgba_texture(e){const t=new Uint8Array(4*e*e);return new L(t,e,e,k)}__create_rgba_float_texture(e){const t=new Float32Array(4*e*e);return new L(t,e,e,k,O)}__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()}}var ft=new class{init(){this.batches=[]}batch(e){const s=[],i=t.ceilPowerOfTwo(Math.sqrt(e.length));this.__init_uv_array(s,i);let r=0;for(let t=0;t<e.length;t++){const n=e[t].getAttribute("position").count,o=Math.floor(t/i),a=t-i*o;for(let e=0;e<n;e++)s[r]=a/i+.5/i,s[r+1]=o/i+.5/i,r+=2}const n=new j(new Float32Array(s),2),o=he.mergeBufferGeometries(e);return o.setAttribute("attr_accessor_uv",n),this.batches.push(new vt(o,i)),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)}};var xt=new class{init(){this.ui_elements=[],this._tmp_normalized_pos=new i,this.ss_scene=new g,this.ss_scene.autoUpdate=!1,this.ss_scene.frustumCulled=!1,this.ws_scene=new g,this.ws_scene.autoUpdate=!1,this.ws_scene.frustumCulled=!1,this.ss_camera=new D(-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(mt.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&&ct.render(this.ss_scene,this.ss_camera),this.ws_scene.children.length>0&&ct.render(this.ws_scene,Ee.current)}clear(){this.current_clicked_element=void 0}};var wt=new class{init(){this.tmp_mat=new I,this.plane=new N,this.ray=new V,this.tmp_size=new e,this.tmp_unproj=new e}get_up_dir(t){t=t||Ee.current;const s=new e;return s.set(0,1,0),s.applyQuaternion(t.quaternion),s}get_forward_dir(t){t=t||Ee.current;const s=new e;return s.set(0,0,-1),s.applyQuaternion(t.quaternion),s}get_right_dir(t){t=t||Ee.current;const s=new e;return s.set(1,0,0),s.applyQuaternion(t.quaternion),s}unproject_mouse_position(t,s){s=s||Ee.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)}get_plane_intersection(t,s,i,r){r=r||Ee.current,i=i||mt.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}fit_points_on_camera(t,s=1){const i=(new B).setFromPoints(t).center,r=this.get_forward_dir(Ee.current).clone(),n=(new N).setFromNormalAndCoplanarPoint(r,i),o=ye.project_points_on_plane(t,n),a=new e;let _=(new z).setFromPoints(o);_.getCenter(a);const l=new e(0,1,0).applyQuaternion(Ee.current.quaternion),h=l.clone().cross(r).normalize(),c=(new I).set(h.x,l.x,r.x,i.x,h.y,l.y,r.y,i.y,h.z,l.z,r.z,i.z,0,0,0,1),u=(new I).getInverse(c);for(let e=0;e<o.length;e++)o[e].applyMatrix4(u);const d=new e;_=(new z).setFromPoints(o),_.getSize(d),d.multiplyScalar(s);const m=new e;return _.getCenter(m),{position:a,zoom:this.get_zoom_to_fit_rect(d.x/2,d.y/2)}}get_zoom_to_fit_rect(e,t){const s=Ee.current.fov/2*Math.PI/180,i=2*Math.atan(Math.tan(s)*Ee.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(t,s){if(s.isOrthographicCamera){t.getSize(this.tmp_size);const e=this.tmp_size.x,s=this.tmp_size.y,i=e/s;return it.aspect_ratio/i>1?it.height/s:it.width/e}{const s=new e;return t.getSize(s),this.get_zoom_to_fit_rect(s.x,s.y)}}get_html_screen_pos(t,s){s=s||Ee.current;const i=new e;return t.getWorldPosition(i),i.project(s),i.x=(.5*i.x+.5)*it.width,i.y=(1-(.5*i.y+.5))*it.height,i}world_pos_to_screen(t,s){s=s||Ee.current;const i=new e;return i.copy(t),i.project(s),i.x=(.5*i.x+.5)*it.width,i.y=(1-(.5*i.y+.5))*it.height,i}update_projection(e){e.left=-it.width/2,e.right=it.width/2,e.top=it.height/2,e.bottom=-it.height/2,e.aspect=it.aspect_ratio,e.updateProjectionMatrix(!0)}};var bt=new class{constructor(){}init(e,t,s){Ee.init(),wt.init(),We.init(),Qe.init(),De.init(),ft.init(),mt.init(t),pt.init(),xe.init(),gt.init(),Pe.init(),Ke.init(),it.init(),Ue.init(),xt.init(),ct.init(e,s),ot.init()}dispose(e){ct.dispose(),mt.dispose(),Ke.dispose(),e.dispose()}},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 Ye{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform mat4 _InverseProjMatrix;uniform float _Bias;uniform float _Radius;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;uniform vec3 _SampleKernel[64];uniform sampler2D _RandomRotation;uniform mat4 _ProjectionMatrix;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec2 encoded_normal=texture2D(_MainTex,uv).zw;vec3 normalValue=normalize(decode_normal(vec4(encoded_normal,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;vec4 inv_proj=_InverseProjMatrix*vec4(vUv*2.0-1.0,1.0,1.0);return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec2 noiseScale=vec2(_Resolution.x/4.0,_Resolution.y/4.0);vec3 fragPos=DecodeViewPos(vUv);vec3 normal=DecodeNormal(vUv);vec3 randomVec=texture2D(_RandomRotation,vUv*noiseScale).xyz;randomVec=vec3(randomVec.xy*2.0-1.0,0);randomVec=normalize(randomVec);vec3 tangent=normalize(randomVec-normal*dot(randomVec,normal));vec3 bitangent=normalize(cross(normal,tangent));mat3 TBN=mat3(tangent,bitangent,normal);float occlusion=0.0;const int kernelSize=64;for(int i=0;i<kernelSize;++i){vec3 sample=TBN*_SampleKernel[i];sample=fragPos+sample*_Radius;vec4 projPos=_ProjectionMatrix*vec4(sample,1.0);vec2 screenPos=projPos.xy/projPos.w;screenPos=screenPos*0.5+0.5;float sampled_depth=DecodeViewPos(screenPos).z;float rangeCheck=smoothstep(0.0,1.0,_Radius/abs(fragPos.z-sampled_depth));occlusion+=step(sample.z+_Bias,sampled_depth)*rangeCheck;}occlusion=(occlusion/float(kernelSize));gl_FragColor.rgb=vec3(occlusion,occlusion,occlusion);gl_FragColor.a=1.0;}",yt),this.uniforms._InverseProjMatrix={value:new I},this.uniforms._ProjectionMatrix={value:new I},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 s=[];for(let i=0;i<64;i++){const r=new e(2*Math.random()-1,2*Math.random()-1,Math.random());r.normalize();let n=i/64;n=t.lerp(.1,1,n*n),r.multiplyScalar(n),s.push(r)}return s}__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,U);return t.wrapS=q,t.wrapT=q,t.needsUpdate=!0,t}}class Mt extends Ye{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 St extends Ye{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform float _FarPlane;varying vec2 vUv;varying vec4 vRay;vec3 decode_normal(vec4 enc){float scale=1.7777;vec3 nn=enc.xyz*vec3(2.0*scale,2.0*scale,0.0)+vec3(-scale,-scale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec3 DecodeNormal(vec2 uv){vec4 depthNormal=texture2D(_MainTex,uv);vec3 normalValue=normalize(decode_normal(vec4(depthNormal.zw,0.,0.)));return normalize(normalValue);}vec3 DecodeViewPos(vec2 uv){vec2 depth=texture2D(_MainTex,uv).xy;return DecodeFloatRG(depth)*(vRay.xyz/vRay.w);}void main(){vec3 viewPos=DecodeViewPos(vUv);vec3 normalValue=DecodeNormal(vUv);float vDepth=clamp(0.0,1.0,length(viewPos)/_FarPlane);vDepth=length(viewPos)/_FarPlane;gl_FragColor=vec4(vDepth,vDepth,vDepth,1.0);}",yt),this.uniforms._FarPlane={value:1},this.uniforms._InverseProjMatrix={value:new I}}}class zt extends Ye{constructor(){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _Resolution;uniform vec2 _SampleDir;varying vec2 vUv;void main(){vec4 sum=vec4(0.,0.,0.,0.);vec2 dir=(0.5/_Resolution)*_SampleDir;float _Distance=2.0;sum+=texture2D(_MainTex,vUv+dir*-4.*_Distance)*0.0525;sum+=texture2D(_MainTex,vUv+dir*-3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*-2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*-1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*0.*_Distance)*0.225;sum+=texture2D(_MainTex,vUv+dir*1.*_Distance)*0.150;sum+=texture2D(_MainTex,vUv+dir*2.*_Distance)*0.110;sum+=texture2D(_MainTex,vUv+dir*3.*_Distance)*0.075;sum+=texture2D(_MainTex,vUv+dir*4.*_Distance)*0.0525;gl_FragColor=vec4(sum);}"),this.uniforms._SampleDir={value:new i}}}class Ft{constructor(e){this.RT1=new C(1,1),this.RT2=new C(1,1),this.box_blur_mat=new zt}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),ct.blit(e,this.RT1,this.box_blur_mat),this.box_blur_mat.uniforms._SampleDir.value.set(0,1),ct.blit(this.RT1,e,this.box_blur_mat)}}class Rt extends Ve{constructor(){super(),this.ssao_mat=new Tt,this.ssao_compose_mat=new Mt,this.debug_normals=new St,this.ssaa=Qe.use_ssaa?2:1,this.main_RT=new C(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT=new C(it.width,it.height),this.blurrer=new Ft,ct.generateDepthNormalTexture=!0}render(){this.__check_RT_size(),ct.clear(this.main_RT,Ee.current,!0,!1),ct.render(Ke.current,Ee.current,this.main_RT),this.__update_uniforms(),ct.blit(ct.depth_normals_RT,this.SSAO_RT,this.ssao_mat),this.blurrer.blur(this.SSAO_RT),ct.blit(this.SSAO_RT,void 0),this.ssao_compose_mat.uniforms._AO.value=this.SSAO_RT.texture,ct.blit(this.main_RT,void 0,this.ssao_compose_mat)}__update_uniforms(){this.ssao_mat.uniforms._InverseProjMatrix.value.getInverse(Ee.current.projectionMatrix),this.ssao_mat.uniforms._ProjectionMatrix.value.copy(Ee.current.projectionMatrix),this.ssao_mat.uniforms._FarPlane.value=Ee.current.far}__check_RT_size(){this.main_RT.width===it.width*this.ssaa&&this.main_RT.height===it.height*this.ssaa||(this.main_RT.setSize(it.width*this.ssaa,it.height*this.ssaa),this.SSAO_RT.setSize(it.width,it.height))}}class At extends Ve{constructor(){super()}render(){ct.clear(void 0,Ee.current,!0,!0),Ke.current.on_pre_render&&Ke.current.on_pre_render(),Ke.current.render?Ke.current.render():ct.render(Ke.current,Ee.current),Ke.current.on_post_render&&Ke.current.on_post_render()}}class Ct extends Ye{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 n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF"),new n("#FFFFFF")];this.uniforms.bloomTintColors={value:t}}set_RT_0(e){this.uniforms.blurTexture1.value=e}set_RT_1(e){this.uniforms.blurTexture2.value=e}set_RT_2(e){this.uniforms.blurTexture3.value=e}set_RT_3(e){this.uniforms.blurTexture4.value=e}set_RT_4(e){this.uniforms.blurTexture5.value=e}set_bloom_strength(e){this.uniforms.bloomStrength.value=e}set_bloom_radius(e){this.uniforms.bloomRadius.value=e}set_tint_color_0(e){this.uniforms.bloomTintColors.value[0].set(e)}set_tint_color_1(e){this.uniforms.bloomTintColors.value[1].set(e)}set_tint_color_2(e){this.uniforms.bloomTintColors.value[2].set(e)}set_tint_color_3(e){this.uniforms.bloomTintColors.value[3].set(e)}set_tint_color_4(e){this.uniforms.bloomTintColors.value[4].set(e)}}class Dt extends Ye{constructor(e){super("#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform sampler2D _SecondTex;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv);gl_FragColor+=texture2D(_SecondTex,vUv);}"),this.uniforms._SecondTex={value:void 0}}set_add_texture(e){this.uniforms._SecondTex.value=e}}class Pt extends Ye{constructor(e){super("#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;uniform sampler2D _MainTex;uniform vec2 texSize;uniform vec2 direction;float gaussianPdf(in float x,in float sigma){return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;}void main(){vec2 invSize=1.0/texSize;float fSigma=float(SIGMA);float weightSum=gaussianPdf(0.0,fSigma);vec4 diffuseSum=texture2D(_MainTex,vUv)*weightSum;for(int i=1;i<KERNEL_RADIUS;i++){float x=float(i);float w=gaussianPdf(x,fSigma);vec2 uvOffset=direction*invSize*x;vec4 sample1=texture2D(_MainTex,vUv+uvOffset);vec4 sample2=texture2D(_MainTex,vUv-uvOffset);diffuseSum+=(sample1+sample2)*w;weightSum+=2.0*w;}gl_FragColor=vec4(diffuseSum/weightSum);}",void 0,{KERNEL_RADIUS:e,SIGMA:e}),this.uniforms.texSize={value:new i(.5,.5)},this.uniforms.direction={value:new i(.5,.5)}}set_size(e,t){this.uniforms.texSize.value.x=e,this.uniforms.texSize.value.y=t}set_direction(e,t){this.uniforms.direction.value.set(e,t)}}class Lt extends Ye{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 n("#000000")},this.uniforms.defaultOpacity={value:0}}}class Ut{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:G,magFilter:G,format:k},this.renderTargetBright=new C(1,1,this.rt_pars),this.renderTargetBright.texture.generateMipmaps=!1,this.init_materials(),this.init_RT(),this.luminosity_high_pass_mat=new Lt}blur(e,t){this.resize_RT(e.width,e.height),t?ct.blit(e,this.renderTargetBright,this.luminosity_high_pass_mat):ct.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),ct.blit(s,this.renderTargetsHorizontal[e],t),t.set_direction(0,1),ct.blit(this.renderTargetsHorizontal[e],this.renderTargetsVertical[e],t),s=this.renderTargetsVertical[e]}}get_blurred_texture(){return this.renderTargetsHorizontal[0].texture}get_blurred_RT(){return this.renderTargetsHorizontal[0]}init_RT(){this.dispose_RT(),this.renderTargetBright.setSize(1,1);for(let e=0;e<this.nMips;e++){const e=new C(1,1,this.rt_pars),t=new C(1,1,this.rt_pars);e.texture.generateMipmaps=!1,t.texture.generateMipmaps=!1,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 Pt(this.kernelSizeArray[e]))}dispose_materials(){for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.separableBlurMaterials.length=0}dispose_RT(){for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsHorizontal[e].dispose(),this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose(),this.renderTargetsHorizontal.length=0,this.renderTargetsVertical.length=0}}class kt extends Ve{constructor(){super(),this.bloom_compose_mat=void 0,this.main_RT=void 0,this.blur_RT=void 0,this.blurrer=void 0,this.add_mat=new Dt}on_enter(){this.blurrer=new Ut,this.main_RT=new C(it.render_width,it.render_height),this.blur_RT=new C(it.render_width,it.render_height),this.bloom_compose_mat=new Ct(5),this.blurrer=new Ut(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(),ct.clear(this.main_RT,Ee.current,!0,!1),ct.render(Ke.current,Ee.current,this.main_RT),this.blurrer.blur(this.main_RT,!0),ct.material_pass(this.bloom_compose_mat,this.blurrer.renderTargetsHorizontal[0]),ct.blit(this.main_RT,void 0,this.add_mat)}__check_RT_size(){this.main_RT.width===it.render_width&&this.main_RT.height===it.render_height||(this.main_RT.setSize(it.render_width,it.render_height),this.blur_RT.setSize(it.render_width,it.render_height))}}class Ot extends D{constructor(e,t,s,i,r,o){super(e,t,s,i,r,o),this.clear_color=new n("#000000"),this.clear_alpha=1}}var jt=new class{constructor(){this.components=[],this.enabled_components=new Set}update(){this.__set_components_opacities();for(const e of this.enabled_components)e.update(je.transition_handler.current_state_data)}register_component(e){this.components.push(e)}enable_component(e){this.enabled_components.add(e)}disable_component(e){this.enabled_components.delete(e)}get_component_by_name(e){console.warn("DEPRECATED. Use ViewComponentManager.get instead"),this.get(e)}get(e){for(let t=0;t<this.components.length;t++)if(this.components[t].name===e)return this.components[t];console.error("[ViewComponentManager.get] no component found for: ",e)}__set_components_opacities(){for(let e=0;e<this.components.length;e++)this.components[e].set_opacity(je.transition_handler.current_state_data)}};class It{constructor(e,t){e=e||new Ne,this._frame_id=-1,this.target_application=e,this.graphics=t,this.is_running=!1,this.frames_passed=0}update(){this.is_running&&(Ue.__update(),1===this.frames_passed&&this.target_application.on_post_start(),this.target_application.update(),je.update(),jt.update(),this.target_application.on_pre_render(),this.graphics.update(),xt.update(),xt.render(this.graphics),this.target_application.on_post_render(),ot.render(this.graphics),this._frame_id=requestAnimationFrame(this.update.bind(this)),this.target_application.on_frame_end(),this.frames_passed++,mt.clear(),xt.clear(),ot.clear())}start(){this.is_running||(0===this.frames_passed&&this.target_application.on_enter(),this.is_running=!0,this.update())}stop(){!1!==this.is_running&&(this.is_running=!1,this.target_application.on_exit(),cancelAnimationFrame(this._frame_id))}set_state(e){this.target_application.on_exit(this),this.target_application=e,this.target_application.on_enter(this)}dispose(){this.stop(),this.frames_passed=0}}class Nt extends Xe{constructor(){super(),this.text_margin=new i(2,0)}__draw(e,t,s,i){i.font=t.font;const r=this.get_text_size(e,t.font);s.width=Math.ceil(r.x+2*this.text_margin.x),s.height=Math.ceil(r.y+2*this.text_margin.y),i.clearRect(0,0,s.width,s.height),i.globalAlpha=0,i.fillStyle=t.font_color||"#000000",i.fillRect(0,0,s.width,s.height),i.globalAlpha=1,i.globalAlpha=1,i.font=t.font,i.fillStyle=t.font_color||"#000000",i.textBaseline="middle",i.textAlign=t.textAlign||"center","center"===i.textAlign?i.fillText(e,s.width/2,s.height/2):i.fillText(e,0,s.height/2)}}class Vt{constructor({name:e,container:t}){this.name=e,this.container=t,this.hidden=!0,jt.register_component(this)}start(){}on_enter(){this.container.classList.remove("hidden"),jt.enable_component(this),this.hidden=!1}update(){}on_exit(){this.container.classList.add("hidden"),jt.disable_component(this),this.hidden=!0}set_opacity(e){this.container.style.opacity=e[`${this.name}_opacity`],this.toggle_hidden()}toggle_hidden(){this.container.style.opacity>.001?this.hidden&&this.on_enter():this.hidden||this.on_exit()}}class Bt extends v{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new x({color:s});const r=new M(e,t);r.rotateX(-1.57),super(r,i)}}class qt extends v{constructor(e,t,s,i){e=e||1,t=t||1,s=s||"#FF0000",i=i||new x({color:s});super(new M(e,t),i)}}class Gt{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 Yt{constructor(){this.sphere=new B}fit_points(t,s,i,r){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),u=this.sphere.center.clone(),d=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,i,r),m=u.clone().add(c.clone().multiplyScalar(-1*d)),p=(new N).setFromNormalAndCoplanarPoint(a,m),g=(new N).setFromNormalAndCoplanarPoint(_,m),v=(new N).setFromNormalAndCoplanarPoint(l,m),f=(new N).setFromNormalAndCoplanarPoint(h,m);this.apply_center_correction_to_pos(m,t,s,p,g,v,f),p.setFromNormalAndCoplanarPoint(a,m),g.setFromNormalAndCoplanarPoint(_,m),v.setFromNormalAndCoplanarPoint(l,m),f.setFromNormalAndCoplanarPoint(h,m);let x=1/0;const w=c.clone().multiplyScalar(-2*d);for(let s=0;s<t.length;s++){const i=new Y(t[s].clone(),t[s].clone().add(w)),r=new e,n=new e,o=new e,a=new e;p.intersectLine(i,r),g.intersectLine(i,n),v.intersectLine(i,o),f.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(),u=Math.min(_,l),d=Math.min(h,c),m=Math.min(u,d);m<x&&(x=m)}const b=c.clone().multiplyScalar(x);return m.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(t,s,i,r){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++){const h=new Y(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new Y(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(5e6))),u=new e,d=new e;s.intersectLine(h,u),i.intersectLine(c,d);const m=u.distanceTo(t[r]),p=d.distanceTo(t[r]);d.length()<1e-4&&console.log("vertical up intersection not found",r),u.length()<1e-4&&console.log("vertical down intersection not found",r),m<_&&(_=m,o=t[r]),p<a&&(a=p,n=t[r])}console.log(n,o);const h=(a-_)/2;return l.clone().multiplyScalar(-h)}get_hozirontal_correction(t,s,i,r){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++){const h=new Y(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(-5e6))),c=new Y(t[r].clone(),t[r].clone().add(l.clone().multiplyScalar(5e6))),u=new e,d=new e;s.intersectLine(h,u),i.intersectLine(c,d);const m=u.distanceTo(t[r]),p=d.distanceTo(t[r]);u.length()<1e-4&&console.log("left intersection not found",r),d.length()<1e-4&&console.log("right intersection not found",r),m<_&&(_=m,o=t[r]),p<a&&(a=p,n=t[r])}const h=(a-_)/2;return console.log(n,o),l.clone().multiplyScalar(-h)}get_up_plane_normal(t,s){const i=new e(0,-1,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(1,0,0),s)),i.applyQuaternion(t),i}get_down_plane_normal(t,s){const i=new e(0,1,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(1,0,0),-s)),i.applyQuaternion(t),i}get_left_plane_normal(t,s){const i=new e(1,0,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(0,1,0),s)),i.applyQuaternion(t),i}get_right_plane_normal(t,s){const i=new e(-1,0,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(0,1,0),-s)),i.applyQuaternion(t),i}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class Et{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 m;return r.setAttribute("position",new j(new Float32Array(i),3)),Et.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 j(new Float32Array(t),3))}}class Wt{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 S(r[i+0],r[i+1],r[i+2],r[i+3])}}var Xt=new class{constructor(){}sample(t,s){const i=[];let r=99999999;const n=t.getAttribute("position"),o=t.getAttribute("normal"),a=t.index,_=[];for(let t=0;t<a.count;t+=3){const s=a.array[t+0],l=a.array[t+1],h=a.array[t+2],c=new e;c.x=n.getX(s),c.y=n.getY(s),c.z=n.getZ(s);const u=new e;u.x=n.getX(l),u.y=n.getY(l),u.z=n.getZ(l);const d=new e;d.x=n.getX(h),d.y=n.getY(h),d.z=n.getZ(h);const m={a:c,b:u,c:d};if(o){const t=new e;t.x=o.getX(s),t.y=o.getY(s),t.z=o.getZ(s);const i=new e;i.x=o.getX(l),i.y=o.getY(l),i.z=o.getZ(l);const r=new e;r.x=o.getX(h),r.y=o.getY(h),r.z=o.getZ(h);const n=t.clone().add(i).add(r).normalize();m.normal=n}_.push(m);const p=this.get_face_area(m);r=Math.min(p,r),i.push(p)}const l=this.get_uniform_face_distribution(i,r,_),h=this.select_random_faces(l,s);return this.sample_data_from_faces(h)}sample_data_from_faces(e){const t=[],s=[];for(let i=0;i<e.length;i++){const r=e[i],n=Math.random(),o=Math.random();t.push(this.sample_point_in_face(n,o,r.a,r.b,r.c).clone()),r.normal&&s.push(r.normal.clone())}return{points:t,normals:s}}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))}};var Qt=new class{get_mesh(e,t){e.traverse((e=>{e instanceof v&&(e.geometry&&(e.geometry=(new m).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 v&&(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 W(o,t.boneInverses),n.matrixWorld)}return t}set_shadow_config(e,t,s){e.traverse((e=>{e instanceof v&&(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 Ht{constructor(){}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 Zt{constructor(){}static capitalize(e){const t=e.split(" ");for(let e=0;e<t.length;e++)t[e]=t[e][0].toUpperCase()+t[e].substr(1);return t.join(" ")}static capitalize_first_letter(e){return e.charAt(0).toUpperCase()+e.slice(1)}static snake_to_camelcase(e){return e.replace(/([-_][a-z])/g,(e=>e.toUpperCase().replace("-","").replace("_","")))}}class Jt{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 $t{constructor(){this.sphere=new B}fit_points(s,i,r,n){this.sphere.setFromPoints(s);const o=t.degToRad(r/2),a=2*Math.atan(Math.tan(o)*n)/2,_=this.get_up_plane_normal(i,o),l=this.get_down_plane_normal(i,o),h=this.get_left_plane_normal(i,a),c=this.get_right_plane_normal(i,a),u=new e(0,0,-1).applyQuaternion(i),d=this.sphere.center.clone(),m=this.get_distance_to_fit_rect(2*this.sphere.radius,2*this.sphere.radius,r,n),p=d.clone().add(u.clone().multiplyScalar(-1*m)),g=(new N).setFromNormalAndCoplanarPoint(_,p),v=(new N).setFromNormalAndCoplanarPoint(l,p),f=(new N).setFromNormalAndCoplanarPoint(h,p),x=(new N).setFromNormalAndCoplanarPoint(c,p);this.apply_center_correction_to_pos(p,s,i,g,v,f,x),g.setFromNormalAndCoplanarPoint(_,p),v.setFromNormalAndCoplanarPoint(l,p),f.setFromNormalAndCoplanarPoint(h,p),x.setFromNormalAndCoplanarPoint(c,p);let w=1/0;const b=u.clone().multiplyScalar(-2*m);for(let t=0;t<s.length;t++){const i=new Y(s[t].clone(),s[t].clone().add(b)),r=new e,n=new e,o=new e,a=new e;g.intersectLine(i,r),v.intersectLine(i,n),f.intersectLine(i,o),x.intersectLine(i,a),r.length()<1e-4&&console.log("up intersection not found",t),n.length()<1e-4&&console.log("down intersection not found",t),o.length()<1e-4&&console.log("left intersection not found",t),a.length()<1e-4&&console.log("right intersection not found",t);const _=s[t].clone().sub(r).length(),l=s[t].clone().sub(n).length(),h=s[t].clone().sub(o).length(),c=s[t].clone().sub(a).length(),u=Math.min(_,l),d=Math.min(h,c),m=Math.min(u,d);m<w&&(w=m)}const y=u.clone().multiplyScalar(w);return p.clone().add(y)}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(t,s,i,r){let n=1/0,o=1/0;const a=new e(0,1,0).applyQuaternion(r);for(let r=0;r<t.length;r++){const _=new Y(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new Y(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 u=h.distanceTo(t[r]),d=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),u<o&&(o=u),d<n&&(n=d)}const _=(n-o)/2;return a.clone().multiplyScalar(-_)}get_horizontal_correction(t,s,i,r){let n=1/0,o=1/0;const a=new e(1,0,0).applyQuaternion(r);for(let r=0;r<t.length;r++){const _=new Y(t[r].clone(),t[r].clone().add(a.clone().multiplyScalar(-5e6))),l=new Y(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 u=h.distanceTo(t[r]),d=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),u<o&&(o=u),d<n&&(n=d)}const _=(n-o)/2;return a.clone().multiplyScalar(-_)}get_up_plane_normal(t,s){const i=new e(0,-1,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(1,0,0),s)),i.applyQuaternion(t),i}get_down_plane_normal(t,s){const i=new e(0,1,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(1,0,0),-s)),i.applyQuaternion(t),i}get_left_plane_normal(t,s){const i=new e(1,0,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(0,1,0),s)),i.applyQuaternion(t),i}get_right_plane_normal(t,s){const i=new e(-1,0,0);return i.applyQuaternion((new E).setFromAxisAngle(new e(0,1,0),-s)),i.applyQuaternion(t),i}get_distance_to_fit_rect(e,t,s,i){const r=s/2*Math.PI/180,n=2*Math.atan(Math.tan(r)*i)/2,o=t/Math.tan(r),a=e/Math.tan(n);return Math.max(Math.abs(a),Math.abs(o))}}class Kt{constructor(){}fit_points(t,s,i,r){const n=s.clone().inverse(),o=[];for(let e=0;e<t.length;e++)o.push(t[e].clone().applyQuaternion(n));const a=(new z).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}}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 es extends v{constructor(){const e=new r({uniforms:{_Color:{value:new n("#919191")}},vertexShader:"#define GLSLIFY 1\nattribute vec3 barycentric;varying vec3 vBarycentric;void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=(modelMatrix*vec4(position,1.0)).xyz;gl_Position=VP*vec4(pos,1.0);vBarycentric=barycentric;}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 _Color;varying vec3 vBarycentric;float edgeFactor(vec3 baryc){vec3 d=fwidth(baryc);vec3 a3=smoothstep(vec3(0.0),d*1.5,baryc);return min(min(a3.x,a3.y),a3.z);}void main(){float alpha=edgeFactor(vBarycentric+vec3(1.,1.,0.));gl_FragColor.rgb=mix(_Color,vec3(0.),alpha);gl_FragColor.a=1.0-alpha;gl_FragColor.a*=0.2;}",extensions:{derivatives:!0},transparent:!0,depthWrite:!1}),t=new M(100,100,100,100);super(Et.convert_to_non_indexed_geometry(t),e),this.rotation.x=-1.57}}class ts extends v{constructor(e){const t=new m;t.setAttribute("position",new j(new Float32Array([]),3)),t.setAttribute("next_position",new j(new Float32Array([]),3)),t.setAttribute("previous_position",new j(new Float32Array([]),3)),t.setAttribute("orientation",new j(new Float32Array([]),1)),t.setAttribute("coverage",new j(new Float32Array([]),1));super(t,new r({uniforms:{_Thickness:{value:.2},_Length:{value:0},_ElapsedTime:{value:0},_Color:{value:new n("#FF0000")}},vertexShader:"#define GLSLIFY 1\nuniform float _Thickness;attribute vec3 next_position;attribute vec3 previous_position;attribute float orientation;attribute float coverage;varying float line_coverage;varying float uv_u;vec3 w_space_normal(vec3 from,vec3 to){vec3 w_from=(modelMatrix*vec4(from,1.0)).xyz;vec3 w_to=(modelMatrix*vec4(to,1.0)).xyz;vec3 z=normalize(w_to-w_from);return normalize(cross(z,normalize(cameraPosition-w_from)));}void main(){mat4 VP=projectionMatrix*viewMatrix;vec3 pos=position;vec3 normal=w_space_normal(next_position,previous_position);pos=(modelMatrix*vec4(pos,1.0)).xyz;pos+=normal*(_Thickness*0.5)*orientation;gl_Position=VP*vec4(pos,1.0);line_coverage=coverage;uv_u=orientation*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nuniform float _Length;uniform float _ElapsedTime;uniform float _Thickness;uniform vec3 _Color;varying float line_coverage;varying float uv_u;float aastep(float threshold,float value){\n#ifdef GL_OES_standard_derivatives\nfloat afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757;return smoothstep(threshold-afwidth,threshold+afwidth,value);\n#else\nreturn step(threshold,value);\n#endif\n}void main(){float u=(1.0-abs(uv_u*2.0-1.0));float diffuse=dot(vec2(u,u),vec2(0.0,1.0))*0.5+0.5;gl_FragColor=vec4(_Color*diffuse,1.0);}",transparent:!0,depthWrite:!1,extensions:{derivatives:!0}})),e&&this.setup(e)}setup(e){const t=[],s=[],i=[],r=[],n=[];let o=0;for(let a=0;a<e.length;a++){t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),r.push(1),t.push(e[a].x),t.push(e[a].y),t.push(e[a].z),r.push(-1);const _=this.__get_next_position(e,a);s.push(_.x),s.push(_.y),s.push(_.z),s.push(_.x),s.push(_.y),s.push(_.z);const l=this.__get_previous_position(e,a);i.push(l.x),i.push(l.y),i.push(l.z),i.push(l.x),i.push(l.y),i.push(l.z),n.push(o),n.push(o),a<e.length-1&&(o+=e[a].distanceTo(_))}const a=new Float32Array(t),_=new Float32Array(s),l=new Float32Array(i),h=new Float32Array(r),c=new Float32Array(n),u=[];for(let e=0;e<(a.length/3-2)/2;e++){const t=2*e+1;u.push(t),u.push(t+1),u.push(t-1),u.push(t),u.push(t+2),u.push(t+1)}this.geometry.setIndex(u),this.geometry.getAttribute("position").copy(new j(a,3)),this.geometry.getAttribute("next_position").copy(new j(_,3)),this.geometry.getAttribute("previous_position").copy(new j(l,3)),this.geometry.getAttribute("orientation").copy(new j(h,1)),this.geometry.getAttribute("coverage").copy(new j(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 ss extends v{constructor(t,s){s=s||new i(0,0);const n=new r({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:X}),o=new Q(1,1,1);o.translate(-s.x/2,-s.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)}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 is extends ss{constructor(e,t,s,i,r){const n=new Nt(r),o={font:t,font_color:s||"#000000"},a=n.draw_on_texture(e,o);a.minFilter=H,a.minFilter=G,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 rs extends Ge{constructor(t=1){super("#define GLSLIFY 1\nuniform vec2 _ScreenSize;uniform vec2 _TextureSize;uniform vec2 _PixelOffset;uniform vec3 _NDC;uniform vec2 _PivotPoint;uniform float _DepthOffset;varying vec2 vUv;vec2 add_pixel_offset(vec2 pos){pos=pos*0.5+0.5;pos*=_ScreenSize;pos=ceil(pos+_PixelOffset)+0.5;pos/=_ScreenSize;return pos*2.0-1.0;}void main(){vec4 projected_pos=projectionMatrix*viewMatrix*vec4(_NDC,1.0);projected_pos.zw+=_DepthOffset;projected_pos.xyz/=projected_pos.w;vec2 normalized_size=_TextureSize/_ScreenSize;vec2 dir=uv*2.0-1.0;dir-=_PivotPoint;vec2 pos=projected_pos.xy+dir*normalized_size;gl_Position=vec4(add_pixel_offset(pos),projected_pos.z,1.0);vUv=uv;}","#define GLSLIFY 1\nuniform sampler2D _MainTex;uniform vec2 _ScreenSize;uniform vec2 _TextureSize;varying vec2 vUv;void main(){gl_FragColor=texture2D(_MainTex,vUv+vec2(0.5,0.5)/_TextureSize);}",{_MainTex:{value:void 0},_ScreenSize:{value:new i(Screen.width,Screen.height)},_TextureSize:{value:new i},_PixelOffset:{value:new i(0,0)},_NDC:{value:new e},_PivotPoint:{value:new i},_DepthOffset:{value:0}}),this.transparent=!0,this.depthWrite=!1,this.depthTest=!1}}class ns{constructor(){this.tmp_vec=new i}get_pos_NDC(e){return this.tmp_vec.set(e.x,e.y)}}class os{constructor(){this.tmp_vec3=new e,this.tmp_vec2=new i}get_pos_NDC(e){return this.tmp_vec3.copy(e),this.tmp_vec3.project(Ee.current),this.tmp_vec2.set(this.tmp_vec3.x,this.tmp_vec3.y)}}class as{constructor(){}update(e,t){}on_enter(e){}on_exit(e){}}class _s extends as{constructor(){super()}update(e,t){e.is_mouse_over(t)&&e.set_state(e._on_enter_state)}}class ls extends as{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 hs extends as{constructor(){super()}on_enter(e){e.on_mouse_exit(),e.set_state(e._on_idle_state)}}class cs extends as{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 us extends v{constructor(t,s){super(new Q(1,1),new rs),this.is_clickable=!1,this.position_strategy=new os,this.current_state=new _s,this._position=new e,this._on_idle_state=new _s,this._on_enter_state=new ls,this._on_exit_state=new hs,this._on_hover_state=new cs,this.on_enter=void 0,this.on_exit=void 0,this.on_hover=void 0,this.mouse_pos_tmp=new i,this.cached_NDC_position=new i,this.screen_pos_tmp=new i,this.texture_size=new i(1,1),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.renderOrder=0,this.size=1,this.pixel_offset=new i}set_render_order(e){this.renderOrder=e}get pivot_point(){return this.material.uniforms._PivotPoint.value}set_pixel_offset(e){this.pixel_offset.copy(e),this.material.uniforms._PixelOffset.value.copy(e)}set_state(e){this.current_state.on_exit(this),this.current_state=e,this.current_state.on_enter(this)}get position(){return this._position}set use_depth(e){this.material.depthTest=e}get use_depth(){return this.material.depthTest}set depth_offset(e){this.material.uniforms._DepthOffset.value=e}get depth_offset(){return this.material.uniforms._DepthOffset.value}clear_state(){this.visible=!1}set_world_space_coordinate_system(){this.position_strategy=new os}set_screen_space_coordinate_system(){this.position_strategy=new ns}set_texture(e){e.minFilter=c,e.magFilter=c,e.needsUpdate=!0,this.texture_size.set(e.image.width,e.image.height),this.material.uniforms._MainTex.value=e,this.get_size(this.material.uniforms._TextureSize.value),this.visible=!0}update_state(e){this.material.uniforms._ScreenSize.value.set(it.width,it.height),this.get_size(this.material.uniforms._TextureSize.value),this.cached_NDC_position.copy(this.position_strategy.get_pos_NDC(this.position)),this.material.uniforms._NDC.value.copy(this.position),this.current_state.update(this,e)}is_mouse_over(e){this.screen_pos_tmp.copy(this.cached_NDC_position),this.to_screen_position(this.screen_pos_tmp),this.screen_pos_tmp.x+=this.pixel_offset.x,this.screen_pos_tmp.y+=this.pixel_offset.y;const t=(new Z).setFromCenterAndSize(this.screen_pos_tmp,this.get_size());return this.mouse_pos_tmp.copy(e),this.to_screen_position(this.mouse_pos_tmp),t.containsPoint(this.mouse_pos_tmp)}to_screen_position(e){e.x=(.5*e.x+.5)*it.width+this.pixel_offset.x,e.y=(.5*e.y+.5)*it.height+this.pixel_offset.y}get_screen_space_position(){const e=this.cached_NDC_position.clone();return this.to_screen_position(e),e}set_screen_space_position(e){this.position.x=e.x/it.width*2-1,this.position.y=e.y/it.height*2-1}dispose(){this.material.uniforms._MainTex.value&&this.material.uniforms._MainTex.value.dispose(),it.remove_screen_material(this.material),this.geometry.dispose(),this.material.dispose()}get_size(e){return e?e.copy(this.texture_size).multiplyScalar(this.size/it.dpr):(new i).copy(this.texture_size).multiplyScalar(this.size/it.dpr)}on_mouse_enter(){}on_mouse_exit(){}on_mouse_hover(){}}class ds extends v{constructor(e,t){super(e,t);const s=this;this.onBeforeRender=()=>{s.material.update()}}}class ms{constructor(e,t,s){const r=t.right-t.left,n=t.top-t.bottom;this.scale=new i(r,n),this.position=new i(e+t.left,t.bottom),this.atlas_bounds=new S(s.left,s.right,s.top,s.bottom)}}class ps{constructor(t,s=""){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 E,this.scale=new e(1,1,1),this.matrix=new I,this.color=new n("#FFFFFF"),this.pivot_point=new i,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(t=0,s=0){const i=(new E).setFromAxisAngle(new e(0,1,0),t/360*Math.PI*2),r=(new E).setFromAxisAngle(new e(1,0,0),-s/360*Math.PI*2);this.quaternion.copy(i.multiply(r)),this.matrix_is_dirty=!0}set_position(e){this.position.copy(e),this.matrix_is_dirty=!0}set_size(e){this.scale.set(e,e,e),this.matrix_is_dirty=!0}set_color(e){this.color.set(e),this.color_is_dirty=!0}set_pivot(e){this.pivot_point.copy(e),this.update_glyphs()}set opacity(e){this.__opacity=e,this.color_is_dirty=!0}get opacity(){return this.__opacity}update_glyphs(){this.__generate_glyphs(this.text)}__generate_glyphs(e){let t=0;this.glyphs.length=0;for(let s=0;s<e.length;s++){const i=e.charCodeAt(s),r=this.glyph_layout.find((e=>e.unicode===i));if(r){if(r.planeBounds){const e=new ms(t,r.planeBounds,r.atlasBounds);this.glyphs.push(e)}t+=r.advance}}const s=new Z,r=this.glyphs[0];s.setFromCenterAndSize(r.position.clone().add(new i(r.scale.x/2,r.scale.y/2)),r.scale);for(let e=1;e<this.glyphs.length;e++){const t=this.glyphs[e],r=(new Z).setFromCenterAndSize(t.position.clone().add(new i(t.scale.x/2,t.scale.y/2)),t.scale);s.union(r)}const n=new i;s.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 gs extends Ge{constructor(e){super("#define GLSLIFY 1\nattribute vec4 transformsCol0;attribute vec4 transformsCol1;attribute vec4 transformsCol2;attribute vec4 transformsCol3;attribute vec4 glyph_bounds;attribute vec4 plane_bounds;attribute vec4 color;varying vec2 vUv;varying vec4 v_glyph_bounds;varying vec4 v_color;void main(){vec4 pos=vec4(position,1.0);pos.x*=plane_bounds.z;pos.y*=plane_bounds.w;pos.x+=plane_bounds.x;pos.y+=plane_bounds.y;mat4 offset_matrix=mat4(transformsCol0,transformsCol1,transformsCol2,transformsCol3);gl_Position=projectionMatrix*viewMatrix*offset_matrix*pos;vUv=uv;v_glyph_bounds=glyph_bounds;v_color=color;}","#define GLSLIFY 1\nuniform sampler2D _Texture;uniform float _Boldness;varying vec2 vUv;uniform vec2 _AtlasSize;varying vec4 v_glyph_bounds;varying vec4 v_color;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){float left=v_glyph_bounds.x/_AtlasSize.x;float right=v_glyph_bounds.y/_AtlasSize.x;float top=v_glyph_bounds.z/_AtlasSize.y;float bottom=v_glyph_bounds.w/_AtlasSize.y;float width=abs(right-left);float height=abs(top-bottom);vec2 coord=vec2(vUv.x*width+left,vUv.y*height+top-height);vec4 col=texture2D(_Texture,coord);float sig_dist=median(col.r,col.g,col.b);float _Cutoff=_Boldness;float dist=(_Cutoff-sig_dist);vec2 ddist=vec2(dFdx(dist),dFdy(dist));float pixelDist=dist/length(ddist);float opacity=clamp(0.5-pixelDist,0.0,1.0);gl_FragColor=vec4(v_color.rgb,opacity*v_color.a);}",{_Texture:{value:e},_Boldness:{value:.5},_AtlasSize:{value:new i(1,1)}}),this.transparent=!0,this.extensions={derivatives:!0},this.depthWrite=!1,this.side=X,e.minFilter=G,e.magFilter=G,e.generateMipMaps=!1}set_atlas_size(e){this.uniforms._AtlasSize.value.copy(e)}set_boldness(e){this.uniforms._Boldness.value=t.lerp(.5,.2,e)}}class vs extends v{constructor(e,t){const s=new J;s.instanceCount=0;const r=new M(1,1);r.translate(.5,.5,0),s.setAttribute("position",new $(r.getAttribute("position").array,3)),s.setAttribute("uv",new $(r.getAttribute("uv").array,2)),s.index=r.index;const n=new K(new Float32Array(8e3),4,!1),o=new K(new Float32Array(8e3),4,!1),a=new K(new Float32Array(8e3),4,!1),_=new K(new Float32Array(8e3),4,!1),l=new K(new Float32Array(8e3),4,!1),h=new K(new Float32Array(8e3),4,!1),c=new K(new Float32Array(8e3),4,!1);n.usage=ee,o.usage=ee,a.usage=ee,_.usage=ee,l.usage=ee,h.usage=ee,c.usage=ee,s.setAttribute("transformsCol0",n),s.setAttribute("transformsCol1",o),s.setAttribute("transformsCol2",a),s.setAttribute("transformsCol3",_),s.setAttribute("glyph_bounds",l),s.setAttribute("plane_bounds",h),s.setAttribute("color",c),super(s,new gs(t)),this.text_elements=[],this.font_layout=e,this.material.set_atlas_size(new i(e.atlas.width,e.atlas.height)),this.frustumCulled=!1}set_boldness(e){this.material.set_boldness(e)}add_text(e){const t=new ps(this.font_layout.glyphs,e);return this.text_elements.push(t),t}remove_text(e){Gt.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,m=u.color,p=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,m.r,m.g,m.b,p),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 fs extends Se{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 xs extends Ye{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 i(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 i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class ws{constructor(e){this.RT=new C(1,1,{type:O,format:k,minFilter:c,magFilter:c}),this.RT1=new C(1,1,{type:O,format:k,minFilter:c,magFilter:c}),this.median_filter_mat=new xs}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),ct.material_pass(this.median_filter_mat,this.RT);for(let e=0;e<0;e++)this.median_filter_mat.set_texture(this.RT.texture),ct.material_pass(this.median_filter_mat,this.RT1),this.median_filter_mat.set_texture(this.RT1.texture),ct.material_pass(this.median_filter_mat,this.RT);return this.RT}get_size(e){return e.isVideoTexture?new i(Math.max(1,e.image.videoWidth),Math.max(1,e.image.videoHeight)):e.isWebGLRenderTarget?new i(e.width,e.height):e.isTexture?new i(e.image.width,e.image.height):new i(1,1)}}class bs extends Ye{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 Ye{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 C(1,1),this.RT1=new C(1,1),this.RT2=new C(1,1),this.RT3=new C(1,1),this.RT4=new C(1,1),this.upscale_blur_mat=new 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),ct.blit(e,this.RT1,this.alpha_filter_mat),ct.blit(this.RT1,this.RT2,this.downscale_blur_mat),ct.blit(this.RT2,this.RT3,this.downscale_blur_mat),ct.blit(this.RT3,this.RT4,this.downscale_blur_mat),ct.blit(this.RT4,this.RT3,this.upscale_blur_mat),ct.blit(this.RT3,this.RT2,this.upscale_blur_mat),ct.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 u{constructor(){super(),this.attributes=[],this.particles=void 0}set_from_geometry(e,t,s){if(s&&void 0===e.getAttribute("storage_uv")){const t=this.build_uv_storage_attribute(e.getAttribute("position").count);e.setAttribute("storage_uv",t)}const i=new te(e,t);i.frustumCulled=!1,this.particles=i,this.add(i)}add_texture_attribute(e){}add_attribute(e,t){}build_uv_storage_attribute(e){const t=this.calculate_resolution(e),s=new Float32Array(2*e);for(let i=0,r=0;i<2*e;i+=2,r++)s[i]=r%t/t+.5/t,s[i+1]=Math.floor(r/t)/t+.5/t;return new j(s,2)}calculate_resolution(e){return Math.ceil(Math.sqrt(e))}update(){for(let e=0;e<this.attributes.length;e++)this.attributes[e].update()}set_attribute_update_material(e,t){for(let s=0;s<this.attributes.length;s++)this.attributes[s].name===e&&(this.attributes[s].update_material=t)}dispose(){this.particles.geometry.dispose(),this.particles.material.dispose()}}class Ss 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 zs extends Ss{constructor(e,t){super(new Uint8Array(e*t*3),e,t,U),this.multiplier=255}}class Fs extends Ss{constructor(e,t){super(new Uint8Array(e*t*4),e,t,k),this.multiplier=255}}class Rs extends Ss{constructor(e,t){super(new Float32Array(e*t*3),e,t,U,O)}}class As extends Ss{constructor(e,t){super(new Float32Array(e*t*4),e,t,k,O)}}class Cs extends v{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 zs(this.batch_width,this.batch_height)}attach_rgba_texture(e){this.material.uniforms[e].value=new Fs(this.batch_width,this.batch_height)}attach_rgb_float_texture(e){this.material.uniforms[e].value=new Rs(this.batch_width,this.batch_height)}attach_rgba_float_texture(e){this.material.uniforms[e].value=new As(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 Ds{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=he.mergeBufferGeometries(s),o=new j(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 Cs(e,t,s,i)}}class Ps{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 se(e):this.audio=new ie(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 Ls extends be{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,t){window.user_interaction_for_audio?this.instantiate_audio(e,t):setTimeout(this.on_preloaded_finished.bind(this,e,t),100)}instantiate_audio(e,t){t.arrayBuffer().then((t=>{re.getContext().decodeAudioData(t,(t=>{e.set_resource(this.resource_id,this.url,new Ps(t,this.loop,this.volume,this.positional)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))}))}}class Us extends be{constructor(e,t,s,i,r){super(e,t,r),this.loader=i,this.loader.setWorkerLimit(1),this.loader.setTranscoderPath("libs/basis/"),this.loader.detectSupport(s)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{s.encoding=ne,e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class ks extends be{constructor(e,t,s){super(e,t,s),this.loader=new oe,this.loader.setPath(t+"/"),this.urls=["px.png","nx.png","py.png","ny.png","pz.png","nz.png"]}on_preloaded_finished(e){const t=this;this.loader.load(this.urls,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error("Image could not be loaded. Maybe wrong name or path, I don't know¯\\_(ツ)_/¯",e),t.__loading_ended()}))}}class Os extends be{constructor(e,t,s){super(e,t,s),this.loader=new ue.ColladaLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class js extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class Is extends be{constructor(e,t,s){super(e,t,s),this.loader=new de}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ns extends be{constructor(e,t,s){super(e,t,s),this.loader=new me.GLTFLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Vs extends be{constructor(e,t,s){super(e,t,s),this.loader=new me.GLTFLoader,this.draco_loader=new pe.DRACOLoader,this.draco_loader.setDecoderPath(window.draco_decoder_path),this.draco_loader.setDecoderConfig({type:"js"}),this.draco_loader.setWorkerLimit(1),this.loader.setDRACOLoader(this.draco_loader)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Bs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ge.HDRCubeTextureLoader,this.url_suffix=["/px.hdr","/nx.hdr","/py.hdr","/ny.hdr","/pz.hdr","/nz.hdr"]}on_preloaded_finished(e){const t=this;this.loader.setPath(this.url).setDataType(_e).load(this.url_suffix,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class qs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,JSON.parse(s)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Gs extends be{constructor(e,t,s){super(e,t,s),this.loader=new ve.OBJLoader}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ys extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,t.parse_path(s)),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}parse_path(t){const s=t.split("\n");""===s[s.length-1]&&s.pop();const i=[];for(let t=0;t<s.length;t+=3){const r=parseFloat(s[t+0]),n=parseFloat(s[t+1]),o=parseFloat(s[t+2]);i.push(new e(r,n,o))}return i}}class Es extends be{constructor(e,t,s){super(e,t,s),this.loader=new fe.RGBELoader,this.loader.setDataType(_e)}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e+"\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource"),t.__loading_ended()}))}}class Ws extends be{constructor(e,t,s){super(e,t,s),this.loader=new ae}on_preloaded_finished(e){const t=this;this.loader.load(this.url,(s=>{e.set_resource(t.resource_id,t.url,s),t.__update_downloaded_bytes(1,1),t.__loading_ended()}),(e=>{}),(e=>{t.__set_error(e),t.__loading_ended()}))}}class Xs extends be{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){t.blob().then((t=>{const s=new le,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()}}))}}class Qs extends be{constructor(e,t,s){super(e,t,s)}on_preloaded_finished(e,t){t.blob().then((t=>{e.set_resource(this.resource_id,this.url,URL.createObjectURL(t)),this.__update_downloaded_bytes(1,1),this.__loading_ended()}))}}class Hs{constructor(e){this.resource_loaders=[],this.batch_name=e||"unnamed batch"}add_loader(e){this.resource_loaders.push(e)}load(e){for(let t=0;t<this.resource_loaders.length;t++)this.resource_loaders[t].load(e||Pe)}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{be as AbstractLoader,Re as ActionEvent,Se as ActionInterpolator,Te as ActionSequencer,Ce as ActionSequencerBuilder,Ie as ApplicationView,Gt as ArrayUtilities,st as Arrow,Ls as AudioLoader,Ne as BaseApplication,Ve as BaseRender,Ge as BaseShaderMaterial,Us as BasisLoader,Ye as BlitMaterial,Ft as Blurrer,xe as Browser,Je as CSSAnimator,Ee as CameraManager,wt as CameraUtilities,Xe as CanvasDrawer,We as Capabilities,Qe as Configuration,et as Cube,ks as CubemapLoader,Os as DAELoader,ot as Debug,dt as DebugNormalsRender,Ae as DrawIOAnimationSheet,bs as DualFilteringBlurMaterial,Ts as DualFilteringBlurrer,Me as EasingFunctions,De as EventManager,js as FileLoader,Is as FontLoader,Yt as FrustumPointFitter,Vs as GLTFDRACOLoader,Ns as GLTFLoader,Ms as GPUParticleSystem,Ut as GaussianBlurrer,Et as GeometryUtilities,ct as Graphics,es as Grid,Bs as HDRCubeTextureLoader,Bt as HorizontalPlane,Wt as ImageUtilities,bt as Initializer,mt as Input,qs as JSONLoader,ts as Line,ws as MedianFilter,Ds as MeshBatcher,Xt as MeshSampler,Qt as ModelUtilities,Rt as NormalAORender,At as NormalRender,ze as NumberInterpolator,Gs as OBJLoader,ye as OMath,pt as OS,Ht as ObjectUtilities,Ot as OrthographicCamera,Kt as OrthographicFrustumPointFitter,nt as PerspectiveCamera,$t as PerspectiveFrustumPointFitter,Ys as PointArrayLoader,Es as RGBETextureLoader,It as RenderLoop,Hs as ResourceBatch,Pe as ResourceContainer,vs as SDFTextBatch,Ke as SceneManager,it as Screen,Nt as SimpleTextDrawer,tt as Sphere,Zt as StringUtilities,is as Text2D,Ws as TextLoader,Xs as TextureLoader,Ue as Time,Jt as TimeUtilities,Le as TransitionTable,xt as UI,us as UIElement,kt as UnrealBloomRender,ds as UpdatableMaterialMesh,we as Validation,fs as VectorInterpolator,qt as VerticalPlane,Qs as VideoLoader,Vt as ViewComponent,jt as ViewComponentManager,Fe as ViewContext,je as ViewManager,ss as WorldImage};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|