mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 07:18:29 +08:00
1 line
6.6 KiB
JavaScript
1 line
6.6 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{"6cU9":function(e,t,s){"use strict";s.d(t,"a",(function(){return o}));var i=s("FXpb"),n=(s("+Mcu"),s("ouMO")),r=s("QmPX");class o extends r.a{constructor(e,t){super(t),this.element=Object(i.n)({className:"core_FileButton core_Button"}),this.input=Object(i.m)({className:"core_FileButton_input core_Button_inner"}),this._files=Object(n.e)([]),this.files=this._files,this.input.type="file",this.input.onchange=()=>{this.input.files&&this.input.files.length?this._files.val=[...this.input.files]:this._files.val=[]};const s=Object(i.r)({className:"core_FileButton_inner core_Button_inner"});t&&(null!=t.accept&&(this.input.accept=t.accept),null!=t.multiple&&(this.input.multiple=t.multiple),null!=t.icon_left&&s.append(Object(i.r)({className:"core_FileButton_left core_Button_left"},Object(i.k)(t.icon_left)))),s.append(Object(i.r)({className:"core_Button_center"},e)),this.element.append(s,this.input),this.disposables(this.enabled.observe(({value:e})=>{this.input.disabled=!e,e?this.element.classList.remove("disabled"):this.element.classList.add("disabled")})),this.finalize_construction()}click(){this.input.click()}}},Ftn7:function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s("pVCM"),n=s("Womt");i.a.install({THREE:Object.assign(Object.assign({},n),{MOUSE:Object.assign(Object.assign({},n.MOUSE),{LEFT:n.MOUSE.RIGHT,RIGHT:n.MOUSE.LEFT})})});class r{constructor(e){this._debug=!1,this.scene=new n.Scene,this.light_holder=new n.Group,this.render_scheduled=!1,this.animation_frame_handle=void 0,this.light=new n.HemisphereLight(16777215,5263440,1),this.controls_clock=new n.Clock,this.size=new n.Vector2(0,0),this.schedule_render=()=>{this.render_scheduled=!0},this.on_mouse_down=e=>{e.currentTarget&&e.currentTarget.focus()},this.call_render=()=>{const e=this.controls.update(this.controls_clock.getDelta()),t=this.render_scheduled||e;this.render_scheduled=!1,t&&this.render(),this.animation_frame_handle=requestAnimationFrame(this.call_render)},this.renderer=e,this.renderer.domElement.tabIndex=0,this.renderer.domElement.addEventListener("mousedown",this.on_mouse_down),this.renderer.domElement.style.outline="none",this.scene.background=new n.Color(1579032),this.light_holder.add(this.light),this.scene.add(this.light_holder)}get debug(){return this._debug}set debug(e){this._debug=e}get canvas_element(){return this.renderer.domElement}set_size(e,t){this.size.set(e,t),this.renderer.setSize(e,t),this.schedule_render()}pointer_pos_to_device_coords(e){e.set(e.x/this.size.width*2-1,e.y/this.size.height*-2+1)}start_rendering(){this.schedule_render(),this.animation_frame_handle=requestAnimationFrame(this.call_render)}stop_rendering(){null!=this.animation_frame_handle&&(cancelAnimationFrame(this.animation_frame_handle),this.animation_frame_handle=void 0)}reset_camera(e,t){this.controls.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z)}dispose(){this.renderer.dispose(),this.controls.dispose()}init_camera_controls(){this.controls=new i.a(this.camera,this.renderer.domElement),this.controls.dampingFactor=1,this.controls.draggingDampingFactor=1}render(){this.renderer.render(this.scene,this.camera)}}},KUR2:function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s("nN8q"),n=s("FXpb");class r extends i.a{constructor(e){super(),this.renderer=e,this.element=Object(n.i)({className:"core_RendererWidget"}),this.element.append(e.canvas_element),this.disposable(e),this.finalize_construction()}start_rendering(){this.renderer.start_rendering()}stop_rendering(){this.renderer.stop_rendering()}resize(e,t){return super.resize(e,t),this.renderer.set_size(e,t),this}}},Za3H:function(e,t,s){"use strict";s.r(t);var i=s("FXpb"),n=s("nN8q"),r=s("6cU9"),o=s("w6HN"),a=s("KUR2"),h=s("Womt"),l=s("Ftn7"),c=s("Tpfs");class d extends l.a{constructor(e,t){super(e),this.disposer=new c.a,this.quad_meshes=[],this.camera=new h.OrthographicCamera(-400,400,300,-300,1,10),this.disposer.add_all(t.textures.observe(({value:e})=>{this.scene.remove(...this.quad_meshes),this.render_textures(e),this.reset_camera(new h.Vector3(0,0,5),new h.Vector3),this.schedule_render()})),this.init_camera_controls(),this.controls.dollySpeed=-1,this.controls.azimuthRotateSpeed=0,this.controls.polarRotateSpeed=0}set_size(e,t){this.camera.left=-Math.floor(e/2),this.camera.right=Math.ceil(e/2),this.camera.top=Math.floor(t/2),this.camera.bottom=-Math.ceil(t/2),this.camera.updateProjectionMatrix(),super.set_size(e,t)}dispose(){super.dispose(),this.disposer.dispose()}render_textures(e){let t=10*(e.length-1),s=0;for(const i of e)t+=i.width,s=Math.max(s,i.height);let i=-Math.floor(t/2);const n=-Math.floor(s/2);for(const t of e){const e=new h.Mesh(this.create_quad(i,n+Math.floor((s-t.height)/2),t.width,t.height),t.texture?new h.MeshBasicMaterial({map:t.texture,transparent:!0}):new h.MeshBasicMaterial({color:16711935}));this.quad_meshes.push(e),this.scene.add(e),i+=10+t.width}}create_quad(e,t,s,i){const n=new h.PlaneGeometry(s,i,1,1);return n.faceVertexUvs=[[[new h.Vector2(0,0),new h.Vector2(0,1),new h.Vector2(1,0)],[new h.Vector2(0,1),new h.Vector2(1,1),new h.Vector2(1,0)]]],n.translate(e+s/2,t+i/2,-5),n}}var u=s("4SjJ");s.d(t,"TextureView",(function(){return _}));class _ extends n.a{constructor(e,t,s){super(),this.element=Object(i.i)({className:"viewer_TextureView"}),this.open_file_button=new r.a("Open file...",{icon_left:i.a.File,accept:".afs, .xvm"}),this.tool_bar=this.disposable(new o.a(this.open_file_button)),this.renderer_view=this.disposable(new a.a(new d(s,t))),this.element.append(this.tool_bar.element,this.renderer_view.element),this.disposable(this.open_file_button.files.observe(({value:e})=>{e.length&&t.load_file(e[0])})),this.renderer_view.start_rendering(),this.disposables(e.tool.observe(({value:e})=>{e===u.b.Viewer?this.renderer_view.start_rendering():this.renderer_view.stop_rendering()})),this.finalize_construction()}resize(e,t){return super.resize(e,t),this.renderer_view.resize(e,Math.max(0,t-this.tool_bar.height)),this}}},w6HN:function(e,t,s){"use strict";s.d(t,"a",(function(){return o}));var i=s("TRid"),n=(s("IQIM"),s("sDu+")),r=s("FXpb");class o extends i.a{constructor(e,...t){super(e instanceof i.a?void 0:e),this.element=Object(r.i)({className:"core_ToolBar"}),this.height=33,this.element.style.height=`${this.height}px`,this.children=e instanceof i.a?[e,...t]:t;for(const e of this.children)if(this.disposable(e),e instanceof n.a&&e.label){const t=Object(r.i)({className:"core_ToolBar_group"});"left"===e.preferred_label_position||"top"===e.preferred_label_position?t.append(e.label.element,e.element):t.append(e.element,e.label.element),this.element.append(t)}else this.element.append(e.element);this.finalize_construction()}set_enabled(e){super.set_enabled(e);for(const t of this.children)t.enabled.val=e}}}}]); |