(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{458:function(t,e,i){"use strict";i.d(e,"b",(function(){return s})),i.d(e,"e",(function(){return n})),i.d(e,"c",(function(){return a})),i.d(e,"a",(function(){return h})),i.d(e,"d",(function(){return u}));var r=i(38);class s{constructor(t,e){this.x=t,this.y=e}get u(){return this.x}get v(){return this.y}}function n(t,e){return new s(t.x-e.x,t.y-e.y)}class a{constructor(t,e,i){this.x=t,this.y=e,this.z=i}}class o{constructor(t){this.data=t,Object(r.d)(9===t.length,"data should be of length 9.")}static of(t,e,i,r,s,n,a,h,u){return new o(new Float32Array([t,r,a,e,s,h,i,n,u]))}static identity(){return o.of(1,0,0,0,1,0,0,0,1)}get(t,e){return this.data[t+3*e]}set(t,e,i){this.data[t+3*e]=i}clone(){return new o(new Float32Array(this.data))}transpose(){let t;const e=this.data;t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t}inverse(){const t=this.clone();return t.invert(),t}invert(){const t=this.data[0],e=this.data[1],i=this.data[2],r=this.data[3],s=this.data[4],n=this.data[5],a=this.data[6],o=this.data[7],h=this.data[8],u=h*s-n*o,d=n*a-h*r,c=o*r-s*a,f=t*u+e*d+i*c;if(0===f)return this.data[0]=1,this.data[1]=0,this.data[2]=0,this.data[3]=0,this.data[4]=1,this.data[5]=0,this.data[6]=0,this.data[7]=0,void(this.data[8]=1);const l=1/f;this.data[0]=u*l,this.data[1]=(i*o-h*e)*l,this.data[2]=(n*e-i*s)*l,this.data[3]=d*l,this.data[4]=(h*t-i*a)*l,this.data[5]=(i*r-n*t)*l,this.data[6]=c*l,this.data[7]=(e*a-o*t)*l,this.data[8]=(s*t-e*r)*l}}class h{constructor(t){this.data=t,Object(r.d)(16===t.length,"data should be of length 16.")}static of(t,e,i,r,s,n,a,o,u,d,c,f,l,_,m,p){return new h(new Float32Array([t,s,u,l,e,n,d,_,i,a,c,m,r,o,f,p]))}static identity(){return h.of(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}static translation(t,e,i){return h.of(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1)}static scale(t,e,i){return h.of(t,0,0,1,0,e,0,1,0,0,i,1,0,0,0,1)}static compose(t,e,i){const r=e.w,s=e.x,n=e.y,a=e.z,o=s+s,u=n+n,d=a+a,c=s*o,f=s*u,l=s*d,_=n*u,m=n*d,p=a*d,g=r*o,v=r*u,x=r*d,y=i.x,w=i.y,b=i.z;return h.of((1-(_+p))*y,(f-x)*w,(l+v)*b,t.x,(f+x)*y,(1-(c+p))*w,(m-g)*b,t.y,(l-v)*y,(m+g)*w,(1-(c+_))*b,t.z,0,0,0,1)}get(t,e){return this.data[t+4*e]}set(t,e,i){this.data[t+4*e]=i}clone(){return new h(new Float32Array(this.data))}normal_mat3(){const t=o.of(this.data[0],this.data[4],this.data[8],this.data[1],this.data[5],this.data[9],this.data[2],this.data[6],this.data[10]);return t.invert(),t.transpose(),t}}function u(t,e){const i=new h(new Float32Array(16));return d(i.data,t,e),i}function d(t,e,i){for(let r=0;r<4;r++)for(let s=0;s<4;s++)for(let n=0;n<4;n++)t[r+4*s]+=e.data[r+4*n]*i.data[n+4*s]}},477:function(t,e,i){"use strict";var r;i.d(e,"d",(function(){return r})),i.d(e,"b",(function(){return s})),i.d(e,"a",(function(){return n})),i.d(e,"c",(function(){return a})),i.d(e,"f",(function(){return o})),i.d(e,"e",(function(){return h})),i.d(e,"g",(function(){return u})),function(t){t[t.PosNorm=0]="PosNorm",t[t.PosTex=1]="PosTex",t[t.PosNormTex=2]="PosNormTex"}(r||(r={}));const s=0,n=1,a=2;function o(t){switch(t){case r.PosNorm:return 24;case r.PosTex:return 16;case r.PosNormTex:return 28}}function h(t){switch(t){case r.PosTex:return-1;case r.PosNorm:case r.PosNormTex:return 12}}function u(t){switch(t){case r.PosNorm:return-1;case r.PosTex:return 12;case r.PosNormTex:return 24}}},495:function(t,e,i){"use strict";var r;i.d(e,"b",(function(){return r})),i.d(e,"a",(function(){return s})),function(t){t[t.RGBA_S3TC_DXT1=0]="RGBA_S3TC_DXT1",t[t.RGBA_S3TC_DXT3=1]="RGBA_S3TC_DXT3"}(r||(r={}));class s{constructor(t,e,i,r,s){this.gfx=t,this.format=e,this.width=i,this.height=r,this.data=s}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)}}},507:function(t,e,i){"use strict";i.d(e,"c",(function(){return n})),i.d(e,"a",(function(){return a})),i.d(e,"b",(function(){return o}));const r=180/Math.PI,s=Math.PI/180;function n(t){return t*r}function a(t){return t*s}function o(t,e){return(t%e+e)%e}},517:function(t,e,i){"use strict";i.d(e,"a",(function(){return s})),i.d(e,"b",(function(){return n}));var r=i(458);class s{constructor(){this.root_node=new n(void 0,r.a.identity())}traverse(t,e){this.traverse_node(this.root_node,t,e)}traverse_node(t,e,i){const r=e(t,i);for(const i of t.children)this.traverse_node(i,e,r)}}class n{constructor(t,e,...i){this.mesh=t,this.transform=e,this._children=i}get children(){return this._children}add_child(t){this._children.push(t)}clear_children(){this._children.splice(0)}}},650:function(t,e,i){"use strict";var r=i(517),s=i(458);class n{constructor(){this.look_at=new s.c(0,0,0),this.x_rot=0,this.y_rot=0,this.z_rot=0,this._zoom=1,this._mat4=s.a.identity()}get mat4(){return this._mat4}pan(t,e,i){return this.look_at.x+=t,this.look_at.y+=e,this.look_at.z+=i,this.update_matrix(),this}zoom(t){return this._zoom*=t,this.look_at.x*=t,this.look_at.y*=t,this.look_at.z*=t,this.update_matrix(),this}reset(){return this.look_at.x=0,this.look_at.y=0,this.look_at.z=0,this.x_rot=0,this.y_rot=0,this.z_rot=0,this._zoom=1,this.update_matrix(),this}update_matrix(){this._mat4.data[12]=-this.look_at.x,this._mat4.data[13]=-this.look_at.y,this._mat4.data[14]=-this.look_at.z,this._mat4.data[0]=this._zoom,this._mat4.data[5]=this._zoom,this._mat4.data[10]=this._zoom}}var a=i(507);i.d(e,"a",(function(){return o}));class o{constructor(t){this.perspective_projection=t,this.projection_mat=s.a.identity(),this.scene=new r.a,this.camera=new n,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=t=>{1===t.buttons&&(this.pointer_pos=new s.b(t.clientX,t.clientY),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup))},this.mousemove=t=>{if(1===t.buttons){const e=new s.b(t.clientX,t.clientY),i=Object(s.e)(e,this.pointer_pos);this.camera.pan(-i.x,i.y,0),this.pointer_pos=e,this.schedule_render()}},this.mouseup=()=>{this.pointer_pos=void 0,window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)},this.wheel=t=>{this.perspective_projection?t.deltaY<0?this.camera.pan(0,0,-5):this.camera.pan(0,0,5):t.deltaY<0?this.camera.zoom(1.1):this.camera.zoom(.9),this.schedule_render()},this.canvas_element.width=800,this.canvas_element.height=600,this.canvas_element.addEventListener("mousedown",this.mousedown),this.canvas_element.addEventListener("wheel",this.wheel,{passive:!0})}dispose(){this.destroy_scene()}set_size(t,e){if(this.perspective_projection){const i=75,r=t/e,n=.1,o=2e3,h=n*Math.tan(Object(a.a)(.5*i)),u=-h,d=r*h,c=-d;this.projection_mat=s.a.of(2*n/(d-c),0,(d+c)/(d-c),0,0,2*n/(h-u),(h+u)/(h-u),0,0,0,-(o+n)/(o-n),-2*o*n/(o-n),0,0,-1,0)}else{const i=t,r=e,n=-1e3,a=1e3;this.projection_mat=s.a.of(2/i,0,0,0,0,2/r,0,0,0,0,2/(n-a),0,0,0,0,1)}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(t=>{var e,i,r;null===(e=t.mesh)||void 0===e||e.destroy(this.gfx),null===(r=null===(i=t.mesh)||void 0===i?void 0:i.texture)||void 0===r||r.destroy(),t.mesh=void 0},void 0),this.scene.root_node.clear_children(),this.scene.root_node.transform=s.a.identity()}}},897:function(t,e,i){"use strict";i.r(e);var r=i(23),s=i(477),n=i(650),a=i(458),o=i(495);class h{constructor(t,e){this.device=t,this.bind_group_layout=e}create_gfx_mesh(t,e,i,r){const s=this.device.createBuffer({size:64,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM}),n=this.device.createBindGroup({layout:this.bind_group_layout,bindings:[{binding:0,resource:{buffer:s}},{binding:1,resource:this.device.createSampler({magFilter:"linear",minFilter:"linear"})},{binding:2,resource:r.gfx_texture.createView()}]}),a=this.device.createBuffer({size:e.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX});a.setSubData(0,new Uint8Array(e));const o=this.device.createBuffer({size:i.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX});return o.setSubData(0,new Uint16Array(i)),{uniform_buffer:s,bind_group:n,vertex_buffer:a,index_buffer:o}}destroy_gfx_mesh(t){t&&(t.uniform_buffer.destroy(),t.vertex_buffer.destroy(),t.index_buffer.destroy())}create_texture(t,e,i,r){if(t===o.b.RGBA_S3TC_DXT1||t===o.b.RGBA_S3TC_DXT3){const t=new ArrayBuffer(16),s=new Uint32Array(t);s[0]=4294901760,s[1]=4278255360,s[2]=4278190335,s[3]=4278255615,e=2,i=2,r=t}const s=this.device.createTexture({size:{width:e,height:i,depth:1},format:"rgba8unorm",usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.SAMPLED}),n=256*Math.ceil(4*e/256),a=n*i,h=this.device.createBuffer({size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});let u;if(a===r.byteLength)u=new Uint8Array(r);else{u=new Uint8Array(a);const t=new Uint8Array(r);let s=0;for(let r=0;r{const i=Object(a.d)(e,t.transform);if(t.mesh){const e=t.mesh.gfx_mesh;e.uniform_buffer.setSubData(0,i.data),n.setBindGroup(0,e.bind_group),n.setVertexBuffer(0,e.vertex_buffer),n.setIndexBuffer(e.index_buffer),n.drawIndexed(t.mesh.index_count,1,0,0,0)}return i},o),n.endPass(),t.defaultQueue.submit([r.finish()])}}}}}]);