phantasmal-world/8.837f86138ee3433acbb1.js
Daan Vanden Bosch 66079d1719 Release 43.
2020-01-03 23:06:15 +01:00

1 line
7.4 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{"6cU9":function(e,t,s){"use strict";s.d(t,"a",(function(){return a}));var i=s("FXpb"),r=(s("+Mcu"),s("ouMO")),n=s("QmPX");class a extends n.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(r.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 n}));var i=s("pVCM"),r=s("Womt");i.a.install({THREE:Object.assign(Object.assign({},r),{MOUSE:Object.assign(Object.assign({},r.MOUSE),{LEFT:r.MOUSE.RIGHT,RIGHT:r.MOUSE.LEFT})})});class n{constructor(e){this._debug=!1,this.scene=new r.Scene,this.light_holder=new r.Group,this.render_scheduled=!1,this.animation_frame_handle=void 0,this.light=new r.HemisphereLight(16777215,5263440,1),this.controls_clock=new r.Clock,this.size=new r.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 r.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 n}));var i=s("nN8q"),r=s("FXpb");class n extends i.a{constructor(e){super(),this.renderer=e,this.element=Object(r.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"),r=s("nN8q"),n=s("6cU9"),a=s("w6HN"),o=s("KUR2"),h=s("Womt"),c=s("Ftn7"),l=s("Tpfs"),d=s("iR5r");const u=s("rwco").c.get("viewer/rendering/TextureRenderer");class _ extends c.a{constructor(e,t){super(e),this.disposer=new l.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 r=-Math.floor(s/2);for(const t of e){let e=void 0;try{e=Object(d.b)(t)}catch(e){u.error("Couldn't convert XVR texture.",e)}const n=new h.Mesh(this.create_quad(i,r+Math.floor((s-t.height)/2),t.width,t.height),e?new h.MeshBasicMaterial({map:e,transparent:!0}):new h.MeshBasicMaterial({color:16711935}));this.quad_meshes.push(n),this.scene.add(n),i+=10+t.width}}create_quad(e,t,s,i){const r=new h.PlaneGeometry(s,i,1,1);return r.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)]]],r.translate(e+s/2,t+i/2,-5),r}}var p=s("4SjJ");s.d(t,"TextureView",(function(){return m}));class m extends r.a{constructor(e,t,s){super(),this.element=Object(i.i)({className:"viewer_TextureView"}),this.open_file_button=new n.a("Open file...",{icon_left:i.a.File,accept:".afs, .xvm"}),this.tool_bar=this.disposable(new a.a(this.open_file_button)),this.renderer_view=this.disposable(new o.a(new _(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===p.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}}},iR5r:function(e,t,s){"use strict";s.d(t,"a",(function(){return r})),s.d(t,"b",(function(){return n}));var i=s("Womt");function r(e){return e.textures.map(n)}function n(e){let t,s;switch(e.format[1]){case 6:t=i.RGBA_S3TC_DXT1_Format,s=e.width*e.height/2;break;case 7:t=i.RGBA_S3TC_DXT3_Format,s=e.width*e.height;break;default:throw new Error(`Format ${e.format.join(", ")} not supported.`)}const r=new i.CompressedTexture([{data:new Uint8Array(e.data,0,s),width:e.width,height:e.height}],e.width,e.height,t);return r.minFilter=i.LinearFilter,r.wrapS=i.MirroredRepeatWrapping,r.wrapT=i.MirroredRepeatWrapping,r.needsUpdate=!0,r}},w6HN:function(e,t,s){"use strict";s.d(t,"a",(function(){return a}));var i=s("TRid"),r=(s("IQIM"),s("sDu+")),n=s("FXpb");class a extends i.a{constructor(e,...t){super(e instanceof i.a?void 0:e),this.element=Object(n.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 r.a&&e.label){const t=Object(n.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}}}}]);