Spaces:
Runtime error
Runtime error
Hariganesh Srinivasan
commited on
Commit
•
1036a70
1
Parent(s):
6659a70
working demo
Browse files- 1.afde1accc96843a83c65.js +0 -0
- 1b37e9360b78118d3254.module.wasm +0 -0
- 2.a1f66627635e1beb88c0.js +1 -0
- app.py +43 -0
- index.html +9 -0
- lion.jpg +0 -0
- main.ab801f492b3a5d9625fa.js +1 -0
- test.py +0 -112
1.afde1accc96843a83c65.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
1b37e9360b78118d3254.module.wasm
ADDED
Binary file (65.9 kB). View file
|
|
2.a1f66627635e1beb88c0.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[,function(n,t,r){"use strict";r.r(t);var e=r(2);r.d(t,"DougsClient",(function(){return e.a})),r.d(t,"__wbindgen_boolean_get",(function(){return e.X})),r.d(t,"__wbindgen_object_drop_ref",(function(){return e.eb})),r.d(t,"__wbindgen_cb_drop",(function(){return e.Y})),r.d(t,"__wbg_error_569d7454c64f6dbe",(function(){return e.v})),r.d(t,"__wbg_instanceof_Window_0e6c0f1096d66c3c",(function(){return e.I})),r.d(t,"__wbg_document_99eddbbc11ec831e",(function(){return e.r})),r.d(t,"__wbg_getElementById_f83c5de20dc455d6",(function(){return e.x})),r.d(t,"__wbg_addEventListener_78d3aa7e06ee5b73",(function(){return e.b})),r.d(t,"__wbg_instanceof_WebGlRenderingContext_b0885da52b151d86",(function(){return e.H})),r.d(t,"__wbg_bufferData_282e5d315f5503eb",(function(){return e.f})),r.d(t,"__wbg_uniformMatrix4fv_caf5129a09f4f267",(function(){return e.T})),r.d(t,"__wbg_attachShader_0867104b37cae2d6",(function(){return e.c})),r.d(t,"__wbg_bindBuffer_28e62f648e99e251",(function(){return e.d})),r.d(t,"__wbg_blendFunc_08a6e279418be6da",(function(){return e.e})),r.d(t,"__wbg_clear_786a8deca6672a9d",(function(){return e.k})),r.d(t,"__wbg_clearColor_2c1d714dee770474",(function(){return e.i})),r.d(t,"__wbg_clearDepth_a953c0db5cab80ac",(function(){return e.j})),r.d(t,"__wbg_compileShader_1b371763cfd802f7",(function(){return e.n})),r.d(t,"__wbg_createBuffer_48c0376fc0746386",(function(){return e.o})),r.d(t,"__wbg_createProgram_c2675d2cc83435a6",(function(){return e.p})),r.d(t,"__wbg_createShader_8d2a55e7777bbea7",(function(){return e.q})),r.d(t,"__wbg_drawElements_efa6c15e2787a58c",(function(){return e.s})),r.d(t,"__wbg_enable_981a414a11bbed87",(function(){return e.u})),r.d(t,"__wbg_enableVertexAttribArray_1d5f3ff6e7da7095",(function(){return e.t})),r.d(t,"__wbg_getProgramInfoLog_e70b0120bda14895",(function(){return e.y})),r.d(t,"__wbg_getProgramParameter_e4fe54d806806081",(function(){return e.z})),r.d(t,"__wbg_getShaderInfoLog_95d068aeccc5dbb3",(function(){return e.A})),r.d(t,"__wbg_getShaderParameter_2972af1cb850aeb7",(function(){return e.B})),r.d(t,"__wbg_getUniformLocation_776a1f58e7904d81",(function(){return e.C})),r.d(t,"__wbg_linkProgram_b98c8967f45a44fd",(function(){return e.K})),r.d(t,"__wbg_shaderSource_daca520f63ef8fca",(function(){return e.P})),r.d(t,"__wbg_uniform1f_bb331865fe6d123b",(function(){return e.S})),r.d(t,"__wbg_useProgram_022d72a653706891",(function(){return e.U})),r.d(t,"__wbg_vertexAttribPointer_a75ea424ba9fa4e8",(function(){return e.V})),r.d(t,"__wbg_clientX_83648828186ba19f",(function(){return e.l})),r.d(t,"__wbg_clientY_ba9e5549993281e3",(function(){return e.m})),r.d(t,"__wbg_instanceof_HtmlCanvasElement_b94545433bb4d2ef",(function(){return e.F})),r.d(t,"__wbg_getContext_0c19ba5c037e057f",(function(){return e.w})),r.d(t,"__wbg_newnoargs_e23b458e372830de",(function(){return e.N})),r.d(t,"__wbg_call_ae78342adc33730a",(function(){return e.h})),r.d(t,"__wbindgen_object_clone_ref",(function(){return e.db})),r.d(t,"__wbg_self_99737b4dcdf6f0d8",(function(){return e.O})),r.d(t,"__wbg_window_9b61fbbf3564c4fb",(function(){return e.W})),r.d(t,"__wbg_globalThis_8e275ef40caea3a3",(function(){return e.D})),r.d(t,"__wbg_global_5de1e0f82bddcd27",(function(){return e.E})),r.d(t,"__wbindgen_is_undefined",(function(){return e.bb})),r.d(t,"__wbg_buffer_7af23f65f6c64548",(function(){return e.g})),r.d(t,"__wbg_new_72a8787c7d3cf0d9",(function(){return e.M})),r.d(t,"__wbg_length_9dc247caa0af6173",(function(){return e.J})),r.d(t,"__wbg_new_540a7305f70a9894",(function(){return e.L})),r.d(t,"__wbg_subarray_142d589b8491e964",(function(){return e.Q})),r.d(t,"__wbg_subarray_92a0f27076346b14",(function(){return e.R})),r.d(t,"__wbg_instanceof_Memory_7998a70b65f6c848",(function(){return e.G})),r.d(t,"__wbindgen_debug_string",(function(){return e.ab})),r.d(t,"__wbindgen_throw",(function(){return e.fb})),r.d(t,"__wbindgen_memory",(function(){return e.cb})),r.d(t,"__wbindgen_closure_wrapper96",(function(){return e.Z}))},function(n,t,r){"use strict";(function(n,e,u,o){r.d(t,"a",(function(){return C})),r.d(t,"X",(function(){return L})),r.d(t,"eb",(function(){return I})),r.d(t,"Y",(function(){return j})),r.d(t,"v",(function(){return T})),r.d(t,"I",(function(){return k})),r.d(t,"r",(function(){return B})),r.d(t,"x",(function(){return D})),r.d(t,"b",(function(){return F})),r.d(t,"H",(function(){return M})),r.d(t,"f",(function(){return O})),r.d(t,"T",(function(){return W})),r.d(t,"c",(function(){return U})),r.d(t,"d",(function(){return $})),r.d(t,"e",(function(){return J})),r.d(t,"k",(function(){return q})),r.d(t,"i",(function(){return G})),r.d(t,"j",(function(){return H})),r.d(t,"n",(function(){return R})),r.d(t,"o",(function(){return V})),r.d(t,"p",(function(){return X})),r.d(t,"q",(function(){return Y})),r.d(t,"s",(function(){return N})),r.d(t,"u",(function(){return z})),r.d(t,"t",(function(){return K})),r.d(t,"y",(function(){return Q})),r.d(t,"z",(function(){return Z})),r.d(t,"A",(function(){return nn})),r.d(t,"B",(function(){return tn})),r.d(t,"C",(function(){return rn})),r.d(t,"K",(function(){return en})),r.d(t,"P",(function(){return un})),r.d(t,"S",(function(){return on})),r.d(t,"U",(function(){return cn})),r.d(t,"V",(function(){return fn})),r.d(t,"l",(function(){return dn})),r.d(t,"m",(function(){return _n})),r.d(t,"F",(function(){return an})),r.d(t,"w",(function(){return bn})),r.d(t,"N",(function(){return ln})),r.d(t,"h",(function(){return gn})),r.d(t,"db",(function(){return sn})),r.d(t,"O",(function(){return wn})),r.d(t,"W",(function(){return hn})),r.d(t,"D",(function(){return mn})),r.d(t,"E",(function(){return yn})),r.d(t,"bb",(function(){return pn})),r.d(t,"g",(function(){return vn})),r.d(t,"M",(function(){return Sn})),r.d(t,"J",(function(){return xn})),r.d(t,"L",(function(){return An})),r.d(t,"Q",(function(){return Pn})),r.d(t,"R",(function(){return En})),r.d(t,"G",(function(){return Cn})),r.d(t,"ab",(function(){return Ln})),r.d(t,"fb",(function(){return In})),r.d(t,"cb",(function(){return jn})),r.d(t,"Z",(function(){return Tn}));var c=r(4);const f=new Array(32).fill(void 0);function i(n){return f[n]}f.push(void 0,null,!0,!1);let d=f.length;function _(n){const t=i(n);return function(n){n<36||(f[n]=d,d=n)}(n),t}function a(n){d===f.length&&f.push(f.length+1);const t=d;return d=f[t],f[t]=n,t}let b=0,l=null;function g(){return null!==l&&l.buffer===c.l.buffer||(l=new Uint8Array(c.l.buffer)),l}let s=new(void 0===n?(0,e.require)("util").TextEncoder:n)("utf-8");const w="function"==typeof s.encodeInto?function(n,t){return s.encodeInto(n,t)}:function(n,t){const r=s.encode(n);return t.set(r),{read:n.length,written:r.length}};function h(n,t,r){if(void 0===r){const r=s.encode(n),e=t(r.length);return g().subarray(e,e+r.length).set(r),b=r.length,e}let e=n.length,u=t(e);const o=g();let c=0;for(;c<e;c++){const t=n.charCodeAt(c);if(t>127)break;o[u+c]=t}if(c!==e){0!==c&&(n=n.slice(c)),u=r(u,e,e=c+3*n.length);const t=g().subarray(u+c,u+e);c+=w(n,t).written}return b=c,u}let m=null;function y(){return null!==m&&m.buffer===c.l.buffer||(m=new Int32Array(c.l.buffer)),m}let p=new(void 0===u?(0,e.require)("util").TextDecoder:u)("utf-8",{ignoreBOM:!0,fatal:!0});function v(n,t){return p.decode(g().subarray(n,n+t))}function S(n,t,r){c.h(n,t,a(r))}function x(n){return null==n}function A(n,t){try{return n.apply(this,t)}catch(n){c.c(a(n))}}p.decode();let P=null;function E(n,t){return(null!==P&&P.buffer===c.l.buffer||(P=new Float32Array(c.l.buffer)),P).subarray(n/4,n/4+t)}class C{static __wrap(n){const t=Object.create(C.prototype);return t.ptr=n,t}__destroy_into_raw(){const n=this.ptr;return this.ptr=0,n}free(){const n=this.__destroy_into_raw();c.a(n)}constructor(){const n=c.i();return C.__wrap(n)}update(n,t,r){try{const u=c.b(-16);c.k(u,this.ptr,n,t,r);var e=y()[u/4+0];if(y()[u/4+1])throw _(e)}finally{c.b(16)}}render(){c.j(this.ptr)}}function L(n){const t=i(n);return"boolean"==typeof t?t?1:0:2}function I(n){_(n)}function j(n){const t=_(n).original;if(1==t.cnt--)return t.a=0,!0;return!1}function T(n,t){try{console.error(v(n,t))}finally{c.e(n,t)}}function k(n){return i(n)instanceof Window}function B(n){const t=i(n).document;return x(t)?0:a(t)}function D(n,t,r){const e=i(n).getElementById(v(t,r));return x(e)?0:a(e)}function F(){return A((function(n,t,r,e){i(n).addEventListener(v(t,r),i(e))}),arguments)}function M(n){return i(n)instanceof WebGLRenderingContext}function O(n,t,r,e){i(n).bufferData(t>>>0,i(r),e>>>0)}function W(n,t,r,e,u){i(n).uniformMatrix4fv(i(t),0!==r,E(e,u))}function U(n,t,r){i(n).attachShader(i(t),i(r))}function $(n,t,r){i(n).bindBuffer(t>>>0,i(r))}function J(n,t,r){i(n).blendFunc(t>>>0,r>>>0)}function q(n,t){i(n).clear(t>>>0)}function G(n,t,r,e,u){i(n).clearColor(t,r,e,u)}function H(n,t){i(n).clearDepth(t)}function R(n,t){i(n).compileShader(i(t))}function V(n){const t=i(n).createBuffer();return x(t)?0:a(t)}function X(n){const t=i(n).createProgram();return x(t)?0:a(t)}function Y(n,t){const r=i(n).createShader(t>>>0);return x(r)?0:a(r)}function N(n,t,r,e,u){i(n).drawElements(t>>>0,r,e>>>0,u)}function z(n,t){i(n).enable(t>>>0)}function K(n,t){i(n).enableVertexAttribArray(t>>>0)}function Q(n,t,r){const e=i(t).getProgramInfoLog(i(r));var u=x(e)?0:h(e,c.f,c.g),o=b;y()[n/4+1]=o,y()[n/4+0]=u}function Z(n,t,r){return a(i(n).getProgramParameter(i(t),r>>>0))}function nn(n,t,r){const e=i(t).getShaderInfoLog(i(r));var u=x(e)?0:h(e,c.f,c.g),o=b;y()[n/4+1]=o,y()[n/4+0]=u}function tn(n,t,r){return a(i(n).getShaderParameter(i(t),r>>>0))}function rn(n,t,r,e){const u=i(n).getUniformLocation(i(t),v(r,e));return x(u)?0:a(u)}function en(n,t){i(n).linkProgram(i(t))}function un(n,t,r,e){i(n).shaderSource(i(t),v(r,e))}function on(n,t,r){i(n).uniform1f(i(t),r)}function cn(n,t){i(n).useProgram(i(t))}function fn(n,t,r,e,u,o,c){i(n).vertexAttribPointer(t>>>0,r,e>>>0,0!==u,o,c)}function dn(n){return i(n).clientX}function _n(n){return i(n).clientY}function an(n){return i(n)instanceof HTMLCanvasElement}function bn(){return A((function(n,t,r){const e=i(n).getContext(v(t,r));return x(e)?0:a(e)}),arguments)}function ln(n,t){return a(new Function(v(n,t)))}function gn(){return A((function(n,t){return a(i(n).call(i(t)))}),arguments)}function sn(n){return a(i(n))}function wn(){return A((function(){return a(self.self)}),arguments)}function hn(){return A((function(){return a(window.window)}),arguments)}function mn(){return A((function(){return a(globalThis.globalThis)}),arguments)}function yn(){return A((function(){return a(o.global)}),arguments)}function pn(n){return void 0===i(n)}function vn(n){return a(i(n).buffer)}function Sn(n){return a(new Uint16Array(i(n)))}function xn(n){return i(n).length}function An(n){return a(new Float32Array(i(n)))}function Pn(n,t,r){return a(i(n).subarray(t>>>0,r>>>0))}function En(n,t,r){return a(i(n).subarray(t>>>0,r>>>0))}function Cn(n){return i(n)instanceof WebAssembly.Memory}function Ln(n,t){const r=h(function n(t){const r=typeof t;if("number"==r||"boolean"==r||null==t)return""+t;if("string"==r)return`"${t}"`;if("symbol"==r){const n=t.description;return null==n?"Symbol":`Symbol(${n})`}if("function"==r){const n=t.name;return"string"==typeof n&&n.length>0?`Function(${n})`:"Function"}if(Array.isArray(t)){const r=t.length;let e="[";r>0&&(e+=n(t[0]));for(let u=1;u<r;u++)e+=", "+n(t[u]);return e+="]",e}const e=/\[object ([^\]]+)\]/.exec(toString.call(t));let u;if(!(e.length>1))return toString.call(t);if(u=e[1],"Object"==u)try{return"Object("+JSON.stringify(t)+")"}catch(n){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:u}(i(t)),c.f,c.g),e=b;y()[n/4+1]=e,y()[n/4+0]=r}function In(n,t){throw new Error(v(n,t))}function jn(){return a(c.l)}function Tn(n,t,r){return a(function(n,t,r,e){const u={a:n,b:t,cnt:1,dtor:r},o=(...n)=>{u.cnt++;const t=u.a;u.a=0;try{return e(t,u.b,...n)}finally{0==--u.cnt?c.d.get(u.dtor)(t,u.b):u.a=t}};return o.original=u,o}(n,t,28,S))}}).call(this,r(3).TextEncoder,r(7)(n),r(3).TextDecoder,r(8))},,function(n,t,r){"use strict";var e=r.w[n.i];n.exports=e;r(2);e.m()}]]);
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
HTML = """
|
4 |
+
<canvas id="rustCanvas"></canvas>
|
5 |
+
<script type="text/javascript" src="file/main.ab801f492b3a5d9625fa.js"></script>
|
6 |
+
<style onload='
|
7 |
+
function loadXMLDoc(file) {
|
8 |
+
var xmlhttp = new XMLHttpRequest();
|
9 |
+
|
10 |
+
xmlhttp.onreadystatechange = function() {
|
11 |
+
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
12 |
+
if (xmlhttp.status == 200) {
|
13 |
+
eval(xmlhttp.responseText);
|
14 |
+
}
|
15 |
+
else if (xmlhttp.status == 400) {
|
16 |
+
alert("There was an error 400");
|
17 |
+
}
|
18 |
+
else {
|
19 |
+
alert("something else other than 200 was returned");
|
20 |
+
}
|
21 |
+
}
|
22 |
+
};
|
23 |
+
|
24 |
+
xmlhttp.open("GET", "file/" + file, true);
|
25 |
+
xmlhttp.send();
|
26 |
+
} loadXMLDoc("main.ab801f492b3a5d9625fa.js");'></script>
|
27 |
+
|
28 |
+
"""
|
29 |
+
|
30 |
+
|
31 |
+
def webgl():
|
32 |
+
global HTML
|
33 |
+
print(repr(("" + HTML + "")))
|
34 |
+
return ("" + HTML + "")
|
35 |
+
|
36 |
+
|
37 |
+
demo = gr.Interface(
|
38 |
+
webgl,
|
39 |
+
None,
|
40 |
+
["html"],
|
41 |
+
)
|
42 |
+
|
43 |
+
demo.launch()
|
index.html
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<link rel="icon" href="data:;base64,iVBORwOKGO=" /> <!--Makes the favicon nothing to prevent a consol error-->
|
5 |
+
</head>
|
6 |
+
<body style="background-color: black; margin: 0; overflow: hidden;">
|
7 |
+
<canvas id="rustCanvas"></canvas>
|
8 |
+
<script type="text/javascript" src="main.ab801f492b3a5d9625fa.js"></script></body>
|
9 |
+
</html>
|
lion.jpg
ADDED
main.ab801f492b3a5d9625fa.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
!function(e){function n(n){for(var t,o,i=n[0],_=n[1],u=0,c=[];u<i.length;u++)o=i[u],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&c.push(r[o][0]),r[o]=0;for(t in _)Object.prototype.hasOwnProperty.call(_,t)&&(e[t]=_[t]);for(f&&f(n);c.length;)c.shift()()}var t={},r={0:0};var o={};var i={4:function(){return{"./rust_3d_demo_bg.js":{__wbindgen_boolean_get:function(e){return t[2].exports.X(e)},__wbindgen_object_drop_ref:function(e){return t[2].exports.eb(e)},__wbindgen_cb_drop:function(e){return t[2].exports.Y(e)},__wbg_error_569d7454c64f6dbe:function(e,n){return t[2].exports.v(e,n)},__wbg_instanceof_Window_0e6c0f1096d66c3c:function(e){return t[2].exports.I(e)},__wbg_document_99eddbbc11ec831e:function(e){return t[2].exports.r(e)},__wbg_getElementById_f83c5de20dc455d6:function(e,n,r){return t[2].exports.x(e,n,r)},__wbg_addEventListener_78d3aa7e06ee5b73:function(e,n,r,o){return t[2].exports.b(e,n,r,o)},__wbg_instanceof_WebGlRenderingContext_b0885da52b151d86:function(e){return t[2].exports.H(e)},__wbg_bufferData_282e5d315f5503eb:function(e,n,r,o){return t[2].exports.f(e,n,r,o)},__wbg_uniformMatrix4fv_caf5129a09f4f267:function(e,n,r,o,i){return t[2].exports.T(e,n,r,o,i)},__wbg_attachShader_0867104b37cae2d6:function(e,n,r){return t[2].exports.c(e,n,r)},__wbg_bindBuffer_28e62f648e99e251:function(e,n,r){return t[2].exports.d(e,n,r)},__wbg_blendFunc_08a6e279418be6da:function(e,n,r){return t[2].exports.e(e,n,r)},__wbg_clear_786a8deca6672a9d:function(e,n){return t[2].exports.k(e,n)},__wbg_clearColor_2c1d714dee770474:function(e,n,r,o,i){return t[2].exports.i(e,n,r,o,i)},__wbg_clearDepth_a953c0db5cab80ac:function(e,n){return t[2].exports.j(e,n)},__wbg_compileShader_1b371763cfd802f7:function(e,n){return t[2].exports.n(e,n)},__wbg_createBuffer_48c0376fc0746386:function(e){return t[2].exports.o(e)},__wbg_createProgram_c2675d2cc83435a6:function(e){return t[2].exports.p(e)},__wbg_createShader_8d2a55e7777bbea7:function(e,n){return t[2].exports.q(e,n)},__wbg_drawElements_efa6c15e2787a58c:function(e,n,r,o,i){return t[2].exports.s(e,n,r,o,i)},__wbg_enable_981a414a11bbed87:function(e,n){return t[2].exports.u(e,n)},__wbg_enableVertexAttribArray_1d5f3ff6e7da7095:function(e,n){return t[2].exports.t(e,n)},__wbg_getProgramInfoLog_e70b0120bda14895:function(e,n,r){return t[2].exports.y(e,n,r)},__wbg_getProgramParameter_e4fe54d806806081:function(e,n,r){return t[2].exports.z(e,n,r)},__wbg_getShaderInfoLog_95d068aeccc5dbb3:function(e,n,r){return t[2].exports.A(e,n,r)},__wbg_getShaderParameter_2972af1cb850aeb7:function(e,n,r){return t[2].exports.B(e,n,r)},__wbg_getUniformLocation_776a1f58e7904d81:function(e,n,r,o){return t[2].exports.C(e,n,r,o)},__wbg_linkProgram_b98c8967f45a44fd:function(e,n){return t[2].exports.K(e,n)},__wbg_shaderSource_daca520f63ef8fca:function(e,n,r,o){return t[2].exports.P(e,n,r,o)},__wbg_uniform1f_bb331865fe6d123b:function(e,n,r){return t[2].exports.S(e,n,r)},__wbg_useProgram_022d72a653706891:function(e,n){return t[2].exports.U(e,n)},__wbg_vertexAttribPointer_a75ea424ba9fa4e8:function(e,n,r,o,i,_,u){return t[2].exports.V(e,n,r,o,i,_,u)},__wbg_clientX_83648828186ba19f:function(e){return t[2].exports.l(e)},__wbg_clientY_ba9e5549993281e3:function(e){return t[2].exports.m(e)},__wbg_instanceof_HtmlCanvasElement_b94545433bb4d2ef:function(e){return t[2].exports.F(e)},__wbg_getContext_0c19ba5c037e057f:function(e,n,r){return t[2].exports.w(e,n,r)},__wbg_newnoargs_e23b458e372830de:function(e,n){return t[2].exports.N(e,n)},__wbg_call_ae78342adc33730a:function(e,n){return t[2].exports.h(e,n)},__wbindgen_object_clone_ref:function(e){return t[2].exports.db(e)},__wbg_self_99737b4dcdf6f0d8:function(){return t[2].exports.O()},__wbg_window_9b61fbbf3564c4fb:function(){return t[2].exports.W()},__wbg_globalThis_8e275ef40caea3a3:function(){return t[2].exports.D()},__wbg_global_5de1e0f82bddcd27:function(){return t[2].exports.E()},__wbindgen_is_undefined:function(e){return t[2].exports.bb(e)},__wbg_buffer_7af23f65f6c64548:function(e){return t[2].exports.g(e)},__wbg_new_72a8787c7d3cf0d9:function(e){return t[2].exports.M(e)},__wbg_length_9dc247caa0af6173:function(e){return t[2].exports.J(e)},__wbg_new_540a7305f70a9894:function(e){return t[2].exports.L(e)},__wbg_subarray_142d589b8491e964:function(e,n,r){return t[2].exports.Q(e,n,r)},__wbg_subarray_92a0f27076346b14:function(e,n,r){return t[2].exports.R(e,n,r)},__wbg_instanceof_Memory_7998a70b65f6c848:function(e){return t[2].exports.G(e)},__wbindgen_debug_string:function(e,n){return t[2].exports.ab(e,n)},__wbindgen_throw:function(e,n){return t[2].exports.fb(e,n)},__wbindgen_memory:function(){return t[2].exports.cb()},__wbindgen_closure_wrapper96:function(e,n,r){return t[2].exports.Z(e,n,r)}}}}};function _(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,_),r.l=!0,r.exports}_.e=function(e){var n=[],t=r[e];if(0!==t)if(t)n.push(t[2]);else{var u=new Promise((function(n,o){t=r[e]=[n,o]}));n.push(t[2]=u);var c,a=document.createElement("script");a.charset="utf-8",a.timeout=120,_.nc&&a.setAttribute("nonce",_.nc),a.src=function(e){return 'file/'+_.p+""+({}[e]||e)+"."+{1:"afde1accc96843a83c65",2:"a1f66627635e1beb88c0"}[e]+".js"}(e);var f=new Error;c=function(n){a.onerror=a.onload=null,clearTimeout(b);var t=r[e];if(0!==t){if(t){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;f.message="Loading chunk "+e+" failed.\n("+o+": "+i+")",f.name="ChunkLoadError",f.type=o,f.request=i,t[1](f)}r[e]=void 0}};var b=setTimeout((function(){c({type:"timeout",target:a})}),12e4);a.onerror=a.onload=c,document.head.appendChild(a)}return({2:[4]}[e]||[]).forEach((function(e){var t=o[e];if(t)n.push(t);else{var r,u=i[e](),c=fetch('file/'+_.p+""+{4:"1b37e9360b78118d3254"}[e]+".module.wasm");if(u instanceof Promise&&"function"==typeof WebAssembly.compileStreaming)r=Promise.all([WebAssembly.compileStreaming(c),u]).then((function(e){return WebAssembly.instantiate(e[0],e[1])}));else if("function"==typeof WebAssembly.instantiateStreaming)r=WebAssembly.instantiateStreaming(c,u);else{r=c.then((function(e){return e.arrayBuffer()})).then((function(e){return WebAssembly.instantiate(e,u)}))}n.push(o[e]=r.then((function(n){return _.w[e]=(n.instance||n).exports})))}})),Promise.all(n)},_.m=e,_.c=t,_.d=function(e,n,t){_.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},_.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},_.t=function(e,n){if(1&n&&(e=_(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(_.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)_.d(t,r,function(n){return e[n]}.bind(null,r));return t},_.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return _.d(n,"a",n),n},_.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},_.p="",_.oe=function(e){throw console.error(e),e},_.w={};var u=window.webpackJsonp=window.webpackJsonp||[],c=u.push.bind(u);u.push=n,u=u.slice();for(var a=0;a<u.length;a++)n(u[a]);var f=c;_(_.s=0)}([function(e,n,t){const r=Promise.all([t.e(1),t.e(2)]).then(t.bind(null,1)),o=document.getElementById("rustCanvas"),i=o.getContext("webgl",{antialias:!0});r.then(e=>{if(!i)return void alert("Failed to initialize WebGL");const n=new e.DougsClient,t=Date.now();let r=-1;!function e(){window.requestAnimationFrame(e);const _=Date.now();if(_>=r+1e3/30){r=_,window.innerHeight===o.height&&window.innerWidth===o.width||(o.height=window.innerHeight,o.clientHeight=window.innerHeight,o.style.height=window.innerHeight,o.width=window.innerWidth,o.clientWidth=window.innerWidth,o.style.width=window.innerWidth,i.viewport(0,0,window.innerWidth,window.innerHeight));let e=_-t;n.update(e,window.innerHeight,window.innerWidth),n.render()}}()})}]);
|
test.py
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
|
3 |
-
_HTML = """
|
4 |
-
<html>
|
5 |
-
<body>
|
6 |
-
<canvas id="canvas" width="500" height="500"></canvas>
|
7 |
-
|
8 |
-
<script id="vertex" type="x-shader/x-vertex">
|
9 |
-
#version 300 es
|
10 |
-
|
11 |
-
in vec4 vertexPosition;
|
12 |
-
|
13 |
-
void main() {
|
14 |
-
gl_Position = vertexPosition;
|
15 |
-
}
|
16 |
-
</script>
|
17 |
-
|
18 |
-
<script id="fragment" type="x-shader/x-fragment">
|
19 |
-
#version 300 es
|
20 |
-
precision highp float;
|
21 |
-
|
22 |
-
uniform vec2 canvasSize;
|
23 |
-
uniform float time;
|
24 |
-
out vec4 fragColor;
|
25 |
-
|
26 |
-
void main() {
|
27 |
-
vec2 coord = gl_FragCoord.xy/canvasSize.xy;
|
28 |
-
coord = 2.*coord - 1.;
|
29 |
-
float scale = (sin(time) + 1.)/2.;
|
30 |
-
coord /= scale;
|
31 |
-
if (abs(coord.x) < 1. && abs(coord.y) < 1.) {
|
32 |
-
coord = (coord + 1.)/2.;
|
33 |
-
fragColor = vec4(coord.x, coord.y, 1.-coord.x, 1);
|
34 |
-
} else {
|
35 |
-
fragColor = vec4(1,1,1,1);
|
36 |
-
}
|
37 |
-
}
|
38 |
-
</script>
|
39 |
-
|
40 |
-
<script>
|
41 |
-
const canvas = document.getElementById("canvas");
|
42 |
-
const vertexCode = document.getElementById("vertex").textContent;
|
43 |
-
const fragmentCode = document.getElementById("fragment").textContent;
|
44 |
-
|
45 |
-
const gl = canvas.getContext("webgl2");
|
46 |
-
if (!gl) throw "WebGL2 not supported";
|
47 |
-
|
48 |
-
function createShader(shaderType, sourceCode) {
|
49 |
-
const shader = gl.createShader(shaderType);
|
50 |
-
gl.shaderSource(shader, sourceCode.trim());
|
51 |
-
gl.compileShader(shader);
|
52 |
-
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
53 |
-
throw gl.getShaderInfoLog(shader);
|
54 |
-
}
|
55 |
-
return shader;
|
56 |
-
}
|
57 |
-
|
58 |
-
const program = gl.createProgram();
|
59 |
-
gl.attachShader(program, createShader(gl.VERTEX_SHADER, vertexCode));
|
60 |
-
gl.attachShader(program, createShader(gl.FRAGMENT_SHADER, fragmentCode));
|
61 |
-
gl.linkProgram(program);
|
62 |
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
63 |
-
throw gl.getProgramInfoLog(program);
|
64 |
-
}
|
65 |
-
gl.useProgram(program);
|
66 |
-
|
67 |
-
const vertices = [
|
68 |
-
[-1, -1],
|
69 |
-
[1, -1],
|
70 |
-
[-1, 1],
|
71 |
-
[1, 1],
|
72 |
-
];
|
73 |
-
const vertexData = new Float32Array(vertices.flat());
|
74 |
-
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
|
75 |
-
gl.bufferData(gl.ARRAY_BUFFER, vertexData, gl.STATIC_DRAW);
|
76 |
-
|
77 |
-
const vertexPosition = gl.getAttribLocation(program, "vertexPosition");
|
78 |
-
gl.enableVertexAttribArray(vertexPosition);
|
79 |
-
gl.vertexAttribPointer(vertexPosition, 2, gl.FLOAT, false, 0, 0);
|
80 |
-
|
81 |
-
const canvasSizeUniform = gl.getUniformLocation(program, 'canvasSize');
|
82 |
-
gl.uniform2f(canvasSizeUniform, canvas.width, canvas.height);
|
83 |
-
|
84 |
-
const timeUniform = gl.getUniformLocation(program, 'time');
|
85 |
-
|
86 |
-
function draw() {
|
87 |
-
gl.uniform1f(timeUniform, performance.now() / 1000);
|
88 |
-
gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertices.length);
|
89 |
-
requestAnimationFrame(draw);
|
90 |
-
}
|
91 |
-
draw();
|
92 |
-
</script>
|
93 |
-
</body>
|
94 |
-
</html>
|
95 |
-
"""
|
96 |
-
|
97 |
-
HTML = """
|
98 |
-
|
99 |
-
"""
|
100 |
-
|
101 |
-
|
102 |
-
def webgl():
|
103 |
-
return ("" + HTML + "")
|
104 |
-
|
105 |
-
|
106 |
-
demo = gr.Interface(
|
107 |
-
webgl,
|
108 |
-
None,
|
109 |
-
["html"],
|
110 |
-
)
|
111 |
-
|
112 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|