You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
34 KiB

3 years ago
  1. var clipboard,plugins,wasm_memory,high_dpi,FS,GL,Module,wasm_exports,emscripten_shaders_hack,importObject,ctx,quad_socket,connected,received_buffer,uid,ongoing_requests;"use strict";const version="0.1.24",canvas=document.querySelector("#glcanvas"),gl=canvas.getContext("webgl");gl===null&&alert("Unable to initialize WebGL. Your browser or machine may not support it."),clipboard=null,plugins=[];high_dpi=!1,canvas.focus(),canvas.requestPointerLock=canvas.requestPointerLock||canvas.mozRequestPointerLock||function(){},document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||function(){};function assert(a,b){a==!1&&alert(b)}function acquireVertexArrayObjectExtension(a){var b=a.getExtension('OES_vertex_array_object');b?(a.createVertexArray=function(){return b.createVertexArrayOES()},a.deleteVertexArray=function(a){b.deleteVertexArrayOES(a)},a.bindVertexArray=function(a){b.bindVertexArrayOES(a)},a.isVertexArray=function(a){return b.isVertexArrayOES(a)}):alert("Unable to get OES_vertex_array_object extension")}function acquireInstancedArraysExtension(a){var b=a.getExtension('ANGLE_instanced_arrays');b&&(a.vertexAttribDivisor=function(a,c){b.vertexAttribDivisorANGLE(a,c)},a.drawArraysInstanced=function(a,c,d,e){b.drawArraysInstancedANGLE(a,c,d,e)},a.drawElementsInstanced=function(a,c,d,e,f){b.drawElementsInstancedANGLE(a,c,d,e,f)})}function acquireDisjointTimerQueryExtension(a){var b=a.getExtension('EXT_disjoint_timer_query');b&&(a.createQuery=function(){return b.createQueryEXT()},a.beginQuery=function(a,c){return b.beginQueryEXT(a,c)},a.endQuery=function(a){return b.endQueryEXT(a)},a.deleteQuery=function(a){b.deleteQueryEXT(a)},a.getQueryObject=function(a,c){return b.getQueryObjectEXT(a,c)})}acquireVertexArrayObjectExtension(gl),acquireInstancedArraysExtension(gl),acquireDisjointTimerQueryExtension(gl),gl.getExtension('WEBGL_depth_texture')==null&&alert("Cant initialize WEBGL_depth_texture extension");function getArray(a,b,c){return new b(wasm_memory.buffer,a,c)}function UTF8ToString(i,j){var b,h,c,a,d,f,g;let e=new Uint8Array(wasm_memory.buffer,i);for(b=0,h=b+j,c='';!(b>=h);){if(a=e[b++],!a)return c;if(!(a&128)){c+=String.fromCharCode(a);continue}if(d=e[b++]&63,(a&224)==192){c+=String.fromCharCode((a&31)<<6|d);continue}f=e[b++]&63,(a&240)==224?a=(a&15)<<12|d<<6|f:((a&248)!=240&&console.warn('Invalid UTF-8 leading byte 0x'+a.toString(16)+' encountered when deserializing a UTF-8 string on the asm.js/wasm heap to a JS string!'),a=(a&7)<<18|d<<12|f<<6|e[b++]&63),a<65536?c+=String.fromCharCode(a):(g=a-65536,c+=String.fromCharCode(55296|g>>10,56320|g&1023))}return c}function stringToUTF8(f,c,b,g){for(var h=b,e=b+g,d=0,a,i;d<f.length;++d)if(a=f.charCodeAt(d),a>=55296&&a<=57343&&(i=f.charCodeAt(++d),a=65536+((a&1023)<<10)|i&1023),a<=127){if(b>=e)break;c[b++]=a}else if(a<=2047){if(b+1>=e)break;c[b++]=192|a>>6,c[b++]=128|a&63}else if(a<=65535){if(b+2>=e)break;c[b++]=224|a>>12,c[b++]=128|a>>6&63,c[b++]=128|a&63}else{if(b+3>=e)break;a>=2097152&&console.warn('Invalid Unicode code point 0x'+a.toString(16)+' encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF).'),c[b++]=240|a>>18,c[b++]=128|a>>12&63,c[b++]=128|a>>6&63,c[b++]=128|a&63}return b-h}FS={loaded_files:[],unique_id:0},GL={counter:1,buffers:[],mappedBuffers:{},programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],timerQueries:[],contexts:{},programInfos:{},getNewId:function(b){for(var c=GL.counter++,a=b.length;a<c;a++)b[a]=null;return c},validateGLObjectID:function(b,a,c,d){a!=0&&(b[a]===null?console.error(c+' called with an already deleted '+d+' ID '+a+'!'):b[a]||console.error(c+' called with an invalid '+d+' ID '+a+'!'))},getSource:function(g,e,f,b){for(var c='',a=0,d;a<e;++a)d=b==0?void 0:getArray(b+a*4,Uint32Array,1)[0],c+=UTF8ToString(getArray(f+a*4,Uint32Array,1)[0],d);return c},populateUniformTable:function(i){var d,h,j,k,g,e,a,b,c,f,l;GL.validateGLObjectID(GL.programs,i,'populateUniformTable','program'),d=GL.programs[i],h=GL.program