phantasmal-world/3.6eae4e69a5845152fbde.js

1 line
8.9 KiB
JavaScript
Raw Normal View History

2020-04-26 04:20:20 +08:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{472:function(e,t,r){"use strict";var i;r.d(t,"d",(function(){return i})),r.d(t,"b",(function(){return n})),r.d(t,"a",(function(){return s})),r.d(t,"c",(function(){return o})),r.d(t,"f",(function(){return a})),r.d(t,"e",(function(){return u})),r.d(t,"g",(function(){return c})),function(e){e[e.PosNorm=0]="PosNorm",e[e.PosTex=1]="PosTex",e[e.PosNormTex=2]="PosNormTex"}(i||(i={}));const n=0,s=1,o=2;function a(e){switch(e){case i.PosNorm:return 24;case i.PosTex:return 16;case i.PosNormTex:return 28}}function u(e){switch(e){case i.PosTex:return-1;case i.PosNorm:case i.PosNormTex:return 12}}function c(e){switch(e){case i.PosNorm:return-1;case i.PosTex:return 12;case i.PosNormTex:return 24}}},496:function(e,t,r){"use strict";var i;r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return n})),function(e){e[e.RGBA_S3TC_DXT1=0]="RGBA_S3TC_DXT1",e[e.RGBA_S3TC_DXT3=1]="RGBA_S3TC_DXT3"}(i||(i={}));class n{constructor(e,t,r,i,n){this.gfx=e,this.format=t,this.width=r,this.height=i,this.data=n}upload(){null==this.gfx_texture&&(this.gfx_texture=this.gfx.create_texture(this.format,this.width,this.height,this.data))}destroy(){this.gfx.destroy_texture(this.gfx_texture)}}},519:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return s}));var i=r(463);class n{constructor(){this.root_node=new s(void 0,i.a.identity())}traverse(e,t){this.traverse_node(this.root_node,e,t)}traverse_node(e,t,r){const i=t(e,r);for(const r of e.children)this.traverse_node(r,t,i)}}class s{constructor(e,t,...r){this.mesh=e,this.transform=t,this._children=r}get children(){return this._children}add_child(e){this._children.push(e)}clear_children(){this._children.splice(0)}}},638:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var i=r(519),n=r(594),s=r(463);class o{constructor(e){this.width=800,this.height=600,this.scene=new i.a,this.canvas_element=document.createElement("canvas"),this.schedule_render=()=>{null==this.animation_frame&&(this.animation_frame=requestAnimationFrame(this.call_render))},this.call_render=()=>{this.animation_frame=void 0,this.render()},this.mousedown=e=>{this.pointer_pos=new s.b(e.clientX,e.clientY),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup),window.addEventListener("contextmenu",this.contextmenu)},this.mousemove=e=>{const t=new s.b(e.clientX,e.clientY),r=Object(s.g)(t,this.pointer_pos);1===e.buttons?this.camera.pan(-r.x,r.y,0):2===e.buttons&&this.camera.rotate(-r.x/(20*Math.PI),-r.y/(20*Math.PI)),this.pointer_pos=t,this.schedule_render()},this.mouseup=e=>{e.preventDefault(),this.pointer_pos=void 0,window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)},this.wheel=e=>{switch(this.camera.projection){case n.b.Orthographic:e.deltaY<0?this.camera.zoom(1.1):this.camera.zoom(.9);break;case n.b.Perspective:e.deltaY<0?this.camera.pan(0,0,-2):this.camera.pan(0,0,2)}this.schedule_render()},this.contextmenu=e=>{e.preventDefault(),window.removeEventListener("contextmenu",this.contextmenu)},this.canvas_element.width=this.width,this.canvas_element.height=this.height,this.canvas_element.addEventListener("mousedown",this.mousedown),this.canvas_element.addEventListener("wheel",this.wheel,{passive:!0}),this.camera=new n.a(this.width,this.height,e)}dispose(){this.destroy_scene()}set_size(e,t){this.width=e,this.height=t,this.camera.set_viewport(e,t),this.schedule_render()}start_rendering(){this.schedule_render()}stop_rendering(){null!=this.animation_frame&&cancelAnimationFrame(this.animation_frame),this.animation_frame=void 0}destroy_scene(){this.scene.traverse(e=>{var t,r,i;null===(t=e.mesh)||void 0===t||t.destroy(this.gfx),null===(i=null===(r=e.mesh)||void 0===r?void 0:r.texture)||void 0===i||i.destroy(),e.mesh=void 0},void 0),this.scene.root_node.clear_children(),this.scene.root_node.transform=s.a.identity()}}},905:function(e,t,r){"use strict";r.r(t),r.d(t,"WebgpuRenderer",(function(){return l}));var i=r(23),n=r(472),s=r(638),o=r(463),a=r(496);class